[
  {
    "path": ".gitignore",
    "content": "build/stage\nbuild/buildpack\nbuild/archives/*.bz2\nvega-build/\nplatform/*/bin\nbuild/tmp\nbuild/dist\ndependencies/hc/output/*.jar\ndependencies/hc/libs/*.jar\n"
  },
  {
    "path": "build/ant/buildpack-targets.xml",
    "content": "<?xml version=\"1.0\"?>\n<project name=\"vega.buildpack\">\n\n\t<!-- The version file is used to identify which version of the buildpack is unpacked in build/buildpack -->\n\t<property name=\"buildpack.path.version\" location=\"build/buildpack/version\" />\n\n\t<!-- Downloaded buildpacks are stored here -->\n\t<property name=\"buildpack.path.archives\" location=\"build/archives\" />\n\n\t<!-- Name of the buildpack file for the required version -->\n\t<property name=\"buildpack.filename\" value=\"buildpack-${buildpack.version}.tar.bz2\" />\n\n\t<!-- Buildpack archive name for the buildpack.version property defined in master build.xml -->\n\t<property name=\"buildpack.archive\" location=\"${buildpack.path.archives}/${buildpack.filename}\" />\n\n\t<!-- If the version file is found, then the correct buildpack is installed -->\n\t<available file=\"${buildpack.path.version}/${buildpack.version}\" property=\"buildpack.installed\" />\n\n\t<!-- Is the buildpack version we are looking for downloaded already? -->\n\t<available file=\"${buildpack.archive}\" property=\"buildpack.available\" />\n\n\t<target name=\"buildpack-setup\" depends=\"buildpack-unpack\" />\n\n\t<!-- If the correct buildpack is not installed, delete the old contents of build/buildpack and unpack the right buildpack -->\n\n\t<target name=\"buildpack-unpack\" depends=\"buildpack-download,buildpack-verify\" unless=\"buildpack.installed\">\n\t\t<delete dir=\"build/buildpack\" />\n\t\t<untar src=\"${buildpack.archive}\" dest=\"${basedir}\" compression=\"bzip2\" />\n\t</target>\n\n\t<!-- Download the buildpack archive if it is not found in the build/archives directory -->\n\n\t<target name=\"buildpack-download\" unless=\"buildpack.available\">\n\t\t<property name=\"buildpack.source\" value=\"http://support.subgraph.com/buildpacks\" />\n\t\t<property name=\"buildpack.url\" value=\"${buildpack.source}/${buildpack.filename}\" />\n\t\t<echo>\n\t\t\tThe build system will now download a buildpack from ${buildpack.url}\n\t\t\t\n\t\t\tDepending on the speed of your connection this may take a few minutes.\n\t\t</echo>\n\t\t<get src=\"${buildpack.url}\" dest=\"${buildpack.archive}.tmp\" />\n\t\t<move file=\"${buildpack.archive}.tmp\" tofile=\"${buildpack.archive}\" />\n\t</target>\n\t\n\t<!-- Calculate the checksum for the buildpack archive and call target to abort if it is invalid -->\n\n\t<target name=\"buildpack-verify\" unless=\"buildpack.installed\">\n\t\t<echo message=\"Verifying checksum on ${buildpack.archive}\"/>\n\t\t<condition property=\"buildpack.checksum.failed\" >\n\t\t\t<not>\n\t\t\t\t<and>\n\t\t\t\t\t<available file=\"${buildpack.archive}\" />\n\t\t\t\t\t<checksum file=\"${buildpack.archive}\" algorithm=\"SHA\" />\n\t\t\t\t</and>\n\t\t\t</not>\n\t\t</condition>\n\t\t<antcall target=\"buildpack-abort-if-checksum-failed\" />\n\t\t<echo message=\"Checksum valid.\" />\n\t</target>\n\n\t<!-- Display a message and fail if the buildpack.checksum.failed propety is set -->\n\n\t<target name=\"buildpack-abort-if-checksum-failed\" if=\"buildpack.checksum.failed\">\n\t\t<echo>\n\t\t\tChecksum verification failed.  Buildpack has an invalid SHA-1 hash.\n\t\t</echo>\n\t\t<fail message=\"Aborted.\"/>\n\t</target>\n\n\t<!--\n\t\tCreate a new build pack from the contents of the build/buildpack directory.\n\t\tSee build/buildpacks.txt for more details.\n\t-->\n\t<target name=\"buildpack-create\">\n\n\t\t<!-- Create buildpack version from today's date -->\n\t\t<tstamp>\n\t\t\t<format property=\"buildpack.tstamp\" pattern=\"MMddyyyy\" />\n\t\t</tstamp>\n\n\t\t<property name=\"buildpack.file\" value=\"buildpack-${buildpack.tstamp}.tar.bz2\" />\n\t\t<delete dir=\"build/buildpack/version\" />\n\t\t<!-- Write the buildpack version file -->\n\t\t<touch file=\"build/buildpack/version/${buildpack.tstamp}\" mkdirs=\"yes\" />\n\t\t<tar destfile=\"build/archives/${buildpack.file}\" \n\t\t\tbasedir=\"${basedir}\" \n\t\t\tincludes=\"build/buildpack/**\" \n\t\t\tlongfile=\"gnu\" \n\t\t\tcompression=\"bzip2\" \n\t\t/>\n\t\t<!-- Write sha-1 hash of tarball to a checksum file -->\n\t\t<checksum file=\"build/archives/${buildpack.file}\" algorithm=\"SHA\" />\n\t\t<echo message=\"Buildpack created at ${buildpack.file}\" />\n\t</target>\n\n</project>\n"
  },
  {
    "path": "build/ant/pde-build-targets.xml",
    "content": "<?xml version=\"1.0\"?>\n<project name=\"vega.pde-build\">\n\n\t<property name=\"basebuilderdir\" value=\"${basedir}/build/buildpack/org.eclipse.releng.basebuilder\" />\n        <property name=\"pde.build\" value=\"org.eclipse.pde.build_3.8.0.v20120119-1950\" />\n\t<property name=\"buildfile\" value=\"${basebuilderdir}/plugins/${pde.build}/scripts/productBuild/productBuild.xml\" />\n\t<property name=\"launcher\" value=\"${basebuilderdir}/plugins/org.eclipse.equinox.launcher.jar\" />\n\t<property name=\"builder\" location=\"build/config\" />\n\t<property name=\"buildpack\" location=\"build/buildpack\" />\n\t<tstamp />\n\n\t<target name=\"pde-build\" depends=\"pde-build-all,pde-build-one,pde-build-nofork\"/>\n\t\n\t<!-- Build vega for all platforms specified in build.properties -->\n\n\t<target name=\"pde-build-all\" if=\"build.all\">\n\t\t<echo>basedir: ${basedir}</echo>\n\t\t<java jar=\"${launcher}\" fork=\"true\" failonerror=\"true\">\n\t\t\t<arg line=\"-application org.eclipse.ant.core.antRunner\" />\n\t\t\t<arg line=\"-buildfile ${buildfile}\" />\n\t\t\t<arg line=\"-Dbasedir=${basedir}\" />\n\t\t\t<arg line=\"-Dbuilder=${builder}\" />\n\t\t\t<arg line=\"-Dbuildpack=${buildpack}\" />\n\t\t\t<arg line=\"-Dtimestamp=${DSTAMP}${TSTAMP}\" />\n\t\t\t<jvmarg value=\"-XX:MaxPermSize=648m\" />\n\t\t\t<jvmarg value=\"-Xmx1024m\" />\n\t\t</java>\n\t</target>\n\n\n\t<!-- Build vega only for the current platform -->\n\n  <target name=\"pde-build-one\" depends=\"pde-set-config\" if=\"build.one\" >\n\t\t<echo>basedir: ${basedir}</echo>\n\t\t<java jar=\"${launcher}\" fork=\"true\" failonerror=\"true\">\n\t\t\t<arg line=\"-application org.eclipse.ant.core.antRunner\" />\n\t\t\t<arg line=\"-buildfile ${buildfile}\" />\n\t\t\t<arg line=\"-Dbasedir=${basedir}\" />\n\t\t\t<arg line=\"-Dbuilder=${builder}\" />\n\t\t\t<arg line=\"-Dbuildpack=${buildpack}\" />\n\t\t\t<arg line=\"-Dtimestamp=${DSTAMP}${TSTAMP}\" />\n\t\t\t<arg line=\"-Dconfigs=${build.config}\" />\n\t\t\t<jvmarg value=\"-XX:MaxPermSize=648m\" />\n\t\t\t<jvmarg value=\"-Xmx1024m\" />\n\t\t</java>\n\t</target>\n\n\t<target name=\"pde-build-nofork\" if=\"build.nofork\">\n\t\t<echo>basedir: ${basedir}</echo>\n    <echo>nofork launch </echo>\n\t\t<java jar=\"${launcher}\" fork=\"false\" failonerror=\"true\">\n\t\t\t<arg line=\"-application org.eclipse.ant.core.antRunner\" />\n\t\t\t<arg line=\"-buildfile ${buildfile}\" />\n\t\t\t<arg line=\"-Dbasedir=${basedir}\" />\n\t\t\t<arg line=\"-Dbuilder=${builder}\" />\n\t\t\t<arg line=\"-Dbuildpack=${buildpack}\" />\n\t\t\t<arg line=\"-Dtimestamp=${DSTAMP}${TSTAMP}\" />\n\t\t\t<jvmarg value=\"-XX:MaxPermSize=648m\" />\n\t\t\t<jvmarg value=\"-Xmx1024m\" />\n\t\t</java>\n  </target>\n\t<!-- Set an appropriate build config to only build vega for the current platform -->\n\n\t<target name=\"pde-set-config\" unless=\"build.all\">\n\t\t<condition property=\"build.config\" value=\"linux,gtk,x86\">\n\t\t\t<os name=\"Linux\"/>\n\t\t</condition>\n\n\t\t<condition property=\"build.config\" value=\"macosx,cocoa,x86\">\n\t\t\t<os name=\"Mac OS X\"/>\n\t\t</condition>\n\n\t\t<condition property=\"build.config\" value=\"win32,win32,x86\">\n\t\t\t<os family=\"windows\"/>\n\t\t</condition>\n\t</target>\n    \n</project>\n"
  },
  {
    "path": "build/ant/setup-targets.xml",
    "content": "<?xml version=\"1.0\"?>\n<project name=\"vega.setup\">\n  <target name=\"setup\" depends=\"copy-files,set-build-id,set-build-number\" />\n\n  <target name=\"set-build-id\" if=\"build.id\">\n    <replace file=\"build/stage/plugins/com.subgraph.vega.application/src/com/subgraph/vega/application/about/AboutDialog.java\" value=\"${build.id}\" token=\"0xC0FFEEEE\" />\n  </target>\n\n  <target name=\"set-build-number\" if=\"build.number\">\n    <replace file=\"build/stage/plugins/com.subgraph.vega.api/src/com/subgraph/vega/api/vuge/IConstants.java\" value=\"${build.number}\" token=\"0x00000000\" />\n  </target>\n  \n  <target name=\"copy-files\">\n    <copy todir=\"build/stage/features\" >\n      <fileset dir=\"platform\" >\n        <include name=\"**/*.feature/**\" />\n\t<include name=\"**/*.ui.product/**\" /> \n      </fileset>\n    </copy>\n\n    <copy todir=\"build/stage/plugins\">\n      <fileset dir=\"platform\">\n        <exclude name=\"**/bin/**\" />\n        <exclude name=\"**/.metadata/**\" />\n        <include name=\"**\" />\n      </fileset>\n    </copy>\n  </target>\n\n  <target name=\"clean\">\n    <delete dir=\"build/stage\" />\n  </target>\n\n</project>\n"
  },
  {
    "path": "build/ant/unpack-targets.xml",
    "content": "<?xml version=\"1.0\"?>\n<project name=\"vega.unpack\">\n\n\t<property name=\"build.output\" location=\"build/stage/I.VegaBuild\" />\n\t<property name=\"unpack.dir\" location=\"build/unpack-tmp\" />\n\t<!-- If running in default 'single build' mode, unpack the final archive so it is ready to run -->\n\n\t<target name=\"unpack-archive\" depends=\"choose-archive,unpack-setup,unpack-and-move\" unless=\"build.all\" />\n\n\t<target name=\"unpack-and-move\" depends=\"unpack-osx,unpack-linux,unpack-win32\" unless=\"build.all\">\n\t\t<move file=\"${unpack.dir}/vega\" tofile=\"vega-build\" />\n\t\t<delete dir=\"${unpack.dir}\" />\n\t</target>\n\n\t<!-- Delete a previously unpacked vega package if it exists -->\n\n\t<target name=\"unpack-setup\">\n\t\t<delete dir=\"vega-build\" />\n\t\t<delete dir=\"${unpack.dir}\" />\n\t\t<mkdir dir=\"${unpack.dir}\" />\n\t</target>\n\n\t<!-- One target for each operating system -->\n\n\t<target name=\"unpack-osx\" if=\"unpack.osx\">\n\t\t<unzip src=\"${build.output}/VegaBuild-macosx.cocoa.x86.zip\" dest=\"${unpack.dir}\" />\n\t\t<chmod file=\"${unpack.dir}/vega/Vega.app/Contents/MacOS/Vega\" perm=\"755\" />\n\t</target>\n\n\t<target name=\"unpack-linux\" if=\"unpack.linux\">\n\t\t<unzip src=\"${build.output}/VegaBuild-linux.gtk.x86.zip\" dest=\"${unpack.dir}\" />\n\t\t<chmod file=\"${unpack.dir}/vega/vega\" perm=\"755\" />\n\t\t<chmod file=\"${unpack.dir}/vega/jre/bin/java\" perm=\"755\" />\n\t</target>\n\n\t<target name=\"unpack-win32\" if=\"unpack.win32\">\n\t\t<unzip src=\"${build.output}/VegaBuild-win32.win32.x86.zip\" dest=\"${unpack.dir}\" />\n\t</target>\n\n\t<!-- Set a property depending on which OS the build is being run on -->\n\n\t<target name=\"choose-archive\" unless=\"build.all\">\n\t\t<condition property=\"unpack.linux\">\n\t\t\t<os name=\"Linux\" />\n\t\t</condition>\n\n\t\t<condition property=\"unpack.osx\">\n\t\t\t<os name=\"Mac OS X\" />\n\t\t</condition>\n\n\t\t<condition property=\"unpack.win32\">\n\t\t\t<os family=\"windows\" />\n\t\t</condition>\n\t</target>\n</project>\n"
  },
  {
    "path": "build/archives/buildpack-06032011.tar.bz2.SHA",
    "content": "769a719ec8ce16f787dbe1d355fe2e57bc84a83e\n"
  },
  {
    "path": "build/archives/buildpack-06222011.tar.bz2.SHA",
    "content": "f03381d48e5a64a4f8d9aeee05754ca0309ccb63\n"
  },
  {
    "path": "build/archives/buildpack-07142012.tar.bz2.SHA",
    "content": "84753975feccd342622d4c411de0761a188eda80\n"
  },
  {
    "path": "build/archives/buildpack-10082010.tar.bz2.SHA",
    "content": "838cd010e4ed38892bdcfa0aa1cf88a49241c27b\n"
  },
  {
    "path": "build/buildpacks.txt",
    "content": "Vega Build Packs\n====================\n\nContents\n--------\n\nA build pack contains several third-party dependencies that are needed to \nbuild Vega.\n\nCurrently the following items are included:\n\n  buildpack/target\n\n\tThe Eclipse RCP SDK and RCP delta pack.\n\n  buildpack/org.eclipse.releng.basebuilder\n\n\tThe Eclipse build system.\n\nEach build pack is versioned with the date that it was published using the\ndate format MMDDYYYY in the filname of the archive.  Inside the unpacked\narchive an empty file exists at buildpack/version/MMDDYYYY which identifies\nthe buildpack version which is currently unpacked to the build system.\n\n\nCreating a new Build Pack\n-------------------------\n\nA new build pack can be created with the master build script by specifying the\nant target 'buildpack-create'\n\n  $ ant buildpack-create\n\nThis will create a new buildpack archive from the current contents of the\nbuild/buildpack directory.  \n\n  1) The empty version file (build/buildpack/version/MMDDYYYY) will \n     automatically be created.\n\n  2) The contents of build/buildpack will be placed in a compressed \n     tarball in the build/archives directory as buildpack-MMDDYYYY.tar.bz2\n\n  3) The sha-1 hash value of the new buildpack tarball will be calculated \n     and stored in buildpack-MMDDYYYY.tar.bz2.SHA\n\nThe sha-1 file must be committed into the git repository and the new buildpack\narchive should be uploaded to the subgraph webserver so that it is available\nto be downloaded by the build system when needed.\n\nTo use the new buildpack in a build a property must be changed near the top of\nthe master build file.  This property is called buildpack.version and should be\nchanged to the MMDDYYYY version value of the newly created buildpack.\n\nOnce the buildpack is available in the buildpack directory on the subgraph\nwebserver, the build script will automatically fetch the file, verify the checksum,\nand unpack it into the build/buildpack directory when performing a build which\nrequires the new version.\n\n\n"
  },
  {
    "path": "build/config/build.properties",
    "content": "topLevelElementType = feature\ntopLevelElementId = com.subgraph.vega.application.product\n\nbuildDirectory=${basedir}/build/stage\nproduct=${buildDirectory}/plugins/com.subgraph.vega.application/vega.product\nrunPackager=true\n\n#Set the name of the archive that will result from the product build.\n#archiveNamePrefix=\n\n# The prefix that will be used in the generated archive.\narchivePrefix=vega\n\n# The location underwhich all of the build output will be collected.\ncollectingFolder=${archivePrefix}\n\nconfigs= \\\n win32, win32, x86 & \\\n win32,win32,x86_64 & \\\n linux, gtk, x86 & \\\n linux, gtk, x86_64 & \\\n macosx, cocoa, x86 & \\\n macosx, cocoa, x86_64\n\n# By default PDE creates one archive (result) per entry listed in the configs property.\n# Setting this value to true will cause PDE to only create one output containing all \n# artifacts for all the platforms listed in the configs property.\n# To control the output format for the group, add a \"group, group, group - <format>\" entry to the\n# archivesFormat. \n#groupConfigurations=true\n\n#The format of the archive. By default a zip is created using antZip.\n#The list can only contain the configuration for which the desired format is different than zip.\n#archivesFormat=win32, win32, x86 - antZip& \\\n#\tlinux, gtk, ppc - antZip &\\\n#    linux, gtk, x86 - antZip& \\\n#\tlinux, gtk, x86_64 - antZip& \\\n# linux, motif, x86 - antZip& \\\n#\tsolaris, motif, sparc - antZip& \\\n#\tsolaris, gtk, sparc - antZip& \\\n#\taix, motif, ppc - antZip& \\\n#\thpux, motif, PA_RISC - antZip& \\\n#\tmacosx, carbon, ppc - antZip\narchivesFormat = *,*,*-zip\n\n#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles.\nallowBinaryCycles = true\n\n#Sort bundles depenedencies across all features instead of just within a given feature.\n#flattenDependencies = true\n\n#Parallel compilation, requires flattenedDependencies=true\n#parallelCompilation=true\n#parallelThreadCount=\n#parallelThreadsPerProcessor=\n\t\n#Set to true if you want the output to be ready for an update jar (no site.xml generated)\n#outputUpdateJars = false\n\n\n\n#Arguments to send to the zip executable\nzipargs=\n\n#Arguments to send to the tar executable\ntarargs=\n\n#Control the creation of a file containing the version included in each configuration - on by default \n#generateVersionsLists=false\n\n############## BUILD NAMING CONTROL ################\n# The directory into which the build elements are fetched and where\n# the build takes place.\n\n# Type of build.  Used in naming the build output.  Typically this value is\n# one of I, N, M, S, ...\nbuildType=I\n\n# ID of the build.  Used in naming the build output.\nbuildId=VegaBuild\n\n# Label for the build.  Used in naming the build output\nbuildLabel=${buildType}.${buildId}\n\n# Timestamp for the build.  Used in naming the build output\ntimestamp=007\n\n#The value to be used for the qualifier of a plugin or feature when you want to override the value computed by pde.\n#The value will only be applied to plugin or features indicating build.properties, qualifier = context \n#forceContextQualifier=<the value for the qualifier>\n\n#Enable / disable the generation of a suffix for the features that use .qualifier. \n#The generated suffix is computed according to the content of the feature   \n#generateFeatureVersionSuffix=true\n\n############# BASE CONTROL #############\n# Settings for the base Eclipse components and Java class libraries \n# against which you are building.\n# Base location for anything the build needs to compile against.  For example,\n# in most RCP app or a plug-in,  the baseLocation should be the location of a previously\n# installed Eclipse against which the application or plug-in code will be compiled and the RCP delta pack.\n\nbasebuilder=${basedir}/build/basebuilder/org.eclipse.releng.basebuilder\nbase=${basedir}/build/buildpack/target\nbaseLocation=${base}/eclipse\n\n#Folder containing repositories whose content is needed to compile against\n#repoBaseLocation=${base}/repos\n#Folder where the content of the repositories from ${repoBaseLocation} will be made available as a form suitable to be compiled against\n#transformedRepoLocation=${base}/transformedRepos\n\n#Os/Ws/Arch/nl of the eclipse specified by baseLocation\nbaseos=win32\nbasews=win32\nbasearch=x86\n\n#this property indicates whether you want the set of plug-ins and features to be considered during the build to be limited to the ones reachable from the features / plugins being built\nfilteredDependencyCheck=false\n\n#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons)\nresolution.devMode=false\n\n#pluginPath is a list of locations in which to find plugins and features.  This list is separated by the platform file separator (; or :)\n#a location is one of:  \n#- the location of the jar or folder that is the plugin or feature : /path/to/foo.jar or /path/to/foo\n#- a directory that contains a /plugins or /features subdirectory\n#- the location of a feature.xml, or for 2.1 style plugins, the plugin.xml or fragment.xml\npluginPath=${basedir}/platform/com.subgraph.vega.application/extra-bundles/\n\nskipBase=true\neclipseURL=<url for eclipse download site>\neclipseBuildId=<Id of Eclipse build to get>\neclipseBaseURL=${eclipseURL}/eclipse-platform-${eclipseBuildId}-win32.zip\n\n\n############# MAP FILE CONTROL ################\n# This section defines CVS tags to use when fetching the map files from the repository.\n# If you want to fetch the map file from repository / location, change the getMapFiles target in the customTargets.xml\n\nskipMaps=true\nmapsRepo=:pserver:anonymous@example.com/path/to/repo\nmapsRoot=path/to/maps\nmapsCheckoutTag=HEAD\n\n#tagMaps=true\nmapsTagTag=v${buildId}\n\n\n############ REPOSITORY CONTROL ###############\n# This section defines properties parameterizing the repositories where plugins, fragments\n# bundles and features are being obtained from. \n\n# The tags to use when fetching elements to build.\n# By default thebuilder will use whatever is in the maps.  \n# This value takes the form of a comma separated list of repository identifier (like used in the map files) and the \n# overriding value\n# For example fetchTag=CVS=HEAD, SVN=v20050101\n# fetchTag=HEAD\nskipFetch=true\n\n\n############# JAVA COMPILER OPTIONS ##############\n# The location of the Java jars to compile against.  Typically the rt.jar for your JDK/JRE\n#bootclasspath=${java.home}/lib/rt.jar\n\n# specific JRE locations to compile against. These values are used to compile bundles specifying a \n# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support\n#CDC-1.0/Foundation-1.0= /path/to/rt.jar\n#CDC-1.1/Foundation-1.1=\n#OSGi/Minimum-1.0=\n#OSGi/Minimum-1.1=\n#JRE-1.1=\n#J2SE-1.2=\n#J2SE-1.3=\n#J2SE-1.4=\n#J2SE-1.5=\n#JavaSE-1.6=\n#PersonalJava-1.1=\n#PersonalJava-1.2=\n#CDC-1.0/PersonalBasis-1.0=\n#CDC-1.0/PersonalJava-1.0=\n#CDC-1.1/PersonalBasis-1.1=\n#CDC-1.1/PersonalJava-1.1=\n\n# Specify the output format of the compiler log when eclipse jdt is used\nlogExtension=.log\n\n# Whether or not to include debug info in the output jars\njavacDebugInfo=false \n\n# Whether or not to fail the build if there are compiler errors\njavacFailOnError=true\n\n# Enable or disable verbose mode of the compiler\njavacVerbose=true\n\n# Extra arguments for the compiler. These are specific to the java compiler being used.\n#compilerArg=\n\n# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties\njavacSource=1.6\n\n# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.\njavacTarget=1.6\n\n\n"
  },
  {
    "path": "build/dist-tools/mount-dmg/Makefile",
    "content": "TARGET=mount-dmg\nall: $(TARGET)\nOBJS=mount-dmg.o\nLD=gcc\nCC=gcc\nCFLAGS=-Wall\n.c.o: \n\t$(CC) $(CFLAGS) -c $<\n$(TARGET): $(OBJS)\n\t$(LD) -o $@ $(OBJS)\nclean:\n\trm -f *.o $(TARGET)\ninstall:\n\tcp $(TARGET) /usr/local/bin/$(TARGET)\n\tchmod 4755 /usr/local/bin/$(TARGET)\n"
  },
  {
    "path": "build/dist-tools/mount-dmg/mount-dmg.c",
    "content": "#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <unistd.h>\n#include <sys/wait.h>\n#include <sys/stat.h>\n\nstatic int do_mount(char *);\nstatic int do_umount();\nstatic void exec_mount(char *);\nstatic void exec_umount();\nstatic int wait_status(pid_t);\nint\nmain(int argc, char** argv)\n{\n    if(argc != 2) {\n    \tfprintf(stderr, \"dmg-mount <file>\\n\");\n        exit(EXIT_FAILURE);\n    }\n    setuid(0);\n    if(strcmp(argv[1], \"-u\") == 0)  {\n        chmod(\"/mnt/dmg\", 0755);\n        do_umount();\n    } else {\n        if(do_mount(argv[1]) == 0)\n\t\t\tchmod(\"/mnt/dmg\", 0777);\n    }\n    exit(EXIT_SUCCESS);\n}\n\nstatic int\ndo_mount(char *path) \n{\n    pid_t pid;\n    if((pid = fork()) == -1) {\n        fprintf(stderr, \"fork() failed\\n\");\n        exit(EXIT_FAILURE);\n    }\n    if(pid == 0)  {\n        exec_mount(path);\n\t\treturn -1;\n\t}\n    else {\n        return wait_status(pid);\n\t}\n    \n}\n\nstatic int\ndo_umount()\n{\n    pid_t pid;\n    if((pid = fork()) == -1) {\n        fprintf(stderr, \"fork() failed\\n\");\n        exit(EXIT_FAILURE);\n    }\n    if(pid == 0) {\n        exec_umount();\n\t\treturn -1;\n\t}\n    else {\n        return wait_status(pid);\n\t}\n}\n\nstatic void\nexec_mount(char *path)\n{\n    char *args[6];\n    char *env[] = {NULL};\n\n    args[0] = \"/bin/mount\";\n    args[1] = \"-o\";\n    args[2] = \"loop,nosuid\";\n    args[3] = path;\n    args[4] = \"/mnt/dmg\";\n    args[5] = NULL;\n    execve(\"/bin/mount\", args, env);\n}\n\nstatic void \nexec_umount() \n{\n    char *args[3];\n    char *env[] = {NULL};\n    args[0] = \"/bin/umount\";\n    args[1] = \"/mnt/dmg\";\n    args[2] = NULL;\n    execve(\"/bin/umount\", args, env);\n}\n\nstatic int\nwait_status(pid_t pid)\n{\n    int status;\n\n    if(waitpid(pid, &status, 0) == -1) {\n        fprintf(stderr, \"waitpid() failed.\");\n        exit(EXIT_FAILURE);\n    }\n\n    if(WIFEXITED(status)) \n      return(status);\n    \n    return -1;\n}\n"
  },
  {
    "path": "build/dist-tools/nsis/epl.txt",
    "content": "Eclipse Public License - v 1.0\nTHE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (\"AGREEMENT\"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.\n\n1. DEFINITIONS\n\n\"Contribution\" means:\n\na) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and\n\nb) in the case of each subsequent Contributor:\n\ni) changes to the Program, and\n\nii) additions to the Program;\n\nwhere such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.\n\n\"Contributor\" means any person or entity that distributes the Program.\n\n\"Licensed Patents\" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.\n\n\"Program\" means the Contributions distributed in accordance with this Agreement.\n\n\"Recipient\" means anyone who receives the Program under this Agreement, including all Contributors.\n\n2. GRANT OF RIGHTS\n\na) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.\n\nb) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.\n\nc) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.\n\nd) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.\n\n3. REQUIREMENTS\n\nA Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:\n\na) it complies with the terms and conditions of this Agreement; and\n\nb) its license agreement:\n\ni) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;\n\nii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;\n\niii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and\n\niv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.\n\nWhen the Program is made available in source code form:\n\na) it must be made available under this Agreement; and\n\nb) a copy of this Agreement must be included with each copy of the Program.\n\nContributors may not remove or alter any copyright notices contained within the Program.\n\nEach Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.\n\n4. COMMERCIAL DISTRIBUTION\n\nCommercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (\"Commercial Contributor\") hereby agrees to defend and indemnify every other Contributor (\"Indemnified Contributor\") against any losses, damages and costs (collectively \"Losses\") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.\n\nFor example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.\n\n5. NO WARRANTY\n\nEXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.\n\n6. DISCLAIMER OF LIABILITY\n\nEXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n7. GENERAL\n\nIf any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.\n\nIf Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.\n\nAll Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.\n\nEveryone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.\n\nThis Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.\n"
  },
  {
    "path": "build/dist-tools/nsis/vega.nsi",
    "content": "; Script generated by the HM NIS Edit Script Wizard.\n\n; HM NIS Edit Wizard helper defines\n!define PRODUCT_NAME \"Vega\"\n!define PRODUCT_VERSION \"1.0\"\n!define PRODUCT_PUBLISHER \"Subgraph\"\n!define PRODUCT_WEB_SITE \"http://www.subgraph.com\"\n!define PRODUCT_DIR_REGKEY \"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Vega.exe\"\n!define PRODUCT_UNINST_KEY \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_NAME}\"\n!define PRODUCT_UNINST_ROOT_KEY \"HKLM\"\n\n; MUI 1.67 compatible ------\n!include \"MUI.nsh\"\n\n; MUI Settings\n!define MUI_ABORTWARNING\n!define MUI_ICON \"${NSISDIR}/Contrib/Graphics/Icons/modern-install.ico\"\n!define MUI_UNICON \"${NSISDIR}/Contrib/Graphics/Icons/modern-uninstall.ico\"\n\n; Welcome page\n!insertmacro MUI_PAGE_WELCOME\n; License page\n!insertmacro MUI_PAGE_LICENSE \"epl.txt\"\n; Directory page\n!insertmacro MUI_PAGE_DIRECTORY\n; Instfiles page\n!insertmacro MUI_PAGE_INSTFILES\n; Finish page\n!define MUI_FINISHPAGE_RUN \"$INSTDIR\\Vega.exe\"\n!insertmacro MUI_PAGE_FINISH\n\n; Uninstaller pages\n!insertmacro MUI_UNPAGE_INSTFILES\n\n; Language files\n!insertmacro MUI_LANGUAGE \"English\"\n\n; MUI end ------\n\nName \"${PRODUCT_NAME} ${PRODUCT_VERSION}\"\nOutFile \"VegaSetup.exe\"\nInstallDir \"$PROGRAMFILES\\Vega\"\nInstallDirRegKey HKLM \"${PRODUCT_DIR_REGKEY}\" \"\"\nShowInstDetails show\nShowUnInstDetails show\n\nSection \"MainSection\" SEC01\n  SetOutPath \"$INSTDIR\"\n  SetOverwrite try\n  File \"vega/.eclipseproduct\"\n  SetOutPath \"$INSTDIR\\configuration\"\n  File \"vega/configuration/config.ini\"\n  SetOutPath \"$INSTDIR\\configuration\\org.eclipse.equinox.simpleconfigurator\"\n  File \"vega/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info\"\n  SetOutPath \"$INSTDIR\\features\"\n  File /r \"vega/features/*.*\"\n  SetOutPath \"$INSTDIR\\plugins\"\n  File /r \"vega/plugins/*.*\"\n  SetOutPath \"$INSTDIR\\scripts\"\n  File \"vega/scripts/.project\"\n  SetOutPath \"$INSTDIR\\scripts\\.settings\"\n  File \"vega/scripts/.settings/.jsdtscope\"\n  File \"vega/scripts/.settings/org.eclipse.wst.jsdt.ui.superType.container\"\n  File \"vega/scripts/.settings/org.eclipse.wst.jsdt.ui.superType.name\"\n  SetOutPath \"$INSTDIR\\scripts\\scanner\\modules\\injection\"\n  File \"vega/scripts/scanner/modules/injection/*.js\"\n  SetOutPath \"$INSTDIR\\scripts\\scanner\\modules\\response\"\n  File \"vega/scripts/scanner/modules/response/*.js\"\n  SetOutPath \"$INSTDIR\\scripts\\scanner\\prelude\"\n  File \"vega/scripts/scanner/prelude/jquery.js\"\n  SetOutPath \"$INSTDIR\\templates\"\n  File \"vega/templates/*.*\"\n  SetOutPath \"$INSTDIR\"\n  File \"vega/Vega.exe\"\n  CreateDirectory \"$SMPROGRAMS\\Vega\"\n  CreateShortCut \"$SMPROGRAMS\\Vega\\Vega.lnk\" \"$INSTDIR\\Vega.exe\"\n  CreateShortCut \"$DESKTOP\\Vega.lnk\" \"$INSTDIR\\Vega.exe\"\n  File \"vega/Vega.ini\"\n  SetOutPath \"$INSTDIR\\xml\\alerts\"\n  File \"vega/xml/alerts/*.xml\"\nSectionEnd\n\nSection -AdditionalIcons\n  SetOutPath $INSTDIR\n  WriteIniStr \"$INSTDIR\\${PRODUCT_NAME}.url\" \"InternetShortcut\" \"URL\" \"${PRODUCT_WEB_SITE}\"\n  CreateShortCut \"$SMPROGRAMS\\Vega\\Website.lnk\" \"$INSTDIR\\${PRODUCT_NAME}.url\"\n  CreateShortCut \"$SMPROGRAMS\\Vega\\Uninstall.lnk\" \"$INSTDIR\\uninst.exe\"\nSectionEnd\n\nSection -Post\n  WriteUninstaller \"$INSTDIR\\uninst.exe\"\n  WriteRegStr HKLM \"${PRODUCT_DIR_REGKEY}\" \"\" \"$INSTDIR\\Vega.exe\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayName\" \"$(^Name)\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"UninstallString\" \"$INSTDIR\\uninst.exe\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayIcon\" \"$INSTDIR\\Vega.exe\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayVersion\" \"${PRODUCT_VERSION}\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"URLInfoAbout\" \"${PRODUCT_WEB_SITE}\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"Publisher\" \"${PRODUCT_PUBLISHER}\"\nSectionEnd\n\n\nFunction un.onUninstSuccess\n  HideWindow\n  MessageBox MB_ICONINFORMATION|MB_OK \"$(^Name) was successfully removed from your computer.\"\nFunctionEnd\n\nFunction un.onInit\n  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \"Are you sure you want to completely remove $(^Name) and all of its components?\" IDYES +2\n  Abort\nFunctionEnd\n\nSection Uninstall\n\n  Delete \"$SMPROGRAMS\\Vega\\Uninstall.lnk\"\n  Delete \"$SMPROGRAMS\\Vega\\Website.lnk\"\n  Delete \"$DESKTOP\\Vega.lnk\"\n  Delete \"$SMPROGRAMS\\Vega\\Vega.lnk\"\n\n  RMDir \"$SMPROGRAMS\\Vega\"\n  RMDir /r \"$INSTDIR\"\n\n  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\"\n  DeleteRegKey HKLM \"${PRODUCT_DIR_REGKEY}\"\n  SetAutoClose true\nSectionEnd\n"
  },
  {
    "path": "build/dist-tools/nsis/win-x86.ini",
    "content": "-vmargs \r\n-Xms256m \r\n-XX:PermSize=128m \r\n-XX:MaxPermSize=256m \r\n-Xmx1024m \r\n\r\n"
  },
  {
    "path": "build/dist-tools/nsis/win-x86_64.ini",
    "content": "-vmargs \r\n-Xms256m \r\n-XX:PermSize=128m \r\n-XX:MaxPermSize=256m \r\n-Xmx2048m \r\n\r\n"
  },
  {
    "path": "build/dist-tools/nsis/windows-dist.sh",
    "content": "#!/bin/sh\n\n\nTARGET=build/tmp/dist-windows\n\nmake_dist() {\n    ARCH=$1\n    VEGA=build/stage/I.VegaBuild/VegaBuild-win32.win32.$ARCH.zip\n    rm -rf $TARGET\n    mkdir -p $TARGET\n    /usr/bin/unzip -d $TARGET $VEGA\n    cp build/dist-tools/nsis/win-$ARCH.ini $TARGET/vega/Vega.ini\n    cp build/dist-tools/nsis/epl.txt $TARGET\n    cp build/dist-tools/nsis/vega.nsi $TARGET\n    /usr/local/bin/makensis $TARGET/vega.nsi\n}\n\nmkdir build/dist\n\nmake_dist x86\nmv $TARGET/VegaSetup.exe build/dist/VegaSetup32.exe\n\nmake_dist x86_64\nmv $TARGET/VegaSetup.exe build/dist/VegaSetup64.exe\n\n\n"
  },
  {
    "path": "build/dist-tools/osx/osx-dist.sh",
    "content": "#!/bin/bash\nTARGET=build/tmp/dist-osx\n\nmake_dist() {\n\techo \"enter make_dist()\"\n\tARCH=$1\n\tVEGA=build/stage/I.VegaBuild/VegaBuild-macosx.cocoa.$ARCH.zip\n\trm -rf $TARGET\n\tmkdir -p $TARGET\n\techo \"Target is $TARGET\"\n\techo \"Vega is $VEGA\"\n\t/usr/bin/unzip -d $TARGET $VEGA\n\tLAUNCHER=$(ls $TARGET/vega/plugins/org.eclipse.equinox.launcher*.jar)\n\tLAUNCHER_LIB=$(ls -d $TARGET/vega/plugins/org.eclipse.equinox.launcher.cocoa*)\n\tcat > $TARGET/Vega.ini <<- EOF\n\t-startup\n\t../Resources/plugins/$(basename $LAUNCHER)\n\t--launcher.library\n\t../Resources/plugins/$(basename $LAUNCHER_LIB)\n\t$(cat $TARGET/vega/Vega.app/Contents/MacOS/Vega.ini)\n\tEOF\n\tRESOURCES=$TARGET/vega/Vega.app/Contents/Resources\n\tmv $TARGET/vega/plugins $RESOURCES\n\tmv $TARGET/vega/features $RESOURCES\n\tmv $TARGET/vega/configuration $RESOURCES\n\tmv $TARGET/vega/scripts $RESOURCES\n\tmv $TARGET/vega/xml $RESOURCES\n\tmv $TARGET/vega/templates $RESOURCES\n\tmv $TARGET/Vega.ini $TARGET/vega/Vega.app/Contents/MacOS/Vega.ini\n}\n\nmake_dmg() {\n\techo \"enter make_dmg()\"\n\tdd if=/dev/zero of=$TARGET/vega.dmg bs=1M count=40\n\tmkfs.hfsplus -v Vega $TARGET/vega.dmg\n\t/usr/local/bin/mount-dmg $TARGET/vega.dmg\n\tmv $TARGET/vega/Vega.app /mnt/dmg\n\t/usr/local/bin/mount-dmg -u\n}\nmkdir build/dist\nmake_dist x86\nmake_dmg\nmv $TARGET/vega.dmg build/dist/Vega.dmg\nmake_dist x86_64\nmake_dmg\nmv $TARGET/vega.dmg build/dist/Vega64.dmg\n#rm -rf build/tmp\n\n\n\n"
  },
  {
    "path": "build.xml",
    "content": "<?xml version=\"1.0\"?>\n<project name=\"vega.build\" default=\"all\">\n\n\t<property name=\"buildpack.version\" value=\"07142012\" />\n\n\t<import file=\"build/ant/setup-targets.xml\" />\n\t<import file=\"build/ant/buildpack-targets.xml\" />\n\t<import file=\"build/ant/pde-build-targets.xml\" />\n\t<import file=\"build/ant/unpack-targets.xml\" />\n\n\t<target name=\"one\">\n    <property name=\"build.one\" value=\"true\" />\n    <antcall target=\"dobuild\" />\n\t</target>\n\n  <target name=\"dobuild\">\n\t\t<antcall target=\"buildpack-setup\" />\n\t\t<antcall target=\"clean\" />\n\t\t<antcall target=\"setup\" />\n\t\t<antcall target=\"pde-build\" />\n\t\t<antcall target=\"unpack-archive\" />\n  </target>\n\n\t<target name=\"all\">\n\t\t<property name=\"build.all\" value=\"true\" />\n\t\t<antcall target=\"dobuild\" />\n\t</target>\n\n  <target name=\"dist\">\n\t<property name=\"build.all\" value=\"true\" />\n\t<antcall target=\"dobuild\" />\n    <exec executable=\"build/dist-tools/osx/osx-dist.sh\"></exec>\n    <exec executable=\"build/dist-tools/nsis/windows-dist.sh\"></exec>\n  </target>\n</project>\n"
  },
  {
    "path": "dependencies/hc/README.txt",
    "content": "\nHow to build OSGi compatible HttpComponents bundles for Vega.\n\n(\n1) Download the latest versions of the source packages:\n\n    httpcomponents-client-4.2.2-src.tar.gz\n    httpcomponents-core-4.2.3-src.tar.gz\n\n2) Unpack both archives.\n\n3) Patch httpclient file: \n\n     httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector\n\n   Change method wrapRequest() from private to protected:\n\n     DefaultRequestDirector#wrapRequest(HttpRequest request)\n\n\n4) Build both packages with the command 'mvn package'\n\n5) Build artifacts can be found in\n\n   httpcomponents-client-4.2.2/httpclient/target\n   httpcomponents-core-4.2.3/httpcore/target\n\n6) Copy the following 4 jar files into the lib/ directory:\n\n  From httpcomponents-client-4.2.2/httpclient/target\n\n    httpclient-4.2.2.jar\n    httpclient-4.2.2-sources.jar\n\n  From httpcomponents-core-4.2.3/httpcore/target\n\n    httpcore-4.2.3-sources.jar\n    httpcore-4.2.3.jar\n\n7) Run 'ant', generated jars appear in output/ directory\n\n    org.apache.http.client_4.2.2.vega.jar\n    org.apache.http.core_4.2.3.vega.jar \n    org.apache.http.client.source_4.2.2.vega.jar\n    org.apache.http.core.source_4.2.3.vega.jar\n\n8) Move all of these to\n\n  Vega/platform/com.subgraph.vega.application/extra-bundles\n\n  Delete the bundles which are begin upgraded \n\n\n9) possibly change feature.xml, reset target platform, etc...\n"
  },
  {
    "path": "dependencies/hc/build.xml",
    "content": "<?xml version=\"1.0\"?>\n<project name=\"vega.bnd\" default=\"main\">\n  <target name=\"main\">\n    <taskdef resource=\"aQute/bnd/ant/taskdef.properties\" classpath=\"../lib/biz.aQute.bnd.jar\" />\n    <bnd files=\"org.apache.http.core.bnd\" output=\"output\" />\n    <bnd files=\"org.apache.http.core.source.bnd\" output=\"output\" />\n    <bnd files=\"org.apache.http.client.bnd\" output=\"output\" />\n    <bnd files=\"org.apache.http.client.source.bnd\" output=\"output\" />\n  </target>\n</project>\n"
  },
  {
    "path": "dependencies/hc/libs/README.txt",
    "content": "Place these 4 jar files here:\n\n  httpclient-4.2.2.jar  \n  httpclient-4.2.2-sources.jar  \n  httpcore-4.2.3.jar  \n  httpcore-4.2.3-sources.jar\n\n"
  },
  {
    "path": "dependencies/hc/org.apache.http.client.bnd",
    "content": "-classpath libs/httpclient-4.2.2.jar\n-output org.apache.http.client_4.2.2.vega.jar\nExport-Package: *\nBundle-Name: org.apache.http.client\nBundle-SymbolicName: org.apache.http.client\nBundle-Version: 4.2.2\nImport-Package: *;resolution:=optional\n\n\n"
  },
  {
    "path": "dependencies/hc/org.apache.http.client.source.bnd",
    "content": "Include-Resource: @libs/httpclient-4.2.2-sources.jar \n-output org.apache.http.client.source_4.2.2.vega.jar\n-classpath libs/httpclient-4.2.2-sources.jar\nBundle-Version: 4.2.2\nEclipse-SourceBundle: org.apache.http.client;version=4.2.2;roots:=\".\"\nPrivate-Package: *\n\n"
  },
  {
    "path": "dependencies/hc/org.apache.http.core.bnd",
    "content": "-classpath libs/httpcore-4.2.3.jar\n-output org.apache.http.core_4.2.3.vega.jar\nBundle-Name: org.apache.http.core\nBundle-SymbolicName: org.apache.http.core\nExport-Package: *\nBundle-Version: 4.2.3\nImport-Package: *;resolution:=optional\n"
  },
  {
    "path": "dependencies/hc/org.apache.http.core.source.bnd",
    "content": "Include-Resource: @libs/httpcore-4.2.3-sources.jar \n-output org.apache.http.core.source_4.2.3.vega.jar\n-classpath libs/httpcore-4.2.3-sources.jar\nBundle-Version: 4.2.3\nEclipse-SourceBundle: org.apache.http.core;version=4.2.3;roots:=\".\"\nPrivate-Package: *\n\n"
  },
  {
    "path": "dependencies/hc/output/README.txt",
    "content": "After processing the output bundles will be placed in this directory.\n"
  },
  {
    "path": "licenses/MPL2.0.txt",
    "content": "The majority of Rhino is licensed under the MPL 2.0:\n\nMozilla Public License Version 2.0\n==================================\n\n1. Definitions\n--------------\n\n1.1. \"Contributor\"\n    means each individual or legal entity that creates, contributes to\n    the creation of, or owns Covered Software.\n\n1.2. \"Contributor Version\"\n    means the combination of the Contributions of others (if any) used\n    by a Contributor and that particular Contributor's Contribution.\n\n1.3. \"Contribution\"\n    means Covered Software of a particular Contributor.\n\n1.4. \"Covered Software\"\n    means Source Code Form to which the initial Contributor has attached\n    the notice in Exhibit A, the Executable Form of such Source Code\n    Form, and Modifications of such Source Code Form, in each case\n    including portions thereof.\n\n1.5. \"Incompatible With Secondary Licenses\"\n    means\n\n    (a) that the initial Contributor has attached the notice described\n        in Exhibit B to the Covered Software; or\n\n    (b) that the Covered Software was made available under the terms of\n        version 1.1 or earlier of the License, but not also under the\n        terms of a Secondary License.\n\n1.6. \"Executable Form\"\n    means any form of the work other than Source Code Form.\n\n1.7. \"Larger Work\"\n    means a work that combines Covered Software with other material, in \n    a separate file or files, that is not Covered Software.\n\n1.8. \"License\"\n    means this document.\n\n1.9. \"Licensable\"\n    means having the right to grant, to the maximum extent possible,\n    whether at the time of the initial grant or subsequently, any and\n    all of the rights conveyed by this License.\n\n1.10. \"Modifications\"\n    means any of the following:\n\n    (a) any file in Source Code Form that results from an addition to,\n        deletion from, or modification of the contents of Covered\n        Software; or\n\n    (b) any new file in Source Code Form that contains any Covered\n        Software.\n\n1.11. \"Patent Claims\" of a Contributor\n    means any patent claim(s), including without limitation, method,\n    process, and apparatus claims, in any patent Licensable by such\n    Contributor that would be infringed, but for the grant of the\n    License, by the making, using, selling, offering for sale, having\n    made, import, or transfer of either its Contributions or its\n    Contributor Version.\n\n1.12. \"Secondary License\"\n    means either the GNU General Public License, Version 2.0, the GNU\n    Lesser General Public License, Version 2.1, the GNU Affero General\n    Public License, Version 3.0, or any later versions of those\n    licenses.\n\n1.13. \"Source Code Form\"\n    means the form of the work preferred for making modifications.\n\n1.14. \"You\" (or \"Your\")\n    means an individual or a legal entity exercising rights under this\n    License. For legal entities, \"You\" includes any entity that\n    controls, is controlled by, or is under common control with You. For\n    purposes of this definition, \"control\" means (a) the power, direct\n    or indirect, to cause the direction or management of such entity,\n    whether by contract or otherwise, or (b) ownership of more than\n    fifty percent (50%) of the outstanding shares or beneficial\n    ownership of such entity.\n\n2. License Grants and Conditions\n--------------------------------\n\n2.1. Grants\n\nEach Contributor hereby grants You a world-wide, royalty-free,\nnon-exclusive license:\n\n(a) under intellectual property rights (other than patent or trademark)\n    Licensable by such Contributor to use, reproduce, make available,\n    modify, display, perform, distribute, and otherwise exploit its\n    Contributions, either on an unmodified basis, with Modifications, or\n    as part of a Larger Work; and\n\n(b) under Patent Claims of such Contributor to make, use, sell, offer\n    for sale, have made, import, and otherwise transfer either its\n    Contributions or its Contributor Version.\n\n2.2. Effective Date\n\nThe licenses granted in Section 2.1 with respect to any Contribution\nbecome effective for each Contribution on the date the Contributor first\ndistributes such Contribution.\n\n2.3. Limitations on Grant Scope\n\nThe licenses granted in this Section 2 are the only rights granted under\nthis License. No additional rights or licenses will be implied from the\ndistribution or licensing of Covered Software under this License.\nNotwithstanding Section 2.1(b) above, no patent license is granted by a\nContributor:\n\n(a) for any code that a Contributor has removed from Covered Software;\n    or\n\n(b) for infringements caused by: (i) Your and any other third party's\n    modifications of Covered Software, or (ii) the combination of its\n    Contributions with other software (except as part of its Contributor\n    Version); or\n\n(c) under Patent Claims infringed by Covered Software in the absence of\n    its Contributions.\n\nThis License does not grant any rights in the trademarks, service marks,\nor logos of any Contributor (except as may be necessary to comply with\nthe notice requirements in Section 3.4).\n\n2.4. Subsequent Licenses\n\nNo Contributor makes additional grants as a result of Your choice to\ndistribute the Covered Software under a subsequent version of this\nLicense (see Section 10.2) or under the terms of a Secondary License (if\npermitted under the terms of Section 3.3).\n\n2.5. Representation\n\nEach Contributor represents that the Contributor believes its\nContributions are its original creation(s) or it has sufficient rights\nto grant the rights to its Contributions conveyed by this License.\n\n2.6. Fair Use\n\nThis License is not intended to limit any rights You have under\napplicable copyright doctrines of fair use, fair dealing, or other\nequivalents.\n\n2.7. Conditions\n\nSections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted\nin Section 2.1.\n\n3. Responsibilities\n-------------------\n\n3.1. Distribution of Source Form\n\nAll distribution of Covered Software in Source Code Form, including any\nModifications that You create or to which You contribute, must be under\nthe terms of this License. You must inform recipients that the Source\nCode Form of the Covered Software is governed by the terms of this\nLicense, and how they can obtain a copy of this License. You may not\nattempt to alter or restrict the recipients' rights in the Source Code\nForm.\n\n3.2. Distribution of Executable Form\n\nIf You distribute Covered Software in Executable Form then:\n\n(a) such Covered Software must also be made available in Source Code\n    Form, as described in Section 3.1, and You must inform recipients of\n    the Executable Form how they can obtain a copy of such Source Code\n    Form by reasonable means in a timely manner, at a charge no more\n    than the cost of distribution to the recipient; and\n\n(b) You may distribute such Executable Form under the terms of this\n    License, or sublicense it under different terms, provided that the\n    license for the Executable Form does not attempt to limit or alter\n    the recipients' rights in the Source Code Form under this License.\n\n3.3. Distribution of a Larger Work\n\nYou may create and distribute a Larger Work under terms of Your choice,\nprovided that You also comply with the requirements of this License for\nthe Covered Software. If the Larger Work is a combination of Covered\nSoftware with a work governed by one or more Secondary Licenses, and the\nCovered Software is not Incompatible With Secondary Licenses, this\nLicense permits You to additionally distribute such Covered Software\nunder the terms of such Secondary License(s), so that the recipient of\nthe Larger Work may, at their option, further distribute the Covered\nSoftware under the terms of either this License or such Secondary\nLicense(s).\n\n3.4. Notices\n\nYou may not remove or alter the substance of any license notices\n(including copyright notices, patent notices, disclaimers of warranty,\nor limitations of liability) contained within the Source Code Form of\nthe Covered Software, except that You may alter any license notices to\nthe extent required to remedy known factual inaccuracies.\n\n3.5. Application of Additional Terms\n\nYou may choose to offer, and to charge a fee for, warranty, support,\nindemnity or liability obligations to one or more recipients of Covered\nSoftware. However, You may do so only on Your own behalf, and not on\nbehalf of any Contributor. You must make it absolutely clear that any\nsuch warranty, support, indemnity, or liability obligation is offered by\nYou alone, and You hereby agree to indemnify every Contributor for any\nliability incurred by such Contributor as a result of warranty, support,\nindemnity or liability terms You offer. You may include additional\ndisclaimers of warranty and limitations of liability specific to any\njurisdiction.\n\n4. Inability to Comply Due to Statute or Regulation\n---------------------------------------------------\n\nIf it is impossible for You to comply with any of the terms of this\nLicense with respect to some or all of the Covered Software due to\nstatute, judicial order, or regulation then You must: (a) comply with\nthe terms of this License to the maximum extent possible; and (b)\ndescribe the limitations and the code they affect. Such description must\nbe placed in a text file included with all distributions of the Covered\nSoftware under this License. Except to the extent prohibited by statute\nor regulation, such description must be sufficiently detailed for a\nrecipient of ordinary skill to be able to understand it.\n\n5. Termination\n--------------\n\n5.1. The rights granted under this License will terminate automatically\nif You fail to comply with any of its terms. However, if You become\ncompliant, then the rights granted under this License from a particular\nContributor are reinstated (a) provisionally, unless and until such\nContributor explicitly and finally terminates Your grants, and (b) on an\nongoing basis, if such Contributor fails to notify You of the\nnon-compliance by some reasonable means prior to 60 days after You have\ncome back into compliance. Moreover, Your grants from a particular\nContributor are reinstated on an ongoing basis if such Contributor\nnotifies You of the non-compliance by some reasonable means, this is the\nfirst time You have received notice of non-compliance with this License\nfrom such Contributor, and You become compliant prior to 30 days after\nYour receipt of the notice.\n\n5.2. If You initiate litigation against any entity by asserting a patent\ninfringement claim (excluding declaratory judgment actions,\ncounter-claims, and cross-claims) alleging that a Contributor Version\ndirectly or indirectly infringes any patent, then the rights granted to\nYou by any and all Contributors for the Covered Software under Section\n2.1 of this License shall terminate.\n\n5.3. In the event of termination under Sections 5.1 or 5.2 above, all\nend user license agreements (excluding distributors and resellers) which\nhave been validly granted by You or Your distributors under this License\nprior to termination shall survive termination.\n\n************************************************************************\n*                                                                      *\n*  6. Disclaimer of Warranty                                           *\n*  -------------------------                                           *\n*                                                                      *\n*  Covered Software is provided under this License on an \"as is\"       *\n*  basis, without warranty of any kind, either expressed, implied, or  *\n*  statutory, including, without limitation, warranties that the       *\n*  Covered Software is free of defects, merchantable, fit for a        *\n*  particular purpose or non-infringing. The entire risk as to the     *\n*  quality and performance of the Covered Software is with You.        *\n*  Should any Covered Software prove defective in any respect, You     *\n*  (not any Contributor) assume the cost of any necessary servicing,   *\n*  repair, or correction. This disclaimer of warranty constitutes an   *\n*  essential part of this License. No use of any Covered Software is   *\n*  authorized under this License except under this disclaimer.         *\n*                                                                      *\n************************************************************************\n\n************************************************************************\n*                                                                      *\n*  7. Limitation of Liability                                          *\n*  --------------------------                                          *\n*                                                                      *\n*  Under no circumstances and under no legal theory, whether tort      *\n*  (including negligence), contract, or otherwise, shall any           *\n*  Contributor, or anyone who distributes Covered Software as          *\n*  permitted above, be liable to You for any direct, indirect,         *\n*  special, incidental, or consequential damages of any character      *\n*  including, without limitation, damages for lost profits, loss of    *\n*  goodwill, work stoppage, computer failure or malfunction, or any    *\n*  and all other commercial damages or losses, even if such party      *\n*  shall have been informed of the possibility of such damages. This   *\n*  limitation of liability shall not apply to liability for death or   *\n*  personal injury resulting from such party's negligence to the       *\n*  extent applicable law prohibits such limitation. Some               *\n*  jurisdictions do not allow the exclusion or limitation of           *\n*  incidental or consequential damages, so this exclusion and          *\n*  limitation may not apply to You.                                    *\n*                                                                      *\n************************************************************************\n\n8. Litigation\n-------------\n\nAny litigation relating to this License may be brought only in the\ncourts of a jurisdiction where the defendant maintains its principal\nplace of business and such litigation shall be governed by laws of that\njurisdiction, without reference to its conflict-of-law provisions.\nNothing in this Section shall prevent a party's ability to bring\ncross-claims or counter-claims.\n\n9. Miscellaneous\n----------------\n\nThis License represents the complete agreement concerning the subject\nmatter hereof. If any provision of this License is held to be\nunenforceable, such provision shall be reformed only to the extent\nnecessary to make it enforceable. Any law or regulation which provides\nthat the language of a contract shall be construed against the drafter\nshall not be used to construe this License against a Contributor.\n\n10. Versions of the License\n---------------------------\n\n10.1. New Versions\n\nMozilla Foundation is the license steward. Except as provided in Section\n10.3, no one other than the license steward has the right to modify or\npublish new versions of this License. Each version will be given a\ndistinguishing version number.\n\n10.2. Effect of New Versions\n\nYou may distribute the Covered Software under the terms of the version\nof the License under which You originally received the Covered Software,\nor under the terms of any subsequent version published by the license\nsteward.\n\n10.3. Modified Versions\n\nIf you create software not governed by this License, and you want to\ncreate a new license for such software, you may create and use a\nmodified version of this License if you rename the license and remove\nany references to the name of the license steward (except to note that\nsuch modified license differs from this License).\n\n10.4. Distributing Source Code Form that is Incompatible With Secondary\nLicenses\n\nIf You choose to distribute Source Code Form that is Incompatible With\nSecondary Licenses under the terms of this version of the License, the\nnotice described in Exhibit B of this License must be attached.\n\nExhibit A - Source Code Form License Notice\n-------------------------------------------\n\n  This Source Code Form is subject to the terms of the Mozilla Public\n  License, v. 2.0. If a copy of the MPL was not distributed with this\n  file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\nIf it is not possible or desirable to put the notice in a particular\nfile, then You may include the notice in a location (such as a LICENSE\nfile in a relevant directory) where a recipient would be likely to look\nfor such a notice.\n\nYou may add additional accurate notices of copyright ownership.\n\nExhibit B - \"Incompatible With Secondary Licenses\" Notice\n---------------------------------------------------------\n\n  This Source Code Form is \"Incompatible With Secondary Licenses\", as\n  defined by the Mozilla Public License, v. 2.0.\n"
  },
  {
    "path": "licenses/db4o-dOCL.txt",
    "content": "============================================================\nNotices for file(s):\n  /Vega/platform/com.subgraph.vega.model/lib/db4o-8.0.249.16098-all-java5.jar\n\nVega uses db4o under the dOCL.\nhttp://community.versant.com/Blogs/db4o/tabid/197/entryid/1044/Default.aspx\n\nLicense text from http://www.versant.com/products/New_db4o/Open_Source_Licensing/dOCL.aspx\n------------------------------------------------------------\n\ndb4o Free/Libre and Open Source Compatibility Software License Agreement (dOCL)\nDecember 2006\n\nPLEASE READ THE FOLLOWING TERMS AND CONDITIONS CAREFULLY BEFORE DOWNLOADING, INSTALLING, DISTRIBUTING, LICENSING, OR USING THE SOFTWARE (DEFINED BELOW). THE TERMS AND CONDITIONS OF THIS SOFTWARE LICENSE AGREEMENT (\"AGREEMENT\") GOVERN USE OF THE SOFTWARE UNLESS YOU AND DB4OBJECTS, INC. (\"DB4OBJECTS\") HAVE EXECUTED A SEPARATE AGREEMENT.\n\nVersant licenses the Software (as defined in Section 1) pursuant to (1) this Agreement, (2) a commercial, royalty-based license agreement, and (3) the GNU General Public License v2.0 (\"GPL\"). You may choose to license the Software pursuant to any of the three agreements. Except for any software or other code licensed pursuant to the free/libre and open source software (\"FLOSS\") licenses set forth in Section 4, where your software is a Derivative Work (defined below) of the Software, this Agreement requires you to distribute and license your software pursuant to the GPL.\n\nIn order for this Agreement to become effective, you must register your software. Register your software by sending an email to community@db4o.com. Please provide your email address or developer website username and your software title. There, you will be asked to provide a short description of your software, release notes, and a link to all versions of your software in binary and/or source code form, whichever is required by the applicable FLOSS license.\n\n1. Subject\n\"Software\" means the current version of the db4o database engine software and all patches, bug fixes, error corrections and future versions. Software does not mean add-on packages which are not part of the db4o database engine such as Hibernate or Bloat, which you would license directly from their respective vendors.\n\n2. Redistribution License\nSubject to your compliance with the terms and conditions of this Agreement, Versant grants you a non-exclusive and non-transferable license to:\na. create a Derivative Work (defined below) of the Software by combining it with your software (thereby creating a \"FLOSS Application\");\nb. sublicense to your end users perpetually, pursuant to the terms of the GPL, those portions of the Software or your FLOSS Application that were not licensed pursuant to a FLOSS License prior to your accepting this Agreement; and\nc. download, install, distribute, license, and use updates of the Software on these same terms and conditions.\nYou may obtain copies of the Software by download from the Versant website. Software governed by this Agreement and Software governed by the GPL are obtained from the same source. For this reason, portions of the Software may be flagged as governed by the GPL license. However, the terms under which Versant licenses the Software to you depend on your choice of license, regardless of any GPL notices contained in the Software.\n\n3. Derivative Works\nFor the purpose of this Agreement, software is deemed a derivative work of the Software (\"Derivative Work\") where it is based on the Software, including without limitation in the following circumstances:\na. the software is compiled against the Software;\nb. the software contains specific references to the Software;\nc. the software requires the Software to work; or\nd. the software uses the proprietary API to the Software.\n\n4. Free/Libre and Open Source Software Licenses\nWhere your FLOSS Application contains software components that were licensed pursuant to one of the FLOSS licenses set forth below (\"FLOSS Licenses\"), you may distribute such software components subject to that pre-existing FLOSS License.\na. GNU Library (or \"Lesser\") General Public License (LGPL), versions 2.0 and 2.1\nb. Apache Software License, versions 1.0, 1.1, or 2.0\nc. BSD License, as copyrighted on July 22, 1999\nd. Eclipse Public License, version 1.0\ne. MIT/X11 License\nf. Mozilla Public License, version 1.1\ng. Microsoft Public License (Ms-PL)\nh. Microsoft Reciprocal License (Ms-RL)\ni. Code Project Open 1.02 License\nFor the avoidance of doubt, any works that are merely aggregated with the Software or your FLOSS Application on a volume of storage or distribution medium and that can reasonably be considered independent and separate works are not Derivative Works of the Software or your FLOSS Application, and are outside the scope of this Agreement.\n\n5. Ownership\nThe Software is licensed, not sold. You own the media on which the Software is recorded, but Versant retains ownership of the Software, including all intellectual property rights therein. The Software is protected by United States copyright law and international treaties. You will not delete or in any manner alter the copyright, trademark, or other proprietary rights notices or markings appearing on the Software as delivered to you.\n\n6. Publicity\nVersant may publicize your use of the Software in the FLOSS Application as part of Versant's efforts to market the Software.\n\n7. Term\nThis Agreement remains effective for as long as your FLOSS Application is listed in our Projects section. You may terminate it at any time by destroying all copies of the Software in your possession or control. This Agreement will automatically terminate without notice if you breach any term of this Agreement. Upon termination, you must promptly destroy all copies of the Software in your possession or control.\n\n8. Warranty Disclaimer\nVERSANT MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NONINFRINGEMENT. VERSANT DOES NOT WARRANT THAT THE SOFTWARE IS ERROR FREE OR THAT YOU WILL BE ABLE TO OPERATE THE SOFTWARE WITHOUT PROBLEMS OR INTERRUPTION. Versant does not guarantee the permanent availability of the Versant website.\n\n9. Limitation of Liability\nIN NO EVENT WILL VERSANT BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY SPECIAL, INCIDENTAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL DAMAGES (INCLUDING LOSS OF USE, DATA, BUSINESS, OR PROFITS) OR FOR THE COST OF PROCURING SUBSTITUTE PRODUCTS ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT OR THE USE OR PERFORMANCE OF THE SOFTWARE, WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY, OR OTHERWISE, AND WHETHER OR NOT VERSANT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. THE FOREGOING LIMITATIONS WILL SURVIVE AND APPLY EVEN IF ANY LIMITED REMEDY SPECIFIED IN THIS AGREEMENT IS FOUND TO HAVE FAILED OF ITS ESSENTIAL PURPOSE.\n\n10. Export Law\nYou agree to comply fully with all U.S. export laws and regulations to ensure that neither the Software nor any technical data related thereto nor any direct product thereof are exported or re-exported directly or indirectly in violation of, or used for any purposes prohibited by, such laws and regulations.\n\n11. General\nThis Agreement will be governed by and construed in accordance with the laws of the State of California, without regard to or application of conflicts of law rules or principles. The United Nations Convention on Contracts for the International Sale of Goods will not apply. You may not assign or transfer this Agreement or any rights granted hereunder, by operation of law or otherwise, without Versant's prior written consent, and any attempt by you to do so, without such consent, will be void and of no effect. Except as expressly set forth in this Agreement, the exercise by either party of any of its remedies under this Agreement will be without prejudice to its other remedies under this Agreement or otherwise. The failure by either party to enforce any provision of this Agreement will not constitute a waiver of future enforcement of that or any other provision. Any waiver, modification, or amendment of any provision of this Agreement will be effective only if in writing and signed by authorized representatives of both parties. If any provision of this Agreement is held to be unenforceable or invalid, that provision will be enforced to the maximum extent possible and the other provisions will remain in full force and effect. This Agreement is the complete and exclusive understanding and agreement between the parties regarding its subject matter, and supersedes all proposals, understandings, or communications between the parties, oral or written, regarding its subject matter, unless you and Versant have executed a separate agreement.\n\nContact Information\nIf you have any questions regarding this Agreement, you may contact Versant at 255 Shoreline Drive, Suite 450, Redwood City, CA 94065, United States, community@db4o.com.\n\nBY REGISTERING YOUR SOFTWARE YOU HAVE INDICATED THAT YOU UNDERSTAND THIS AGREEMENT AND ACCEPT ALL OF ITS TERMS. IF YOU DO NOT ACCEPT ALL THE TERMS OF THIS AGREEMENT, THEN VERSANT IS UNWILLING TO LICENSE THE SOFTWARE TO YOU UNDER THESE TERMS.\n"
  },
  {
    "path": "licenses/freemarker.txt",
    "content": "============================================================\nNotices for file(s):\n  /Vega/platform/com.subgraph.vega.ui.scanner/lib/freemarker.jar\n\nLicense text from http://freemarker.sourceforge.net/docs/app_license.html\n------------------------------------------------------------\n\nFreeMarker 1.x was released under the LGPL license. Later, by community\nconsensus, we have switched over to a BSD-style license. As of FreeMarker\n2.2pre1, the original author, Benjamin Geer, has relinquished the copyright in\nbehalf of Visigoth Software Society. The current copyright holder is the\nVisigoth Software Society.\n\n------------------------------------------------------------------------------\nCopyright (c) 2003 The Visigoth Software Society. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice,\n    this list of conditions and the following disclaimer.\n\n2. The end-user documentation included with the redistribution, if any, must\n    include the following acknowlegement:\n      \"This product includes software developed by the\n      Visigoth Software Society (http://www.visigoths.org/).\"\n    Alternately, this acknowlegement may appear in the software itself, if and\n    wherever such third-party acknowlegements normally appear.\n\n3. Neither the name \"FreeMarker\", \"Visigoth\", nor any of the names of the\n    project contributors may be used to endorse or promote products derived\n    from this software without prior written permission. For written\n    permission, please contact visigoths@visigoths.org.\n\n4. Products derived from this software may not be called \"FreeMarker\" or\n    \"Visigoth\" nor may \"FreeMarker\" or \"Visigoth\" appear in their names\n    without prior written permission of the Visigoth Software Society.\n\nTHIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nVISIGOTH SOFTWARE SOCIETY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\nINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\nBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\nOF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n------------------------------------------------------------------------------\n\nThis software consists of voluntary contributions made by many individuals on\nbehalf of the Visigoth Software Society. For more information on the Visigoth\nSoftware Society, please see http://www.visigoths.org/\n\n------------------------------------------------------------------------------\n\nFREEMARKER SUBCOMPONENTS UNDER DIFFERENT LICENSE:\n\nFreeMarker includes a number of subcomponents that are licensed by the Apache\nSoftware Foundation under the Apache License, Version 2.0. Your use of these\nsubcomponents is subject to the terms and conditions of the Apache License,\nVersion 2.0. You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n    \nThe subcomponents under this licence are the following files, which are\nincluded both in freemarker.jar and in the source code:\n  \n    freemarker/ext/jsp/web-app_2_2.dtd\n    freemarker/ext/jsp/web-app_2_3.dtd\n    freemarker/ext/jsp/web-app_2_4.xsd\n    freemarker/ext/jsp/web-app_2_5.xsd\n    freemarker/ext/jsp/web-jsptaglibrary_1_1.dtd\n    freemarker/ext/jsp/web-jsptaglibrary_1_2.dtd\n    freemarker/ext/jsp/web-jsptaglibrary_2_0.xsd\n    freemarker/ext/jsp/web-jsptaglibrary_2_1.xsd\n"
  },
  {
    "path": "licenses/jsoup.txt",
    "content": "============================================================\nNotices for file(s):\n  /Vega/platform/com.subgraph.vega.application/extra-bundles/jsoup-1.7.2-SNAPSHOT.jar\n\nLicense text from http://jsoup.org/license\n------------------------------------------------------------\n\njsoup License\nThe jsoup code-base (include source and compiled packages) are distributed under the open source MIT license as described below.\n\nThe MIT License\nCopyright (c) 2009, 2010 Jonathan Hedley (jonathan@hedley.net)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "licenses/mit-license.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) \n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.analysis</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/.settings/org.eclipse.pde.core.prefs",
    "content": "#Sun Mar 13 12:48:28 EDT 2011\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Analysis\nBundle-SymbolicName: com.subgraph.vega.analysis\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.subgraph.vega.api.analysis,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.html,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.util,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client.utils;version=\"4.2.2\",\n org.jsoup,\n org.jsoup.nodes,\n org.jsoup.parser,\n org.jsoup.select\nService-Component: OSGI-INF/analysis.xml\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/OSGI-INF/analysis.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.analysis\">\n   <implementation class=\"com.subgraph.vega.internal.analysis.ContentAnalyzerFactory\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.analysis.IContentAnalyzerFactory\"/>\n   </service>\n   <reference bind=\"setModel\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.model.IModel\" name=\"IModel\" policy=\"static\" unbind=\"unsetModel\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/CSSDetector.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic class CSSDetector {\n\t\n\tboolean isBodyCSS(IHttpResponse response) {\n\t\tif(!response.isMostlyAscii())\n\t\t\treturn false;\n\t\tfinal String body = response.getBodyAsString();\n\t\tif(body == null || body.isEmpty())\n\t\t\treturn false;\n\t\t\n\t\tint i = 0;\n\t\tchar lastChar = 0;\n\t\tboolean first = false;\n\t\t\n\t\twhile(i < body.length()) {\n\t\t\ti = skipWhitespace(body, i);\n\t\t\ti = skipComments(body, i);\n\t\t\tif(i >= body.length()) break;\n\t\t\tif(isCSSKeyword(body, i))\n\t\t\t\treturn true;\n\t\t\t\n\t\t\tchar c = body.charAt(i);\n\t\t\tif(c == '{') {\n\t\t\t\tif(!first || lastChar == 0 || (!Character.isLetterOrDigit(lastChar) && (\"-_]*\".indexOf(lastChar) == -1)))\n\t\t\t\t\treturn false;\n\t\t\t\telse\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\tif(first) {\n\t\t\t\tif(!Character.isLetterOrDigit(c) && (\":,.#_-*[]~=\\\"'>\".indexOf(c) == -1))\n\t\t\t\t\treturn false;\t\t\t\t\n\t\t\t} else {\n\t\t\t\tif(!Character.isLetterOrDigit(c) && (\".#_-*\".indexOf(c) == -1))\n\t\t\t\t\treturn false;\n\t\t\t\tfirst = true;\n\t\t\t}\n\t\t\tlastChar = c;\n\t\t\ti += 1;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate int skipWhitespace(String body, int idx) {\n\t\twhile(idx < body.length() && Character.isWhitespace(body.charAt(idx)))\n\t\t\tidx += 1;\n\t\treturn idx;\n\t}\n\t\n\tprivate int skipComments(String body, int idx) {\n\t\twhile(idx < body.length()) {\n\t\t\tif(body.startsWith(\"<!--\", idx)) {\n\t\t\t\tidx += 4;\n\t\t\t} else if(body.startsWith(\"//\")) {\n\t\t\t\tint end = body.indexOf(\"\\r\\n\", 2);\n\t\t\t\tidx = (end == -1) ? (body.length()) : (idx + end + 2);\n\t\t\t} else if(body.startsWith(\"/*\")) {\n\t\t\t\tint end = body.indexOf(\"*/\");\n\t\t\t\tidx = (end == -1) ? (body.length()) : (idx + end + 2);\n\t\t\t} else {\n\t\t\t\treturn idx;\n\t\t\t}\n\t\t}\n\t\treturn idx;\n\t}\n\t\n\tprivate boolean isCSSKeyword(String body, int idx) {\n\t\tif((idx + 1) < body.length() && body.charAt(idx) == '@') {\n\t\t\tint end = (idx + 8 > body.length()) ? (body.length()) : (idx + 8);\n\t\t\tString chunk = body.substring(idx + 1, end).toLowerCase();\n\t\t\treturn (chunk.startsWith(\"import\") || chunk.startsWith(\"media\") || chunk.startsWith(\"charset\"));\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/ContentAnalyzer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpRequest;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.analysis.IContentAnalyzerResult;\nimport com.subgraph.vega.api.analysis.MimeType;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.web.IWebModel;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.internal.analysis.urls.UrlExtractor;\n\npublic class ContentAnalyzer implements IContentAnalyzer {\n\t\n\tprivate final Logger logger = Logger.getLogger(\"analysis\");\n\t\n\tprivate final IScanInstance scanInstance;\n\tprivate final ContentAnalyzerFactory factory;\n\tprivate final UrlExtractor urlExtractor = new UrlExtractor();\n\tprivate final MimeDetector mimeDetector = new MimeDetector();\n\n\tprivate final Object responseProcessingLock = new Object();\n\n\tprivate List<IResponseProcessingModule> responseProcessingModules;\n\tprivate boolean addLinksToModel;\n\tprivate boolean defaultAddToRequestLog;\n\t\t\n\tContentAnalyzer(ContentAnalyzerFactory factory, IScanInstance scanInstance) {\n\t\tthis.factory = factory;\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.addLinksToModel = true;\n\t\tthis.defaultAddToRequestLog = true;\n\t}\n\n\t@Override\n\tpublic IContentAnalyzerResult processResponse(IHttpResponse response) {\n\t\treturn processResponse(response, defaultAddToRequestLog, true);\n\t}\n\n\t@Override\n\tpublic void setDefaultAddToRequestLog(boolean flag) {\n\t\tdefaultAddToRequestLog = flag;\t\t\n\t}\n\n\t@Override\n\tpublic IContentAnalyzerResult processResponse(IHttpResponse response, boolean addToRequestLog, boolean scrapePage) {\n\t\tfinal ContentAnalyzerResult result = new ContentAnalyzerResult();\n\t\tif(response == null) {\n\t\t\tlogger.warning(\"ContentAnalyzer.processResponse() called with null response\");\n\t\t\treturn result;\n\t\t}\n\n\t\tfinal IWorkspace workspace = factory.getCurrentWorkspace();\n\t\tif(workspace == null) {\n\t\t\tlogger.warning(\"ContentAnalyzer.processResponse() called while no workspace is active\");\n\t\t\treturn result;\n\t\t}\n\t\t\n\t\tif(addToRequestLog) { \n\t\t\tworkspace.getRequestLog().addRequestResponse(response);\n\t\t}\n\n\t\tfinal VegaURI uri = VegaURI.fromHostAndRequest(response.getHost(), response.getOriginalRequest());\n\t\tfinal IWebPath path = workspace.getWebModel().getWebPathByUri(uri);\n\t\tpath.setVisited(true);\n\t\t\n\t\tresult.setDeclaredMimeType(mimeDetector.getDeclaredMimeType(response));\n\t\tresult.setSniffedMimeType(mimeDetector.getSniffedMimeType(response));\n\t\t\n\t\tfinal String mimeType = getBestMimeType(result);\n\t\tif(mimeType != null && path.getMimeType() == null) {\n\t\t\tpath.setMimeType(mimeType);\n\t\t}\n\t\t\n\t\tif(scrapePage)\n\t\t\trunExtractUrls(result, response, workspace.getWebModel());\n\t\trunResponseProcessingModules(response.getOriginalRequest(), response, result.getDeclaredMimeType(), result.getSniffedMimeType(), workspace);\n\t\treturn result;\n\t}\n\t\n\tprivate String getBestMimeType(IContentAnalyzerResult result) {\n\t\tif(result.getSniffedMimeType() != MimeType.MIME_NONE) {\n\t\t\treturn result.getSniffedMimeType().getCanonicalName();\n\t\t} else if(result.getDeclaredMimeType() != MimeType.MIME_NONE) {\n\t\t\treturn result.getDeclaredMimeType().getCanonicalName();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setResponseProcessingModules(List<IResponseProcessingModule> modules) {\n\t\tresponseProcessingModules = new ArrayList<IResponseProcessingModule>(modules);\n\t}\n\t\n\tprivate void runExtractUrls(ContentAnalyzerResult result, IHttpResponse response, IWebModel webModel) {\n\t\tif(response.isMostlyAscii()) {\n\t\t\tfor(VegaURI u : urlExtractor.findUrls(response)) {\n\t\t\t\tif(addLinksToModel && (schemeEquals(u, \"http\") || schemeEquals(u, \"https\")))\n\t\t\t\t\twebModel.getWebPathByUri(u);\n\t\t\t\tresult.addUri(u);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate boolean schemeEquals(VegaURI uri, String scheme) {\n\t\tfinal String s = uri.getTargetHost().getSchemeName();\n\t\treturn s.equalsIgnoreCase(scheme);\n\t}\n\t\n\tprivate void runResponseProcessingModules(HttpRequest request, IHttpResponse response, MimeType declaredMime, MimeType sniffedMime, IWorkspace workspace) {\n\t\tif(responseProcessingModules == null || !response.isMostlyAscii()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif(!(isDefaultResponseProcessingMimetype(declaredMime) || isDefaultResponseProcessingMimetype(sniffedMime))) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tsynchronized (responseProcessingLock) {\n\t\t\tfor(IResponseProcessingModule m: responseProcessingModules) {\n\t\t\t\tif(m.isEnabled()) {\n\t\t\t\t\tm.processResponse(scanInstance, request, response, workspace);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate boolean isDefaultResponseProcessingMimetype(MimeType mime) {\n\t\tfinal String name = mime.getCanonicalName();\n\t\treturn (name.contains(\"text\") || name.contains(\"javascript\") || name.contains(\"xml\"));\n\t}\n\n\t@Override\n\tpublic void setAddLinksToModel(boolean flag) {\n\t\taddLinksToModel = flag;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/ContentAnalyzerFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.analysis.IContentAnalyzerFactory;\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\npublic class ContentAnalyzerFactory implements IContentAnalyzerFactory {\n\t\n\tprivate final IEventHandler workspaceEventHandler;\n\tprivate IModel model;\n\tprivate IWorkspace currentWorkspace;\n\t\n\t\n\tpublic ContentAnalyzerFactory() {\n\t\tworkspaceEventHandler = createWorkspaceEventHandler();\n\t}\n\t\n\t@Override\n\tpublic IContentAnalyzer createContentAnalyzer(IScanInstance scanInstance) {\n\t\treturn new ContentAnalyzer(this, scanInstance);\n\t}\n\n\tprivate IEventHandler createWorkspaceEventHandler() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent)\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceCloseEvent)\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceResetEvent)\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tcurrentWorkspace = event.getWorkspace();\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tcurrentWorkspace = null;\n\t}\n\t\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tcurrentWorkspace = event.getWorkspace();\n\t}\n\n\tIWorkspace getCurrentWorkspace() {\n\t\treturn currentWorkspace;\n\t}\n\n\tvoid activate() {\n\t\tcurrentWorkspace = model.addWorkspaceListener(workspaceEventHandler);\n\t}\n\t\n\tvoid deactivate() {\n\t\tmodel.removeWorkspaceListener(workspaceEventHandler);\n\t\tcurrentWorkspace = null;\n\t}\n\n\tprotected void setModel(IModel model) {\n\t\tthis.model = model;\n\t}\n\t\n\tprotected void unsetModel(IModel model) {\n\t\tthis.model = null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/ContentAnalyzerResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis;\n\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzerResult;\nimport com.subgraph.vega.api.analysis.MimeType;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic class ContentAnalyzerResult implements IContentAnalyzerResult {\n\tprivate final Set<VegaURI> uniqueUris = new HashSet<VegaURI>();\n\t\n\tprivate MimeType declaredType = MimeType.MIME_NONE;\n\tprivate MimeType sniffedType = MimeType.MIME_NONE;\n\t\n\tvoid addUri(VegaURI uri) {\n\t\tuniqueUris.add(uri);\n\t}\n\n\tvoid setDeclaredMimeType(MimeType mime) {\n\t\tdeclaredType = mime;\n\t}\n\t\n\tvoid setSniffedMimeType(MimeType mime) {\n\t\tsniffedType = mime;\n\t}\n\t\n\t@Override\n\tpublic List<VegaURI> getDiscoveredURIs() {\n\t\treturn new ArrayList<VegaURI>(uniqueUris);\n\t}\n\n\t@Override\n\tpublic MimeType getDeclaredMimeType() {\n\t\treturn declaredType;\n\t}\n\n\t@Override\n\tpublic MimeType getSniffedMimeType() {\n\t\treturn sniffedType;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/JavascriptDetector.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic class JavascriptDetector {\n\tprivate final static int MAX_JS_WHITE = 16;\n\t\n\tboolean isBodyJavascript(IHttpResponse response) {\n\t\tif(!response.isMostlyAscii())\n\t\t\treturn false;\n\t\tfinal String body = response.getBodyAsString();\n\t\tif(body == null || body.isEmpty())\n\t\t\treturn false;\n\t\t\n\t\tint i = 0;\n\t\tboolean first = false;\n\t\tint whiteCount = 0;\n\t\twhile(i < body.length()) {\n\t\t\ti = skipComments(body, i);\n\t\t\tif(i >= body.length()) break;\n\t\t\tif(body.startsWith(\" saved from url=\", i))\n\t\t\t\treturn false;\n\t\t\tchar c = body.charAt(i);\n\t\t\t\n\t\t\tif(\"({[\\\"'\".indexOf(c) != -1) \n\t\t\t\treturn true;\n\t\t\t\t\n\t\t\tif(first && (\"=;\".indexOf(c) != -1))\n\t\t\t\treturn true;\n\t\t\t\n\t\t\tif(!(Character.isLetterOrDigit(c) || Character.isWhitespace(c) || c == '_' ||  c == '$' || c == '.'))\n\t\t\t\treturn false;\n\t\t\t\n\t\t\t\n\t\t\tif(!Character.isWhitespace(c)) {\n\t\t\t\twhiteCount += 1;\n\t\t\t\tif(whiteCount > MAX_JS_WHITE)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\t\n\t\t\tfirst = true;\n\t\t\ti+= 1;\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate int skipComments(String body, int idx) {\n\t\twhile(idx < body.length()) {\n\t\t\tif(body.startsWith(\"<!--\", idx)) {\n\t\t\t\tidx += 4;\n\t\t\t} else if(body.startsWith(\"//\")) {\n\t\t\t\tint end = body.indexOf(\"\\r\\n\", 2);\n\t\t\t\tidx = (end == -1) ? (body.length()) : (idx + end + 2);\n\t\t\t} else if(body.startsWith(\"/*\")) {\n\t\t\t\tint end = body.indexOf(\"*/\");\n\t\t\t\tidx = (end == -1) ? (body.length()) : (idx + end + 2);\n\t\t\t} else {\n\t\t\t\treturn idx;\n\t\t\t}\n\t\t}\n\t\treturn idx;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/MimeDetector.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.apache.http.Header;\n\nimport com.subgraph.vega.api.analysis.MimeType;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic class MimeDetector {\n\tprivate static final List<String> genericAsciiPrefixes = new ArrayList<String>();\n\tprivate static final Map<String, MimeType> nameMap = new HashMap<String, MimeType>();\n\t\n\tstatic {\n\t\tgenericAsciiPrefixes.addAll(Arrays.asList(\"text/x-\", \"text/vnd.\", \"application/x-httpd-\"));\n\t\tfor(MimeType mt: MimeType.values())\n\t\t\tnameMap.put(mt.getCanonicalName(), mt);\n\t\taddExtraNames(MimeType.MIME_ASC_GENERIC, \"text/csv\");\n\t\taddExtraNames(MimeType.MIME_ASC_JAVASCRIPT, \"application/x-javascript\", \"application/json\", \"text/javascript\"); \n\t\taddExtraNames(MimeType.MIME_ASC_RTF, \"application/rtf\");\n\t\taddExtraNames(MimeType.MIME_XML_GENERIC, \"application/xml\");\n\t\taddExtraNames(MimeType.MIME_IMG_BMP, \"image/bmp\", \"image/x-icon\");\n\t\taddExtraNames(MimeType.MIME_AV_WAV, \"audio/wav\");\n\t\taddExtraNames(MimeType.MIME_AV_RA, \"audio/x-pn-realaudio\", \"audio/x-realaudio\");\n\t\taddExtraNames(MimeType.MIME_AV_MPEG, \"video/mp4\");\n\t\taddExtraNames(MimeType.MIME_AV_FLV, \"video/x-flv\");\n\t\taddExtraNames(MimeType.MIME_AV_WMEDIA, \"audio/x-ms-wma\", \"video/x-ms-asf\");\n\t\taddExtraNames(MimeType.MIME_BIN_ZIP, \"application/x-zip-compressed\");\n\t\taddExtraNames(MimeType.MIME_BIN_GZIP, \"application/x-gunzip\", \"application/x-tar-gz\");\n\t\taddExtraNames(MimeType.MIME_BIN_GENERIC, \"application/octet-stream\");\n\t}\n\n\tstatic void addExtraNames(MimeType mime, String ... names) {\n\t\tfor(int i = 0; i < names.length; i++)\n\t\t\tnameMap.put(names[i], mime);\n\t}\n\t\t\n\tprivate final CSSDetector cssDetector = new CSSDetector();\n\tprivate final JavascriptDetector jsDetector = new JavascriptDetector();\n\t\n\tMimeType getDeclaredMimeType(IHttpResponse response) {\n\t\tif(response.getRawResponse().containsHeader(\"Content-Type\"))\n\t\t\treturn headerToMimeType(response.getRawResponse().getFirstHeader(\"Content-Type\"));\n\t\treturn MimeType.MIME_NONE;\n\t}\n\t\n\tprivate MimeType headerToMimeType(Header hdr) {\n\t\tif(hdr == null || hdr.getValue() == null)\n\t\t\treturn MimeType.MIME_NONE;\n\t\t\n\t\tfinal String ctype = hdr.getValue();\n\t\t\n\t\tif(nameMap.containsKey(ctype))\n\t\t\treturn nameMap.get(ctype);\n\t\tfor(String prefix : genericAsciiPrefixes) {\n\t\t\tif(ctype.startsWith(prefix))\n\t\t\t\treturn MimeType.MIME_ASC_GENERIC;\n\t\t}\n\t\treturn MimeType.MIME_NONE;\n\t}\n\n\tMimeType getSniffedMimeType(IHttpResponse response) {\n\t\tfinal String body = response.getBodyAsString();\n\t\tif(body == null)\n\t\t\treturn MimeType.MIME_NONE;\n\t\tfinal String buffer = (body.length() > 1024) ? (body.substring(0, 1024)) : (body);\n\t\t\n\t\tif(cssDetector.isBodyCSS(response))\n\t\t\treturn MimeType.MIME_ASC_CSS;\n\t\telse if(jsDetector.isBodyJavascript(response))\n\t\t\treturn MimeType.MIME_ASC_JAVASCRIPT;\n\t\telse if(response.isMostlyAscii())\n\t\t\treturn getSniffedMimeTypeForAscii(buffer);\n\t\telse\n\t\t\treturn getSniffedMimeTypeForBinary(buffer);\n\t}\n\t\n\tMimeType getSniffedMimeTypeForAscii(String buffer) {\n\t\tif(buffer.startsWith(\"%!PS\"))\n\t\t\treturn MimeType.MIME_ASC_POSTSCRIPT;\n\t\telse if(buffer.startsWith(\"{\\\\rtf\"))\n\t\t\treturn MimeType.MIME_ASC_RTF;\n\t\telse if(buffer.startsWith(\"%PDF\"))\n\t\t\treturn MimeType.MIME_EXT_PDF;\n\t\telse if(buffer.contains(\"<OpenSearch\"))\n\t\t\treturn MimeType.MIME_XML_OPENSEARCH;\n\t\telse if(buffer.contains(\"<channel>\") \n\t\t\t\t|| buffer.contains(\"<description>\") \n\t\t\t\t|| buffer.contains(\"<item>\") \n\t\t\t\t|| buffer.contains(\"<rdf:RDF\"))\n\t\t\treturn MimeType.MIME_XML_RSS;\n\t\telse if(buffer.contains(\"<feed\") || buffer.contains(\"<updated>\"))\n\t\t\treturn MimeType.MIME_XML_ATOM;\n\t\t\n\t\tfinal String lower = buffer.toLowerCase();\n\t\tif(lower.contains(\"<wml\") || lower.contains(\"<!doctype wml \"))\n\t\t\treturn MimeType.MIME_XML_WML;\n\t\telse if(lower.contains(\"<cross-domain-policy>\"))\n\t\t\treturn MimeType.MIME_XML_CROSSDOMAIN;\n\t\telse if(buffer.contains(\"<?xml\") || buffer.contains(\"<!DOCTYPE\")) {\n\t\t\tif(lower.contains(\"<!doctype html\") || buffer.contains(\"http://www.w3.org/1999/xhtml\"))\n\t\t\t\treturn MimeType.MIME_XML_XHTML;\n\t\t\telse\n\t\t\t\treturn MimeType.MIME_XML_GENERIC;\n\t\t}\n\t\t\n\t\tfinal List<String> htmlStrings = Arrays.asList(\"<html\", \"<meta\", \"<head\", \"<title\", \"<body\", \"</body\", \"<!doctype\",\n\t\t\t\t\"<--\", \"<style\", \"<script\", \"<font\", \"<span\", \"<div\", \"<img\", \"<form\", \"<br\", \"<td\", \"<h1\", \"<li\", \"<p>\", \"href=\");\n\t\tfor(String s: htmlStrings) {\n\t\t\tif(lower.contains(s))\n\t\t\t\treturn MimeType.MIME_ASC_HTML;\n\t\t}\n\t\t\n\t\tif(buffer.contains(\"<![CDATA[\") || buffer.contains(\"</\") || buffer.contains(\"/>\"))\n\t\t\treturn MimeType.MIME_XML_GENERIC;\n\t\t\n\t\treturn MimeType.MIME_ASC_GENERIC;\n\t\t\t\n\t\t\t\t\n\t}\n\t\n\tMimeType getSniffedMimeTypeForBinary(String buffer) {\n\t\tfinal char c0 = charAt(buffer, 0);\n\t\tfinal char c1 = charAt(buffer, 1);\n\t\tfinal char c2 = charAt(buffer, 2);\n\t\tfinal char c3 = charAt(buffer, 3);\n\t\t\n\t\tif(c0 == 0xFF && c1 == 0xD8 && c2 == 0xFF) \n\t\t\treturn MimeType.MIME_IMG_JPEG;\n\t\telse if(buffer.startsWith(\"GIF8\")) \n\t\t\treturn MimeType.MIME_IMG_GIF;\n\t\telse if(c0 == 0x89 && buffer.startsWith(\"PNG\", 1)) \n\t\t\treturn MimeType.MIME_IMG_PNG;\n\t\telse if(buffer.startsWith(\"BM\"))\n\t\t\treturn MimeType.MIME_IMG_BMP;\n\t\telse if(buffer.startsWith(\"II\") && c2 == 42)\n\t\t\treturn MimeType.MIME_IMG_TIFF;\n\t\telse if(buffer.startsWith(\"RIFF\")) {\n\t\t\tif(charAt(buffer, 8) == 'A') {\n\t\t\t\tif(charAt(buffer, 9) == 'C')\n\t\t\t\t\treturn MimeType.MIME_IMG_ANI;\n\t\t\t\telse \n\t\t\t\t\treturn MimeType.MIME_AV_AVI;\n\t\t\t} else\n\t\t\t\treturn MimeType.MIME_AV_WAV;\n\t\t\t\n\t\t} else if(c0 == 0 && c1 == 0 && c2 != 0 && c3 == 0) \n\t\t\treturn MimeType.MIME_IMG_BMP;\n\t\telse if(c0 == 0x30 && c1 == 0x26 && c2 == 0xB2)\n\t\t\treturn MimeType.MIME_AV_WMEDIA;\n\t\telse if(c0 == 0xFF && c1 == 0xFB)\n\t\t\treturn MimeType.MIME_AV_MP3;\n\t\telse if(c0 == 0x00 && c1 == 0x00 && c2 == 0x01 && (c3 >> 4) == 0x0B)\n\t\t\treturn MimeType.MIME_AV_MPEG;\n\t\telse if(buffer.length() >= 4 && buffer.substring(0, 4).equalsIgnoreCase(\"OggS\"))\n\t\t\treturn MimeType.MIME_AV_OGG;\n\t\telse if(c0 == 0x28 && buffer.startsWith(\"RMF\",1))\n\t\t\treturn MimeType.MIME_AV_RA;\n\t\telse if(c0 == 0x2E && buffer.startsWith(\"RMF\",1))\n\t\t\treturn MimeType.MIME_AV_RV;\n\t\telse if(buffer.startsWith(\"free\", 4) || buffer.startsWith(\"mdat\", 4) ||\n\t\t\t\tbuffer.startsWith(\"wide\", 4) || buffer.startsWith(\"pnot\", 4) || \n\t\t\t\tbuffer.startsWith(\"skip\", 4) || buffer.startsWith(\"moov\", 4))\n\t\t\treturn MimeType.MIME_AV_QT;\n\t\telse if(buffer.startsWith(\"FLV\"))\n\t\t\treturn MimeType.MIME_AV_FLV;\n\t\telse if(buffer.startsWith(\"FCWS\") || buffer.startsWith(\"CWS\"))\n\t\t\treturn MimeType.MIME_EXT_FLASH;\n\t\telse if(buffer.startsWith(\"%PDF\"))\n\t\t\treturn MimeType.MIME_EXT_PDF;\n\t\telse if(buffer.startsWith(\"PK\") && c2 < 6 && c3 < 7) {\n\t\t\tif(buffer.contains(\"META-INF/\"))\n\t\t\t\treturn MimeType.MIME_EXT_JAR;\n\t\t\telse\n\t\t\t\treturn MimeType.MIME_BIN_ZIP;\n\t\t} else if(c0 == 0xCA && c1 == 0xFE && c2 == 0xBA && c3 == 0xBE)\n\t\t\treturn MimeType.MIME_EXT_CLASS;\n\t\telse if(buffer.length() > 512 && c0 == 0xD0 && c1 == 0xCF && c2 == 0x11 && c3 == 0xE0) {\n\t\t\tswitch(buffer.charAt(512)) {\n\t\t\tcase 0xEC:\n\t\t\t\treturn MimeType.MIME_EXT_WORD;\n\t\t\tcase 0xFD:\n\t\t\tcase 0x09:\n\t\t\t\treturn MimeType.MIME_EXT_EXCEL;\n\t\t\tcase 0x00:\n\t\t\tcase 0x0F:\n\t\t\tcase 0xA0:\n\t\t\t\treturn MimeType.MIME_EXT_PPNT;\n\t\t\t}\n\t\t} else if(c0 == 0x1F && c1 == 0x8B && c2 == 0x08)\n\t\t\treturn MimeType.MIME_BIN_GZIP;\n\t\telse if(buffer.startsWith(\"MSCF\") && charAt(buffer, 4) == 0x00)\n\t\t\treturn MimeType.MIME_BIN_CAB;\n\t\t\t\n\t\treturn MimeType.MIME_BIN_GENERIC;\n\t}\n\t\n\tchar charAt(String buffer, int idx) {\n\t\tif(idx >= buffer.length())\n\t\t\treturn 0xFFFF;\n\t\treturn buffer.charAt(idx);\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/urls/HtmlUrlExtractor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2013 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis.urls;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.io.StringWriter;\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.utils.URIUtils;\nimport org.jsoup.Jsoup;\nimport org.jsoup.nodes.Document;\nimport org.jsoup.nodes.Element;\nimport org.jsoup.parser.Parser;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic class HtmlUrlExtractor {\n\n\tList<VegaURI> findHtmlUrls(IHttpResponse response) {\n\t\tfinal IHTMLParseResult htmlParseResult = response.getParsedHTML();\n\t\tfinal ArrayList<VegaURI> uris = new ArrayList<VegaURI>();\n\n\t\tif(htmlParseResult != null) {\n\t\t\turis.addAll(extractUrlsFromDocument(response, htmlParseResult.getJsoupDocument(), response.getBodyAsString()));\n\t\t} \n\t\t\n\t\tif (response.getRawResponse().containsHeader(\"Location\")) {\n\t\t\tVegaURI v = locationExtractor(response, response.getRawResponse().getFirstHeader(\"Location\").getValue());\n\t\t\tif (v != null) {\n\t\t\t\turis.add(v);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn uris;\n\t}\n\t\n\tList<VegaURI> findHtmlUrls(IHttpResponse response, HttpEntity entity, URI basePath) throws IOException {\n\t\tfinal String htmlString = inputStreamToString(entity.getContent());\n\t\tfinal Document document = Jsoup.parse(htmlString, basePath.toString());\n\t\treturn extractUrlsFromDocument(response, document, htmlString);\n\t}\n\t\n\tprivate List<VegaURI> extractUrlsFromDocument(IHttpResponse response, Document document, String html) {\n\t\tfinal ArrayList<VegaURI> uris = new ArrayList<VegaURI>();\n\t\turis.addAll(extractURIs(response, document, \"a[href]\", \"abs:href\"));\n\t\turis.addAll(extractURIs(response, document, \"[src]\", \"abs:src\"));\n\t\turis.addAll(extractURIs(response, document, \"link[href]\", \"abs:href\"));\n\t\turis.addAll(extractURIs(response, document, \"meta\",\"\"));\n\t    uris.addAll(responseBodyUriScanFast(response, document, html));\n\t\treturn uris;\n\t}\n\t\n\tprivate String inputStreamToString(InputStream in) throws IOException {\n\t\tfinal Reader r = new InputStreamReader(in, \"UTF-8\");\n\t\tfinal StringWriter w = new StringWriter();\n\t\tfinal char[] buffer = new char[8192];\n\t\twhile(true) {\n\t\t\tint n = r.read(buffer, 0, buffer.length);\n\t\t\tif(n <= 0)\n\t\t\t\treturn w.toString();\n\t\t\tw.write(buffer, 0, n);\n\t\t}\n\t}\n\tprivate List<VegaURI> extractURIs(IHttpResponse response, Document document, String query, String attribute) {\n\t\tfinal ArrayList<VegaURI> uris = new ArrayList<VegaURI>();\n\t\tfor(Element e: document.select(query)) {\n\t\t\tString link;\n\t\t\tif (e.tagName().equals(\"meta\") && e.attr(\"http-equiv\").toLowerCase().equals(\"refresh\")) {\n\t\t\t\tString candidateLink = extractMetaRefresh(document, e);\n\t\t\t\tif (!candidateLink.startsWith(\"http://\") && (!candidateLink.startsWith(\"https://\"))) {\n\t\t\t\t\tlink = absUri(response, document.baseUri(), candidateLink);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlink = candidateLink;\n\t\t\t\t}\n\t\t\t\tURI uri = createURI(link);\n\t\t\t\tif(uri != null && hasValidHttpScheme(uri)) {\n\t\t\t\t\tfinal HttpHost targetHost = URIUtils.extractHost(uri);\n\t\t\t\t\tif(validateHost(targetHost)) {\n\t\t\t\t\t\tfinal VegaURI vegaURI = new VegaURI(targetHost, uri.normalize().getPath(), uri.getQuery());\n\t\t\t\t\t\turis.add(vegaURI);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlink = e.attr(attribute);\n\t\t\t\t\n\t\t\t\tlink = link.replace(\"\\\\\", \"%5C\");\n\t\t\t\tURI uri = createURI(link);\n\t\t\t\n\t\t\t\tif(uri != null && hasValidHttpScheme(uri)) {\n\t\t\t\t\tfinal HttpHost targetHost = URIUtils.extractHost(uri);\n\t\t\t\t\tif(validateHost(targetHost)) {\n\t\t\t\t\t\tfinal VegaURI vegaURI = new VegaURI(targetHost, uri.normalize().getPath(), uri.getQuery());\n\t\t\t\t\t\turis.add(vegaURI);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn uris;\n\t}\n\t\n\tprivate boolean validateHost(HttpHost host) {\n\t\tif(host.getHostName() == null || host.getHostName().isEmpty()) {\n\t\t\treturn false;\n\t\t}\n\t\ttry {\n\t\t\tnew URI(host.getSchemeName(), null, host.getHostName(), host.getPort(), null, null, null);\n\t\t\treturn true;\n\t\t} catch (URISyntaxException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate boolean hasValidHttpScheme(URI uri) {\n\t\tfinal String scheme = uri.getScheme();\n\t\treturn (scheme != null && (scheme.equalsIgnoreCase(\"http\") || scheme.equalsIgnoreCase(\"https\")));\n\t}\n\t\n\tprivate URI createURI(String link) {\n\t\ttry {\n\t\t\tif(link.isEmpty())\n\t\t\t\treturn null;\n\t\t\treturn new URI(Parser.unescapeEntities(link, false));\n\t\t} catch (URISyntaxException ex) {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate String extractMetaRefresh(Document document, Element e) {\n\t\tfinal String content = e.attr(\"content\");\n\t\tString clean = content.replaceAll(\"\\\\s\", \"\");\n\t\tif (clean.toLowerCase().contains(\"url=\")) {\n\t\t\treturn clean.split(\"=\")[1];\n\t\t}\n\t\treturn \"\";\n\t}\n\t\n\t\n\tprivate String absUri(IHttpResponse response, String baseUri, String path) {\n\t\tfinal String link;\n\t\tString parentPath = baseUri;\n\t\tURI u = null;\n\t\tboolean finished = false;\n\t\tint index = 0;\n\t\tint lastIndex = -1;\n\t\t\n\t\tif (path.startsWith(\"/\")) {\n\t\t\treturn response.getRequestUri().getScheme() + \"://\" + response.getRequestUri().getHost() + path;\n\t\t}\n\t\t\n\t\tif (baseUri.startsWith(\"http://\") || (baseUri.startsWith(\"https://\"))) {\n\t\t\ttry {\n\t\t\t\tu = new URI(baseUri);\n\t\t\t} catch (URISyntaxException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (u != null) {\n\t\t\t\tparentPath = u.getPath();\n\t\t\t} else return \"\";\n\t\t} \n\t\t\n\n\n\t\twhile ((index < parentPath.length()) && !finished) {\n\t\t\tif (parentPath.startsWith(\".php\", index) ||  parentPath.startsWith(\".html\",index) || parentPath.startsWith(\".asp\", index) || parentPath.startsWith(\".jsp\", index)) {\n\t\t\t\tfinished = true;\n\t\t\t} else if ((parentPath.charAt(index) == '/') || (parentPath.charAt(index) == '\\\\')) {\n\t\t\t\tlastIndex = index;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\t\n\t\t\t\t\n\t\tif (finished) {\n\t\t\tif (lastIndex >= 0) {\n\t\t\t\tlink = response.getRequestUri().getScheme() + \"://\" + response.getRequestUri().getHost() + \"/\" + parentPath.substring(0, lastIndex) + \"/\" + path;\n\t\t\t} else\n\t\t\t{\n\t\t\t\tlink = response.getRequestUri().getScheme() + \"://\" + response.getRequestUri().getHost() + \"/\" + parentPath + \"/\" + path;\n\t\t\t}\n\t\t}\n\t\telse if (lastIndex >= 0) {\n  \t\t  link = response.getRequestUri().getScheme() + \"://\" + response.getRequestUri().getHost() + parentPath.substring(0, lastIndex) + \"/\" + path;\n\t\t} else\n\t\t{\n\t\t\tlink = response.getRequestUri().getScheme() + \"://\" + response.getRequestUri().getHost() + parentPath + \"/\" + path;\n\t\t}\n\t\treturn link;\n\t}\n\t\n\tprivate ArrayList<VegaURI> responseBodyUriScanFast(IHttpResponse response, Document document, String s) {\n\t\t\n\t\tfinal ArrayList<VegaURI> uris = new ArrayList<VegaURI>();\n\t\tint i = 0;\n\t\t\n\t\tString l = s.toLowerCase();\n\t\t\n\t\twhile (i < s.length()) {\n\t\t\t\n\t\t\tif (l.startsWith(\"http://\", i) || l.startsWith(\"https://\", i)) {\n\t\t\t\t\n\t\t\t\tif (l.startsWith(\"http://\", i))\n\t\t\t\t{\n\t\t\t\t\tif (i+7 >= s.length()) {\n\t\t\t\t\t\treturn uris;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (l.startsWith(\"https://\", i)) {\n\t\t\t\t\tif (i+8 >= s.length()) {\n\t\t\t\t\t\treturn uris;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tint start = i;\n\t\t\t\tint index = start;\n\t\t\t\tBoolean finished = false;\n\t\t\t\tString link;\n\t\t\t\t\n\t\t\t\twhile (index < s.length() && !finished) {\n\t\t\t\t\t\n\t\t\t\t\t// TODO : Some of these terminating chars are valid in URIs, e.g. ')'\n\t\t\t\t\t\n\t\t\t\t\tif (Character.isWhitespace(s.charAt(index)) || (s.charAt(index) == '\"') || (s.charAt(index) == '\\'') || (s.charAt(index) == '>') || (s.charAt(index) == '<') || (s.charAt(index) == ')') ) {\n\t\t\t\t\t\tlink = s.substring(start, index);\n\t\t\t\t\t\tURI uri = createURI(link);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(uri != null && hasValidHttpScheme(uri)) {\n\t\t\t\t\t\t\tfinal HttpHost targetHost = URIUtils.extractHost(uri);\n\t\t\t\t\t\t\tif(validateHost(targetHost)) {\n\t\t\t\t\t\t\t\tfinal VegaURI vegaURI = new VegaURI(targetHost, uri.normalize().getPath(), uri.getQuery());\n\t\t\t\t\t\t\t\turis.add(vegaURI);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti = index + 1;\n\t\t\t\t\t\tfinished = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tindex++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (l.startsWith(\".php\",i) || l.startsWith(\".asp\",i) || l.startsWith(\".jsp\",i) || l.startsWith(\".html\",i)) {\n\t\t\t\n\t\t\t\t// found possible path\n\t\t\t\t\t\t\t\t\n\t\t\t\tBoolean finished = false;\n\t\t\t\tint fileOffset = i; // point of \"file\" discovery\n\t\t\t\tint index = fileOffset;\n\t\t\t\tint startOffset = 0;    // \"file\" start point\n\t\t\t\tint endOffset = s.length();      // \"file\" end point\n\t\t\t\t\n\t\t\t\t// work backwards\n\t\t\t\t\n\t\t\t\twhile (index >= 0 && !finished) {\n\t\t\t\t  if (Character.isWhitespace(s.charAt(index)) || (s.charAt(index) == '(') || (s.charAt(index) == '\"') || (s.charAt(index) == '\\'') || (s.charAt(index) == '>') || (s.charAt(index) == '<') || (s.charAt(index) == ')')) {\n\t\t\t\t\t  startOffset = index+1;\n\t\t\t\t\t  finished = true;\n\t\t\t\t  } else {\n\t\t\t\t\t  index--;\n\t\t\t\t  }\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tindex = startOffset;\n\t\t\t\tfinished = false;\n\t\t\t\t\n\t\t\t\t// work forwards\n\t\t\t\t\t\t\t\t\n\t\t\t\twhile (index < s.length() && !finished) {\n\t\t\t\t  if (Character.isWhitespace(s.charAt(index)) || (s.charAt(index) == '\"') || (s.charAt(index) == '\\'') || (s.charAt(index) == '>') || (s.charAt(index) == '<') || (s.charAt(index) == ')')) {\n\t\t\t\t\t  endOffset = index;\n\t\t\t\t\t  finished = true;\n\t\t\t\t      String link = s.substring(startOffset, endOffset);\n\n\t\t\t\t\t  if (!link.startsWith(\"http://\") && !link.startsWith(\"https://\")) {\n\t\t\t\t\t\t\tlink = absUri(response, document.baseUri(), link);\n\t\t\t\t\t  }\n\t\t\t\t\t\t\t\n\t\t\t\t      URI uri = createURI(link);\n\t\t\t\t\t\t\n\t\t\t\t\t  if(uri != null && hasValidHttpScheme(uri)) {\n\t\t\t\t\t\tfinal HttpHost targetHost = URIUtils.extractHost(uri);\n\t\t\t\t\t\tif(validateHost(targetHost)) {\n\t\t\t\t\t\t\tfinal VegaURI vegaURI = new VegaURI(targetHost, uri.normalize().getPath(), uri.getQuery());\n\t\t\t\t\t\t\turis.add(vegaURI);\n\t\t\t\t\t\t}\n\t\t\t\t\t  }\n\t\t\t\t\t  i = index + 1;\n\t\t\t\t  } else {\n\t\t\t\t\t  index++;\n\t\t\t\t  }\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\treturn uris;\n\t}\n\t\n\tprivate VegaURI locationExtractor(IHttpResponse response, String v) {\n\t\tfinal String link;\n\t\t\n\t\tif (!v.startsWith(\"http://\") && !v.startsWith(\"https://\")) {\n\t\t\tlink = absUri(response, response.getRequestUri().toString(), v);\n\t\t} else\n\t\t{\n\t\t\tlink = v;\n\t\t}\n\t\tURI uri = createURI(link);\n\t\tif(uri != null && hasValidHttpScheme(uri)) {\n\t\t\tfinal HttpHost targetHost = URIUtils.extractHost(uri);\n\t\t\tif(validateHost(targetHost)) {\n\t\t\t\treturn new VegaURI(targetHost, uri.normalize().getPath(), uri.getQuery());\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.analysis/src/com/subgraph/vega/internal/analysis/urls/UrlExtractor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.analysis.urls;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic class UrlExtractor {\n\tprivate final HtmlUrlExtractor htmlExtractor = new HtmlUrlExtractor();\n\n\tpublic List<VegaURI> findUrls(IHttpResponse response) {\n\t\treturn htmlExtractor.findHtmlUrls(response);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.api</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/.settings/org.eclipse.pde.core.prefs",
    "content": "#Mon Sep 06 14:22:01 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Api\nBundle-SymbolicName: com.subgraph.vega.api\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.google.common.net,\n com.subgraph.vega.api.html,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client,\n org.apache.http.client.methods,\n org.apache.http.client.utils;version=\"4.2.2\",\n org.apache.http.cookie,\n org.apache.http.params;version=\"4.0.0\",\n org.apache.http.protocol;version=\"4.0.0\",\n org.jsoup.nodes,\n org.w3c.dom.html2\nExport-Package: com.subgraph.vega.api.analysis,\n com.subgraph.vega.api.annotations,\n com.subgraph.vega.api.console,\n com.subgraph.vega.api.crawler,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.http.proxy,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.conditions,\n com.subgraph.vega.api.model.conditions.match,\n com.subgraph.vega.api.model.identity,\n com.subgraph.vega.api.model.macros,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.scope,\n com.subgraph.vega.api.model.tags,\n com.subgraph.vega.api.model.variables,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.api.model.web.forms,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.util,\n com.subgraph.vega.api.vuge,\n com.subgraph.vega.api.xml\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/analysis/IContentAnalyzer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.analysis;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\n\npublic interface IContentAnalyzer {\n\tIContentAnalyzerResult processResponse(IHttpResponse response);\n\tIContentAnalyzerResult processResponse(IHttpResponse response, boolean addToRequestLog, boolean scrapePage);\n\tvoid setResponseProcessingModules(List<IResponseProcessingModule> modules);\n\tvoid setAddLinksToModel(boolean flag);\n\tvoid setDefaultAddToRequestLog(boolean flag);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/analysis/IContentAnalyzerFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.analysis;\n\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\npublic interface IContentAnalyzerFactory {\n\tIContentAnalyzer createContentAnalyzer(IScanInstance scanInstance);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/analysis/IContentAnalyzerResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.analysis;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic interface IContentAnalyzerResult {\n\tList<VegaURI> getDiscoveredURIs();\n\tMimeType getDeclaredMimeType();\n\tMimeType getSniffedMimeType();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/analysis/MimeType.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.analysis;\n\npublic enum MimeType {\n\tMIME_NONE\t\t\t\t\t(\"none\"),\n\tMIME_ASC_GENERIC \t\t\t(\"text/plain\"),\n\tMIME_ASC_HTML \t\t\t\t(\"text/html\"),\n\tMIME_ASC_JAVASCRIPT \t\t(\"application/javascript\"),\n\tMIME_ASC_CSS \t\t\t\t(\"text/css\"),\n\tMIME_ASC_POSTSCRIPT\t\t\t(\"application/postscript\"),\n\tMIME_ASC_RTF\t\t\t\t(\"text/rtf\"),\n\t\n\tMIME_XML_GENERIC\t\t\t(\"text/xml\"),\n\tMIME_XML_OPENSEARCH\t\t\t(\"application/opensearchdescription+xml\"),\n\tMIME_XML_RSS\t\t\t\t(\"application/rss+xml\"),\n\tMIME_XML_ATOM\t\t\t\t(\"application/atom+xml\"),\n\tMIME_XML_WML\t\t\t\t(\"text/vnd.wap.wml\"),\n\tMIME_XML_CROSSDOMAIN\t\t(\"text/x-cross-domain-policy\"),\n\tMIME_XML_SVG\t\t\t\t(\"image/svg+xml\"),\n\tMIME_XML_XHTML\t\t\t\t(\"application/xhtml+xml\"),\n\t\n\tMIME_IMG_JPEG\t\t\t\t(\"image/jpeg\"),\n\tMIME_IMG_GIF\t\t\t\t(\"image/gif\"),\n\tMIME_IMG_PNG\t\t\t\t(\"image/png\"),\n\tMIME_IMG_BMP\t\t\t\t(\"image/x-ms-bmp\"),\n\tMIME_IMG_TIFF\t\t\t\t(\"image/tiff\"),\n\tMIME_IMG_ANI\t\t\t\t(\"application/x-navi-animation\"),\n\t\n\tMIME_AV_WAV\t\t\t\t\t(\"audio/x-wav\"),\n\tMIME_AV_MP3\t\t\t\t\t(\"audio/mpeg\"),\n\tMIME_AV_OGG\t\t\t\t\t(\"application/ogg\"),\n\tMIME_AV_RA\t\t\t\t\t(\"audio/vnd.rn-realaudio\"),\n\t\n\tMIME_AV_AVI\t\t\t\t\t(\"video/avi\"),\n\tMIME_AV_MPEG\t\t\t\t(\"video/mpeg\"),\n\tMIME_AV_QT\t\t\t\t\t(\"video/quicktime\"),\n\tMIME_AV_FLV\t\t\t\t\t(\"video/flv\"),\n\tMIME_AV_RV\t\t\t\t\t(\"video/vnd.rn-realvideo\"),\n\tMIME_AV_WMEDIA\t\t\t\t(\"video/x-ms-wmv\"),\n\t\n\tMIME_EXT_FLASH\t\t\t\t(\"application/x-shockwave-flash\"),\n\tMIME_EXT_PDF\t\t\t\t(\"application/pdf\"),\n\tMIME_EXT_JAR\t\t\t\t(\"application/java-archive\"),\n\tMIME_EXT_CLASS\t\t\t\t(\"application/java-vm\"),\n\tMIME_EXT_WORD\t\t\t\t(\"application/msword\"),\n\tMIME_EXT_EXCEL\t\t\t\t(\"application/vnd.ms-excel\"),\n\tMIME_EXT_PPNT\t\t\t\t(\"application/vnd.ms-powerpoint\"),\n\tMIME_BIN_ZIP\t\t\t\t(\"application/zip\"),\n\tMIME_BIN_GZIP\t\t\t\t(\"application/x-gzip\"),\n\tMIME_BIN_CAB\t\t\t\t(\"application/vnd.ms-cab-compressed\"),\n\tMIME_BIN_GENERIC\t\t\t(\"application/binary\");\n\t\n\t\n\tpublic static MimeType fromCanonicalName(String name) {\n\t\tfinal String lower = name.toLowerCase();\n\t\tfor(MimeType mt: values())\n\t\t\tif(mt.getCanonicalName().equals(lower))\n\t\t\t\treturn mt;\n\t\treturn MIME_NONE;\n\t}\n\n\tprivate final String canonicalName;\n\t\n\tMimeType(String name) {\n\t\tcanonicalName = name;\n\t}\n\t\n\tpublic String getCanonicalName() {\n\t\treturn canonicalName;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/annotations/GuardedBy.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.annotations;\n/*                                                                                                                                                                                                                                          \n * Copyright (c) 2005 Brian Goetz and Tim Peierls                                                                                                                                                                                           \n * Released under the Creative Commons Attribution License                                                                                                                                                                                  \n *   (http://creativecommons.org/licenses/by/2.5)                                                                                                                                                                                           \n * Official home: http://www.jcip.net                                                                                                                                                                                                       \n *                                                                                                                                                                                                                                          \n * Any republication or derived work distributed in source code form                                                                                                                                                                        \n * must include this copyright and license notice.                                                                                                                                                                                          \n */                                                                                                                                                                                                                                         \n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        \nimport java.lang.annotation.ElementType;                                                                                                                                                                                                    \nimport java.lang.annotation.Retention;                                                                                                                                                                                                      \nimport java.lang.annotation.RetentionPolicy;                                                                                                                                                                                                \nimport java.lang.annotation.Target;                                                                                                                                                                                                         \n                                                                                                                                                                                                                                            \n/**                                                                                                                                                                                                                                         \n * The field or method to which this annotation is applied can only be accessed                                                                                                                                                             \n * when holding a particular lock, which may be a built-in (synchronization) lock,                                                                                                                                                          \n * or may be an explicit java.util.concurrent.Lock.                                                                                                                                                                                         \n *                                                                                                                                                                                                                                          \n * The argument determines which lock guards the annotated field or method:                                                                                                                                                                 \n * <ul>                                                                                                                                                                                                                                     \n * <li>                                                                                                                                                                                                                                     \n * <code>this</code> : The intrinsic lock of the object in whose class the field is defined.                                                                                                                                                \n * </li>                                                                                                                                                                                                                                    \n * <li>                                                                                                                                                                                                                                     \n * <code>class-name.this</code> : For inner classes, it may be necessary to disambiguate 'this';                                                                                                                                            \n * the <em>class-name.this</em> designation allows you to specify which 'this' reference is intended                                                                                                                                        \n * </li>                                                                                                                                                                                                                                    \n * <li>                                                                                                                                                                                                                                     \n * <code>itself</code> : For reference fields only; the object to which the field refers.                                                                                                                                                   \n * </li>                                                                                                                                                                                                                                    \n * <li>                                                                                                                                                                                                                                     \n * <code>field-name</code> : The lock object is referenced by the (instance or static) field                                                                                                                                                \n * specified by <em>field-name</em>.                                                                                                                                                                                                        \n * </li>                                                                                                                                                                                                                                    \n * <li>                                                                                                                                                                                                                                     \n * <code>class-name.field-name</code> : The lock object is reference by the static field specified                                                                                                                                          \n * by <em>class-name.field-name</em>.                                                                                                                                                                                                       \n * </li>                                                                                                                                                                                                                                    \n * <li>                                                                                                                                                                                                                                     \n * <code>method-name()</code> : The lock object is returned by calling the named nil-ary method.                                                                                                                                            \n * </li>                                                                                                                                                                                                                                    \n * <li>                                                                                                                                                                                                                                     \n * <code>class-name.class</code> : The Class object for the specified class should be used as the lock object.                                                                                                                              \n * </li>                                                                                                                                                                                                                                    \n */                                                                                                                                                                                                                                         \n@Target({ElementType.FIELD, ElementType.METHOD})                                                                                                                                                                                            \n@Retention(RetentionPolicy.RUNTIME)                                                                                                                                                                                                         \npublic @interface GuardedBy {                                                                                                                                                                                                               \n    String value();                                                                                                                                                                                                                         \n}                                                                                                                                                                                                                                           \n                                       \n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/annotations/Immutable.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.annotations;\n\nimport java.lang.annotation.*;\n\n/*                                                                                                                                                                                                                                          \n * Copyright (c) 2005 Brian Goetz and Tim Peierls                                                                                                                                                                                           \n * Released under the Creative Commons Attribution License                                                                                                                                                                                  \n *   (http://creativecommons.org/licenses/by/2.5)                                                                                                                                                                                           \n * Official home: http://www.jcip.net                                                                                                                                                                                                       \n *                                                                                                                                                                                                                                          \n * Any republication or derived work distributed in source code form                                                                                                                                                                        \n * must include this copyright and license notice.                                                                                                                                                                                          \n */                                                                                                                                                                                                                                         \n                                                                                                                                                                                                                                            \n                                                                                                                                                                                                                                            \n/**                                                                                                                                                                                                                                         \n * The class to which this annotation is applied is immutable.  This means that                                                                                                                                                             \n * its state cannot be seen to change by callers, which implies that                                                                                                                                                                        \n * <ul>                                                                                                                                                                                                                                     \n * <li> all public fields are final, </li>                                                                                                                                                                                                  \n * <li> all public final reference fields refer to other immutable objects, and </li>                                                                                                                                                       \n * <li> constructors and methods do not publish references to any internal state                                                                                                                                                            \n *      which is potentially mutable by the implementation. </li>                                                                                                                                                                           \n * </ul>                                                                                                                                                                                                                                    \n * Immutable objects may still have internal mutable state for purposes of performance                                                                                                                                                      \n * optimization; some state variables may be lazily computed, so long as they are computed                                                                                                                                                  \n * from immutable state and that callers cannot tell the difference.                                                                                                                                                                        \n * <p>                                                                                                                                                                                                                                      \n * Immutable objects are inherently thread-safe; they may be passed between threads or                                                                                                                                                      \n * published without synchronization.                                                                                                                                                                                                       \n */                                                                                                                                                                                                                                         \n@Documented                                                                                                                                                                                                                                 \n@Target(ElementType.TYPE)                                                                                                                                                                                                                   \n@Retention(RetentionPolicy.RUNTIME)                                                                                                                                                                                                         \npublic @interface Immutable {                                                                                                                                                                                                               \n}                               \n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/annotations/NotThreadSafe.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.annotations;\n\nimport java.lang.annotation.*;                                                                                                                                                                                                              \n\n/*                                                                                                                                                                                                                                          \n * Copyright (c) 2005 Brian Goetz and Tim Peierls                                                                                                                                                                                           \n * Released under the Creative Commons Attribution License                                                                                                                                                                                  \n *   (http://creativecommons.org/licenses/by/2.5)                                                                                                                                                                                           \n * Official home: http://www.jcip.net                                                                                                                                                                                                       \n *                                                                                                                                                                                                                                          \n * Any republication or derived work distributed in source code form                                                                                                                                                                        \n * must include this copyright and license notice.                                                                                                                                                                                          \n */                                                                                                                                                                                                                                         \n                                                                                                                                                                                                                                            \n                                                                                                                                                                                                                                            \n/**                                                                                                                                                                                                                                         \n * The class to which this annotation is applied is not thread-safe.                                                                                                                                                                        \n * This annotation primarily exists for clarifying the non-thread-safety of a class                                                                                                                                                         \n * that might otherwise be assumed to be thread-safe, despite the fact that it is a bad                                                                                                                                                     \n * idea to assume a class is thread-safe without good reason.                                                                                                                                                                               \n * @see ThreadSafe                                                                                                                                                                                                                          \n */                                                                                                                                                                                                                                         \n@Documented                                                                                                                                                                                                                                 \n@Target(ElementType.TYPE)                                                                                                                                                                                                                   \n@Retention(RetentionPolicy.RUNTIME)                                                                                                                                                                                                         \npublic @interface NotThreadSafe {                                                                                                                                                                                                           \n}                                  \n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/annotations/ThreadSafe.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.annotations;\n\nimport java.lang.annotation.*;                                                                                                                                                                                                              \n\n/*                                                                                                                                                                                                                                          \n * Copyright (c) 2005 Brian Goetz and Tim Peierls                                                                                                                                                                                           \n * Released under the Creative Commons Attribution License                                                                                                                                                                                  \n *   (http://creativecommons.org/licenses/by/2.5)                                                                                                                                                                                           \n * Official home: http://www.jcip.net                                                                                                                                                                                                       \n *                                                                                                                                                                                                                                          \n * Any republication or derived work distributed in source code form                                                                                                                                                                        \n * must include this copyright and license notice.                                                                                                                                                                                          \n */                                                                                                                                                                                                                                         \n                                                                                                                                                                                                                                            \n                                                                                                                                                                                                                                            \n                                                                                                                                                                                                                                            \n/**                                                                                                                                                                                                                                         \n * The class to which this annotation is applied is thread-safe.  This means that                                                                                                                                                           \n * no sequences of accesses (reads and writes to public fields, calls to public methods)                                                                                                                                                    \n * may put the object into an invalid state, regardless of the interleaving of those actions                                                                                                                                                \n * by the runtime, and without requiring any additional synchronization or coordination on the                                                                                                                                              \n * part of the caller.                                                                                                                                                                                                                      \n */                                                                                                                                                                                                                                         \n@Documented                                                                                                                                                                                                                                 \n@Target(ElementType.TYPE)                                                                                                                                                                                                                   \n@Retention(RetentionPolicy.RUNTIME)                                                                                                                                                                                                         \npublic @interface ThreadSafe {                                                                                                                                                                                                              \n}                                                                                                                                                                                                                                           \n                                \n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/console/ConsoleOutputEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.console;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ConsoleOutputEvent implements IEvent {\n\t\n\tprivate final String output;\n\tprivate final boolean isErrorOutput;\n\t\n\tpublic ConsoleOutputEvent(String output, boolean isErrorOutput) {\n\t\tthis.output = output;\n\t\tthis.isErrorOutput = isErrorOutput;\n\t}\n\t\n\tpublic String getOutput() {\n\t\treturn output;\n\t}\n\n\tpublic boolean isErrorOutput() {\n\t\treturn isErrorOutput;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/console/IConsole.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.console;\n\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic interface IConsole {\n\tvoid write(String output);\n\tvoid error(String output);\n\tvoid registerDisplay(IConsoleDisplay display);\n\tvoid addConsoleOutputListener(IEventHandler listener);\n\tvoid removeConsoleOutputListener(IEventHandler listener);\n\tvoid debug(String output); \n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/console/IConsoleDisplay.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.console;\n\npublic interface IConsoleDisplay {\n\tvoid printOutput(String output);\n\tvoid printDebug(String output);\n\tvoid printError(String output);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/crawler/ICrawlerResponseProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.crawler;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic interface ICrawlerResponseProcessor {\n\tvoid processResponse(IWebCrawler crawler, HttpUriRequest request, IHttpResponse response, Object argument);\n\tvoid processException(HttpUriRequest request, Throwable ex, Object argument);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/crawler/IWebCrawler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.crawler;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\n\npublic interface IWebCrawler {\n\tIHttpRequestEngine getRequestEngine();\n\tvoid submitTask(HttpUriRequest request, ICrawlerResponseProcessor callback, Object argument);\n\tvoid submitTask(HttpUriRequest request, ICrawlerResponseProcessor callback);\n\tvoid setStopOnEmptyQueue(boolean value);\n\tvoid start();\n\tvoid pause();\n\tvoid unpause();\n\tboolean isPaused();\n\tvoid stop() throws InterruptedException;\n\tvoid waitFinished() throws InterruptedException;\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/crawler/IWebCrawlerFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.crawler;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\npublic interface IWebCrawlerFactory {\n\tIWebCrawler create(IRequestOrigin requestOrigin);\n\tIWebCrawler create(IHttpRequestEngine requestEngine);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/events/EventListenerManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.events;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class EventListenerManager {\n\tprivate final List<IEventHandler> handlers = new ArrayList<IEventHandler>();\n\n\tpublic void addListener(final IEventHandler listener) {\n\t\tsynchronized (this) {\n\t\t\thandlers.add(listener);\n\t\t}\n\t}\n\n\tpublic void removeListener(final IEventHandler listener) {\n\t\tsynchronized (this) {\n\t\t\thandlers.remove(listener);\n\t\t}\n\t}\n\n\tpublic synchronized void clearListeners() {\n\t\thandlers.clear();\n\t}\n\n\tpublic void fireEvent(final IEvent event) {\n\t\tIEventHandler[] handlersCopy;\n\n\t\tsynchronized (this) {\n\t\t\thandlersCopy = new IEventHandler[handlers.size()];\n\t\t\thandlers.toArray(handlersCopy);\n\t\t}\n\t\tfor (IEventHandler handler : handlersCopy) {\n\t\t\ttry {\n\t\t\t\thandler.handleEvent(event);\n\t\t\t} catch (Exception e) {\n\t\t\t\t// TODO should log\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/events/IEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.events;\n\n/**\n * Base interface for all event types\n */\npublic interface IEvent {}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/events/IEventHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.events;\n\npublic interface IEventHandler {\n\tvoid handleEvent(IEvent event);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/events/NamedEventListenerManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.events;\n\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class NamedEventListenerManager {\n\t\n\tprivate final Map<String, EventListenerManager> eventManagerMap = new HashMap<String, EventListenerManager>();\n\t\n\tpublic void addListener(String key, IEventHandler listener) {\n\t\tgetEventManagerByName(key).addListener(listener);\n\t}\n\t\n\tpublic void fireEvent(String key, final IEvent event) {\n\t\tgetEventManagerByName(key).fireEvent(event);\n\t}\n\n\tpublic void fireAllKeys(IEvent event) {\n\t\tsynchronized (eventManagerMap) {\n\t\t\tfor(String key: eventManagerMap.keySet()) \n\t\t\t\teventManagerMap.get(key).fireEvent(event);\n\t\t}\n\t}\n\n\tpublic void removeListener(String name, IEventHandler listener) {\n\t\tgetEventManagerByName(name).removeListener(listener);\n\t}\n\t\n\tpublic void removeListener(IEventHandler listener) {\n\t\tsynchronized(eventManagerMap) {\n\t\t\tfor(EventListenerManager manager: eventManagerMap.values()) \n\t\t\t\tmanager.removeListener(listener);\n\t\t}\n\t}\n\t\n\tpublic Collection<String> getAllKeys() {\n\t\treturn eventManagerMap.keySet();\n\t}\n\t\n\tprivate EventListenerManager getEventManagerByName(String key) {\n\t\tsynchronized(eventManagerMap) {\n\t\t\tif(!eventManagerMap.containsKey(key))\n\t\t\t\teventManagerMap.put(key, new EventListenerManager());\n\t\t\treturn eventManagerMap.get(key);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/HttpInterceptorLevel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\npublic enum HttpInterceptorLevel {\n\tDISABLED(\"disabled\", -1),\n\tENABLED_ALL(\"all transactions\", 1),\n\tENABLED_BREAKPOINTS(\"breakpoints\", 0);\n\n\tprivate final String name;\n\tprivate final Integer serializeValue;\n\t\n\tprivate HttpInterceptorLevel(String name, Integer serializeValue) {\n\t\tthis.name = name;\n\t\tthis.serializeValue = serializeValue;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic Integer getSerializeValue() {\n\t\treturn serializeValue;\n\t}\n\n\tpublic static HttpInterceptorLevel fromValue(Integer serializeValue) {\n\t\tif (serializeValue != null) {\n\t\t\tfor (HttpInterceptorLevel level: values()) {  \n\t\t\t\tif (level.serializeValue.compareTo(serializeValue) == 0) {  \n\t\t\t\t\treturn level;  \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic static HttpInterceptorLevel getDefault() {\n\t\treturn DISABLED;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpInterceptProxyEventHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\npublic interface IHttpInterceptProxyEventHandler {\n\tvoid handleRequest(IProxyTransaction transaction);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpInterceptor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction.TransactionDirection;\n\n/**\n * When a transaction is added to the queue, event handlers registered with the interceptor are notified. Transactions\n * are removed from the queue by either forwarding or dropping them individually. \n */\npublic interface IHttpInterceptor {\n\tvoid setEnabled(boolean enabled);\n\tboolean isEnabled();\n\tvoid addEventHandler(IHttpInterceptorEventHandler eventHandler);\n\tvoid removeEventHandler(IHttpInterceptorEventHandler eventHandler);\n\tvoid setInterceptLevel(TransactionDirection direction, HttpInterceptorLevel level);\n\tHttpInterceptorLevel getInterceptLevel(TransactionDirection direction);\n\tint transactionQueueSize();\n\tIProxyTransaction[] getTransactions();\n\tIProxyTransaction transactionQueueGet(int idx);\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpInterceptorEventHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\npublic interface IHttpInterceptorEventHandler {\n\t/**\n\t * Notification that a transaction was queued for processing.\n\t *\n\t * @param transaction Transaction.\n\t * @param idx Array index in queue transaction was added at.\n\t */\n\tpublic void notifyQueue(IProxyTransaction transaction, int idx);\n\n\t/**\n\t * Notification that a transaction was removed from the queue. Not invoked when the last item is removed form the\n\t * queue, notifyEmpty() is invoked instead.\n\t * \n\t * @param idx Array index of transaction that was removed. \n\t */\n\tpublic void notifyRemove(int idx);\n\n\t/**\n\t * Notification that the transaction queue is empty.\n\t */\n\tpublic void notifyEmpty();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpProxyListener.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\n\npublic interface IHttpProxyListener {\n\tIHttpProxyListenerConfig getConfig();\n\tIHttpRequestEngine getRequestEngine();\n\tvoid start();\n\tvoid stop();\n\tvoid registerEventHandler(IHttpInterceptProxyEventHandler handler);\n\tvoid unregisterEventHandler(IHttpInterceptProxyEventHandler handler);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpProxyListenerConfig.java",
    "content": "package com.subgraph.vega.api.http.proxy;\n\nimport java.net.InetAddress;\n\npublic interface IHttpProxyListenerConfig {\n\tInetAddress getInetAddress();\n\tvoid setInetAddress(InetAddress address);\n\tint getPort();\n\tvoid setPort(int port);\n\tint getBacklog();\n\tvoid setBacklog(int backlog);\n\tString getListenerAddress();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpProxyService.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\n\npublic interface IHttpProxyService {\n\tvoid registerEventHandler(IHttpProxyServiceEventHandler handler);\n\tvoid unregisterEventHandler(IHttpProxyServiceEventHandler handler);\n\tboolean isRunning();\n\tboolean isPassthrough();\n\tboolean isProxyScanEnabled();\n\tIHttpProxyListenerConfig createListenerConfig();\n\tvoid setListenerConfigs(IHttpProxyListenerConfig[] listenerConfigs);\n\tIHttpProxyListener[] getListeners();\n\tIHttpProxyListenerConfig[] getListenerConfigs();\n\tint getListenerConfigsCount();\n\tvoid setPassthrough(boolean enabled);\n\tvoid setProxyScanEnabled(boolean enabled);\n\tIScannerConfig getProxyScanConfig();\n\tvoid start();\n\tvoid stop();\n\tIHttpProxyTransactionManipulator getTransactionManipulator();\n\tIHttpInterceptor getInterceptor();\n\tList<IResponseProcessingModule> getResponseProcessingModules();\n\tList<IBasicModuleScript> getProxyScanModules();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpProxyServiceEventHandler.java",
    "content": "package com.subgraph.vega.api.http.proxy;\n\npublic interface IHttpProxyServiceEventHandler {\n\t/**\n\t * Notification that the proxy service started listening.\n\t * @param numListeners Number of proxy listeners.\n\t */\n\tvoid notifyStart(int numListeners);\n\n\t/**\n\t * Notification that a listener started listening.\n\t * @param listener The listener that started listening. \n\t */\n\tvoid notifyStartListener(IHttpProxyListener listener);\n\t\n\t/**\n\t * Notification that the proxy service stopped listening.\n\t */\n\tvoid notifyStop();\n\n\t/**\n\t * Notification that a listener stopped listening.\n\t * @param listener The listener that is no longer listening. \n\t */\n\tvoid notifyStopListener(IHttpProxyListener listener);\n\t\n\t/**\n\t * Notification that the proxy service configuration changed.\n\t * @param numListeners Number of proxy listeners.\n\t */\n\tvoid notifyConfigChange(int numListeners);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IHttpProxyTransactionManipulator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\n/**\n * Interface to set properties of request and response manipulation to be performed by the proxy. Transactions are\n * manipulated before being passed through the interceptor.\n *\n * Future plans: support addition and removal of headers, match and replace of headers and entity bodies, etc.\n */\npublic interface IHttpProxyTransactionManipulator {\n\t/**\n\t * Set the content of the User-Agent header sent in a client request. \n\t * \n\t * @param userAgent Content of the User-Agent header, or null to disable.\n\t */\n\tvoid setUserAgent(String userAgent);\n\n\t/**\n\t * Set whether to always override the client User-Agent header.\n\t * \n\t * @param override Boolean value indicating whether to override the client User-Agent header.\n\t */\n\tvoid setUserAgentOverride(boolean override);\n\t\n\t/**\n\t * Set whether to prevent browser caching by manipulating related headers. \n\t * \n\t * @param disable Boolean value indicating whether to disable browser caching.  \n\t */\n\tvoid setBrowserCacheDisable(boolean disable);\n\n\t/**\n\t * Set whether to prevent intermediate (proxy) caching by manipulating related headers. \n\t * \n\t * @param disable Boolean value indicating whether to disable intermediate caching.  \n\t */\n\tvoid setProxyCacheDisable(boolean disable);\n\n\t/**\n\t * Manipulate a HTTP request.\n\t * \n\t * @param request HttpRequest.\n\t */\n\tvoid process(HttpRequest request);\n\t\n\t/**\n\t * Manipulate a HTTP response.\n\t *\n\t * @param response HttpResponse.\n\t */\n\tvoid process(HttpResponse response);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IProxyTransaction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic interface IProxyTransaction {\n\tenum TransactionDirection {\n\t\tDIRECTION_REQUEST(\"request\"),\n\t\tDIRECTION_RESPONSE(\"response\");\n\t\tprivate final String name;\n\t\tTransactionDirection(String name) { this.name = name; }\n\t\tString getName() { return name; }\n\t};\n\n\t/**\n\t * @return Request engine associated with the transaction.\n\t */\n\tIHttpRequestEngine getRequestEngine();\n\n\t/**\n\t * Set an event handler to receive a notification when the transaction completes.\n\t *  \n\t * @param eventHandler Proxy event handler, or null to unset.\n\t */\n\tvoid setEventHandler(IProxyTransactionEventHandler eventHandler);\n\n\t/**\n\t * Set the request to be sent by the proxy, overriding the intercepted request. If none is set when the pending\n\t * request is forwarded, the intercepted request is sent as is.\n\t *\n\t * @param request HttpUriRequest to be sent by the proxy. \n\t */\n\tvoid setRequest(HttpUriRequest request);\n\n\t/**\n\t * @return Boolean indicating whether this transaction has a HTTP request received by the proxy.\n\t */\n\tboolean hasRequest();\n\n\t/**\n\t * @return HTTP request received by the proxy. Immutable.\n\t */\n\tHttpUriRequest getRequest();\n\n\t/**\n\t * @return Boolean indicating whether this transaction has a HTTP response received by the proxy.\n\t */\n\tboolean hasResponse();\n\n\t/**\n\t * @return HTTP response received by the proxy.\n\t */\n\tIHttpResponse getResponse();\n\n\t/**\n\t * Forward the pending request or response. \n\t */\n\tvoid doForward();\n\n\t/**\n\t * Drop the pending request or response.\n\t */\n\tvoid doDrop();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/IProxyTransactionEventHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\npublic interface IProxyTransactionEventHandler {\n\t/**\n\t * Notification that the transaction is about to be forwarded. May indicate the request is about to be sent to the\n\t * target server or that the response is about to be sent to the client.\n\t */\t\n\tvoid notifyForward();\n\n\t/**\n\t * Notification that the transaction is complete.\n\t * \n\t * @param dropped Boolean indicating whether the transaction was dropped.\n\t */\n\tvoid notifyComplete(boolean dropped);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/proxy/ProxyTransactionEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.proxy;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ProxyTransactionEvent implements IEvent {\n\tprivate final IProxyTransaction transaction;\n\t\n\tpublic ProxyTransactionEvent(IProxyTransaction transaction) {\n\t\tthis.transaction = transaction;\n\t}\n\n\tpublic IProxyTransaction getTransaction() {\n\t\treturn transaction;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpHeaderBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.Header;\n\npublic interface IHttpHeaderBuilder {\n\tpublic void setFromHeader(Header header);\n\tpublic void setName(String name);\n\tpublic String getName();\n\tpublic void setValue(String value);\n\tpublic String getValue();\n\tpublic Header buildHeader();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpMacroContext.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.util.Map;\n\npublic interface IHttpMacroContext {\n\t/**\n\t * Set the variable dictionary for this macro context.\n\t * @param dict Variable dictionary.\n\t */\n\tvoid setDict(Map<String, String> dict);\n\t\n\t/**\n\t * Get the variable dictionary for this macro context.\n\t * @return Variable dictionary, or null if none is set.\n\t */\n\tMap<String, String> getDict();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpMacroExecutor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.protocol.HttpContext;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\n\n/**\n * Manages execution of a HTTP macro.\n */\npublic interface IHttpMacroExecutor {\n\t/**\n\t * Get the request engine used with the macro executor.\n\t * @return Request engine.\n\t */\n\tIHttpRequestEngine getRequestEngine();\n\n\t/**\n\t * Get the macro.\n\t * @return Macro.\n\t */\n\tIHttpMacro getMacro();\n\n\t/**\n\t * Get the HTTP macro context.\n\t * @return Macro context.\n\t */\n\tIHttpMacroContext getMacroContext();\n\t\n\t/**\n\t * Determine whether the macro has additional items to execute.\n\t * @return Boolean indicating whether the macro has additional items to execute.\n\t */\n\tboolean hasNext();\n\n\t/**\n\t * Send the next request in the macro, returning the request task managing request execution. The provided\n\t * HttpContext should use the request engine's HttpContext as its parent.\n\t * @param context HTTP execution context.\n\t * @return Request task, or null if no further items exist to execute.\n\t * @throws URISyntaxException \n\t * @throws UnsupportedEncodingException \n\t */\n\tIHttpRequestTask sendNextRequest(HttpContext context) throws URISyntaxException, UnsupportedEncodingException;\n\n\t/**\n  \t * Send the next request in the macro, returning the request task managing request execution. A HttpContext is\n  \t * automatically generated for the request using the request engine's HttpContext as its parent. \n\t * @return Request task, or null if no further items exist to execute.\n\t * @throws URISyntaxException \n\t * @throws UnsupportedEncodingException \n\t */\n\tIHttpRequestTask sendNextRequest() throws URISyntaxException, UnsupportedEncodingException;\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpMessageBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.params.HttpParams;\n\npublic interface IHttpMessageBuilder {\n\t/**\n\t * Clear contents of the message, reverting it to its initial state.\n\t */\n\tvoid clear();\n\n\t/**\n\t * Set message parameters. A copy of the parameters is not made.\n\t *\n\t * @param params Message parameters.\n\t */\n\tvoid setParams(HttpParams params);\n\n\t/**\n\t * Get message parameters.\n\t * \n\t * @return Message parameters.\n\t */\n\tHttpParams getParams();\n\n\tvoid setProtocolVersion(ProtocolVersion protocolVersion);\n\tProtocolVersion getProtocolVersion();\n\t\n\tvoid setHeaders(Header[] headers);\n\tIHttpHeaderBuilder addHeader(String name, String value);\n\tIHttpHeaderBuilder setHeader(String name, String value);\n\tvoid removeHeader(IHttpHeaderBuilder header);\n\tvoid removeHeaders(String name);\n\tvoid clearHeaders();\n\tvoid swapHeader(int idx1, int idx2);\n\tint getHeaderIdxOf(IHttpHeaderBuilder next);\n\tint getHeaderCnt();\n\tIHttpHeaderBuilder getHeader(int idx);\n\tIHttpHeaderBuilder[] getHeaders();\n\n\tvoid setEntity(HttpEntity entity);\n\tHttpEntity getEntity();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpMutableRequest.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.HttpMessage;\nimport org.apache.http.client.methods.HttpUriRequest;\n\npublic interface IHttpMutableRequest extends HttpUriRequest, HttpMessage {\n\tvoid setMethod(String method);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic  interface IHttpRequestBuilder extends IHttpMessageBuilder {\n\t/**\n\t * Set request fields from a HttpRequest provided by IRequestLogRecord. Any previously set fields are unset.\n\t *\n\t * @param request IRequestLogRecord containing HttpRequest.\n\t * @throws URISyntaxException \n\t */\n\tvoid setFromRequest(IRequestLogRecord record) throws URISyntaxException;\n\n\t/**\n\t * Set request fields from a HttpRequest. Any previously set fields are unset.\n\t *\n\t * @param request HttpRequest\n\t * @throws URISyntaxException \n\t */\n\tvoid setFromRequest(HttpRequest request) throws URISyntaxException;\n\n\t/**\n\t * Set the request method, scheme, host, host port, path, and protocol version fields from a RequestLine.\n\t *\n\t * @param requestLine RequestLine \n\t * @throws URISyntaxException \n\t */\n\tvoid setFromRequestLine(RequestLine requestLine) throws URISyntaxException;\n\n\t/**\n\t * Set the path from a URI. The scheme, host, and host port are also set if set within the URI. \n\t * \n\t * @param uri URI\n\t */\n\tvoid setFromUri(URI uri);\n\n\t/**\n\t * Set the scheme, host, and host port from a HttpHost.\n\t *\n\t * @param host HttpHost\n\t */\n\tvoid setFromHttpHost(HttpHost host);\n\t\n\tvoid setScheme(String scheme);\n\tString getScheme();\n\n\tvoid setHost(String host);\n\tString getHost();\n\tvoid setHostPort(int port);\n\tint getHostPort();\n\t\n\tvoid setMethod(String method);\n\tString getMethod();\n\n\tvoid setPath(String path);\n\tString getPath();\n\n\tString getRequestLine();\n\n\tHttpUriRequest buildRequest(boolean setHeadersEntity) throws URISyntaxException;\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpRequestEngine.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.util.List;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.protocol.HttpContext;\n\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\npublic interface IHttpRequestEngine {\n\tenum EngineConfigType { CONFIG_SCANNER, CONFIG_PROXY };\n\t/**\n\t * Get the configuration for this request engine.\n\t * \n\t * @return IHttpRequestEngineConfig\n\t */\n\tIHttpRequestEngineConfig getRequestEngineConfig();\n\n\t/**\n\t * Get the request origin associated with this request engine.\n\t * @return Request origin.\n\t */\n\tIRequestOrigin getRequestOrigin();\n\n\t/**\n\t * Get the HttpClient used by this request engine.\n\t * @return HttpClient.\n\t */\n\tHttpClient getHttpClient();\n\t\n\t/**\n\t * Get the parent HttpContext associated with this request engine. The parent HttpContext is thread-safe and should\n\t * be used as the parent for the request HttpContext.\n\t * @return Parent HttpContext.\n\t */\n\tHttpContext getHttpContext();\n\t\n\t/**\n\t * Get the cookie store from the HttpClient instance used by this request engine\n\t * \n\t * @return CookieStore instance from HttpClient.\n\t */\n\tCookieStore getCookieStore();\n\t\n\t/**\n\t * Replace the cookie store for the HttpClient instance used by this request engine.\n\t * \n\t * @param cookieStore The new CookieStore to use.\n\t */\n\tvoid setCookieStore(CookieStore cookieStore);\n\t\n\t/**\n\t * Returns the cookies which would be applied to the specified request before transmitting it\n\t * to the given host.  This method does not modify the request, it only searches the cookie store\n\t * for the cookies which would be added to the request before transmission and returns them.\n\t * \n\t * @param targetHost The host this request will be sent to.\n\t * @param request The request which the cookies would be added to.\n\t * @return The list of cookies which would be added to this request upon transmission.\n\t */\n\tList<Cookie> getCookiesForRequest(HttpHost targetHost, HttpRequest request);\n\t\n\t/**\n\t * Register a request modifier.\n\t * @param modifier IHttpRequestModifier.\n\t */\n\tvoid addRequestModifier(IHttpRequestModifier modifier);\n\n\t/**\n\t * Register an event listener to watch for requests as they are executed by this request engine. Fires:\n\t * \t- RequestTaskStartEvent\n\t *  - RequestTaskStopEvent\n\t * @param listener Event listener.\n\t */\n\tvoid addRequestListener(IEventHandler listener);\n\n\t/**\n\t * Deregister a request event listener.\n\t * @param listener Event listener.\n\t */\n\tvoid removeRequestListener(IEventHandler listener);\n\n\t/**\n\t * Obtain a list of requests in progress.\n\t * @return List of requests in progress.\n\t */\n\tIHttpRequestTask[] getRequestList();\n\n\t/**\n\t * Send a request, returning the request task managing request execution. The provided HttpContext should use this\n\t * request engine's HttpContext as its parent.\n\t * @param request Request to be send.\n\t * @param context HTTP execution context.\n\t * @return Request task.\n\t */\n\tIHttpRequestTask sendRequest(HttpUriRequest request, HttpContext context);\n\n\t/**\n\t * Send a request, returning the request task managing request execution. A HttpContext is automatically generated\n\t * for the request using this request engine's HttpContext as its parent.\n\t * @param request Request to be send.\n\t * @return Request task.\n\t */\n\tIHttpRequestTask sendRequest(HttpUriRequest request);\n\t\n\t/**\n\t * Create a macro context.\n\t * @return Macro context.\n\t */\n\tIHttpMacroContext createMacroContext();\n\t\n\t/**\n\t * Create a macro executor to execute a macro with this request engine.\n\t * @param macro Macro to execute.\n\t * @param context Macro context.\n\t * @return Macro executor.\n\t */\n\tIHttpMacroExecutor createMacroExecutor(IHttpMacro macro, IHttpMacroContext context);\n\t\n\tHttpUriRequest createGetRequest(HttpHost target, String uri);\n\tHttpUriRequest createPostRequest(HttpHost target, String uri);\n\tHttpUriRequest createRawRequest(HttpHost target, RequestLine requestLine);\n\tHttpUriRequest createRawEntityEnclosingRequest(HttpHost target, RequestLine requestLine);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpRequestEngineConfig.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.util.List;\n\npublic interface IHttpRequestEngineConfig {\n\tfinal static int DEFAULT_MAX_CONNECTIONS = 25;\n\tfinal static int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 25;\n\tvoid setForceIdentityEncoding(boolean value);\n\tvoid setDecompressGzipEncoding(boolean value);\n\tvoid setUndoURLEncoding(boolean value);\n\tboolean getForceIdentityEncoding();\n\tboolean getDecompressGzipEncoding();\n\tboolean getUndoURLEncoding();\n\tvoid registerResponseProcessor(IHttpResponseProcessor processor);\n\tList<IHttpResponseProcessor> getResponseProcessors();\n\tvoid setRequestsPerMinute(int rpm);\n\tint getRequestsPerMinute();\n\tvoid setMaxConnections(int value);\n\tint getMaxConnections();\n\tvoid setMaxConnectionsPerRoute(int value);\n\tint getMaxConnectionsPerRoute();\n\tvoid setMaximumResponseKilobytes(int kb);\n\tint getMaximumResponseKilobytes();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpRequestEngineFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.HttpHost;\n\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\npublic interface IHttpRequestEngineFactory {\n\t/**\n\t * Default User-Agent string.\n\t */\n\tstatic final String DEFAULT_USER_AGENT = \n\t\t\t\"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; InfoPath.1; .NET CLR \" +\n\t          \"2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Vega/1.0\";\n\t\n\t/**\n\t * Set a simple one-hop proxy to be set for all HttpClients instantiated from this request engine factory.\n\t * @param proxy Simple one hop proxy, or null to unset.\n\t */\n\tvoid setProxy(HttpHost proxy);\n\n\tIHttpRequestEngineConfig createConfig();\n\tIHttpRequestEngine createRequestEngine(IHttpRequestEngine.EngineConfigType type, IHttpRequestEngineConfig config, IRequestOrigin requestOrigin);\n\n\t/**\n\t * Instantiate a HttpRequestBuilder.\n\t * \n\t * @return HttpRequestBuilder instance.\n\t */\n\tIHttpRequestBuilder createRequestBuilder();\n\n\t/**\n\t * Instantiate a HttpResponseBuilder.\n\t *\n\t * @return HttpResponseBuilder instance.\n\t */\n\tIHttpResponseBuilder createResponseBuilder();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpRequestModifier.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.protocol.HttpContext;\n\n/**\n * Optionally modifies a HttpContext or HttpRequest before a request is sent by the request engine.\n */\npublic interface IHttpRequestModifier {\n\t/**\n\t * Process a request before it is sent.\n\t * @param request HttpRequest.\n\t * @param context HttpContext.\n\t */\n\tvoid process(HttpRequest request, HttpContext context);\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpRequestTask.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.util.Date;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\n/**\n * Represents a task to perform a HTTP request using the request engine. \n */\npublic interface IHttpRequestTask {\n\t/**\n\t * Get the request engine managing this task.\n\t * @return Request engine.\n\t */\n\tIHttpRequestEngine getRequestEngine();\n\n\t/**\n\t * Get the request being executed.\n\t * @return Request.\n\t */\n\tHttpUriRequest getRequest();\n\n\t/**\n\t * Abort the request.\n\t * @throws UnsupportedOperationException\n\t */\n\tvoid abort() throws UnsupportedOperationException;\n\t\n\t/**\n\t * Get the result of the request. Blocks until the request result is ready.\n\t * @return Response.\n\t * @throws RequestEngineException \n\t */\n\tIHttpResponse get(boolean readEntity) throws RequestEngineException;\n\n\t/**\n\t * Determine whether the request task has completed.\n\t * @return Boolean indicating whether the request task has completed. \n\t */\n\tboolean isComplete();\n\t\n\t/**\n\t * Get the time the request task finished performing the request.\n\t * @return Completion time, or null.\n\t */\n\tDate getTimeCompleted();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpResponse.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport java.net.URI;\nimport java.util.List;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.cookie.Cookie;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.api.model.tags.ITag;\n\npublic interface IHttpResponse {\n\tenum ResponseStatus { RESPONSE_OK };\n\tResponseStatus getResponseStatus();\n\tURI getRequestUri();\n\tint getResponseCode();\n\tboolean isFetchFail();\n\tHttpRequest getOriginalRequest();\n\tList<Cookie> getSentCookies();\n\tList<IHttpResponseCookie> getResponseCookies();\n\tvoid setRawResponse(HttpResponse response); // temporary, probably. used in interceptor.\n\tHttpResponse getRawResponse();\n\tHttpHost getHost();\n\tString getBodyAsString();\n\tIHTMLParseResult getParsedHTML();\n\tboolean isMostlyAscii();\n\tIPageFingerprint getPageFingerprint();\n\tboolean lockResponseEntity();\n\tlong getRequestMilliseconds();\n\t\n\t/**\n\t * Set the database ID of a IRequestLogRecord created for this object. Must only be invoked when a IRequestLogRecord\n\t * is inserted into the database.\n\t * @param requestId Database ID of IRequestLogRecord.\n\t */\n\tvoid setRequestId(long requestId);\n\n\t/**\n\t * Get the database ID of the IRequestLogRecord corresponding with this object.\n\t * @return Database ID of IRequestLogRecord, or -1 if none has been set.\n\t */\n\tlong getRequestId();\n\n\t/**\n\t * Get the origin within Vega of the request.\n\t * @return Request origin.\n\t */\n\tIRequestOrigin getRequestOrigin();\n\t\n\t/**\n\t * Get a list of all tags applied to this record.\n\t * @return Tags applied to this record.\n\t */\n\tList<ITag> getTags();\n\n\t/**\n\t * Apply a tag to this record.\n\t * @param tag Tag.\n\t */\n\tvoid addTag(ITag tag);\n\n\t/**\n\t * Remove a tag from this record.\n\t * @param tag Tag.\n\t */\n\tvoid removeTag(ITag tag);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpResponseBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.HttpResponse;\nimport org.apache.http.StatusLine;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic interface IHttpResponseBuilder extends IHttpMessageBuilder {\n\t/**\n\t * Set Response fields from a HttpResponse provided by IRequestLogRecord. Any previously set fields are unset.\n\t *\n\t * @param record IRequestLogRecord containing HttpResponse.\n\t */\n\tvoid setFromResponse(IRequestLogRecord record);\n\n\t/**\n\t * Set Response fields from a HttpResponse. Any previously set fields are unset.\n\t *\n\t * @param response HttpResponse.\n\t */\n\tvoid setFromResponse(HttpResponse response);\n\n\t/**\n\t * Set the response protocol version, status code, and reason pharse fields from a ResponseLine.\n\t *\n\t * @param statusLine StatusLine \n\t */\n\tvoid setFromStatusLine(StatusLine statusLine);\n\n\t/**\n\t * Get the status line.\n\t * \n\t * @return Status line.\n\t */\n\tString getStatusLine();\n\n\t/**\n\t * Build a HttpResponse.\n\t * \n\t * @return HttpResponse.\n\t */\n\tHttpResponse buildResponse();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpResponseCookie.java",
    "content": "package com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.cookie.ClientCookie;\n\npublic interface IHttpResponseCookie extends ClientCookie {\n\tString getHeader();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IHttpResponseProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.protocol.HttpContext;\n\npublic interface IHttpResponseProcessor {\n\tvoid processResponse(HttpRequest request, IHttpResponse response, HttpContext context);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/IPageFingerprint.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\npublic interface IPageFingerprint {\n\tint getCode();\n\tint[] getData();\n\tboolean isSame(IPageFingerprint other);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/RequestEngineException.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\npublic class RequestEngineException extends Exception {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tpublic RequestEngineException(String message) {\n\t\tsuper(message);\n\t}\n\t\n\tpublic RequestEngineException(String message, Throwable ex) {\n\t\tsuper(message, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/RequestTaskStartEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport com.subgraph.vega.api.events.IEvent;\n\n/**\n * Event indicating an IHttpRequestTask has begun performing an HTTP request.\n */\npublic class RequestTaskStartEvent implements IEvent {\n\tprivate final IHttpRequestTask requestTask;\n\t\n\tpublic RequestTaskStartEvent(IHttpRequestTask requestTask) {\n\t\tthis.requestTask = requestTask;\n\t}\n\n\tpublic IHttpRequestTask getRequestTask() {\n\t\treturn requestTask;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/http/requests/RequestTaskStopEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.http.requests;\n\nimport com.subgraph.vega.api.events.IEvent;\n\n/**\n * Event indicating an IHttpRequestTask has finished performing an HTTP request.\n */\npublic class RequestTaskStopEvent implements IEvent {\n\tprivate final IHttpRequestTask requestTask;\n\t\n\tpublic RequestTaskStopEvent(IHttpRequestTask requestTask) {\n\t\tthis.requestTask = requestTask;\n\t}\n\n\tpublic IHttpRequestTask getRequestTask() {\n\t\treturn requestTask;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/IModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\n\n\npublic interface IModel {\n\tIWorkspace addWorkspaceListener(IEventHandler handler);\n\tvoid removeWorkspaceListener(IEventHandler handler);\n\tvoid resetCurrentWorkspace();\n\t\n\t/**\n\t * Attempts to open the 'default' workspace, returning <code>true</code> on success.  If another workspace is currently\n\t * active, it will be closed before opening the new workspace.\n\t * \n\t * The default workspace is chosen using the following strategy:\n\t * \n\t * 1) If no workspace directories currently exist, a new workspace directory is created with index 00 and name 'default'.\n\t * 2) If a single workspace directory exists, it is chosen as the default workspace.\n\t * 3) If multiple workspace directories exist, they are searched in sequential order for the first one containing a file \n\t *    named '.autostart', which is chosen as the default workspace.  Otherwise the workspace with the lowest index is chosen.\n\t *    \n\t * @return <code>true</code> if the default workspace could be successfully opened, <code>false</code> otherwise.\n\t */\n\tboolean openDefaultWorkspace();\n\n\t/**\n\t * Return a list of <code>IWorkspaceEntry</code> elements corresponding to existing workspace directories.\n\t * \n\t * @return A list of <code>IWorkspaceEntry</code> elements corresponding to existing workspace directories.\n\t */\n\tList<IWorkspaceEntry> getWorkspaceEntries();\n\t\n\t/**\n\t * Attempt to open the workspace specified by the workspace index argument.  A valid workspace index is obtained by\n\t * first calling <code>getWorkspaceEntries()</code> to retrieve a list of metadata describing existing workspaces.\n\t * \n\t * @param index The index of the workspace to open.\n\t * @return <code>true</code> if the workspace specified by the <code>index</code> argument could be successfully opened, <code>false</code> otherwise.\n\t */\n\tboolean openWorkspaceByIndex(int index);\n\t\n\tIWorkspace getCurrentWorkspace();\n\n\t/**\n\t * Tracks condition set changes across changing workspaces\n\t * \n\t * @param name Name of condition set\n\t * @param handler Callback which processes ConditionSetChanged messages\n\t * @return The current named condition set if a workspace is currently open, null otherwise.\n\t */\n\tIHttpConditionSet addConditionSetTracker(String name, IEventHandler handler);\n\t\n\tvoid removeConditionSetTracker(String name, IEventHandler handler);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/IModelProperties.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport java.util.List;\n\npublic interface IModelProperties {\n\tvoid setProperty(String name, Object value);\n\tvoid setStringProperty(String name, String value);\n\tvoid setIntegerProperty(String name, int value);\n\tObject getProperty(String name);\n\tString getStringProperty(String name);\n\tInteger getIntegerProperty(String name);\n\tList<String> propertyKeys();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/IModelVersion.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\npublic interface IModelVersion {\n\tint getVerMajor();\n\tint getVerMinor();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/IWorkspace.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\nimport com.subgraph.vega.api.model.tags.ITagModel;\nimport com.subgraph.vega.api.model.variables.IVariableModel;\nimport com.subgraph.vega.api.model.web.IWebModel;\n\npublic interface IWorkspace extends IModelProperties {\n\tIModel getModel();\n\tIModelVersion getModelVersion();\n\tITagModel getTagModel();\n\tIWebModel getWebModel();\n\tIVariableModel getVariableModel();\n\tIHttpMacroModel getHttpMacroModel();\n\tIIdentityModel getIdentityModel();\n\tIScanAlertRepository getScanAlertRepository();\n\tIRequestLog getRequestLog();\n\tIHttpConditionManager getHttpConditionMananger();\n\tIHTMLParser getHTMLParser();\n\tITargetScopeManager getTargetScopeManager();\n\tvoid consoleWrite(String output);\n\tvoid consoleDebug(String output);\n\tvoid consoleError(String output);\n\tboolean open();\n\tvoid close();\n\tvoid lock();\n\tvoid unlock();\n\tvoid reset();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/IWorkspaceEntry.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport java.io.File;\n\n/**\n * A workspace entry describes a single workspace on the file system.  \n */\npublic interface IWorkspaceEntry {\n\tString getName();\n\tint getIndex();\n\tboolean isAutostart();\n\tFile getPath();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/WorkspaceCloseEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class WorkspaceCloseEvent implements IEvent {\n\tprivate final IWorkspace workspace;\n\t\n\tpublic WorkspaceCloseEvent(IWorkspace workspace) {\n\t\tthis.workspace = workspace;\n\t}\n\t\n\tpublic IWorkspace getWorkspace() {\n\t\treturn workspace;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/WorkspaceLockStatusEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class WorkspaceLockStatusEvent implements IEvent {\n\tprivate final boolean isLockEvent;\n\t\n\tpublic WorkspaceLockStatusEvent(boolean isLockEvent) {\n\t\tthis.isLockEvent = isLockEvent;\n\t}\n\t\n\tpublic boolean isLockEvent() {\n\t\treturn isLockEvent;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/WorkspaceOpenEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class WorkspaceOpenEvent implements IEvent {\n\tprivate final IWorkspace workspace;\n\t\n\tpublic WorkspaceOpenEvent(IWorkspace workspace) {\n\t\tthis.workspace = workspace;\n\t}\n\n\tpublic IWorkspace getWorkspace() {\n\t\treturn workspace;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/WorkspaceResetEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class WorkspaceResetEvent implements IEvent {\nprivate final IWorkspace workspace;\n\t\n\tpublic WorkspaceResetEvent(IWorkspace workspace) {\n\t\tthis.workspace = workspace;\n\t}\n\n\tpublic IWorkspace getWorkspace() {\n\t\treturn workspace;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/ActiveScanInstanceEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ActiveScanInstanceEvent implements IEvent {\n\tprivate final IScanInstance scanInstance;\n\t\n\tpublic ActiveScanInstanceEvent(IScanInstance scanInstance) {\n\t\tthis.scanInstance = scanInstance;\n\t}\n\t\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/IScanAlert.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.model.IModelProperties;\n\npublic interface IScanAlert extends IModelProperties {\n\tenum Severity { HIGH, MEDIUM, LOW, INFO, UNKNOWN }\n\tString getDiscretionaryHostname();\n\tString getName();\n\tSeverity getSeverity();\n\tString getTitle();\n\tString getResource();\n\tvoid setTemplateName(String name);\n\tString getTemplateName();\n\tString getKey();\n\tboolean hasAssociatedRequest();\n\tIScanInstance getScanInstance();\n\tlong getScanId();\n\tlong getRequestId();\n\tvoid addStringMatchHighlight(String matchStr);\n\tvoid addRegexHighlight(String regex);\n\tvoid addRegexCaseInsensitiveHighlight(String regex);\n\tCollection<IScanAlertHighlight> getHighlights();\n\tvoid setDiscretionaryHostname(String hostname);\n\tvoid setResource(String resourceString);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/IScanAlertHighlight.java",
    "content": "package com.subgraph.vega.api.model.alerts;\n\npublic interface IScanAlertHighlight {\n\tboolean isRegularExpression();\n\tboolean isCaseSensitive();\n\tString getMatchString();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/IScanAlertRepository.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic interface IScanAlertRepository {\n\tfinal static int PROXY_ALERT_ORIGIN_SCAN_ID = -1;\n\tList<IScanInstance> addActiveScanInstanceListener(IEventHandler listener);\n\tvoid removeActiveScanInstanceListener(IEventHandler listener);\n\tvoid addActiveScanInstance(IScanInstance scanInstance);\n\tvoid removeActiveScanInstance(IScanInstance scanInstance);\n\tList<IScanInstance> getAllActiveScanInstances();\n\tList<IScanInstance> getAllScanInstances();\n\tIScanInstance createNewScanInstance();\n\tvoid removeScanInstance(IScanInstance scanInstance);\n\tIScanInstance getScanInstanceByScanId(long scanId);\n\tIScanInstance getProxyScanInstance();\n\tCollection<IScanAlert> getAlertsByRequestId(long requestId);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/IScanInstance.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport java.util.Collection;\nimport java.util.Date;\nimport java.util.List;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModelProperties;\nimport com.subgraph.vega.api.scanner.IScan;\n\npublic interface IScanInstance extends IModelProperties {\n\tfinal static int SCAN_CONFIG = 0; /** Scan is being configured */\n\tfinal static int SCAN_PROBING = 1; /** Pre-scan site probing */\n\tfinal static int SCAN_STARTING = 2; /** Scan is starting */\n\tfinal static int SCAN_AUDITING = 3;\n\tfinal static int SCAN_COMPLETED = 4;\n\tfinal static int SCAN_CANCELLED = 5;\n\t\n\tIScanAlert createAlert(String type);\n\tIScanAlert createAlert(String type, String key);\n\tIScanAlert createAlert(String type, String key, long requestId);\n\tvoid addAlert(IScanAlert alert);\n\tvoid removeAlert(IScanAlert alert);\n\tvoid removeAlerts(Collection<IScanAlert> alerts);\n\tboolean hasAlertKey(String key);\n\tIScanAlert getAlertByKey(String key);\n\tList<IScanAlert> getAllAlerts();\n\t\n\tlong getScanId();\n\tIScan getScan();\n\t\n\t/**\n\t * Get the scan start time. Returns null until state is SCAN_PROBING or greater.\n\t * @return Scan start time, or null.\n\t */\n\tDate getStartTime();\n\n\t/**\n\t * Get the scan stop time. Returns null until state is SCAN_COMPLETED or SCAN_CANCELLED.\n\t * @return Scan start time, or null.\n\t */\n\tDate getStopTime();\n\t\n\tint getScanStatus();\n\tboolean isActive();\n\tboolean isComplete();\n\tint getScanCompletedCount();\n\tint getScanTotalCount();\n\tString getScanCurrentPath();\n\tvoid setScan(IScan scan);\n\tvoid updateScanProgress(String currentPath, int completedCount, int totalCount);\n\tvoid updateScanProgress(int completedCount, int totalCount);\n\tvoid updateScanStatus(int status);\n\tvoid notifyScanException(HttpUriRequest request, Throwable exception);\n\tvoid notifyScanPauseState(boolean isPaused);\n\tboolean isScanPaused();\n\t\n\tvoid addScanEventListenerAndPopulate(IEventHandler listener);\n\tvoid removeScanEventListener(IEventHandler listener);\n\t\n\tvoid deleteScanInstance();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/NewScanAlertEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class NewScanAlertEvent implements IEvent {\n\tprivate final IScanAlert alert;\n\t\n\tpublic NewScanAlertEvent(IScanAlert alert) {\n\t\tthis.alert = alert;\n\t}\n\t\n\tpublic IScanAlert getAlert() {\n\t\treturn alert;\n\t}\n\t\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/NewScanInstanceEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class NewScanInstanceEvent implements IEvent {\n\tprivate final IScanInstance scanInstance;\n\t\n\tpublic NewScanInstanceEvent(IScanInstance scanInstance) {\n\t\tthis.scanInstance = scanInstance;\n\t}\n\t\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/RemoveScanAlertsEvent.java",
    "content": "package com.subgraph.vega.api.model.alerts;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class RemoveScanAlertsEvent implements IEvent {\n\tprivate final IScanInstance scanInstance;\n\tprivate final Collection<IScanAlert> removedAlerts;\n\t\n\tpublic RemoveScanAlertsEvent(IScanInstance scanInstance, Collection<IScanAlert> removedAlerts) {\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.removedAlerts = removedAlerts;\n\t}\n\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n\n\tpublic Collection<IScanAlert> getRemovedEvents() {\n\t\treturn removedAlerts;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/RemoveScanInstanceEvent.java",
    "content": "package com.subgraph.vega.api.model.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class RemoveScanInstanceEvent implements IEvent {\n\tprivate final IScanInstance scanInstance;\n\n\tpublic RemoveScanInstanceEvent(IScanInstance scanInstance) {\n\t\tthis.scanInstance = scanInstance;\n\t}\n\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/ScanExceptionEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ScanExceptionEvent implements IEvent {\n\t\n\tprivate final HttpUriRequest request;\n\tprivate final Throwable exception;\n\t\n\t\n\tpublic ScanExceptionEvent(HttpUriRequest request, Throwable exception) {\n\t\tthis.request = request;\n\t\tthis.exception = exception;\n\t}\n\t\n\tpublic HttpUriRequest getRequest() {\n\t\treturn request;\n\t}\n\t\n\tpublic Throwable getException() {\n\t\treturn exception;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/ScanPauseStateChangedEvent.java",
    "content": "package com.subgraph.vega.api.model.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ScanPauseStateChangedEvent implements IEvent {\n\tprivate final boolean isPaused;\n\t\n\tpublic ScanPauseStateChangedEvent(boolean isPaused) {\n\t\tthis.isPaused = isPaused;\n\t}\n\t\n\tpublic boolean getPauseState() {\n\t\treturn isPaused;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/alerts/ScanStatusChangeEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ScanStatusChangeEvent implements IEvent {\n\tprivate final IScanInstance scanInstance;\n\tprivate final String currentPath;\n\tprivate final int scanStatus;\n\tprivate final int scanCompletedCount;\n\tprivate final int scanTotalCount;\n\n\tpublic ScanStatusChangeEvent(IScanInstance scanInstance, String currentPath, int status, int completed, int total) {\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.currentPath = currentPath;\n\t\tthis.scanStatus = status;\n\t\tthis.scanCompletedCount = completed;\n\t\tthis.scanTotalCount = total;\n\t}\n\t\n\tpublic String getCurrentPath() {\n\t\treturn currentPath;\n\t}\n\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n\n\tpublic int getStatus() {\n\t\treturn scanStatus;\n\t}\n\t\n\tpublic int getCompletedCount() {\n\t\treturn scanCompletedCount;\n\t}\n\t\n\tpublic int getTotalCount() {\n\t\treturn scanTotalCount;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/ConditionSetChanged.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ConditionSetChanged implements IEvent {\n\tprivate final IHttpConditionSet conditionSet;\n\n\tpublic ConditionSetChanged(IHttpConditionSet conditionSet) {\n\t\tthis.conditionSet = conditionSet;\n\t}\n\n\tpublic IHttpConditionSet getConditionSet() {\n\t\treturn conditionSet;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/IHttpCondition.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic interface IHttpCondition {\n\tIHttpConditionType getType();\n\tIHttpConditionMatchAction getMatchAction();\n\tvoid setMatchAction(IHttpConditionMatchAction matchAction);\n\tIHttpCondition createCopy();\n\tString getValueString();\n\tboolean matches(IRequestLogRecord record);\n\tboolean matches(HttpRequest request);\n\tboolean matches(HttpResponse response);\n\tboolean matches(HttpRequest request, HttpResponse response);\n\tboolean isEnabled();\n\tvoid setEnabled(boolean state);\n\tboolean isInternal();\n\t/**\n\t * Returns true if the sufficient flag has been set.  A sufficient condition will cause a {@link IHttpConditionSet#matchesAll(IRequestLogRecord)}\n\t * to return true if at least one sufficient condition matches the query.\n\t * @return\n\t */\n\tboolean isSufficient();\n\tvoid setSufficient(boolean value);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/IHttpConditionManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions;\n\nimport java.util.List;\n\npublic interface IHttpConditionManager {\n\tpublic static final String CONDITION_SET_FILTER = \"filter\";\n\tpublic static final String CONDITION_SET_BREAKPOINTS_REQUEST = \"breakpoints-request\";\n\tpublic static final String CONDITION_SET_BREAKPOINTS_RESPONSE = \"breakpoints-response\";\n\tIHttpConditionSet getConditionSet(String name);\n\tIHttpConditionSet getConditionSetCopy(String name);\n\tvoid saveConditionSet(String name, IHttpConditionSet conditionSet);\n\tList<IHttpConditionType> getConditionTypes();\n\tList<IHttpConditionType> getConditionTypes(boolean includeInternal);\n\tIHttpConditionType getConditionTypeByName(String name);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/IHttpConditionSet.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions;\n\nimport java.util.List;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic interface IHttpConditionSet {\n\tString getName();\n\tboolean matchesAll(IRequestLogRecord record);\n\tboolean matchesAll(HttpRequest request, HttpResponse response);\n\tboolean matchesAny(IRequestLogRecord record);\n\tboolean matchesAny(HttpRequest request, HttpResponse response);\n\t\n\tboolean hasActiveConditions(boolean includeInternal);\n\t\n\tvoid notifyChanged();\n\t/**\n\t * Add a temporary condition to this set.  Temporary conditions are not persisted in the database.\n\t * @param condition The temporary condition to add.\n\t */\n\tvoid appendTemporaryCondition(IHttpCondition condition, boolean notify);\n\tvoid removeTemporaryCondition(IHttpCondition condition, boolean notify);\n\tvoid clearTemporaryConditions(boolean notify);\n\tList<IHttpCondition> getAllTemporaryConditions(boolean includeInternal);\n\t\n\tvoid appendCondition(IHttpCondition condition, boolean notify);\n\tvoid removeCondition(IHttpCondition condition, boolean notify);\n\tvoid clearConditions(boolean notify);\n\tList<IHttpCondition> getAllConditions();\n\tList<IHttpCondition> getAllConditions(boolean includeInternal);\n\tIHttpConditionManager getConditionManager();\n\tvoid setMatchOnEmptySet(boolean flag);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/IHttpConditionType.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic interface IHttpConditionType {\n\tString getName();\n\tboolean isInternal();\n\tIHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction);\n\tList<IHttpConditionMatchAction> getMatchActions();\n\tIHttpConditionMatchAction getMatchActionByName(String name);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/match/IHttpConditionIntegerMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions.match;\n\npublic interface IHttpConditionIntegerMatchAction extends IHttpConditionMatchAction {\n\tvoid setInteger(int value);\n\tboolean matchesValue(int value);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/match/IHttpConditionMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions.match;\n\npublic interface IHttpConditionMatchAction {\n\tenum MatchActionArgumentType { ARGUMENT_REGEX, ARGUMENT_STRING, ARGUMENT_INTEGER, ARGUMENT_RANGE };\n\t\n\tString getLabel();\n\tMatchActionArgumentType getArgumentType();\n\tString getArgumentAsString();\n\tboolean setArgumentFromString(String value);\n\tboolean isValidArgumentString(String value);\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/match/IHttpConditionRangeMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions.match;\n\npublic interface IHttpConditionRangeMatchAction extends IHttpConditionMatchAction {\n\tvoid setRange(int rangeLow, int rangeHigh);\n\tboolean matchesValue(int value);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/conditions/match/IHttpConditionStringMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.conditions.match;\n\npublic interface IHttpConditionStringMatchAction extends IHttpConditionMatchAction {\n\tvoid setString(String value);\n\tboolean matchesValue(String value);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/IAuthMethod.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\n\n/**\n * Base interface for an authentication method used to authenticate an identity with a website.\n */\npublic interface IAuthMethod {\n\tenum AuthMethodType {\n\t\t/**\n\t\t * Basic and digest access authentication as defined in RFC2617. IAuthMethodRfc2617.\n\t\t */\n\t\tAUTH_METHOD_RFC2617,\n\n\t\t/**\n\t\t * NTLM and NTLMv2. IAuthMethodNtlm.\n\t\t */\n\t\tAUTH_METHOD_NTLM,\n\t\t\n\t\t/**\n\t\t * HTTP macro.\n\t\t */\n\t\tAUTH_METHOD_HTTP_MACRO,\n\t}\n\n\t/**\n\t * Get the authentication method type.\n\t * @return Authentication method type.\n\t */\n\tAuthMethodType getType();\n\t\n\t/**\n\t * Set up authentication parameters within a request engine.\n\t * @param requestEngine Request engine.\n\t */\n\tvoid setAuth(IHttpRequestEngine requestEngine);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/IAuthMethodHttpMacro.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\n\npublic interface IAuthMethodHttpMacro extends IAuthMethod {\n\t/**\n\t * Set the HTTP macro to be used for authentication.\n\t * @param macro Authentication macro.\n\t */\n\tvoid setMacro(IHttpMacro macro);\n\n\t/**\n\t * Get the HTTP macro to be used for authentication.\n\t * @return Authentication macro.\n\t */\n\tIHttpMacro getMacro();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/IAuthMethodNtlm.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\n/**\n * NTLMv1, NTLMv2, and NTLM2 session authentication.\n */\npublic interface IAuthMethodNtlm extends IAuthMethod {\n\t/**\n\t * Set the username. This should not include the domain to authenticate with. For example: \"user\" is correct whereas\n\t * \"DOMAIN\\\\user\" is not.\n\t * @param username Username.\n\t */\n\tvoid setUsername(String username);\n\t\n\t/**\n\t * Get the username.\n\t * @return Username.\n\t */\n\tString getUsername();\n\t\n\t/**\n\t * Set the password.\n\t * @param password Password.\n\t */\n\tvoid setPassword(String password);\n\t\n\t/**\n\t * Get the password.\n\t * @return Password.\n\t */\n\tString getPassword();\n\t\n\t/**\n\t * Set the name of the workstation the authentication requests will originate from. Essentially, the computer name\n\t * for this machine.\n\t * @param workstation Workstation name.\n\t */\n\tvoid setWorkstation(String workstation);\n\n\t/**\n\t * Get the name of the workstation the authentication requests will originate from.\n\t * @return Workstation name.\n\t */\n\tString getWorkstation();\n\t\n\t/**\n\t * Set the domain to authenticate with.\n\t * @param domain Domain to authenticate with.\n\t */\n\tvoid setDomain(String domain);\n\n\t/**\n\t * Get the domain to authenticate with.\n\t * @return Domain to authenticate with.\n\t */\n\tString getDomain();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/IAuthMethodRfc2617.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\npublic interface IAuthMethodRfc2617 extends IAuthMethod {\n\tenum AuthScheme {\n\t\t/**\n\t\t * Basic authentication scheme as described by RFC2617. Sends authentication information as cleartext.\n\t\t */\n\t\tAUTH_SCHEME_BASIC,\n\t\t\n\t\t/**\n\t\t * Digest authentication scheme as described by RFC2617. Hashes the password with a shared secret before it is\n\t\t * sent.\n\t\t */\n\t\tAUTH_SCHEME_DIGEST,\n\t};\n\n\t/**\n\t * Set the authentication scheme. The scheme is set to AUTH_SCHEME_DIGEST by default.\n\t * @param authScheme Authentication scheme. \n\t */\n\tvoid setAuthScheme(AuthScheme authScheme);\n\n\t/**\n\t * Get the authentication scheme.\n\t * @return Authentication scheme.\n\t */\n\tAuthScheme getAuthScheme();\n\t\n\t/**\n\t * Set the username to use when authenticating.\n\t * @param username Username.\n\t */\n\tvoid setUsername(String username);\n\t\n\t/**\n\t * Get the username to use when authenticating.\n\t * @return Username.\n\t */\n\tString getUsername();\n\t\n\t/**\n\t * Set the password to use when authenticating.\n\t * @param password Password.\n\t */\n\tvoid setPassword(String password);\n\n\t/**\n\t * Get the password to use when authenticating.\n\t * @return Password.\n\t */\n\tString getPassword();\n\n\t/**\n\t * Set the charset to be used when encoding user credentials. Set to \"US-ASCII\" by default.\n\t * @param charset Character set.\n\t */\n\tvoid setCharset(String charset);\n\n\t/**\n\t * Get the charset to be used when encoding user credentials.\n\t * @return Character set.\n\t */\n\tString getCharset();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/IIdentity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.model.variables.IVariableDictionary;\n\n/**\n * An identity consists of a dictionary of information about a website identity (typical ex. a user on a website) and\n * additional information about how to interact with a site when using that identity.\n */\npublic interface IIdentity extends IVariableDictionary {\n\t/**\n\t * Set the name of this identity. The identity name must be unique within the workspace.\n\t * @param name Identity name.\n\t */\n\tvoid setName(String name);\n\n\t/**\n\t * Get the name of this identity.\n\t * @return Identity name.\n\t */\n\tString getName();\n\t\n\t/**\n\t * Set the authentication method for this identity.\n\t * @param authMethod Authentication method.\n\t */\n\tvoid setAuthMethod(IAuthMethod authMethod);\n\t\n\t/**\n\t * Get the authentication method for this identity.\n\t * @return Authentication method.\n\t */\n\tIAuthMethod getAuthMethod();\n\n\t/**\n\t * Add a path exclusion regular expression to prevent the scanner from accessing paths. \n\t * @param expression Path exclusion, a regular expression.\n\t */\n\tvoid addPathExclusion(String expression);\n\n\t/**\n\t * Get all path exclusion expressions for this identity.\n\t * @return Path exclusion expressions for this identity.\n\t */\n\tCollection<String> getPathExclusions();\n\n\t/**\n\t * Remove a path exclusion.\n\t * @param expression Path exclusion expression.\n\t */\n\tvoid rmPathExclusion(String expression);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/IIdentityModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic interface IIdentityModel {\n\t/**\n\t * Get all identities managed by the model.\n\t * @return Identities managed by the model.\n\t */\n\tCollection<IIdentity> getAllIdentities();\n\n\t/**\n\t * Create a new identity with no fields set. The identity is not stored to the database.\n\t * @return New identity.\n\t */\n\tIIdentity createIdentity();\n\n\t/**\n\t * Create an IAuthMethodRfc2617 instance with no fields set. The IAuthMethod is not associated with any identity. \n\t * @return IAuthMethodRfc2617.\n\t */\n\tIAuthMethodRfc2617 createAuthMethodRfc2617();\n\n\t/**\n\t * Create an IAuthMethodNtlm instance with no fields set. The IAuthMethod is not associated with any identity. \n\t * @return IAuthMethodNtlm.\n\t */\n\tIAuthMethodNtlm createAuthMethodNtlm();\n\n\t/**\n\t * Create an IAuthMethodHttpMacro instance with no fields set. The IAuthMethod is not associated with any identity.\n\t * @return IAuthMethodHttpMacro.\n\t */\n\tIAuthMethodHttpMacro createAuthMethodHttpMacro();\n\n\t/**\n\t * Store an identity in the workspace. The caller is responsible for ensuring an IIdentity with the same name does\n\t * not already exist.\n\t * @param scanIdentity Scan identity to store.\n\t */\n\tvoid store(IIdentity scanIdentity);\n\n\t/**\n\t * Determine whether an identity exists in the workspace.\n\t * @param identity Identity.\n\t * @return Boolean indicating whether the identity exists in the workspace.\n\t */\n\tboolean isIdentityStored(IIdentity identity);\n\n\t/**\n\t * Lookup an identity in the workspace by name. The lookup is case-insensitive.\n\t * @param name Identity, or null if none exists with the given name.\n\t */\n\tIIdentity getIdentityByName(String name);\n\n\t/**\n\t * Register an event listener to watch for changes to identities managed by the model. Fires:\n\t * \t- NewIdentityEvent\n\t * @param listener Event listener.\n\t */\n\tvoid addChangeListener(IEventHandler listener);\n\n\t/**\n\t * De4register a change event listener.\n\t * @param listener Event listener.\n\t */\n\tvoid removeChangeListener(IEventHandler listener);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/identity/NewIdentityEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.identity;\n\nimport com.subgraph.vega.api.events.IEvent;\n\n/**\n * Event indicating a new identity was stored to the database.\n */\npublic class NewIdentityEvent implements IEvent {\n\tprivate final IIdentity identity;\n\t\n\tpublic NewIdentityEvent(IIdentity identity) {\n\t\tthis.identity = identity;\n\t}\n\n\tpublic IIdentity getIdentity() {\n\t\treturn identity;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/macros/IHttpMacro.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.macros;\n\nimport java.io.IOException;\nimport java.net.URISyntaxException;\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\n/**\n * A HTTP macro. A macro is a sequence of one or more requests.\n */\npublic interface IHttpMacro {\t\n\t/**\n\t * Set the name of the macro.\n\t * @param name Macro name.\n\t */\n\tvoid setName(String name);\n\n\t/**\n\t * Get the name of the macro.\n\t * @param name Macro name.\n\t */\n\tString getName();\n\n\t/**\n\t * Create an IHttpMacroItem and add it to this macro.\n\t * @param record IRequestLogRecord to create the item for.\n\t * @return\n\t * @throws IOException \n\t * @throws URISyntaxException \n\t */\n\tIHttpMacroItem createMacroItem(IRequestLogRecord record) throws URISyntaxException, IOException;\n\n\t/**\n\t * Remove a macro item.\n\t * @param item Macro item.\n\t */\n\tvoid removeMacroItem(IHttpMacroItem item);\n\t\n\t/**\n\t * Get the macro items comprising this macro. The collection is ordered by item execution order.\n\t * @return Macro items. \n\t */\n\tCollection<IHttpMacroItem> getMacroItems();\n\n\t/**\n\t * Returns the number of macro items in this macro.\n\t * @return The number of macro items.\n\t */\n\tint macroItemsSize();\n\t\n\t/**\n\t * Get the array index of a macro item.\n\t * @param item Macro item.\n\t * @return Array index, or -1.\n\t */\n\tint indexOfMacroItem(IHttpMacroItem item);\n\t\n\t/**\n\t * Swap macro items at two positions.\n\t * @return Swapped macro items. \n\t */\n\tvoid swapMacroItems(int idx1, int idx2);\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/macros/IHttpMacroItem.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.macros;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URISyntaxException;\nimport java.util.Collection;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpMacroContext;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam.ValueSetIn;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic interface IHttpMacroItem {\n\t/**\n\t * Get the IRequestLogRecord this macro is derived from.\n\t * @return IRequestLogRecord.\n\t */\n\tIRequestLogRecord getRequestLogRecord();\n\n\t/**\n\t * Set whether cookies set in the request engine should be used when sending the macro request. \n\t * @param useCookies Boolean value indicating whether cookies should be used.\n\t */\n\tvoid setUseCookies(boolean useCookies);\n\n\t/**\n\t * Returns a boolean value indicating whether cookies set in the request engine should be used when sending the\n\t * macro request.\n\t * @return Boolean value Boolean value indicating whether cookies should be used.\n\t */\n\tboolean getUseCookies();\n\t\n\t/**\n\t * Set whether cookies from the response should be kept in the request engine.\n\t * @param keepCookies Booelan value indicating whether cookies from the response should be kept. \n\t */\n\tvoid setKeepCookies(boolean keepCookies);\n\n\t/**\n\t * Returns a boolean value indicating whether cookies received in the response to the macro should be set in the\n\t * request engine.\n\t * @return Booelan value indicating whether cooies from the response should be kept,\n\t */\n\tboolean getKeepCookies();\n\n\t/**\n\t * Create an IHttpMacroItemParam and add it to this macro item.\n\t * @param name Parameter name.\n\t * @param value Parameter value, or null.\n\t * @param setIn Where the parameter is set.\n\t * @return IHttpMacroItemParam.\n\t */\n\tIHttpMacroItemParam createParam(String name, String value, ValueSetIn setIn);\n\n\t/**\n\t * Remove a parameter.\n\t * @param param Parameter.\n\t */\n\tvoid removeParam(IHttpMacroItemParam param);\n\t\n\t/**\n\t * Returns the number of parameters in this macro.\n\t * @return The number of parameters.\n\t */\n\tint paramsSize();\n\n\t/**\n\t * Get the array index of a parameter.\n\t * @param param Parameter.\n\t * @return Array index, or -1.\n\t */\n\tint indexOfParam(IHttpMacroItemParam param);\n\t\n\t/**\n\t * Swap parameters at two positions.\n\t * @return Swapped parameters. \n\t */\n\tvoid swapParams(int idx1, int idx2);\n\n\t/**\n\t * Get a list of request parameters.\n\t * @return Request parameters. \n\t */\n\tCollection<IHttpMacroItemParam> getParams();\n\n\t/**\n\t * Get any request parameters for a parameter name.\n\t * @param name Parameter name.\n\t * @return Array of parameters for the name.\n\t */\n\tIHttpMacroItemParam[] getParam(String name);\n\n\t/**\n\t * Create a request for this macro item.\n\t * @param requestBuilder Request builder.\n\t * @throws UnsupportedEncodingException \n\t * @throws URISyntaxException \n\t */\n\tHttpUriRequest createRequest(IHttpMacroContext context) throws URISyntaxException, UnsupportedEncodingException;\n\t\n\t/**\n\t * Set the contents of a request for this macro item within a request builder. Any existing message properties that\n\t * would interfere with the meaning of the request builder are removed. \n\t * @param requestBuilder Request builder.\n\t * @param context Macro context.\n\t * @throws UnsupportedEncodingException \n\t * @throws URISyntaxException \n\t */\n\tvoid setRequestBuilder(IHttpRequestBuilder requestBuilder, IHttpMacroContext context) throws UnsupportedEncodingException, URISyntaxException;\n\n\t/**\n\t * Update the macro request from a request builder. \n\t * @param requestBuilder Request builder.\n\t * @throws URISyntaxException \n\t */\n\tvoid updateFromRequestBuilder(IHttpRequestBuilder requestBuilder) throws URISyntaxException;\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/macros/IHttpMacroItemParam.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.macros;\n\n/**\n * Parameter submitted as part of an IHttpMacroItem.\n */\npublic interface IHttpMacroItemParam {\n\t/**\n\t * Enumeration of parameter value sources.\n\t */\n\tenum ValueSource {\n\t\tSOURCE_LITERAL(\"literal value\"), /** Use a literal value. */\n\t\tSOURCE_VARIABLE(\"use a dictionary variable\"), /** Obtain the variable from an identity variable dictionary. */\n\t\tSOURCE_DERIVE(\"derive from previous page\"); /** Derive the value from the previous page retrieval. */\n\t\t\n\t\tprivate String description;\n\n\t\tprivate ValueSource(String description) {\n\t\t\tthis.description = description;\n\t\t}\n\t\t\n\t\tpublic String getDescription() {\n\t\t\treturn description;\n\t\t}\n\t};\n\n\t/**\n\t * Enumeration of where the parameter is set.\n\t */\n\tenum ValueSetIn {\n\t\tVALUE_SET_IN_URI,\n\t\tVALUE_SET_IN_BODY,\n\t}\n\n\t/**\n\t * Get the parameter name.\n\t * @return Parameter name.\n\t */\n\tString getName();\n\n\t/**\n\t * Set the value source for the parameter.\n\t * @param source Value source.\n\t */\n\tvoid setValueSource(ValueSource source);\n\n\t/**\n\t * Get the value source for the parameter.\n\t * @return Value source.\n\t */\n\tValueSource getValueSource();\n\n\t/**\n\t * Set where the parameter is to be put in a request.\n\t * @param setIn Where the parameter is to be put in a request.\n\t */\n\tvoid setSetIn(ValueSetIn setIn);\n\n\t/**\n\t * Get where the parameter is to be put in a request.\n\t * @return Where the parameter is to be put in a request.\n\t */\n\tValueSetIn getSetIn();\n\t\n\t/**\n\t * Set the value of the parameter. Varies depending on the ValueSource:\n\t * \t- SOURCE_LITERAL: the literal value to submit.\n\t * \t- SOURCE_VARIABLE: the name of the variable in a variable dictionary to obtain a value from.\n\t *  - SOURCE_DERIVE: must be null\n\t */\n\tvoid setValue(String value);\n\t\n\t/**\n\t * Get the value of the parameter. Varies depending on the ValueSource:\n\t * \t- SOURCE_LITERAL: the literal value to submit.\n\t * \t- SOURCE_VARIABLE: the name of the variable in a variable dictionary to obtain a value from.\n\t *  - SOURCE_DERIVE: always null\n\t * @return Parameter value, or null if none is set.\n\t */\n\tString getValue();\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/macros/IHttpMacroModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.macros;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic interface IHttpMacroModel {\n\t/**\n\t * Get all macros managed by the model.\n\t * @return Identities managed by the model.\n\t */\n\tCollection<IHttpMacro> getAllMacros();\n\n\t/**\n\t * Create a new macro with nothing set. The macro is not stored to the database.\n\t * @return New macro.\n\t */\n\tIHttpMacro createMacro();\n\n\t/**\n\t * Store a macro in the workspace. The caller is responsible for ensuring an IHttpMacro with the same name does\n\t * not already exist.\n\t * @param macro Macro to store.\n\t */\n\tvoid store(IHttpMacro macro);\n\n\t/**\n\t * Determine whether an macro exists in the workspace.\n\t * @param macro Macro.\n\t * @return Boolean indicating whether the macro exists in the workspace.\n\t */\n\tboolean isMacroStored(IHttpMacro macro);\n\n\t/**\n\t * Lookup an macro in the workspace by name. The lookup is case-insensitive.\n\t * @param name Macro, or null if none exists with the given name.\n\t */\n\tIHttpMacro getMacroByName(String name);\n\n\t/**\n\t * Register an event listener to watch for changes to identities managed by the model. Fires:\n\t * \t- NewMacroEvent\n\t * @param listener Event listener.\n\t */\n\tvoid addChangeListener(IEventHandler listener);\n\n\t/**\n\t * Deregister a change event listener.\n\t * @param listener Event listener.\n\t */\n\tvoid removeChangeListener(IEventHandler listener);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/macros/NewMacroEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.macros;\n\nimport com.subgraph.vega.api.events.IEvent;\n\n/**\n * Event indicating a new macro was stored to the database.\n */\npublic class NewMacroEvent implements IEvent {\n\tprivate IHttpMacro macro;\n\t\n\tpublic NewMacroEvent(IHttpMacro macro) {\n\t\tthis.macro = macro;\n\t}\n\t\n\tpublic IHttpMacro getMacro() {\n\t\treturn macro;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/IRequestLog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.requests;\n\nimport java.net.InetAddress;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\n\npublic interface IRequestLog {\n\tlong getNextRequestId();\n\tlong allocateRequestId();\n\tlong addRequestResponse(IHttpResponse response);\n\tIRequestLogRecord lookupRecord(long requestId);\n\tList<IRequestLogRecord> getAllRecords();\n\tList<IRequestLogRecord> getRecordsByConditionSet(IHttpConditionSet filterCondition);\n\tIterator<IRequestLogRecord> getRecordIteratorByConditionSet(IHttpConditionSet filterCondition);\n\tIRequestOriginProxy getRequestOriginProxy(InetAddress address, int port);\n\tIRequestOriginScanner getRequestOriginScanner(IScanInstance scanInstance);\n\tIRequestOrigin getRequestOriginRequestEditor();\n\n\tvoid addNewRecordListener(IRequestLogNewRecordListener callback);\n\tvoid addNewRecordListener(IRequestLogNewRecordListener callback, IHttpConditionSet filterCondition);\n\tvoid removeNewRecordListener(IRequestLogNewRecordListener callback);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/IRequestLogNewRecordListener.java",
    "content": "package com.subgraph.vega.api.model.requests;\n\npublic interface IRequestLogNewRecordListener {\n\tpublic void onNewRecord(RequestLogNewRecordEvent event);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/IRequestLogRecord.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.requests;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.subgraph.vega.api.model.tags.ITaggable;\n\npublic interface IRequestLogRecord extends ITaggable {\n\tlong getRequestId();\n\tlong getTimestamp();\n\t\n\t/**\n\t * Get the end-to-end request execution time in milliseconds.\n\t * @return Request execution time in milliseconds, or -1 if unknown.\n\t */\n\tlong getRequestMilliseconds();\n\n\t/**\n\t * Get information about the origin of the request within Vega.\n\t * @return Vega request origin.\n\t */\n\tIRequestOrigin getRequestOrigin();\n\t\n\tHttpHost getHttpHost();\n\tHttpRequest getRequest();\n\tHttpResponse getResponse();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/IRequestOrigin.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.requests;\n\n/**\n * Describes the origin of a request within Vega, i.e. which module generated a request, along with optional additional\n * information about the origin.\n */ \npublic interface IRequestOrigin {\n\t/**\n\t * Enumeration of request origins.\n\t */\n\tpublic enum Origin {\n\t\tORIGIN_SCANNNER, /** IRequestOriginScanner */\n\t\tORIGIN_PROXY, /** IRequestOriginProxy */\n\t\tORIGIN_REQUEST_EDITOR,\n\t};\n\n\t/**\n\t * Get the origin.\n\t * @return Origin.\n\t */\n\tOrigin getOrigin();\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/IRequestOriginProxy.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.requests;\n\nimport java.net.InetAddress;\n\n/**\n * Request origin information for the Vega intercepting proxy.\n */\npublic interface IRequestOriginProxy extends IRequestOrigin {\n\t/**\n\t * Get the internet address of the proxy listener.\n\t * @return Proxy listener address.\n\t */\n\tInetAddress getInetAddress();\n\n\t/**\n\t * Get the port of the proxy listener.\n\t * @return Proxy listener port.\n\t */\n\tint getPort();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/IRequestOriginScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.requests;\n\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\n/**\n * Request origin information for the scanner.\n */\npublic interface IRequestOriginScanner extends IRequestOrigin {\n\t/**\n\t * Get the IScanInstance that generated the request.\n\t * @return IScanInstance.\n\t */\n\tIScanInstance getScanInstance();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/requests/RequestLogNewRecordEvent.java",
    "content": "package com.subgraph.vega.api.model.requests;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class RequestLogNewRecordEvent implements IEvent {\n\t\n\tprivate final IRequestLogRecord record;\n\t\n\tpublic RequestLogNewRecordEvent(IRequestLogRecord record) {\n\t\tthis.record = record;\n\t}\n\t\n\tpublic IRequestLogRecord getNewRecord() {\n\t\treturn record;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/scope/ActiveScopeChangedEvent.java",
    "content": "package com.subgraph.vega.api.model.scope;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class ActiveScopeChangedEvent implements IEvent {\n\tprivate final ITargetScope activeScope;\n\t\n\tpublic ActiveScopeChangedEvent(ITargetScope activeScope) {\n\t\tthis.activeScope = activeScope;\n\t}\n\t\n\tpublic ITargetScope getActiveScope() {\n\t\treturn activeScope;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/scope/ITargetScope.java",
    "content": "package com.subgraph.vega.api.model.scope;\n\nimport java.net.URI;\nimport java.util.Collection;\n\nimport org.apache.http.HttpHost;\n\npublic interface ITargetScope {\n\t\n\tlong getScopeId();\n\t\n\t/**\n\t * Returns the name of this scope instance.\n\t * \n\t * Use {@link #setName()} to change name.\n\t * \n\t * @return The name of this scope instance.\n\t */\n\tString getName();\n\t\n\t/**\n\t * Set a new name for this scope instance.\n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t * \n\t * @param name The new name for this scope.\n\t */\n\tvoid setName(String name);\n\t\n\t/**\n\t * Add an URI to this scope instance.\n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t * \n\t * @param uri The URI path to add to the scope.\n\t */\n\tvoid addScopeURI(URI uri);\n\t\n\t/** \n\t * Removes the specified URI from this scope instance.  If the\n\t * removeContained flag is set, also remove any URIs from this\n\t * scope which are contained by specified URI.  \n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t *  \n\t * @param uri The URI to remove.\n\t * @param removeContained Also remove any scope URIs which are contained\n\t *                        by the specified URI.\n\t */\n\tvoid removeScopeURI(URI uri, boolean removeContained);\n\t\n\t/**\n\t * Return all URIs which have been added to this scope instance\n\t * with the {@link #addScopeURI(URI)} method.\n\t * \n\t * @return All URIs which have been added to this scope instance.\n\t */\n\tCollection<URI> getScopeURIs();\n\t\n\t/**\n\t * Add a regular expression pattern to the exclusion filter.\n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t * \n\t * @param pattern The regular expression to add.\n\t */\n\tvoid addExclusionPattern(String pattern);\n\t\n\t/**\n\t * Add an URI to the exclusion filter.\n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t * \n\t * @param uri The URI to add.\n\t */\n\tvoid addExclusionURI(URI uri);\n\t\n\t/**\n\t * Remove a regular expression pattern from the exclusion filter.\n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t * \n\t * @param pattern The regular expression to remove.\n\t */\n\tvoid removeExclusionPattern(String pattern);\n\t\n\t/**\n\t * Remove a URI from the exclusion filter.\n\t * \n\t * Fires {@link ActiveScopeChangedEvent} if this is the active scope.\n\t * \n\t * @param uri The URI to remove.\n\t */\n\tvoid removeExclusionURI(URI uri);\n\t\n\t/**\n\t * Returns a collection of all regular expressions added to the exclusion filter.\n\t * \n\t * @return a collection of all regular expressions added to the exclusion filter.\n\t */\n\tCollection<String> getExclusionPatterns();\n\t\n\t/**\n\t * Returns a collection of all URIs added to the exclusion filter.\n\t * \n\t * @return a collection of all URIs added to the exclusion filter.\n\t */\n\tCollection<URI> getExclusionURIs();\n\t\n\t/**\n\t * Returns true if the given URI matches the exclusion filter\n\t * \n\t * @param uri The uri to test.\n\t * @return true if uri matches exclusion filter.\n\t */\n\tboolean isExcluded(URI uri);\n\t\n\t/**\n\t * Returns true if the given host and uriPath pair matches\n\t * the exclusion filter.\n\t * \n\t * @param host The host to test.\n\t * @param uriPath The uriPath to test.\n\t * @return true if the host and uriPath pair matches the exclusion filter.\n\t */\n\tboolean isExcluded(HttpHost host, String uriPath);\n\n\t/**\n\t * Returns true if the given URI matches the scope filter.\n\t * @param uri The uri to test\n\t * @return true if the uri matches the scope filter.\n\t */\n\tboolean isInsideScope(URI uri);\n\t\n\t/**\n\t * Returns true if the given host and uriPath pair matches the \n\t * scope filter.\n\t * @param host The host to test.\n\t * @param uriPath The uri path to test.\n\t * @return true if the host and uriPath pair matches the scope filter.\n\t */\n\tboolean isInsideScope(HttpHost host, String uriPath);\n\t\n\t/**\n\t * Returns true if the given URI matches the scope filter but\n\t * does not match the exclusion filter.\n\t * \n\t * Equivalent to (isInsideScope(uri) && !isExcluded(uri))\n\t * \n\t * @param uri The uri to test.\n\t * @return true if the given URI matches the scope filter but\n\t *              does not match the exclusion filter.\n\t */\n\tboolean filter(URI uri);\n\n\t\n\t/**\n\t * Returns true if the given host and uriPath matches the scope filter but\n\t * does not match the exclusion filter.\n\t * \n\t * Equivalent to (isInsideScope(host, uriPath) && !isExcluded(host, uriPath))\n\t * \n\t * @param host The host to test\n\t * @param uriPath The path to test\n\t * @return true if the given host and uriPath pair matches the scope filter but\n\t *              does not match the exclusion filter.\n\t */\n\n\tboolean filter(HttpHost host, String uriPath);\n\t\n\t/**\n\t * Resets the state of this scope instance by removing all scope URIs \n\t * and exclusion patterns. \n\t */\n\tvoid clear();\n\t\n\t/**\n\t * Returns true if this is the default scope.\n\t * @return true if this is the default scope.\n\t */\n\tboolean isDefaultScope();\n\t\n\t/**\n\t * Returns true if this is the currently active scope.\n\t * \n\t * @return true if this is the active scope.\n\t */\n\tboolean isActiveScope();\n\n\tvoid setReadOnly(boolean value);\n\t\t\n\tboolean isReadOnly();\n\t\n\tboolean isDetached();\n\t\n\tboolean isEmpty();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/scope/ITargetScopeManager.java",
    "content": "package com.subgraph.vega.api.model.scope;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic interface ITargetScopeManager {\n\t/**\n\t * Create and return a new empty scope instance.  The returned\n\t * scope will not be saved persistently in the database until the\n\t * {@link #saveScope(ITargetScope)} method is called.\n\t * \n\t * @return The new scope instance.\n\t */\n\tITargetScope createNewScope();\n\t\n\t/**\n\t * Create and return a new scope instance which is a duplicate of\n\t * the scope parameter.\n\t * \n\t * @param scope The scope instance to duplicate.\n\t * @return A new scope instance which is a duplicate of the scope parameter.\n\t */\n\tITargetScope createDuplicatedScope(ITargetScope scope);\n\t\n\t/**\n\t * Remove the specified scope instance from the manager.  The\n\t * default scope cannot be removed.  This method will return \n\t * false if passed the default scope or a scope instance not\n\t * recognized by the manager.  If the currently active scope\n\t * is removed, the default scope will become the active scope.\n\t * \n\t * @param scope The scope to remove.\n\t * @return true if the scope was successfully removed.\n\t */\n\tboolean removeScope(ITargetScope scope);\n\t\n\t/**\n\t * Save this scope in the database.\n\t * \n\t * @param scope The scope to save.\n\t */\n\tvoid saveScope(ITargetScope scope);\n\t\n\t/**\n\t * Return all persistent scope instances from the manager.\n\t * \n\t * @return All scope instances.\n\t */\n\tCollection<ITargetScope> getAllScopes();\n\t\n\t/** \n\t * Return the currently active scope.  There is always a single active\n\t * scope.  Use {@link #setActiveScope(ITargetScope)} to change the\n\t * active scope.\n\t * \n\t * @return The currently active scope.\n\t */\n\tITargetScope getActiveScope();\n\t\n\t/**\n\t * Return the default scope.  The default scope is created automatically\n\t * for a workspace and cannot be removed.\n\t * @return\n\t */\n\tITargetScope getDefaultScope();\n\t\n\t/**\n\t * Set the active scope to the specified scope instance.\n\t * \n\t * @param scope The scope to set as the active scope.\n\t */\n\tvoid setActiveScope(ITargetScope scope);\n\t\n\t/**\n\t * Add a listener for the event {@link ActiveScopeChangedEvent}.  This event\n\t * is fired when the currently active scope is changed to another scope or the\n\t * properties of the active scope are modified.\n\t * \n\t * @param listener The event handler to register.\n\t * @return The currently active target scope\n\t */\n\tITargetScope addActiveScopeChangeListener(IEventHandler listener);\n\t\n\t/**\n\t * Removes an event handler registered with {@link #addActiveScopeChangeListener(IEventHandler)}.\n\t * \n\t * @param listener The event handler to remove.\n\t */\n\tvoid removeActiveScopeChangeListener(IEventHandler listener);\n\t\n\tvoid setScopeDetached(ITargetScope scope);\n\tvoid setScopeAttached(ITargetScope scope);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/tags/ITag.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.tags;\n\n/**\n * A tag is a unique single word identifier that can be applied to a record such as a web transaction or a scan to mark\n * it as significant and to simplify later searching.\n */\npublic interface ITag {\n\t/**\n\t * Set the name identifier for the tag.\n\t * @param name Tag name.\n\t */\n\tvoid setName(String name);\n\n\t/**\n\t * Get the name identifier for the tag.\n\t * @return Tag name.\n\t */\n\tString getName();\n\t\n\t/**\n\t * Set the description for the tag. Can be null.\n\t * @param description Tag description. Can be null.\n\t */\n\tvoid setDescription(String description);\n\n\t/**\n\t * Get the description for the tag. May be null.\n\t * @return Tag description. May be null.\n\t */\n\tString getDescription();\n\n\t/**\n\t * Set the 24-bit sRGB color to be applied to the tag name in certain displays.\n\t * @param color sRGB color for the tag name.\n\t */\n\tvoid setNameColor(int color);\n\n\t/**\n\t * Get the 24-bit sRGB color for the tag name.\n\t * @return sRGB color for the tag name.\n\t */\n\tint getNameColor();\n\n\t/**\n\t * Ser the 24-bit sRGB color to be applied to the background of rows in a table the tag is applied to.\n\t * @param color sRGB color for table rows the tag is applied to.\n\t */\n\tvoid setRowColor(int color);\n\n\t/**\n\t * Get the 24-bit sRGB color for tagged table rows.\n\t * @return sRGB color for tagged table rows.\n\t */\n\tint getRowColor();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/tags/ITagModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.tags;\n\nimport java.util.Collection;\n\npublic interface ITagModel {\n\t/**\n\t * Get all tags managed by the model.\n\t * @return Tags managed by the model.\n\t */\n\tCollection<ITag> getAllTags();\n\n\t/**\n\t * Create a new tag with no fields set. The tag is not stored to the workspace.\n\t * @return Tag.\n\t */\n\tITag createTag();\n\t\n\t/**\n\t * Create a copy of a tag. The copy is not stored to the workspace.\n\t * @return Copy of tag.\n\t */\n\tITag createTag(ITag tag);\n\t\n\t/**\n\t * Store a tag in the workspace. The caller is responsible for ensuring a tag with the same name does not already\n\t * exist.\n\t * @param tag Tag to store.\n\t */\n\tvoid store(ITag tag);\n\n\t/**\n\t * Determine whether a tag exists in the workspace.\n\t * @param tag Tag.\n\t * @return Boolean indicating whether the tag exists in the workspace.\n\t */\n\tboolean isTagStored(ITag tag);\n\n\t/**\n\t * Lookup a tag in the workspace by name. The lookup is case-insensitive.\n\t * @param name Tag, or null if none exists with the given name.\n\t */\n\tITag getTagByName(String name);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/tags/ITaggable.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.tags;\n\nimport java.util.Collection;\n\n/**\n * Interface for an object to which tags can be applied.\n */\npublic interface ITaggable {\n\t/**\n\t * Get a collection of all tags applied to this object.\n\t * @return Tags applied to this record.\n\t */\n\tCollection<ITag> getAllTags();\n\n\t/**\n\t * Get a tag with a given array index.\n\t * @param idx Array index.\n\t * @return Tag.\n\t */\n\tITag getTag(int idx);\n\t\n\t/**\n\t * Get a count of tags applied to this object.\n\t * @return Count of tags applied to this object.\n\t */\n\tint getTagCount();\n\n\t/**\n\t * Set the tags for this object. Clears any existing tags.\n\t * @param tags Tags.\n\t */\n\tvoid setTags(Collection<ITag> tags);\n\t\n\t/**\n\t * Apply a tag to this object.\n\t * @param tag Tag.\n\t */\n\tvoid addTag(ITag tag);\n\n\t/**\n\t * Remove a tag from this object.\n\t * @param tag Tag.\n\t */\n\tvoid removeTag(ITag tag);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/variables/IVariable.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.variables;\n\npublic interface IVariable {\n\t/**\n\t * Set the variable name. The variable name cannot be null.\n\t * @param name Variable name.\n\t */\n\tvoid setName(String name);\n\t\n\t/**\n\t * Get the variable name.\n\t * @return Variable name.\n\t */\n\tString getName();\n\n\t/**\n\t * Set a description for the variable.\n\t * @param description Variable description.\n\t */\n\tvoid setDescription(String description);\n\n\t/**\n\t * Get the description for the variable.\n\t * @return Description of the variable, or null if none is set.\n\t */\n\tString getDescription();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/variables/IVariableDictionary.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.variables;\n\nimport java.util.Map;\n\npublic interface IVariableDictionary {\n\t/**\n\t * Set a dictionary value.\n\t * @param key IVariable name to set.\n\t * @param value Value to set.\n\t * @return Previous value, or null if none was set.\n\t */\n\tString setDictValue(String key, String value);\n\n\t/**\n\t * Get a dictionary value for a variable name.\n\t * @param key IVariable name.\n\t * @return Dictionary value, or null if none exists.\n\t */\n\tString getDictValue(String key);\n\n\t/**\n\t * Get a copy of the dictionary as a map.\n\t * @return Dictionary.\n\t */\n\tMap<String, String> getDict();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/variables/IVariableModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.variables;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.model.variables.IVariable;\n\npublic interface IVariableModel {\n\t/**\n\t * Get all identities managed by the model.\n\t * @return Identities managed by the model.\n\t */\n\tCollection<IVariable> getAllIdentities();\n\n\t/**\n\t * Create a new variable with no fields set. The variable is not stored to the database.\n\t * @return New variable.\n\t */\n\tIVariable createVariable();\n\t\n\t/**\n\t * Store an variable in the workspace. The caller is responsible for ensuring an IVariable with the same name does\n\t * not already exist.\n\t * @param variable Variable to store.\n\t */\n\tvoid store(IVariable variable);\n\n\t/**\n\t * Determine whether an variable exists in the workspace.\n\t * @param variable Variable.\n\t * @return Boolean indicating whether the variable exists in the workspace.\n\t */\n\tboolean isVariableStored(IVariable variable);\n\n\t/**\n\t * Lookup an variable in the workspace by name. The lookup is case-insensitive.\n\t * @param name Variable, or null if none exists with the given name.\n\t */\n\tIVariable getVariableByName(String name);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebEntity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport org.apache.http.HttpHost;\n\nimport com.subgraph.vega.api.model.IModelProperties;\n\npublic interface IWebEntity extends IModelProperties, IWebModelVisitable {\n\tboolean isVisited();\n\tvoid setVisited(boolean notify);\n\tboolean isScanned();\n\tvoid setScanned();\n\tIWebEntity getParent();\n\tHttpHost getHttpHost();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebHost.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport java.net.URI;\n\npublic interface IWebHost extends IWebEntity {\n\tURI getUri();\n\tString getScheme();\n\tString getHostname();\n\tint getPort();\n\tIWebMountPoint getRootMountPoint();\n\tIWebPath getRootPath();\n\tIWebPath addPath(String path);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport java.util.Collection;\n\nimport org.apache.http.HttpHost;\nimport org.w3c.dom.html2.HTMLDocument;\n\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.web.forms.IWebForm;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic interface IWebModel extends IWebModelVisitable {\n\tvoid addChangeListenerAndPopulate(IEventHandler listener);\n\tvoid removeChangeListener(IEventHandler listener);\n\tCollection<IWebHost> getAllWebHosts();\n\tIWebHost getWebHostByHttpHost(HttpHost host);\n\tIWebHost createWebHostFromHttpHost(HttpHost host);\n\tIWebPath getWebPathByUri(VegaURI uri);\n\t\n\tIWebPath addGetTarget(VegaURI uri);\n\n\tCollection<IWebHost> getUnscannedHosts();\n\tCollection<IWebPath> getUnscannedPaths();\n\tCollection<IWebPath> getAllPaths();\n\t\n\tCollection<IWebForm> parseForms(IWebPath source, HTMLDocument document);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebModelVisitable.java",
    "content": "package com.subgraph.vega.api.model.web;\n\npublic interface IWebModelVisitable {\n\tvoid accept(IWebModelVisitor visitor);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebModelVisitor.java",
    "content": "package com.subgraph.vega.api.model.web;\n\npublic interface IWebModelVisitor {\n\tvoid visit(IWebHost host);\n\tvoid visit(IWebPath path);\n\tvoid visit(IWebResponse response);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebMountPoint.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\npublic interface IWebMountPoint {\n\tIWebHost getWebHost();\n\tIWebPath getMountPath();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebPath.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport java.net.URI;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\n\npublic interface IWebPath extends IWebEntity {\n\tenum PathType { PATH_UNKNOWN, PATH_DIRECTORY, PATH_FILE, PATH_PATHINFO };\n\tIWebPath getParentPath();\n\tString getPathComponent();\n\tString getFullPath();\n\tURI getUri();\n\tIWebPath addChildPath(String pathComponent);\n\tIWebPath getChildPath(String pathComponent);\n\tIWebMountPoint getMountPoint();\n\tCollection<IWebPath> getChildPaths();\n\t\n\tvoid setPathType(PathType type);\n\tPathType getPathType();\n\t\n\tvoid setMimeType(String mimeType);\n\tString getMimeType();\n\t\n\tboolean isGetTarget();\n\tboolean isPostTarget();\n\t\n\tvoid addGetParameterList(List<NameValuePair> params);\n\tvoid addPostParameterList(List<NameValuePair> params);\n\n\tIWebPathParameters getGetParameters();\n\tIWebPathParameters getPostParameters();\n\t\n\tList<IWebResponse> getGetResponses();\n\tList<IWebResponse> getPostResponses();\n\t\n\tvoid addGetResponse(String query, String mimeType);\n\tvoid addPostResponse(List<NameValuePair> parameters, String mimeType);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebPathParameters.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport java.util.Collection;\nimport java.util.List;\nimport org.apache.http.NameValuePair;\n\n/**\n * \n * ?id=100&page=welcome\n * ?id=202&action=foo\n * ?id=300&action=foo\n * \n * getParameterLists() : [ [id=100,page=welcome], [id=202,action=foo], [id=300,action=foo] ]\n * getParameterNameLists() : [ [id, page], [id, action] ]\n * getParameterNames(): [ id, page, action ]\n * getValuesForParameter(id) : [100, 202, 300]\n * getValuesForParameter(action): [foo]\n *\n */\npublic interface IWebPathParameters {\n\tboolean hasParameters();\n\tCollection< List<NameValuePair> > getParameterLists();\n\tCollection< List<String> > getParameterNameLists();\n\tCollection<String> getParameterNames();\n\tCollection<String> getValuesForParameter(String name);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/IWebResponse.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\n\npublic interface IWebResponse extends IWebEntity {\n\tIWebPath getPathEntity();\n\tString getQueryString();\n\tList<NameValuePair> getRequestParameters();\n\tString getMimeType();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/NewWebEntityEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class NewWebEntityEvent implements IEvent {\n\tprivate final IWebEntity entity;\n\t\n\tpublic NewWebEntityEvent(IWebEntity entity) {\n\t\tthis.entity = entity;\n\t}\n\t\n\tpublic IWebEntity getEntity() {\n\t\treturn entity;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/UpdatedWebEntityEvent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class UpdatedWebEntityEvent implements IEvent {\n\tprivate final IWebEntity entity;\n\t\n\tpublic UpdatedWebEntityEvent(IWebEntity entity) {\n\t\tthis.entity = entity;\n\t}\n\t\n\tpublic IWebEntity getEntity() {\n\t\treturn entity;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/forms/IWebForm.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web.forms;\n\nimport java.net.URI;\nimport java.util.Collection;\n\npublic interface IWebForm {\n\tenum FormMethod { METHOD_GET, METHOD_POST };\n\tenum EncType { FORM_URLENCODED, FORM_DATA };\n\t\n\tEncType getEncodingType();\n\tFormMethod getMethod();\n\tURI getAction();\n\tCollection<IWebFormField> getFields();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/model/web/forms/IWebFormField.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.model.web.forms;\n\nimport java.util.Set;\n\n\npublic interface IWebFormField {\n\tpublic enum FieldType { INPUT_TEXT, INPUT_PASSWORD, INPUT_CHECKBOX, INPUT_RADIO, INPUT_HIDDEN, INPUT_FILE, TEXTAREA, SELECT_OPTION };\n\t\n\tFieldType getType();\n\tString getName();\n\tString getValue();\n\tboolean hasMultipleValues();\n\tSet<String> getMultipleValues();\n\tSet<String> getCheckedValues();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/paths/IPathFinder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.paths;\n\nimport java.io.File;\n\npublic interface IPathFinder {\n\tFile getVegaDirectory();\n\tFile getWorkspaceDirectory();\n\tFile getConfigFilePath();\n\tFile getDataDirectory();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IFormCredential.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\n\npublic interface IFormCredential {\n\tvoid setTargetName(String name);\n\tvoid setUsernameFieldName(String name);\n\tvoid setPasswordFieldName(String name);\n\n\tString getUsername();\n\tString getPassword();\n\n\tString getTargetName();\n\tString getUsernameFieldName();\n\tString getPasswordFieldName();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IInjectionModuleContext.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2013 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport java.util.List;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.google.common.net.InternetDomainName;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\n\npublic interface IInjectionModuleContext extends IModuleContext {\n\tint getCurrentIndex();\n\tIPathState getPathState();\n\tint incrementResponseCount();\n\tboolean allResponsesReceived();\n\tvoid addRequestResponse(HttpUriRequest request, IHttpResponse response);\n\tvoid addRequestResponse(int index, HttpUriRequest request, IHttpResponse response);\n\tHttpUriRequest getSavedRequest(int index);\n\tIHttpResponse getSavedResponse(int index);\n\t/* Added below method because of bug #547 */\n\tString getSavedResponseBody(int index);\n\tIPageFingerprint getSavedFingerprint(int index);\n\tboolean isFingerprintMatch(int idx1, int idx2);\n\tboolean isFingerprintMatch(int idx, IPageFingerprint fp);\n\tvoid setModuleFailed();\n\tboolean hasModuleFailed();\n\tvoid submitRequest(HttpUriRequest request, ICrawlerResponseProcessor callback, int index);\n\tvoid submitRequest(HttpUriRequest request, ICrawlerResponseProcessor callback);\n\tvoid submitRequest(ICrawlerResponseProcessor callback, int flag);\n\tvoid submitAlteredRequest(ICrawlerResponseProcessor callback, String value);\n\tvoid submitAlteredRequest(ICrawlerResponseProcessor callback, String value, int flag);\n\tvoid submitAlteredRequest(ICrawlerResponseProcessor callback, String value, boolean append, int flag);\n\tvoid submitAlteredParameterNameRequest(ICrawlerResponseProcessor callback, String name, int flag);\n\tvoid submitMultipleAlteredRequests(ICrawlerResponseProcessor callback, String[] injectables);\n\tvoid submitMultipleAlteredRequests(ICrawlerResponseProcessor callback, String[] injectables, boolean append);\n\t\n\tvoid responseChecks(int idx);\n\tvoid responseChecks(HttpUriRequest request, IHttpResponse response);\n\tvoid contentChecks(HttpUriRequest request, IHttpResponse response);\n\tvoid pivotChecks(HttpUriRequest request, IHttpResponse response);\n\n\tvoid analyzePage(HttpUriRequest request, IHttpResponse response);\n\t\n\tInternetDomainName internetDomainName(String domain);\n\tboolean isValidInternetDomainName(String domain);\n\n\tList<String> getFileExtensionList();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IModuleContext.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IModelProperties;\n\npublic interface IModuleContext extends IModelProperties {\n\tvoid reportRequestException(HttpUriRequest request, Throwable ex);\n\tvoid error(HttpUriRequest request, IHttpResponse response, String message);\n\tvoid debug(String msg);\n\tvoid debug(String msg, Boolean flag);\n\tvoid addStringHighlight(String str);\n\tvoid addRegexHighlight(String regex);\n\tvoid addRegexCaseInsensitiveHighlight(String regex);\n\tvoid reset();\n\tvoid publishAlert(String type, String key, String message, HttpRequest request, IHttpResponse response, Object ...properties);\n\tvoid publishAlert(String type, String message, HttpRequest request, IHttpResponse response, Object ...properties);\n\tboolean alertExists(String key);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IPathState.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\n\npublic interface IPathState {\n\tIPathState getParentState();\n\tboolean isParametric();\n\tboolean doInjectionChecks();\n\tboolean isDone();\n\tvoid setFailed404Detection();\n\tboolean hasFailed404Detection();\n\tboolean has404Fingerprints();\n\tboolean has404FingerprintMatching(IPageFingerprint fp);\n\tboolean hasParent404FingerprintMatchingThis();\n\tboolean hasParent404Fingerprint(IPageFingerprint fp);\n\tvoid clear404Fingerprints();\n\n\tboolean add404Fingerprint(IPageFingerprint fp);\n\tvoid setDone();\n\tIWebPath getPath();\n\tvoid setResponseVaries();\n\tboolean getResponseVaries();\n\tNameValuePair getFuzzableParameter();\n\tIInjectionModuleContext createModuleContext();\n\tvoid setUnknownFingerprint(IPageFingerprint fp);\n\tIPageFingerprint getPathFingerprint();\n\tIPageFingerprint getUnknownFingerprint();\n\tvoid maybeAddParameters(List<NameValuePair> parameters);\n\tvoid maybeAddPostParameters(List<NameValuePair> parameters);\n\n\tint allocateXssId();\n\tString createXssTag(int xssId);\n\tString createXssTag(String prefix, int xssId);\n\tvoid registerXssRequest(HttpUriRequest request, int xssId);\n\tHttpUriRequest getXssRequest(int xssId, int scanId);\n\n\tHttpUriRequest createAlteredRequest(String value, boolean append);\n\tHttpUriRequest createRequest();\n\n\tvoid setResponse(IHttpResponse response);\n\tIHttpResponse getResponse();\n\tvoid unlockChildren();\n\tIPathState get404Parent();\n\tvoid setPageMissing();\n\tboolean matchesPathFingerprint(IPageFingerprint fp);\n\n\tvoid setBogusParameter();\n\tboolean isBogusParameter();\n\tvoid setSureDirectory();\n\tboolean isSureDirectory();\n\tboolean isRootPath();\n\n\tList<IBasicModuleScript> getInjectionModules();\n\tvoid setBadParentDirectory();\n\tboolean hasBadParentDirectory();\n\n\tboolean isIPSDetected();\n\tvoid setIPSDetected();\n\tlong getScanId();\n\tString createXssPattern(String prefix, int xssId);\n\tString createXssPattern(int xssId);\n\n\tIHttpRequestEngine getRequestEngine();\n\t\n\tvoid decrementOutstandingRequests();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IProxyScan.java",
    "content": "package com.subgraph.vega.api.scanner;\n\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\n\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic interface IProxyScan {\n\t/**\n\t * Get the configuration for this scan.\n\t * @return Scan configuration.\n\t */\n\tIScannerConfig getConfig();\n\tvoid reloadModules();\n\tList<IBasicModuleScript> getInjectionModules();\n\tvoid scanGetTarget(VegaURI target, List<NameValuePair> parameters);\n\tvoid scanPostTarget(VegaURI target, List<NameValuePair> parameters);\n\tvoid stop();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IScan.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport java.net.URI;\nimport java.util.List;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\n\npublic interface IScan {\n\t/**\n\t * Get the configuration for this scan.\n\t * @return Scan configuration.\n\t */\n\tIScannerConfig getConfig();\n\n\t/**\n\t * Get a configurable list of modules for this scan. TODO: integrate this with config\n\t * @return Modules for this scan.\n\t */\n\tList<IScannerModule> getModuleList();\n\n\t/**\n\t * Probe a URI for redirects. Runs in the thread this is invoked from.\n\t * @param uri URI to proble.\n\t * @return Probe results.\n\t */\n\tIScanProbeResult probeTargetUri(URI uri);\n\t\n\t/**\n\t * Start the scan of the target specified in the configuration. The scan starts in a new thread.\n\t */\n\tvoid startScan();\n\n\t/**\n\t * Stop the scan.\n\t */\n\tvoid stopScan();\n\t\n\tvoid pauseScan();\n\tvoid unpauseScan();\n\tboolean isPausedScan();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IScanProbeResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport java.net.URI;\n\npublic interface IScanProbeResult {\n\tenum ProbeResultType { PROBE_OK, PROBE_REDIRECT, PROBE_REDIRECT_FAILED, PROBE_CONNECT_FAILED };\n\t\n\tProbeResultType getProbeResultType();\n\tURI getRedirectTarget();\n\tString getFailureMessage();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport org.apache.http.client.CookieStore;\n\nimport com.subgraph.vega.api.model.IWorkspace;\n\npublic interface IScanner {\n\tIScan createScan();\n\tIProxyScan createProxyScan(IWorkspace workspace, CookieStore cookieStore);\n\tvoid runDomTests();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/IScannerConfig.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner;\n\nimport java.util.List;\nimport java.util.Set;\n\nimport org.apache.http.cookie.Cookie;\n\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\n\npublic interface IScannerConfig {\n\tfinal static int DEFAULT_MAX_DESCENDANTS = 8192;\n\tfinal static int DEFAULT_MAX_CHILDREN = 512;\n\tfinal static int DEFAULT_MAX_DEPTH = 16;\n\tfinal static int DEFAULT_MAX_DUPLICATE_PATHS = 3;\n\tfinal static int DEFAULT_MAX_PARAMETER_COUNT = 16;\n\tfinal static int DEFAULT_MAX_REQUEST_PER_SECOND = 25;\n\tfinal static int DEFAULT_MAX_CONNECTIONS = 50;\n\tfinal static int DEFAULT_MAX_RESPONSE_KILOBYTES = 1024;\n\n\tvoid setScanTargetScope(ITargetScope scope);\n\n\t/**\n\t * Set the website identity the scan will be performed as. \n\t * @param scanIdentity Scan identity to perform the scan as, or null.\n\t */\n\tvoid setScanIdentity(IIdentity scanIdentity);\n\t\n\tvoid setUserAgent(String userAgent);\n\tvoid setCookieList(List<Cookie> list);\n//\tvoid setBasicUsername(String username);\n//\tvoid setBasicPassword(String password);\n//\tvoid setBasicRealm(String realm);\n//\tvoid setBasicDomain(String domain);\n//\tvoid setNtlmUsername(String username);\n//\tvoid setNtlmPassword(String password);\n\tvoid setModulesList(List<String> modules);\n\n\tvoid setExcludedParameterNames(Set<String> names);\n\tvoid setLogAllRequests(boolean flag);\n\tvoid setDisplayDebugOutput(boolean flag);\n\tvoid setMaxRequestsPerSecond(int rps);\n\tvoid setMaxDescendants(int value);\n\tvoid setMaxChildren(int value);\n\tvoid setMaxDepth(int value);\n\tvoid setMaxDuplicatePaths(int value);\n\tvoid setMaxParameterCount(int value);\n\tvoid setMaxConnections(int value);\n\tvoid setMaxResponseKilobytes(int kb);\n\t\n\tList<Cookie> getCookieList();\n//\tString getBasicUsername();\n//\tString getBasicPassword();\n//\tString getBasicRealm();\n//\tString getBasicDomain();\n//\tString getNtlmUsername();\n//\tString getNtlmPassword();\n\tITargetScope getScanTargetScope();\n\tString getUserAgent();\n\n\t/**\n\t * Get the identity the scan will be performed as. \n\t * @return Scan identity to perform the scan as, or null if none is set.\n\t */\n\tIIdentity getScanIdentity();\n\t\n\tList<String> getModulesList();\n\t\n\tSet<String> getDefaultExcludedParameterNames();\n\tSet<String> getExcludedParameterNames();\n\n\tIFormCredential createFormCredential(String username, String password) ; // XXX\n\tList<IFormCredential> getFormCredentials(); // XXX\n\tboolean getLogAllRequests();\n\tboolean getDisplayDebugOutput();\n\tboolean getDirectoryInjectionChecksFlag();\n\tboolean getNonParameterFileInjectionChecksFlag();\n\tint getMaxRequestsPerSecond();\n\tint getMaxDescendants();\n\tint getMaxChildren();\n\tint getMaxDepth();\n\tint getMaxDuplicatePaths();\n\tint getMaxParameterCount();\n\tint getMaxConnections();\n\tint getMaxResponseKilobytes();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/LockStatusEvent.java",
    "content": "package com.subgraph.vega.api.scanner;\n\nimport com.subgraph.vega.api.events.IEvent;\n\npublic class LockStatusEvent implements IEvent {\n\tprivate final IScan scan;\n\n\tpublic LockStatusEvent(IScan scan) {\n\t\tthis.scan = scan;\n\t}\n\t\n\tpublic IScan getScan() {\n\t\treturn scan;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/IBasicModuleScript.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic interface IBasicModuleScript extends IScannerModule {\n\tvoid runScript(IPathState pathState);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/IEnableableModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\npublic interface IEnableableModule {\n\tvoid setEnabled(boolean flag);\n\tboolean isEnabled();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/IResponseProcessingModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\nimport org.apache.http.HttpRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\npublic interface IResponseProcessingModule extends IScannerModule {\n\tboolean responseCodeFilter(int code);\n\tboolean mimeTypeFilter(String mimeType);\n\t\n\tvoid processResponse(IScanInstance scanInstance, HttpRequest request, IHttpResponse response, IWorkspace workspace);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/IScannerModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\npublic interface IScannerModule {\n\tString getModuleName();\n\tString getModuleCategoryName();\n\tboolean isEnabled();\n\tboolean isDifferential();\n\tboolean isTimeSensitive();\n\tIScannerModuleRunningTime getRunningTimeProfile();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/IScannerModuleRegistry.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\nimport java.util.List;\n\npublic interface IScannerModuleRegistry {\n\tfinal static int PROXY_SCAN_ID = -1;\n\tvoid runDomTests();\n\tList<IResponseProcessingModule> getResponseProcessingModules();\n\tList<IResponseProcessingModule> updateResponseProcessingModules(List<IResponseProcessingModule> currentModules);\n\t\n\tList<IBasicModuleScript> getBasicModules();\n\tList<IBasicModuleScript> updateBasicModules(List<IBasicModuleScript> currentModules);\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/IScannerModuleRunningTime.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\npublic interface IScannerModuleRunningTime {\n\tvoid reset();\n\tint getInvocationCount();\n\tdouble getAverageTime();\n\tint getTotalTime();\n\tint getWorstTime();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/scanner/modules/ModuleScriptType.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.scanner.modules;\n\npublic enum ModuleScriptType {\n\tRESPONSE_PROCESSOR(\"response-processor\", \"Response Processing Modules\"),\n\tBASIC_MODULE(\"basic\", \"Basic module\"),\n\tDOM_TEST(\"dom-test\", \"DOM testing Modules\");\n\n\tprivate final String name;\n\tprivate final String verboseName;\n\t\n\tprivate ModuleScriptType(String name, String verbose) {\n\t\tthis.name = name;\n\t\tthis.verboseName = verbose;\n\t}\n\t\n\tpublic static ModuleScriptType lookup(String name) {\n\t\tfor(ModuleScriptType type: ModuleScriptType.values()) {\n\t\t\tif(type.name.equals(name))\n\t\t\t\treturn type;\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\tpublic String getVerboseName() {\n\t\treturn verboseName;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/util/UriTools.java",
    "content": "package com.subgraph.vega.api.util;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.HttpHost;\n\npublic class UriTools {\n\tprivate final static String[] schemePrefixes = new String[] {\"http://\", \"https://\"};\n\t\n\n\tpublic static boolean isTextValidURI(String input) {\n\t\treturn getURIFromText(input) != null;\n\t}\n\t\n\tpublic static URI getURIFromText(String input) {\n\t\ttry {\n\t\t\tfinal URI uri = new URI(textToAbsoluteURL(input.trim()));\n\t\t\tif(uri.getHost() == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn uri;\n\t\t} catch (URISyntaxException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tpublic static boolean doesBaseUriContain(URI base, URI uri) {\n\t\t/*\n\t\t * Compare host names to avoid a base scope such as\n\t\t * http://acme.com matching http://acme.computers.net\n\t\t * \n\t\t * Reparse the URIs because only the 'string' field\n\t\t * in the URI class is repopulated when URI objects\n\t\t * are retrieved from database.\n\t\t * \n\t\t * XXX create a class VegaURI which persists correctly\n\t\t * and move this method to that class.\n\t\t */\n\t\tfinal URI parsedBase = URI.create(base.toString());\n\t\tfinal URI parsedURI = URI.create(uri.toString());\n\t\tfinal String baseString = parsedBase.toString();\n\t\treturn parsedBase.getHost().equalsIgnoreCase(parsedURI.getHost()) &&\n\t\t\t\turi.toString().startsWith(baseString);\n\t}\n\n\n\tprivate static String textToAbsoluteURL(String input) {\n\t\tfor(String prefix: schemePrefixes) {\n\t\t\tif(input.toLowerCase().startsWith(prefix)) {\n\t\t\t\treturn input;\n\t\t\t}\n\t\t}\n\t\treturn \"http://\"+ input;\n\t}\n\t\n\tpublic static URI stripQueryFromUri(URI uri) {\n\t\ttry {\n\t\t\treturn new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), null, null);\n\t\t} catch (URISyntaxException e) {\n\t\t\tthrow new IllegalArgumentException(e);\n\t\t}\n\t}\n\t\n\tpublic static URI createUriFromTargetAndLine(HttpHost target, String line) {\n\t\ttry {\n\t\t\treturn new URI(target.getSchemeName().toLowerCase(), null, target.getHostName(), target.getPort(), extractPath(line), extractQuery(line), null);\n\t\t} catch (URISyntaxException e) {\n\t\t\tthrow new IllegalArgumentException(\"Failed to parse URI fields\", e);\n\t\t}\n\t}\n\t\n\tprivate static String extractQuery(String line) {\n\t\tfinal int idx = line.indexOf('?');\n\t\tif(idx == -1) {\n\t\t\treturn null;\n\t\t}\n\t\treturn line.substring(idx + 1);\n\t}\n\t\n\tprivate static String extractPath(String line) {\n\t\tfinal int idx = line.indexOf('?');\n\t\tif(idx == -1) {\n\t\t\treturn line;\n\t\t}\n\t\treturn line.substring(0, idx);\n\t}\n\n\t\n\tprivate static boolean isHex(char c) {\n\t\treturn \"abcdefABCDEF0123456789\".indexOf(c) != -1;\n\t}\n\t\n\t\n\tpublic static String removeUnicodeEscapes(String line) {\n\t\tif(line.indexOf(\"%u\") == -1) {\n\t\t\treturn line;\n\t\t}\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tint idx = 0;\n\t\twhile(idx < line.length()) {\n\t\t\tif(isUnicodeEscape(line, idx)) {\n\t\t\t\tsplitUnicodeEscape(line, idx, sb);\n\t\t\t\tidx += 6;\n\t\t\t} else {\n\t\t\t\tsb.append(line.charAt(idx));\n\t\t\t\tidx += 1;\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static boolean isUnicodeEscape(String line, int idx) {\n\t\tif(idx > (line.length() - 6)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn line.charAt(idx) == '%' &&\n\t\t\t\tline.charAt(idx + 1) == 'u' &&\n\t\t\t\tisHex(line.charAt(idx + 2)) &&\n\t\t\t\tisHex(line.charAt(idx + 3)) &&\n\t\t\t\tisHex(line.charAt(idx + 4)) &&\n\t\t\t\tisHex(line.charAt(idx + 5));\n\t}\n\t\n\tprivate static void splitUnicodeEscape(String line, int idx, StringBuilder sb) {\n\t\tsb.append('%');\n\t\tsb.append(line.charAt(idx + 2));\n\t\tsb.append(line.charAt(idx + 3));\n\t\tsb.append('%');\n\t\tsb.append(line.charAt(idx + 4));\n\t\tsb.append(line.charAt(idx + 5));\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/util/VegaURI.java",
    "content": "package com.subgraph.vega.api.util;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.client.utils.URIUtils;\n\npublic class VegaURI {\n\t\n\tpublic static VegaURI fromHostAndRequest(HttpHost targetHost, HttpRequest request) {\n\t\tfinal String line = request.getRequestLine().getUri();\n\t\treturn new VegaURI(targetHost, lineToPath(line), lineToQuery(line));\n\t}\n\n\tprivate static String lineToPath(String line) {\n\t\tfinal int idx = line.indexOf('?');\n\t\tif(idx == -1) {\n\t\t\treturn line;\n\t\t}\n\t\treturn line.substring(0, idx);\n\t}\n\t\n\tprivate static String lineToQuery(String line) {\n\t\tfinal int idx = line.indexOf('?');\n\t\tif(idx == -1) {\n\t\t\treturn null;\n\t\t}\n\t\treturn line.substring(idx + 1);\n\t}\n\n\tprivate final HttpHost targetHost;\n\tprivate final String path;\n\tprivate final String query;\n\t\n\tpublic VegaURI(HttpHost targetHost, String path, String query) {\n\t\tthis.targetHost = targetHost;\n\t\tthis.path = path;\n\t\tthis.query = query;\n\t}\n\t\n\tpublic HttpHost getTargetHost() {\n\t\treturn targetHost;\n\t}\n\t\n\tpublic String getPath() {\n\t\treturn path;\n\t}\n\t\n\tpublic String getQuery() {\n\t\treturn query;\n\t}\n\n\tpublic URI toURI() {\n\t\ttry {\n\t\t\tfinal URI pathURI = new URI(null, null, null, -1, path, query, null);\n\t\t\treturn URIUtils.rewriteURI(pathURI, targetHost);\n\t\t} catch (URISyntaxException e) {\n\t\t\tthrow new IllegalStateException(\"Failed to convert VegaURI to URI: \"+ toString(), e);\n\t\t}\n\t}\n\n\tpublic VegaURI resolve(String uriLine) {\n\t\tfinal String newPath = lineToPath(uriLine);\n\t\tfinal String newQuery = lineToQuery(uriLine);\n\t\t\n\t\tif(newPath.startsWith(\"/\")) {\n\t\t\treturn new VegaURI(targetHost, newPath, newQuery);\n\t\t} else {\n\t\t\treturn new VegaURI(targetHost, resolvePath(path, newPath, true), newQuery);\n\t\t}\n\t}\n\n\t// -- Normalization, resolution, and relativization --\n\n    // RFC2396 5.2 (6)\n    private static String resolvePath(String base, String child,\n                                      boolean absolute)\n    {\n        int i = base.lastIndexOf('/');\n        int cn = child.length();\n        String path = \"\";\n\n        if (cn == 0) {\n            // 5.2 (6a)\n            if (i >= 0)\n                path = base.substring(0, i + 1);\n        } else {\n            StringBuffer sb = new StringBuffer(base.length() + cn);\n            // 5.2 (6a)\n            if (i >= 0)\n                sb.append(base.substring(0, i + 1));\n            // 5.2 (6b)\n            sb.append(child);\n            path = sb.toString();\n        }\n\n        // 5.2 (6c-f)\n        String np = normalize(path);\n\n        // 5.2 (6g): If the result is absolute but the path begins with \"../\",\n        // then we simply leave the path as-is\n\n        return np;\n    }\n    \n      // Normalize the given path string.  A normal path string has no empty\n    // segments (i.e., occurrences of \"//\"), no segments equal to \".\", and no\n    // segments equal to \"..\" that are preceded by a segment not equal to \"..\".\n    // In contrast to Unix-style pathname normalization, for URI paths we\n    // always retain trailing slashes.\n    //\n    private static String normalize(String ps) {\n\n        // Does this path need normalization?\n        int ns = needsNormalization(ps);        // Number of segments\n        if (ns < 0)\n            // Nope -- just return it\n            return ps;\n\n        char[] path = ps.toCharArray();         // Path in char-array form\n\n        // Split path into segments\n        int[] segs = new int[ns];               // Segment-index array\n        split(path, segs);\n\n        // Remove dots\n        removeDots(path, segs);\n\n        // Prevent scheme-name confusion\n        maybeAddLeadingDot(path, segs);\n\n        // Join the remaining segments and return the result\n        String s = new String(path, 0, join(path, segs));\n        if (s.equals(ps)) {\n            // string was already normalized\n            return ps;\n        }\n        return s;\n    }\n    \n    // -- Path normalization --\n\n    // The following algorithm for path normalization avoids the creation of a\n    // string object for each segment, as well as the use of a string buffer to\n    // compute the final result, by using a single char array and editing it in\n    // place.  The array is first split into segments, replacing each slash\n    // with '\\0' and creating a segment-index array, each element of which is\n    // the index of the first char in the corresponding segment.  We then walk\n    // through both arrays, removing \".\", \"..\", and other segments as necessary\n    // by setting their entries in the index array to -1.  Finally, the two\n    // arrays are used to rejoin the segments and compute the final result.\n    //\n    // This code is based upon src/solaris/native/java/io/canonicalize_md.c\n\n\n    // Check the given path to see if it might need normalization.  A path\n    // might need normalization if it contains duplicate slashes, a \".\"\n    // segment, or a \"..\" segment.  Return -1 if no further normalization is\n    // possible, otherwise return the number of segments found.\n    //\n    // This method takes a string argument rather than a char array so that\n    // this test can be performed without invoking path.toCharArray().\n    //\n    static private int needsNormalization(String path) {\n        boolean normal = true;\n        int ns = 0;                     // Number of segments\n        int end = path.length() - 1;    // Index of last char in path\n        int p = 0;                      // Index of next char in path\n\n        // Skip initial slashes\n        while (p <= end) {\n            if (path.charAt(p) != '/') break;\n            p++;\n        }\n        if (p > 1) normal = false;\n\n        // Scan segments\n        while (p <= end) {\n\n            // Looking at \".\" or \"..\" ?\n            if ((path.charAt(p) == '.')\n                && ((p == end)\n                    || ((path.charAt(p + 1) == '/')\n                        || ((path.charAt(p + 1) == '.')\n                            && ((p + 1 == end)\n                                || (path.charAt(p + 2) == '/')))))) {\n                normal = false;\n            }\n            ns++;\n\n            // Find beginning of next segment\n            while (p <= end) {\n                if (path.charAt(p++) != '/')\n                    continue;\n\n                // Skip redundant slashes\n                while (p <= end) {\n                    if (path.charAt(p) != '/') break;\n                    normal = false;\n                    p++;\n                }\n\n                break;\n            }\n        }\n\n        return normal ? -1 : ns;\n    }\n\n\n    // Split the given path into segments, replacing slashes with nulls and\n    // filling in the given segment-index array.\n    //\n    // Preconditions:\n    //   segs.length == Number of segments in path\n    //\n    // Postconditions:\n    //   All slashes in path replaced by '\\0'\n    //   segs[i] == Index of first char in segment i (0 <= i < segs.length)\n    //\n    static private void split(char[] path, int[] segs) {\n        int end = path.length - 1;      // Index of last char in path\n        int p = 0;                      // Index of next char in path\n        int i = 0;                      // Index of current segment\n\n        // Skip initial slashes\n        while (p <= end) {\n            if (path[p] != '/') break;\n            path[p] = '\\0';\n            p++;\n        }\n\n        while (p <= end) {\n\n            // Note start of segment\n            segs[i++] = p++;\n\n            // Find beginning of next segment\n            while (p <= end) {\n                if (path[p++] != '/')\n                    continue;\n                path[p - 1] = '\\0';\n\n                // Skip redundant slashes\n                while (p <= end) {\n                    if (path[p] != '/') break;\n                    path[p++] = '\\0';\n                }\n                break;\n            }\n        }\n\n        if (i != segs.length)\n            throw new InternalError();  // ASSERT\n    }\n\n\n    // Join the segments in the given path according to the given segment-index\n    // array, ignoring those segments whose index entries have been set to -1,\n    // and inserting slashes as needed.  Return the length of the resulting\n    // path.\n    //\n    // Preconditions:\n    //   segs[i] == -1 implies segment i is to be ignored\n    //   path computed by split, as above, with '\\0' having replaced '/'\n    //\n    // Postconditions:\n    //   path[0] .. path[return value] == Resulting path\n    //\n    static private int join(char[] path, int[] segs) {\n        int ns = segs.length;           // Number of segments\n        int end = path.length - 1;      // Index of last char in path\n        int p = 0;                      // Index of next path char to write\n\n        if (path[p] == '\\0') {\n            // Restore initial slash for absolute paths\n            path[p++] = '/';\n        }\n\n        for (int i = 0; i < ns; i++) {\n            int q = segs[i];            // Current segment\n            if (q == -1)\n                // Ignore this segment\n                continue;\n\n            if (p == q) {\n                // We're already at this segment, so just skip to its end\n                while ((p <= end) && (path[p] != '\\0'))\n                    p++;\n                if (p <= end) {\n                    // Preserve trailing slash\n                    path[p++] = '/';\n                }\n            } else if (p < q) {\n                // Copy q down to p\n                while ((q <= end) && (path[q] != '\\0'))\n                    path[p++] = path[q++];\n                if (q <= end) {\n                    // Preserve trailing slash\n                    path[p++] = '/';\n                }\n            } else\n                throw new InternalError(); // ASSERT false\n        }\n\n        return p;\n    }\n\n\n    // Remove \".\" segments from the given path, and remove segment pairs\n    // consisting of a non-\"..\" segment followed by a \"..\" segment.\n    //\n    private static void removeDots(char[] path, int[] segs) {\n        int ns = segs.length;\n        int end = path.length - 1;\n\n        for (int i = 0; i < ns; i++) {\n            int dots = 0;               // Number of dots found (0, 1, or 2)\n\n            // Find next occurrence of \".\" or \"..\"\n            do {\n                int p = segs[i];\n                if (path[p] == '.') {\n                    if (p == end) {\n                        dots = 1;\n                        break;\n                    } else if (path[p + 1] == '\\0') {\n                        dots = 1;\n                        break;\n                    } else if ((path[p + 1] == '.')\n                               && ((p + 1 == end)\n                                   || (path[p + 2] == '\\0'))) {\n                        dots = 2;\n                        break;\n                    }\n                }\n                i++;\n            } while (i < ns);\n            if ((i > ns) || (dots == 0))\n                break;\n\n            if (dots == 1) {\n                // Remove this occurrence of \".\"\n                segs[i] = -1;\n            } else {\n                // If there is a preceding non-\"..\" segment, remove both that\n                // segment and this occurrence of \"..\"; otherwise, leave this\n                // \"..\" segment as-is.\n                int j;\n                for (j = i - 1; j >= 0; j--) {\n                    if (segs[j] != -1) break;\n                }\n                if (j >= 0) {\n                    int q = segs[j];\n                    if (!((path[q] == '.')\n                          && (path[q + 1] == '.')\n                          && (path[q + 2] == '\\0'))) {\n                        segs[i] = -1;\n                        segs[j] = -1;\n                    }\n                }\n            }\n        }\n    }\n\n\n    // DEVIATION: If the normalized path is relative, and if the first\n    // segment could be parsed as a scheme name, then prepend a \".\" segment\n    //\n    private static void maybeAddLeadingDot(char[] path, int[] segs) {\n\n        if (path[0] == '\\0')\n            // The path is absolute\n            return;\n\n        int ns = segs.length;\n        int f = 0;                      // Index of first segment\n        while (f < ns) {\n            if (segs[f] >= 0)\n                break;\n            f++;\n        }\n        if ((f >= ns) || (f == 0))\n            // The path is empty, or else the original first segment survived,\n            // in which case we already know that no leading \".\" is needed\n            return;\n\n        int p = segs[f];\n        while ((p < path.length) && (path[p] != ':') && (path[p] != '\\0')) p++;\n        if (p >= path.length || path[p] == '\\0')\n            // No colon in first segment, so no \".\" needed\n            return;\n\n        // At this point we know that the first segment is unused,\n        // hence we can insert a \".\" segment at that position\n        path[0] = '.';\n        path[1] = '\\0';\n        segs[0] = 0;\n    }\n\n\n\t@Override\n\tpublic String toString() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tsb.append(targetHost.toURI());\n\t\tif(!path.startsWith(\"/\")) {\n\t\t\tsb.append(\"/\");\n\t\t}\n\t\tsb.append(path);\n\t\tif(query != null) {\n\t\t\tsb.append(\"?\");\n\t\t\tsb.append(query);\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\t@Override\n\tpublic int hashCode() {\n\t\tfinal int prime = 31;\n\t\tint result = 1;\n\t\tresult = prime * result + ((path == null) ? 0 : path.hashCode());\n\t\tresult = prime * result + ((query == null) ? 0 : query.hashCode());\n\t\tresult = prime * result\n\t\t\t\t+ ((targetHost == null) ? 0 : targetHost.hashCode());\n\t\treturn result;\n\t}\n\n\t@Override\n\tpublic boolean equals(Object obj) {\n\t\tif (this == obj)\n\t\t\treturn true;\n\t\tif (obj == null)\n\t\t\treturn false;\n\t\tif (getClass() != obj.getClass())\n\t\t\treturn false;\n\t\tVegaURI other = (VegaURI) obj;\n\t\tif (path == null) {\n\t\t\tif (other.path != null)\n\t\t\t\treturn false;\n\t\t} else if (!path.equals(other.path))\n\t\t\treturn false;\n\t\tif (query == null) {\n\t\t\tif (other.query != null)\n\t\t\t\treturn false;\n\t\t} else if (!query.equals(other.query))\n\t\t\treturn false;\n\t\tif (targetHost == null) {\n\t\t\tif (other.targetHost != null)\n\t\t\t\treturn false;\n\t\t} else if (!targetHost.equals(other.targetHost))\n\t\t\treturn false;\n\t\treturn true;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/vuge/IConstants.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.vuge;\n\npublic interface IConstants {\n\t/**\n\t * Major version number.\n\t */\n\tstatic final int VERSION_MAJOR = 1;\n\t\n\t/**\n\t * Minor version number.\n\t */\n\tstatic final int VERSION_MINOR = 0;\n\n\t/**\n\t * Version string.\n\t */\n\tstatic final String VERSION_STRING = \"1.0\";\n\t\n\t/**\n\t * Build number (injected by Ant/Hudson)\n\t */\n\tstatic final int BUILD_NUMBER = 0x00000000;\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.api/src/com/subgraph/vega/api/xml/IXmlRepository.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.xml;\n\nimport org.w3c.dom.Document;\n\npublic interface IXmlRepository {\n\tDocument getDocument(String path);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.application</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Application\nBundle-SymbolicName: com.subgraph.vega.application; singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.application.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nImport-Package: com.subgraph.vega.api.console,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.vuge,\n com.subgraph.vega.ui.http,\n com.subgraph.vega.ui.util.images,\n com.subgraph.vega.ui.util.preferences,\n org.apache.http;version=\"4.1.0\",\n org.apache.http.client.methods;version=\"4.2.2\",\n org.eclipse.ui.console,\n org.eclipse.ui.internal.console\nExport-Package: com.subgraph.vega.ui.util\nService-Component: OSGI-INF/path-finder.xml, OSGI-INF/console.xml\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/OSGI-INF/console.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.console\">\n   <implementation class=\"com.subgraph.vega.internal.console.ConsoleService\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.console.IConsole\"/>\n   </service>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/OSGI-INF/path-finder.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.path-finder\">\n   <implementation class=\"com.subgraph.vega.internal.paths.PathFinder\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.paths.IPathFinder\"/>\n   </service>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/build.properties",
    "content": "output.. = bin/\nbin.includes = plugin.xml,\\\n               META-INF/,\\\n               .,\\\n               icons/,\\\n               splash.bmp,\\\n               plugin_customization.ini,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/extra-bundles/README",
    "content": "Google Guava OSGi\nhttps://code.google.com/a/eclipselabs.org/p/guava-bundle/\n\ncommons-lang is needed by jsoup\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/icons/Vega.xpm",
    "content": "/* XPM */\nstatic char *vega________[] = {\n/* columns rows colors chars-per-pixel */\n\"256 256 256 2\",\n\"   c #270D0D\",\n\".  c #3D0C0B\",\n\"X  c #350908\",\n\"o  c #3C110E\",\n\"O  c #290F10\",\n\"+  c #270E10\",\n\"@  c #2E1312\",\n\"#  c #341313\",\n\"$  c #3B1413\",\n\"%  c #3D1917\",\n\"&  c #3A0F10\",\n\"*  c #440D0B\",\n\"=  c #4D0B09\",\n\"-  c #470906\",\n\";  c #5A0C0A\",\n\":  c #540A08\",\n\">  c #45110D\",\n\",  c #58110F\",\n\"<  c #431512\",\n\"1  c #4B1613\",\n\"2  c #441916\",\n\"3  c #4B1A16\",\n\"4  c #441B18\",\n\"5  c #4C1D1A\",\n\"6  c #531613\",\n\"7  c #5B1614\",\n\"8  c #541A16\",\n\"9  c #5B1917\",\n\"0  c #531D1A\",\n\"q  c #5C1B19\",\n\"w  c #5F0E10\",\n\"e  c #640C0C\",\n\"r  c #6C0B0B\",\n\"t  c #670506\",\n\"y  c #740B0C\",\n\"u  c #7C0B0D\",\n\"i  c #770608\",\n\"p  c #6D0F11\",\n\"a  c #660F11\",\n\"s  c #730F11\",\n\"d  c #7D0E10\",\n\"f  c #641615\",\n\"g  c #6C1616\",\n\"h  c #641916\",\n\"j  c #6C1816\",\n\"k  c #631B1A\",\n\"l  c #6C1B1A\",\n\"z  c #671719\",\n\"x  c #731616\",\n\"c  c #7A1516\",\n\"v  c #741817\",\n\"b  c #771718\",\n\"n  c #7C1718\",\n\"m  c #741B1A\",\n\"M  c #7C191A\",\n\"N  c #7A1816\",\n\"B  c #62110E\",\n\"V  c #56201C\",\n\"C  c #5B211C\",\n\"Z  c #63221D\",\n\"A  c #6C221D\",\n\"S  c #74231E\",\n\"D  c #7B221E\",\n\"F  c #742220\",\n\"G  c #7C2321\",\n\"H  c #742A26\",\n\"J  c #70302E\",\n\"K  c #622122\",\n\"L  c #754645\",\n\"P  c #713F40\",\n\"I  c #830A0D\",\n\"U  c #8B0B0E\",\n\"Y  c #80070B\",\n\"T  c #930C0F\",\n\"R  c #840F11\",\n\"E  c #8C0D11\",\n\"W  c #940E11\",\n\"Q  c #9A0E12\",\n\"!  c #821416\",\n\"~  c #8B1215\",\n\"^  c #831719\",\n\"/  c #89171A\",\n\"(  c #84191B\",\n\")  c #8C191B\",\n\"_  c #891817\",\n\"`  c #931215\",\n\"'  c #9C1215\",\n\"]  c #941619\",\n\"[  c #941A1D\",\n\"{  c #9B1C1F\",\n\"}  c #9B1619\",\n\"|  c #8E100F\",\n\" . c #A50F13\",\n\".. c #A21215\",\n\"X. c #AB1216\",\n\"o. c #A31619\",\n\"O. c #AB161A\",\n\"+. c #A11C1F\",\n\"@. c #AC1B1E\",\n\"#. c #B3161A\",\n\"$. c #BB151A\",\n\"%. c #B41A1C\",\n\"&. c #BD1A1D\",\n\"*. c #B51216\",\n\"=. c #84221F\",\n\"-. c #8C211F\",\n\";. c #93211F\",\n\":. c #9A201F\",\n\">. c #8B1E20\",\n\",. c #851F20\",\n\"<. c #951E20\",\n\"1. c #9D1D20\",\n\"2. c #A41E21\",\n\"3. c #AB1F22\",\n\"4. c #B21F23\",\n\"5. c #BA1E24\",\n\"6. c #842321\",\n\"7. c #8B2322\",\n\"8. c #872A2B\",\n\"9. c #932222\",\n\"0. c #9C2223\",\n\"q. c #98292C\",\n\"w. c #993738\",\n\"e. c #8C3334\",\n\"r. c #A42223\",\n\"t. c #AC2023\",\n\"y. c #A8282C\",\n\"u. c #B42023\",\n\"i. c #BB2225\",\n\"p. c #B9272A\",\n\"a. c #A92D31\",\n\"s. c #B42E32\",\n\"d. c #BA2E33\",\n\"f. c #A83739\",\n\"g. c #B83539\",\n\"h. c #C21B1E\",\n\"j. c #CB181B\",\n\"k. c #D61A1D\",\n\"l. c #C31F24\",\n\"z. c #CA1E22\",\n\"x. c #D71D22\",\n\"c. c #C32326\",\n\"v. c #CB2527\",\n\"b. c #CB2827\",\n\"n. c #C52528\",\n\"m. c #CD2628\",\n\"M. c #C52929\",\n\"N. c #CC2A2A\",\n\"B. c #D22327\",\n\"V. c #DC2227\",\n\"C. c #D32927\",\n\"Z. c #DB2926\",\n\"A. c #D32628\",\n\"S. c #DB2629\",\n\"D. c #D42C2D\",\n\"F. c #DB2A2A\",\n\"G. c #D6302E\",\n\"H. c #D9312F\",\n\"J. c #D92E31\",\n\"K. c #D02D30\",\n\"L. c #C93031\",\n\"P. c #C53539\",\n\"I. c #DD3334\",\n\"U. c #D43135\",\n\"Y. c #C72E32\",\n\"T. c #E1282A\",\n\"R. c #E12827\",\n\"E. c #E33B3C\",\n\"W. c #E03737\",\n\"Q. c #B43E42\",\n\"!. c #A93E41\",\n\"~. c #C63D42\",\n\"^. c #E63F40\",\n\"/. c #924B4B\",\n\"(. c #A94548\",\n\"). c #B74649\",\n\"_. c #BA4E51\",\n\"`. c #BE575B\",\n\"'. c #B75557\",\n\"]. c #AA5254\",\n\"[. c #BC5D60\",\n\"{. c #B96768\",\n\"}. c #B97576\",\n\"|. c #AA6E6F\",\n\" X c #976362\",\n\".X c #CB464A\",\n\"XX c #C74549\",\n\"oX c #C74E52\",\n\"OX c #CC5154\",\n\"+X c #C5575B\",\n\"@X c #D55054\",\n\"#X c #E74040\",\n\"$X c #C65E61\",\n\"%X c #D35D61\",\n\"&X c #CB666A\",\n\"*X c #C76669\",\n\"=X c #D4686C\",\n\"-X c #CA6E71\",\n\";X c #D66D71\",\n\":X c #C97679\",\n\">X c #D5767A\",\n\",X c #89413E\",\n\"<X c #BC817F\",\n\"1X c #D77E81\",\n\"2X c #C77F80\",\n\"3X c #BB8C8C\",\n\"4X c #CD8183\",\n\"5X c #C7898A\",\n\"6X c #DB8A8D\",\n\"7X c #D68587\",\n\"8X c #D98E91\",\n\"9X c #D39496\",\n\"0X c #DD9194\",\n\"qX c #DC9B9D\",\n\"wX c #D8999B\",\n\"eX c #C59596\",\n\"rX c #E29C9E\",\n\"tX c #E29699\",\n\"yX c #E48D8F\",\n\"uX c #DA9FA0\",\n\"iX c #E29EA1\",\n\"pX c #DBA5A7\",\n\"aX c #DBB7B7\",\n\"sX c #CBADAC\",\n\"dX c #E4A3A5\",\n\"fX c #E6AAAC\",\n\"gX c #E7A8AB\",\n\"hX c #E7AFB1\",\n\"jX c #EAB3B5\",\n\"kX c #ECBABC\",\n\"lX c #E6B6B7\",\n\"zX c #F2B9BC\",\n\"xX c #ECBEC0\",\n\"cX c #F0BFC1\",\n\"vX c #EEC4C6\",\n\"bX c #ECC8C9\",\n\"nX c #F2CBCC\",\n\"mX c #F2C5C7\",\n\"MX c #F3CFD0\",\n\"NX c #ECD2D3\",\n\"BX c #F3D1D3\",\n\"VX c #F5DBDC\",\n\"CX c #F9DBDC\",\n\"ZX c #F7D6D7\",\n\"AX c #EFCFD0\",\n\"SX c #FADFE0\",\n\"DX c #F6E4E4\",\n\"FX c #FBE3E4\",\n\"GX c #FCECEC\",\n\"HX c #FBE8E9\",\n\"JX c #FDEFF0\",\n\"KX c #FEF3F3\",\n\"LX c #FFFFFF\",\n\"PX c #FEF7F8\",\n\"IX c #EDE2E2\",\n\"UX c None\",\n/* pixels */\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXg g g x x x x x b b c c c c c c c c c c c c c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf g g x x b c n n n ^ ^ ^ ^ ^ ( ( ( ( ( ( ( / / / / / / ( ^ ^ ^ ^ ^ n n n c c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf f g x x b n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( / / / / / / / / / / ) ) ) ) ) ) / / ^ ^ ! n n ! UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf f g x b n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( / / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) / ^ ^ ! ! UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f g x b n n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ ) ) / ^ ! ! UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf g x b b N N b n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ ) ) / ^ ! UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f g x b b b b b c b n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ) ) / ^ ^ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f g x b b b b b b b N b n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ^ / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ) / ^ ^ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f g x x x x x b b b b c N n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ ( / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ) / ^ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f g x x x x x x b b b b c n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ ^ / / / / / ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ) / ^ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f g x x x x x x x b b b b b n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ^ ^ / / / / / / ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ / ^ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 7 g x x x x x x x x x b b b b b n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { [ [ [ [ [ [ [ [ [ [ [ [ ) / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f g j x x x x x x x x b b b b b b n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ( ( ^ ^ / / / / / / ) ) / ) ) [ [ [ { 1.1.r.r.t.t.u.p.p.p.M.p.{ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { [ [ { { [ [ / / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f g g j g x x x x x x x x b b b b b n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ^ ^ / / / / / ) ) / ) p.N.N.N.D.D.G.G.H.H.H.H.H.H.H.H.H.H.D.M.r.[ [ [ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { [ [ / / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f g j g j g x x x x x x x b b b b b c n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ( ^ ( / / / / / / ) ) / ) p.H.H.H.H.G.G.G.G.G.G.G.G.G.G.G.G.G.G.N.M.M.t.{ [ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { [ ) / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 7 g g g g g j x x x x x x x b b b b b c n n n n n n n n n ^ ^ ^ ^ ^ ( ( ( ^ ^ / / / / / ) ) ) / [ p.N.N.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.G.N.M.p.p.u.1.{ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { [ / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f g g g g j j x x x x x x x b b b b b c N n n n n n n n n ^ ^ ^ ^ ^ ( ( ^ ^ ^ / / / / / ) ) ) ) { p.p.M.N.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.M.p.p.p.u.u.2.{ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { [ ) / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f g g g g g j j g x x x x x x x b b b b N N n n n n n n n n ^ ^ ^ ^ ^ ( ( ^ ^ / / / / / / ) ) ) ) { t.u.p.p.M.N.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.D.M.p.p.u.u.t.t.2.{ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { [ ) / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f g g g g g g g j g x x x x x x x b b b b N N n n n n n n n ^ ^ ^ ^ ^ ^ ( ^ ^ ^ / / / / / / ) ) ) ) { r.r.t.u.p.p.M.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.p.p.p.u.t.t.3.3.2.2.{ { { { { { { { { { { +.+.2.2.2.2.2.2.2.2.2.+.+.{ { { { { { { { { { { { { { { { { { { { { [ ) / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 f g g g g g g g j g x x x x x x x x b b b N N n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / ) ) ) ) [ [ { r.r.t.u.p.M.v.v.v.v.v.v.v.v.v.v.v.v.v.v.m.n.p.u.u.u.t.3.2.2.3.2.{ { 2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.+.+.+.+.{ { { { { { { { { { { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f f f g g g g g g j g x x x x x x x x b b b N N n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / ) ) ) ) ) ) [ { 1.r.r.t.p.p.n.n.n.n.n.n.n.n.n.n.n.n.n.n.v.c.p.u.u.t.3.2.2.2.2.1.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.+.{ { { { { { { { { { { { { { [ / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 f f f f g g g g g j g x x x x x x x x b b b N N n n n n n n n ^ ^ ^ ^ ^ ^ ( ^ ^ ^ / / / / / / ) ) ) ) ) ) ) ) [ { 1.r.t.t.p.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.i.u.u.t.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { { { { { { [ ) / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f f f f f g g g g g j j x x x x x x x v x b b b N n n n n n n n ^ ^ ^ ^ ^ ( ( ^ ^ ^ / / / / / / ) ) ) ) ) [ [ [ ) ) [ { 1.r.t.u.i.l.l.l.l.l.l.l.l.l.l.l.l.l.l.i.u.t.3.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.{ { { { { { { { { { { { [ / UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 f f f f f f g g g g g j g x x x x x x v v b b b N N n n n n n n ^ ^ ^ ^ ^ ( ^ ^ ^ ^ / / / / / / ) ) ) ) ) [ [ [ [ [ ) ) [ { r.r.t.%.h.&.&.&.&.&.&.&.&.&.&.&.&.&.%.t.t.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.{ { { { { { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 7 f f f f f f g g g g g j g x x x x x x x v b b b b b b n M ^ ^ ^ ^ n n n ^ ^ ^ ^ ( ( / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ ) ) [ 1.{ u.dXnXvXvXvXvXvXvXvXvXvXvXvXvXnX>XO.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 f f f f f f f g g g g g j g x x x x x x x x x b n ^ / ) [ [ [ ) ) / ( n n b ^ ^ ^ ( ( / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ / ) ] o.hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX).o.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.{ { { 2.2.2.3.3.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 f f f f f f f g g g g g g g g x x x g x n ( [ { 2.2.2.2.2.1.{ [ ) ) ( ( n n b c ^ ( ( / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ ) / } iXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjXO.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.{ 1.2.2.2.2.t.t.t.u.u.u.t.t.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { { { [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 f f f f f f f f f g g g g g g g x x g b 3.4.5.i.i.4.4.3.2.2.1.1.[ [ ) ) ( ( n n c x n ( / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { [ E &XLXKXJXJXJXJXJXJXJXJXJXJXJXJXJXJXJXKXPX=Xo.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.t.t.t.t.t.2.1.1.2.2.3.t.t.t.u.u.u.i.i.i.i.i.i.i.u.t.3.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 7 f f f f f f f f g g g g g g g g x x x 3.v.c.i.i.u.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x ^ / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { +.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.s.d.d.d.3.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.t.t.t.t.t.t.t.t.2.{ 1.2.2.2.t.t.t.u.u.u.p.i.i.i.n.M.b.N.N.N.C.u.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 f f f f f f f f f f g g g g g g x x x g [ v.c.c.i.i.u.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x n / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { } } } } } } } } } } } +.+.+.+.+.+.+.+.+.2.2.3.3.3.3.3.3.3.3.3.t.t.t.t.t.t.t.t.t.t.t.t.t.t.2.1.2.2.2.t.t.t.u.u.u.p.i.i.i.n.M.M.N.N.N.D.S.A.3.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 f f f f f f f f f g g g g g g g x x x g ) c.c.c.c.c.i.u.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x x / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { 1.1.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.2.1.2.2.2.t.t.t.u.u.u.p.i.i.i.n.M.M.N.N.N.D.S.S.F.m.3.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 f f f f f f f f f g g g g g g g g x x g ^ c.c.c.c.c.c.i.u.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x g ^ ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { { 1.1.1.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.3.t.t.u.u.u.p.i.i.i.n.M.M.N.N.N.D.S.S.S.S.F.m.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 f f f f f f f f f g g g g g g g x x g b 4.i.c.c.c.c.c.c.u.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x g x ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { { 1.1.1.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.t.u.3.2.2.2.3.t.t.u.u.u.p.i.i.i.n.M.M.b.N.N.D.F.V.S.S.S.F.F.n.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 f f f f f f f f g g g g g g g g x j x 2.i.i.i.c.c.c.c.c.i.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x g a n ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { { 1.1.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.u.u.u.u.u.u.u.2.2.2.3.t.t.u.u.u.u.i.i.i.n.M.M.b.N.N.D.D.V.V.S.S.S.F.F.F.i.2.3.2.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 f f f f f f f f f g g g g g g g g x g { 4.4.u.u.i.i.c.c.c.c.4.3.3.2.2.1.1.[ [ ) ) ( ( n n c x x g f g ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.u.u.u.u.u.u.u.u.u.3.2.2.3.t.t.t.u.u.u.i.i.i.c.n.M.b.N.N.D.D.V.V.V.S.S.S.F.F.F.F.u.2.3.3.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 7 f f f f f f f f g g g g g g g g g g ) 3.3.3.4.u.i.i.i.c.c.c.c.3.3.2.2.1.1.[ [ ) ) ( ^ c s y r t t t ; ! [ [ [ [ [ [ [ [ [ { { { { { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.u.u.u.u.u.u.u.u.u.u.u.2.2.3.t.t.t.u.u.u.i.i.i.i.n.M.M.N.N.D.D.S.V.V.V.S.S.S.F.F.F.F.D.u.3.3.3.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 7 7 f f f f f f f f g g g g g g g g g ( 2.2.2.3.3.4.u.u.i.i.c.c.c.5.3.2.+.} ] ` E E E ~ ) q.w.(.].|.|.3X:X2.] [ [ [ [ [ [ [ { { { { { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.o...O.@.@.4.u.u.i.i.i.c.n.M.b.N.N.D.D.D.V.V.V.V.S.S.S.F.F.F.F.F.N.t.t.t.3.3.2.2.2.2.2.2.2.2.2.2.2.{ { { { { { { ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 7 7 7 7 7 f f f f f f f f f g g g g g g g g b { 1.1.2.2.3.3.3.4.u.u.i.i.c.c.#.3.y.g._.$X:X8XdXkXZXHXPXLXLXLXLXLX=X` ) [ [ [ [ [ [ [ { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.4.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.5.>X>X+XXXg.p.5.%.#.#.&.&.c.c.b.N.D.D.D.V.R.V.V.V.S.S.S.F.F.F.F.F.F.b.3.t.t.t.3.2.2.2.2.2.2.2.2.2.2.2.+.{ { { { { { ] UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 7 7 7 7 7 7 f f f f f f f f g g g g g g g g x ) [ { 1.1.2.2.3.3.3.4.u.u.i.i.$.=XZXFXKXLXLXLXLXLXLXLXLXLXLXLXLXLXtXW ) [ [ [ [ [ [ [ { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.4.4.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.%.;XLXLXLXKXDXMXkXrX7X;X+XXXP.n.5.&.h.k.R.V.V.V.V.S.S.S.F.F.F.F.F.D.F.n.3.3.t.t.3.2.2.2.2.2.2.2.2.2.2.2.{ { { { { { { ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g g ( ) [ [ { 1.1.2.2.3.3.3.4.u.u.*.+XPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZXt.~ [ [ [ [ [ [ [ { { { { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.4.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.*.jXLXLXLXLXLXLXLXLXLXLXLXKXVXbXjXiXOXk.R.V.V.V.S.S.S.F.F.F.F.F.D.D.D.i.3.3.t.t.3.3.2.2.2.2.2.2.2.2.2.2.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g n / / ) [ [ { 1.1.2.2.2.3.3.4.O.XXGXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX-XU [ [ [ [ [ [ [ { { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.%.XXKXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKX@Xk.V.V.V.S.S.S.F.F.F.F.F.D.D.D.D.u.3.3.t.t.3.3.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g x n ( ( / ) ) [ [ 1.1.2.2.2.3.O.p.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkX} ) [ [ [ [ [ [ [ { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.*.1XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXDXK.k.V.V.S.S.S.F.F.F.F.F.D.D.D.D.D.u.t.3.3.t.3.3.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x c n ^ ( / ) ) [ [ { 1.1.2.o.t.hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXCXs.~ [ [ [ [ [ [ [ { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.4.4.4.u.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.i.i.5.&.hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXlXA.x.V.S.S.S.F.F.F.F.F.D.D.D.D.H.M.3.t.3.3.t.t.3.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 7 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x c n n ( ( / ) ) [ { 1.} +.lXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX).E [ [ [ [ [ [ [ { { { { { { { { { { +.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.5.i.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkXv.x.S.S.S.F.F.F.F.F.D.D.D.D.D.u.t.t.t.3.3.t.t.3.2.2.2.2.2.2.2.2.2.+.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 7 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x c n n ( ( / ) ) [ [ ' pXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX7XT ) [ [ [ [ [ [ [ { { { { { { { { { +.2.2.2.2.2.2.3.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.m.v.m.v.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.$.OXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXfXj.V.S.S.F.F.F.F.F.D.D.D.H.n.3.t.t.t.t.3.3.t.3.3.2.2.2.2.2.2.2.2.2.{ { { { { { { [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 6 6 7 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g x x x x x x c n n ( ( / ) ) E 8XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXvXo./ [ [ [ [ [ [ [ { { { { { { { { { +.2.2.2.2.2.2.2.c.Z.R.R.R.R.R.R.R.R.R.R.R.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.R.A.i.u.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.$.6XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX0Xj.V.F.F.F.F.F.F.D.D.F.D.u.u.t.t.t.t.t.t.3.t.3.3.2.2.2.2.2.2.2.2.+.{ { { { { { { [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x x x c n n ^ ( / I :XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXJXg.~ [ [ [ [ [ [ [ [ { { { { { { { { +.+.2.2.2.2.2.2.5.c.C.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.v.5.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.5.5.vXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX1Xk.S.F.F.F.F.F.D.D.D.i.3.u.u.t.t.t.t.t.t.t.t.3.3.2.2.2.2.2.2.2.2.+.1.{ { { { { { ] UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 6 6 7 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x x x x b c n ^ u [.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>XT ) [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.3.c.l.B.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.c.5.4.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.c.c.c.&.XXKXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX=Xk.F.F.F.F.F.D.F.N.u.u.u.u.u.t.t.t.t.t.t.t.t.3.2.2.2.2.2.2.2.2.2.{ { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x v v x x x b c y (.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX' ) [ [ [ [ [ [ [ { { { { { { { { { +.2.2.2.2.2.2.3.c.c.l.v.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.c.5.4.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.$.7XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKX@Xk.F.F.F.F.F.D.i.u.u.u.u.u.u.t.t.t.t.t.t.t.t.3.2.2.2.2.2.2.2.2.+.{ { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x v v b g g x r w.DXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXf.~ [ [ [ [ [ [ [ { { { { { { { { { +.2.2.2.2.2.2.2.5.c.c.c.v.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.i.5.4.4.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.vXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXDX.Xx.F.F.F.F.i.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.t.3.2.2.2.2.2.2.2.2.+.1.{ { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g x x x x x v v b b x g e 6.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX;XU ) [ [ [ [ [ [ [ { { { { { { { { { 2.2.2.2.2.2.2.4.c.c.c.c.c.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.i.5.4.4.3.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.h.~.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXVXL.V.F.F.N.u.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.3.3.2.2.2.2.2.2.2.2.{ 1.{ { { { { { [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x x x b b c p D bXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXhX' ) [ [ [ [ [ [ [ { { { { { { { { { 2.2.2.2.2.2.2.3.c.c.c.c.c.c.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.m.i.5.4.4.3.3.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.$.>XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXbXN.S.F.c.u.u.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.3.2.2.2.2.2.2.2.2.+.{ { { { { { { [ ] UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x x b b b b c a.*X`.*X*X&X:X-X>X7X7X6X0X8XwXiXrXgXfXgXs.~ [ [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.5.c.c.c.c.c.c.m.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.v.i.5.4.4.3.3.4.c.c.c.c.c.c.c.c.c.c.c.c.c.c.n.n.n.n.n.n.n.n.c.h.jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXxXK.m.i.i.i.u.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.3.2.2.2.2.2.2.2.2.{ { { { { { { { [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 6 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g x x x x x v b b b b c n c y u u u u u u I I I I I I U U U W W W ) ) [ [ [ [ [ [ [ { { { { { { { { { 2.2.2.2.2.2.2.3.c.c.c.c.c.c.l.v.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.m.m.m.m.C.n.i.i.4.4.3.3.3.4.c.c.c.c.c.c.c.c.c.c.n.n.n.n.n.n.n.n.n.n.n.n.h.P.BXDXVXVXBXBXBXbXvXvXkXkXkXfXfXgXrXiXgX.X&.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.3.3.2.2.2.2.2.2.2.2.{ { { { { { { { [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g x x x x x x b b b b c c n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.3.i.i.i.i.i.i.i.i.n.C.m.m.m.m.m.m.m.b.b.b.b.b.b.b.b.b.b.b.m.c.i.i.4.4.3.3.3.2.i.c.c.c.c.c.c.n.n.n.n.n.n.n.v.v.v.v.v.v.v.v.v.c.M.M.M.M.c.c.c.l.h.h.&.&.&.$.$.$.$.$.$.5.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.3.2.2.2.2.2.2.2.2.+.{ { { { { { { [ ] UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 f f f f f f f g g g g g g g x x x x x x b b b c c n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { { 2.2.2.2.2.2.2.4.5.5.5.i.i.i.i.i.c.m.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.c.i.i.4.4.3.3.3.2.2.i.c.c.n.n.n.n.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.c.c.c.c.c.c.c.c.c.c.c.c.c.c.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.3.3.2.2.2.2.2.2.2.2.{ { { { { { { [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 6 6 6 6 6 6 7 7 7 7 7 f f x b v v l q 9 f g g g g g g g x x x x x x b b b b n c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.3.4.4.4.4.5.5.5.5.5.i.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.c.i.i.4.4.3.3.3.2.2.3.n.n.n.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.n.n.n.c.c.c.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.t.3.2.3.3.2.2.2.2.2.+.{ { { { { { { [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 6 6 6 6 6 6 6 7 7 7 b n ^ / / ^ M m l k 8 f g g g g g g g x x x x x v b b b c c n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.2.4.4.4.4.4.4.4.4.4.4.i.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.v.c.i.i.4.4.3.3.3.2.2.{ i.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.t.t.t.9.6.9.1.2.2.2.2.2.2.{ { { { { { { [ [ [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 6 6 6 6 6 6 7 7 6 M 2.( ^ / ^ ^ M m l k 8 9 g g g g g g g x x x x x v b b b c c n n n n n n ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.3.3.4.4.4.4.4.4.4.4.4.4.n.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.n.c.i.i.4.4.3.3.3.2.2.{ +.c.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.n.n.n.c.c.c.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.t.t.t.t.t.6.6.7.7.9.1.1.2.2.2.{ { { { { { { [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 6 6 6 6 6 6 6 6 7 6 g 1.2.{ ( ^ ^ ^ M m l k 8 3 f g g g g g x x x x x v v b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.4.4.4.4.c.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.b.n.c.i.i.4.4.3.3.3.2.2.2.{ 2.v.v.v.v.v.v.v.v.m.m.m.m.m.m.m.m.m.m.m.m.m.v.v.v.v.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.t.0.G 6.7.9.9.<.1.1.2.3.+.{ { { { { { { [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 6 6 6 6 6 6 6 6 6 6 ) 2.{ { { / ^ ^ M m l k 8 3 7 g g g g g x x x x x v v b b c c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.i.v.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.n.c.c.i.i.4.4.3.3.3.2.2.2.{ [ u.m.v.v.v.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.m.v.v.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.t.t.t.6.G 6.7.9.9.<.1.2.3.4.2.{ { { { { { { [ [ [ [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 6 6 6 6 6 6 6 6 6 6 v 2.{ { { [ [ / ^ M m l k 8 3 2 g g g g g x x x x x v b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.4.N.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.L.N.l.c.i.i.4.4.3.3.3.2.2.2.{ { [ u.m.m.m.m.m.m.m.m.A.A.A.A.A.A.A.A.A.A.m.m.m.m.m.m.v.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.t.u.9.D 6.6.7.9.9.<.1.3.3.4.4.+.{ { { { { { [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 6 6 6 6 6 6 6 6 7 { 2.{ { [ [ [ [ ( M m l k 8 3 % 7 g g g g x x x x x v b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3...+XHXDXDXDXDXDXDXDXDXDXDXDXDXDXDXDXDXHX%X$.i.i.4.4.3.3.3.2.2.2.{ { [ { m.m.m.m.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.m.m.m.m.m.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.t.G D 6.6.7.9.9.1.2.3.3.4.5.4.{ { { { { { { [ [ [ [ UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 1 1 6 6 6 6 6 6 6 6 ) 2.{ { { [ [ [ ) ) ^ m l k 8 3 2 < g j g g x x x x x x b b c c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ { { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.t.AXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX5.5.i.4.4.3.3.3.2.2.2.{ { [ u.A.m.m.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.m.m.m.m.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.0.S G 6.6.7.9.<.{ 2.3.3.4.5.l.2.{ { { { { { [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 6 6 6 6 6 6 6 6 v 2.1.{ { { [ [ [ ) ) / n z 9 6 < $ # 7 j g x x x x x x x b b c c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { { 2.2.2.2.2.2.2.{ { { { 1.2.2.2.2.2.2.Q *XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>X$.i.4.4.3.3.3.2.2.2.{ [ { m.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.v.n.n.n.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.( A D D =.7.<.{ { 2.3.3.4.5.l.5.{ { { { { { [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 1 1 6 6 6 6 6 6 6 7 { 2.1.{ { [ [ [ ) ) / / / c j A q q 5 q x g x x x x x x x b b c c c n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.2.2.{ { { { { { { { { { { o.vXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXDXY.5.4.4.3.3.3.2.2.2.{ [ i.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.v.v.n.n.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.6.6.7.7.9.) [ { { 2.3.3.4.5.l.z.4.{ { { { { { [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 6 6 6 6 6 6 6 ( 2.1.{ { { [ [ [ ) ) / ^ ! <.kXDXVXVXDX7Xy g x x x x x x b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.2.2.{ { { { { { { { { W -XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXtX*.4.4.3.3.3.2.2.2.{ 3.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.v.v.n.c.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.4.4.jXDXVXVXDXwX` { { 2.3.3.4.5.l.z.v.2.{ { { { { [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 6 6 6 6 6 6 b 2.2.1.{ { [ [ [ ) ) / / ! ~ lXLXLXLXLXLXrXy g x x x x x x b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.2.3.+.[ [ [ [ { { { ` f.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX+X#.4.3.3.3.2.2.{ +.v.A.A.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.A.A.A.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.4.4.BXLXLXLXLXLX:XT { 2.3.3.4.5.l.l.B.z.{ { { { { [ [ [ [ [ ] UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< 1 1 1 1 6 6 6 6 6 f 2.2.1.{ { [ [ [ [ ) ) / ^ Y 4XLXLXLXLXLXLXqXy g x x x x x x b b c c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.{ [ [ [ [ [ [ ` hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX5.4.3.3.3.2.2.{ i.A.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.S.S.S.S.A.A.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.4.4.BXLXLXLXLXLXDXy.} 2.3.3.4.5.l.l.v.B.5.{ { { { { [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 6 6 6 6 6 6 ) 2.2.1.{ { [ [ [ ) ) / / u (.PXLXLXLXLXLXLXqXy g x x x x x x b b b c n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / ) ) ) ) ) [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.2.[ [ [ [ [ E `.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>XX.3.3.3.2.2.2.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.A.A.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.4.BXLXLXLXLXLXLXhX' +.3.3.4.5.l.l.v.B.B.2.{ { { { [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUX< 1 1 1 1 6 6 6 6 1 h 2.2.1.{ { { [ [ [ ) ) / ! 9.VXLXLXLXLXLXLXLXrXy g x x x x x x b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.3.{ ) [ [ ) { BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXDXd.@.3.3.2.2.i.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.A.A.A.A.A.A.A.m.m.m.m.v.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.4.MXLXLXLXLXLXLXLX:XQ 3.3.4.5.l.l.v.B.V.5.{ { { { [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 1 6 6 6 6 6 [ 2.2.1.{ { [ [ [ ) ) / ^ I pXLXLXLXLXLXLXLXLX*Xr g x x x x x b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.2.2.3.3.3.3.3.3.[ [ [ U :XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX6XX.3.3.2.3.m.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.#.jXLXLXLXLXLXLXLXKX)...3.4.5.l.l.v.B.B.B.2.{ { { [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUX< 1 1 1 1 1 6 6 6 1 M 3.2.1.{ { { [ [ [ ) ) / u {.LXLXLXLXLXLXLXLXcX~ g x x x x x x b b b c c n n n n n ^ ^ ^ ^ ^ ^ ^ / / / ) ) ) ) ) [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.3.3.3.2.[ ~ a.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZXu.@.3.2.c.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.S.F.F.S.S.S.S.S.S.S.S.S.S.A.A.A.A.A.A.A.m.m.m.v.v.v.v.v.n.n.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.#.+XLXLXLXLXLXLXLXLXAXt.@.4.5.l.l.v.B.B.V.l.{ { { [ [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 1 1 6 6 1 j 2.2.2.1.{ { [ [ [ ) ) ) R q.DXLXLXLXLXLXLXLXGXf.e g x x x x x b b b b c c n n n n n n ^ ^ ^ ^ ^ ^ ^ / / ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.{ ] kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXqXX.2.u.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.F.F.F.F.F.F.F.S.S.S.S.S.S.S.S.A.A.A.A.A.A.m.m.m.v.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.#.tXLXLXLXLXLXLXLXLXlX@.4.5.l.l.v.B.B.B.V.5.[ { { [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 1 1 6 6 6 ) 2.2.2.{ { { [ [ [ ) ) / ~ lXLXLXLXLXLXLXLXLX7Xi g g x x x x x b b b b c c n n n / ) ) ) ) ) ) ) ) ) ) ) ) ) / / / / / / / [ [ [ { { { { { { { { 2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.X.*XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX_.O.v.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.F.F.F.F.F.F.F.F.T.T.F.F.S.S.S.S.S.S.A.A.A.A.A.A.m.m.v.v.v.v.n.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.%.d.DXLXLXLXLXLXLXLXLX7XX.5.l.l.v.B.B.B.B.V.3.[ { [ [ [ [ [ [ ) ) UXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUX# < 1 1 1 1 1 1 6 6 6 n / ) [ [ { [ [ [ [ ) / Y :XLXLXLXLXLXLXLXLXZX<.f g g x x x x x b b b b c c n n ^ 3.2.{ { { { [ [ [ [ ) ) ) / / ^ ^ ^ n n c n [ { { { { { { { { { 2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.@.~.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXlX&.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.F.T.T.T.T.F.F.A.v.v.v.m.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.n.n.n.v.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.X.>XLXLXLXLXLXLXLXLXPXoX$.l.l.v.B.B.B.v.v.4.{ { [ [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 1 1 1 6 6 6 n / ^ ^ ^ / / ) ) ) ) R (.PXLXLXLXLXLXLXLXLX*Xr g g g x x x x x b b b b c c n c { 4.3.{ { { { [ [ [ [ ) ) ) / / ^ ^ ^ ! n c c ! { { { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.X.=XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX1Xz.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.F.T.T.T.T.T.T.A.[ ) [ [ [ { { { +.2.2.3.3.3.3.4.4.5.i.i.i.i.c.v.n.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.4.4.nXLXLXLXLXLXLXLXLXnX5.l.l.v.c.c.i.u.u.3.{ { [ [ [ [ [ [ [ ) ) UXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUX< 1 1 1 1 1 1 1 6 6 6 b ^ ^ ^ ^ ^ ^ ^ ^ ^ ! ) AXLXLXLXLXLXLXLXLXmX! g g g g x x x x x b b b b c c n ^ 3.3.3.2.{ { { [ [ [ [ ) ) ) / / ^ ^ ^ ! n c c c / { { { { { { { { +.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.#.gXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXdXj.B.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.T.T.T.T.T.T.T.i./ ) [ [ { { { { +.2.2.3.3.3.3.4.4.5.i.i.i.c.A.A.v.n.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.O.+XLXLXLXLXLXLXLXLXLX=X#.i.u.u.u.u.u.i.4.{ { [ [ [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUX# < 1 1 1 1 1 1 1 6 6 6 j M M M M M M M M M x (.LXLXLXLXLXLXLXLXLX-Xe g g g x x x x x x b b b b c n n 2.4.3.3.3.2.{ { [ [ [ [ ) ) ) / / ^ ^ ^ ! n c c c c [ { { { { { { { 2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.u.@.d.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXBXn.v.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.T.T.T.T.T.T.T.T.{ ) [ [ [ [ { { { +.2.2.3.3.3.3.4.4.5.i.i.c.A.D.D.A.c.c.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.#.fXLXLXLXLXLXLXLXLXfX#.u.u.u.u.u.u.u.4.{ { { [ [ [ [ [ [ [ ) UXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUX$ 1 1 1 1 1 1 1 1 6 6 6 h m m m m m m m m l e {.LXLXLXLXLXLXLXLXjX! f g g g x x x x x x b b b c c b { 4.3.3.3.3.2.+.[ [ [ [ [ ) ) ) / / ^ ^ ^ ! n c c c x c { { { { { { 1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.O.XXKXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKXOXj.m.A.A.A.A.A.A.A.S.S.S.S.S.S.F.F.F.T.T.T.T.T.T.T.i./ ) [ [ [ [ { { { +.2.2.3.3.3.3.4.4.5.5.n.D.D.D.D.F.N.c.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.@.d.SXLXLXLXLXLXLXLXBXu.4.u.u.u.t.t.t.t.{ { { [ [ [ [ [ [ [ ) / UXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUX# < < 1 1 1 1 1 1 1 6 6 6 9 l l z l l z k k k e eXLXLXLXLXLXLXLXKXf.e g g g g x x x x x x b b b c b ) 4.4.3.3.3.2.2.2.{ [ [ [ [ ) ) ) / / ^ ^ ^ ! n c c c c x ^ { { { { { 1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.X.>XLXLXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXPXLXLX;Xj.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.F.F.F.T.T.T.T.T.T.T.{ / ) [ [ [ [ { { { +.2.2.3.3.3.3.4.4.4.c.D.D.J.J.J.I.J.n.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.u.X.;XLXLXLXLXLXLXLXJXg.2.t.t.t.r.r.r.r.{ { { [ [ [ [ [ [ [ ) ) UXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUX$ < < 1 1 1 1 1 1 1 6 6 6 9 k k k k q q q q q w aXLXLXLXLXLXLXLX0Xy g g g g g x x x x x x b b b b n 3.4.3.3.3.3.2.2.2.+.[ [ [ [ ) ) ) / / ^ ^ ^ ! n c c c c x x ) 1.{ { { 1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.4.5.XXXXXXXXXXXXXXXXXX.X.X.X.X.X.X.X.X.X.X.X.X.X.X.X.Xz.m.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.F.F.F.T.T.T.T.T.T.m./ ) ) [ [ [ [ { { { +.2.2.3.3.3.3.4.4.i.D.J.J.I.I.I.I.I.D.c.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.u.3.%.vXLXLXLXLXLXLXLX_.{ r.r.r.r.r.r.r.{ { { [ [ [ [ [ [ [ ) ) / UXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUX# < < < 1 1 1 1 1 1 1 6 6 6 8 9 9 9 9 9 8 8 8 8 k ZXLXLXLXLXLXLXFXq.f g g g g g x x x x x x b b b b { 4.3.3.3.3.2.2.2.2.{ { [ [ [ ) ) ) / / ^ ^ ^ ! n c c c c x x x [ 1.{ { 2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.t.u.u.u.u.4.%.%.%.%.%.%.%.&.&.&.&.&.&.&.h.h.h.h.h.h.z.z.z.z.z.v.m.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.F.F.F.T.T.T.T.T.T.i.^ ) ) [ [ [ [ { { { +.2.2.3.3.3.3.4.i.D.J.I.I.I.I.I.I.I.I.N.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.X.=XLXLXLXLXLXLXLX-X] 0.0.0.0.0.0.0.{ { { [ [ [ [ [ [ [ ) ) ) UXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUX# < < < 1 1 1 1 1 1 1 6 6 6 6 0 0 0 0 0 5 5 5 1 J KXLXLXLXLXLXLX-Xr f g g g g g x x x x x x b b x / 4.4.3.3.3.3.2.2.2.+.{ { { [ [ ) ) ) / / ^ ^ ^ ! n c c c c x x g c { { { 2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.n.v.v.v.v.v.m.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.F.F.F.F.T.T.T.T.T.{ / ) ) [ [ [ [ { { { +.2.2.3.3.3.3.4.D.J.I.I.I.I.W.W.W.W.W.I.c.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.3.p.ZXLXLXLXLXLXLX9X] 9.9.9.9.9.9.9.<.{ { [ [ [ [ [ [ [ ) ) ) UXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUX$ < < < 1 1 1 1 1 1 1 6 6 6 6 3 3 3 3 3 3 2 2 o /.LXLXLXLXLXLXmX/ f g g g g g g x x x x x x b b c 3.4.3.3.3.3.2.2.2.2.{ { { { [ ) U U I I I Y u u u i i i i i i t t t I 1.{ 2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.n.v.v.v.v.v.m.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.F.F.F.T.T.T.T.v.^ / ) ) [ [ [ [ { { { +.2.2.3.3.3.3.v.J.J.I.I.W.W.E.E.E.E.E.E.D.c.c.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.t.X.&XLXLXLXLXLXLXlX) 7.7.7.7.7.7.7.<.{ { [ [ [ [ [ [ [ ) ) ) / UXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUX# < < < < 1 1 1 1 1 1 1 6 6 6 1 % % % % % % % % X |.LXLXLXLXLXKX(.e g g g g g g g x x x x x x b x { u.4.3.3.3.3.2.2.2.2.{ { { [ ] +.7XwX9X9X9X9X9X9X9X9X9X9X9X9X9X9X9X9X:Xo.{ 2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.n.v.v.v.v.m.m.m.B.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.F.F.F.F.T.T.+.^ / ) ) [ [ [ [ { { { +.2.2.3.3.3.v.D.J.I.I.W.E.E.E.E.E.E.E.E.W.n.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.t.3.O.gXLXLXLXLXLXVX8.=.6.6.6.6.6.6.9.{ { [ [ [ [ [ [ [ ) ) ) / UXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUX# < < < < 1 1 1 1 1 1 1 6 6 6 1 # # # # # # # # X 5XHXCXCXCXFX7Xr f g g g g g g g x x x x x x x ^ 4.4.4.3.3.3.3.2.2.2.{ { { { [ W &XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXs.} 2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.v.v.v.v.v.v.m.m.m.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.F.F.F.T.v.^ / / ) ) [ [ [ [ { { { +.2.2.3.3.n.F.D.J.I.I.W.E.E.#X#X#X#X#XE.E.G.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.t.t.@.d.MXCXVXVXCXBXw.S G G G G G H 7.{ { [ [ [ [ [ [ [ ) ) ) ) / UXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUX$ < < < < 1 1 1 1 1 1 1 6 6 6 6 1 6 6 6 6 6 6 6 7 ( ( ( ( ( ) c f f g g g g g g g x x x x x x x 2.4.4.3.3.3.3.2.2.2.2.{ { { [ ] 2.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX;X' 1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.m.m.m.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.F.F.F.T...i I I I U U U W W W W Q Q Q ....l.A.D.D.I.I.W.E.E.^.#X#X#X#X#X^.E.E.M.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.t.t.t.@.u.u.u.u.u.u.r.9.9.9.[ [ [ ) [ { { [ [ [ [ [ [ [ ) ) ) ) / UXUXUXUXUXUX\",\n\"UXUXUXUXUXUX# < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f g g g g g g x x x x x x x [ 5.4.4.3.3.3.3.2.2.2.+.{ { { [ W >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX..{ 2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.m.m.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.F.Z.B.4XuXwXwXwXwXwXwXwXqXqXqXqXqXqXuXqXU.B.D.D.I.I.W.E.E.#X#X#X#X#X#X#XE.E.I.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.t.t.t.t.3.@.+.+.+.+.2.2.2.2.+.+.{ { { { { [ [ [ [ [ [ [ ) ) ) ) ) UXUXUXUXUXUX\",\n\"UXUXUXUXUXUX# < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x x x x M 4.4.4.3.3.3.3.2.2.2.2.{ { { { ] y.FXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXJXg.} 2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.m.m.m.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.S.k.@XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXtXj.D.D.I.I.W.E.E.^.#X#X#X#X#X#XE.E.W.N.i.i.i.i.i.i.u.u.u.u.u.u.u.u.t.t.t.t.3.3.3.3.2.2.2.2.2.2.1.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) ) UXUXUXUXUXUX\",\n\"UXUXUXUXUXUX$ < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x x x x 2.5.4.4.3.3.3.3.2.2.2.+.{ { { [ T 6XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX-X' 2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.m.m.m.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.S.S.k.kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX@Xx.D.I.I.I.E.E.E.#X#X#X#X#XE.E.W.W.I.c.i.i.i.i.i.u.u.u.u.u.u.u.u.t.t.t.t.3.3.3.3.2.2.2.2.2.2.1.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) / / UXUXUXUXUX\",\n\"UXUXUXUXUXUX$ < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x x x [ 5.4.4.3.3.3.3.2.2.2.+.{ { { { ` ).KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgX' 2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.m.m.m.B.A.A.A.A.A.A.A.A.S.S.S.S.S.S.S.k.=XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnXD.A.J.I.I.W.E.E.E.#X#X#XE.E.E.W.I.I.D.i.i.i.i.i.u.u.u.u.u.u.u.u.t.t.t.t.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ [ ) ) ) ) ) / UXUXUXUXUX\",\n\"UXUXUXUXUX# < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x g ( 5.4.4.4.3.3.3.3.2.2.2.+.{ { { [ ' jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXVXt.{ 2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.v.v.v.v.v.v.v.m.m.m.A.A.A.A.A.A.A.A.A.S.S.S.S.S.S.m.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXyXk.J.I.I.I.W.E.E.E.E.E.E.E.W.I.I.I.J.n.i.i.i.i.u.u.u.u.u.u.u.u.t.t.t.t.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ [ ) ) ) ) / / UXUXUXUXUX\",\n\"UXUXUXUXUX# < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x x 3.5.4.4.3.3.3.3.2.2.2.+.{ { { { ` _.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXoX' 2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.v.v.v.v.v.v.v.m.m.m.B.A.A.A.A.A.A.A.A.S.S.S.S.S.k.;XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKX.XA.J.I.I.I.W.E.E.E.E.E.W.I.I.I.J.D.D.i.i.i.i.u.u.u.u.u.u.u.u.t.t.t.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ ) ) ) ) ) ) / / UXUXUXUX\",\n\"UXUXUXUXUX$ < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x g [ 5.4.4.4.3.3.3.3.2.2.2.+.{ { { [ W rXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXrX..2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.v.v.v.v.v.v.v.v.m.m.m.B.A.A.A.A.A.A.A.A.S.S.S.S.m.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjXB.D.J.I.I.I.I.W.W.W.W.I.I.I.J.D.D.D.v.i.i.i.u.u.u.u.u.u.4.u.t.t.t.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ ) ) ) ) ) / ) / UXUXUXUX\",\n\"UXUXUXUX@ $ < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x j n 4.4.4.4.4.3.3.3.2.2.2.2.{ { { { ` g.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX@.{ 2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.v.m.m.m.m.A.A.A.A.A.A.A.A.A.S.S.k.;XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX%XB.J.J.I.I.I.I.I.I.I.I.I.J.D.D.D.A.B.i.i.i.u.u.u.u.u.u.4.t.t.t.t.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ ) ) ) ) ) / ) / UXUXUXUX\",\n\"UXUXUXUX# $ < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g g [ i.u.4.4.3.3.3.3.2.2.2.2.{ { { [ Q dXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX;X..2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.v.v.v.v.v.v.v.m.m.m.m.B.A.A.A.A.A.A.A.A.A.S.j.jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXhXk.D.D.J.J.I.I.I.I.I.J.J.D.D.D.A.B.B.c.u.u.u.u.u.u.u.u.u.t.t.t.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) ) / / / UXUXUXUX\",\n\"UXUXUXUX# < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g j n [ +.3.4.3.3.3.3.2.2.2.+.{ { { ` oXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXxXo.{ 2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.v.m.m.m.m.B.A.A.A.A.A.A.A.A.x.@XPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX=Xx.D.D.D.J.J.J.J.D.D.D.D.A.A.B.m.m.B.i.u.u.u.u.u.u.4.u.t.t.t.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) ) / ( / / UXUXUX\",\n\"UXUXUXUX$ < < < < < < < 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g j x ! ! ^ [ 2.3.3.2.2.2.2.{ { { ] +.MXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPXoX' 2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.v.m.m.m.m.B.A.A.A.A.A.A.A.j.6XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXU.B.D.D.D.D.D.D.D.D.A.A.A.B.B.m.v.v.c.u.u.u.u.u.u.4.t.t.t.t.3.3.3.3.2.2.2.2.2.2.2.1.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) ) ) ( / / UXUXUX\",\n\"UXUXUX@ $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g x x ^ ^ ^ ! ^ ) +.2.2.2.+.{ { { W ;XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXtX..{ 2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.v.v.v.v.v.v.v.v.m.m.m.m.m.A.A.A.A.A.A.B.L.DXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXrXj.A.A.A.A.A.A.A.A.A.m.v.c.c.c.i.i.u.u.u.u.u.u.4.4.t.t.t.t.3.3.3.3.2.2.2.2.2.2.2.1.{ { { { { { [ [ [ [ [ [ ) ) ) ) ) ) / ( ( / UXUXUX\",\n\"UXUXUX@ $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 f f f f f f f f f g g g g g g x j n ^ ^ ^ ^ ^ ^ / { 2.+.{ { ] t.CXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXCXp.} 1.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.n.v.v.v.v.v.v.v.v.m.m.m.m.A.A.A.A.A.A.A.j.yXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX@Xj.B.B.B.m.v.c.c.c.i.i.i.i.i.i.i.u.u.u.u.u.u.4.4.t.t.t.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ ) ) ) ) ) ) / ( ( / UXUXUX\",\n\"UXUXUX# $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x ^ ^ ^ ^ ^ ^ n n ^ [ { { W 7XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX&XQ { 1.1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.t.t.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.v.v.v.v.v.v.v.v.m.m.m.m.A.A.A.A.A.A.A.B.K.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXmXz.l.c.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.4.u.t.t.t.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ ) ) ) ) ) ) / ( ( / / UXUX\",\n\"UXUXUX# < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x ! ^ ^ ^ ^ ^ n n n c n ~ s.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX..{ { 1.1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.v.v.v.v.v.v.v.m.m.m.m.m.B.A.A.A.A.A.A.j.=XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXfX#.4.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.4.4.u.t.t.3.3.3.3.3.2.2.2.2.2.2.2.1.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) ) ) ( ( ( / / UXUX\",\n\"UXUXUX$ < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g x x x c ^ ^ ^ ^ ^ n n n n b x ) fXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXs.] { { 1.1.1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.n.v.v.v.v.v.v.v.m.m.m.m.m.m.A.A.A.A.A.B.j.dXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKX).O.4.4.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.4.4.u.t.t.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { { [ [ [ [ [ [ ) ) ) ) ) / ( ( ( ( / UXUX\",\n\"UXUX@ $ $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g x x x ^ ^ ^ ^ ^ n n n n c b g [ nXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX+XW { { { { 1.1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.v.v.v.v.v.v.v.v.m.m.m.m.m.m.m.m.A.A.B.N.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXqX .3.3.4.4.4.5.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.4.4.t.t.3.3.3.3.3.2.2.2.2.2.2.2.2.{ { { { { { { { [ [ [ [ [ [ ) ) ) ) ) / ( ( ( ( / UXUX\",\n\"UXUX@ $ $ $ < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g x x x n ^ ^ ^ ^ n n n n c b x r Q.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgX' [ { { { { 1.1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.v.v.v.v.v.v.v.v.v.m.m.m.m.m.m.m.m.m.j.%XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKXg.o.3.3.3.4.4.4.4.i.i.i.i.i.i.i.u.u.u.u.u.u.u.4.4.t.t.3.3.3.3.3.2.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ [ ) ) ) ) ) / ( ( ( ( / UXUX\",\n\"UXUX# $ $ $ < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f f g g g g g g g x x x b ^ ^ ^ ^ n n n n c b x j y >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXHXs.] { { { { { 1.1.1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.n.v.v.v.v.v.v.v.v.v.m.m.m.m.m.m.m.m.m.j.gXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXdX..2.2.3.3.3.3.4.4.4.5.i.i.i.i.u.u.u.u.u.u.u.4.4.u.t.3.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { { [ [ [ [ [ [ [ ) ) ) ) / / ( ( ( ( / / UX\",\n\"UXUX# $ $ $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 f f f f f f f g g g g g g g x x x x ! ^ ^ ^ n n n n c b x x g R hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX7XT [ { { { { { { 1.1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.n.n.v.v.v.v.v.v.v.v.v.m.m.m.m.m.m.m.z.P.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX).' +.2.2.2.3.3.3.3.4.4.4.5.i.i.u.u.u.u.u.4.u.4.4.t.t.3.3.3.3.3.3.2.2.2.2.2.2.2.{ { { { { { { [ [ [ [ [ [ [ ) ) ) ) ) / / ( ( ( ( ( ^ UX\",\n\"UXUX# $ $ $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 7 7 7 7 , , 7 7 7 f f f f f f f g g g g g g g g x x x c ^ ^ ^ n n n n c b x x j a q.SXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXHXa.] { { { { { { { 1.1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.t.t.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.n.n.v.v.v.v.v.v.v.v.v.v.v.m.m.m.m.m.j.>XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXfXQ { { { +.2.2.2.3.3.3.4.4.4.i.u.u.u.u.u.4.4.4.4.3.t.3.3.3.3.3.3.2.2.2.2.+.+.2.+.+.{ { { { { { [ [ [ [ [ [ [ ) ) ) ) ) / ( ( ( ( ( ( ^ UX\",\n\"UX@ # $ $ $ < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 8.8.7 7 7 f f f f f f f f g g g g g g g x x x v ^ ^ ^ n n n n c b x x j g t {.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX&XW [ [ { { { { { { 1.1.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.u.u.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.n.n.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.z.kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX[.E [ { { { { 2.2.2.3.3.3.3.u.i.u.u.u.u.u.4.4.4.4.t.3.3.3.3.3.3.3.2.2.2.2.3.{ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ) ) ) ) ) / ( ( ( ( ( ( ^ UX\",\n\"UX@ $ $ $ $ < < < < < < < 1 1 1 1 1 1 6 q 9 8 8 1 1 < < & a mXnXc 7 7 f f f f f f f f g g g g g g g x x x x n ^ ^ n n n n c b x x j g f y iXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXdXQ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.u.u.@.O.O.#.#.#.#.#.#.#.%.%.%.%.%.%.%.&.&.&.&.&.i.c.c.c.c.c.c.c.c.c.c.c.n.n.n.v.v.v.v.v.v.v.v.v.v.v.v.j.OXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX{ ) [ [ [ { { { +.2.2.2.2.4.i.u.u.u.u.u.u.4.4.u.3.3.3.3.3.3.3.3.2.2.2.2...>X/.u n n n n ! ! ^ ^ ) [ [ [ [ [ ) ) ) ) ) / / ( ( ( ( ^ ^ ^ UX\",\n\"UX@ $ $ $ $ < < < < < < < 1 1 1 1 1 1 9 k 9 9 8 6 1 1 < . w.PXLX_.; 7 f f f f f f f f z g g g g g g x x x x b ^ ^ n n n n c b x x j g z 7 <.ZXLXLXLXLXLXLXLXLXLXLXLXLXLXFXs.` [ [ [ [ { { { { { { 1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.t.@.g.OXoXoXoXoXoXoXOXOXOXOXOXOXOXOXOXOXOXOXOXXX5.i.i.c.c.c.c.c.c.c.c.c.c.n.n.v.v.v.v.v.v.v.v.v.v.v.v.v.h.dXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX&XU ) [ [ [ [ { { { { +.2.2.i.i.u.u.u.u.u.u.4.4.4.3.3.3.3.3.3.3.3.2.2.2.+.u.FXeXi ! ! ! ^ ^ ^ ^ ^ / [ [ [ [ [ ) ) ) ) ) / / ( ( ( ( ^ ^ ^ UX\",\n\"UX@ $ $ $ $ < < < < < < < < 1 1 1 1 1 k k q 9 8 8 1 1 < = 4XLXLXjXy 7 f f f f f f f f g g g g g g g x x x x x ! ^ n n n n c b x x j g z f ; ).PXLXLXLXLXLXLXLXLXLXLXLXLX=XW [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.4.mXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXP.&.i.i.c.c.c.c.c.c.c.c.c.c.c.n.n.n.n.v.v.v.v.v.v.v.v.v.z.Y.DXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZX{ ! / ) ) [ [ [ [ { { { { 3.i.u.u.u.u.u.u.4.4.4.3.3.3.3.3.3.3.3.2.2.2.2...&XLXNX^ ! ^ ^ ^ ^ / / / / [ [ [ [ [ ) ) ) ) ) / ( ( ( ( ( ^ ^ ^ UX\",\n\"UX@ $ $ $ $ < < < < < < < < 1 1 1 1 8 l k k 9 9 8 8 1 < b nXLXLXLX(.; 7 f f f f f f f f g g g g g g g x x x x n ^ n n n n c b x x j g z f 7 t 1XLXLXLXLXLXLXLXLXLXLXLXkX' ) [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.X.;XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXiX$.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.n.n.v.v.v.v.v.v.n.v.h.;XLXLXLXLXLXLXLXLXLXLXLXLXLXLX:XY ^ / / / ) ) [ [ [ [ { +.i.u.u.u.u.u.u.4.4.4.4.3.3.3.3.3.3.3.3.2.2.2.2.@.mXLXLX(.u ^ ^ / / / / / / ) [ [ [ ) ) ) ) ) / / ( ( ( ( ( ^ ^ ^ ^ \",\n\"UX@ $ $ $ $ $ < < < < < < < 1 1 1 1 k l k k q 9 9 8 1 * (.LXLXLXLXgXr 7 f f f f f f f f g g g g g g g x x x x b ^ n n n n c b x x j g z f f 6 c kXLXLXLXLXLXLXLXLXLXKXg.~ [ [ [ [ [ [ [ { { { { { { { 2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.@.p.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX.X$.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.n.n.n.n.n.n.n.c.h.lXLXLXLXLXLXLXLXLXLXLXLXLXSX0.c ^ ^ / / / ) ) [ [ [ [ 3.i.u.u.u.u.u.4.4.4.4.3.3.3.3.3.3.3.3.3.2.2.2...+XLXLXLXwXu / / / / / ) ) ) ) [ [ [ ) ) ) ) ) / / ( ( ( ( ^ ^ ( ^ ! \",\n\"UX# $ $ $ $ $ < < < < < < < 1 1 1 1 m m l k k q 9 8 1 ; 0XLXLXLXLXPX!.; f f f f f f f f g g g g g g g x x x x x n ! n n n c b x x g g z f 7 7 = q.FXLXLXLXLXLXLXLXLX1XT ) [ [ [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.X.6XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkX&.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.h.~.GXLXLXLXLXLXLXLXLXLXLXLX>XY ! ^ ^ ^ ^ / / / ) ) ) +.i.u.u.u.u.u.u.4.u.4.4.3.3.3.3.3.3.3.3.3.2.2.2.O.kXLXLXLXDX7.~ / / ) ) ) ) ) [ [ [ ) ) ) ) ) ) / / ( ( ( ( ^ ^ ( ^ ^ \",\n\"UX# $ $ $ $ $ < < < < < < < 1 1 < h M m l l k k q 9 1 q.HXLXLXLXLXLXjXy 7 f f f f f f f g g g g g g g x x x x x b c c N b c b b b b b x x x x g p a._._._._._._._.).} ) [ [ [ [ [ [ [ [ [ { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.3.3.3.O.oXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>X$.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.n.h.=XLXLXLXLXLXLXLXLXLXLXBX{ c ^ ^ ^ ^ ^ ^ ^ / / / [ u.u.u.u.u.u.u.u.u.4.4.3.3.3.3.3.3.3.3.3.2.2.2...+XLXLXLXLXLX}.I ) ) ) ) [ [ [ [ [ [ ) ) ) ) ) / / ( / ( ( ^ ^ ^ M ^ ^ \",\n\"UX# $ $ $ $ $ < < < < < < < 1 1 1 m M m m l l k q 9 ; *XLXLXLXLXLXLXPX(.; f f f f f f f z g g g g g g x x x x x x x b b b c n n n n n ! ^ ^ ^ ^ ^ ! R R R R R R R ~ ) ) [ [ [ [ [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.3.3.3.@.xXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXDXY.5.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.&.hXLXLXLXLXLXLXLXLXLX-XY ! ^ ^ ^ ^ ! ! ! ^ ^ ^ 3.i.u.u.u.u.u.u.u.4.4.3.3.3.3.3.3.3.3.3.2.2.2.2.O.kXLXLXLXLXLXvX~ ) ) [ [ [ [ [ [ [ [ ) ) ) ) ) / / ( ( ( ( ^ ^ ^ M ^ ^ \",\n\"O # $ $ $ $ $ < < < < < < < < < 9 ( M m m l l z k 9 x jXLXLXLXLXLXLXLXdXr 7 f f f f f f g g g g g g g x x x x x x b b b b b n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.3...&XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX6X*.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.h.P.GXLXLXLXLXLXLXLXVX1.c ! ! ! ! ^ ^ ^ / / / { i.u.u.u.u.u.u.u.4.u.3.3.3.3.3.3.3.3.3.3.2.2.2.o.XXLXLXLXLXLXLXPXf.~ [ [ [ [ [ [ [ { [ ) ) ) ) ) / ( ( ( ( ( ^ ^ ^ M ^ ^ \",\n\"O # $ $ $ $ $ < < < < < < < < 1 M ( M M m m l l k 7 w.KXLXLXLXLXLXLXLXKXf.; f f f f f f f g g g g g g x x x x x x x b b b b n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { { 1.2.2.2.2.2.2.2.2.2.2.+.u.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZXi.5.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.5.~.OXOXOXOXOXOXOXP.o.2.3.3.3.3.t.u.u.u.u.u.u.u.u.u.u.u.u.u.4.4.4.3.3.3.3.3.3.3.3.3.2.2.2.2...dXLXLXLXLXLXLXLX5XU [ [ [ [ [ { { { { [ ) ) ) ) / ( ( ( ( ( ^ ^ ^ M M ^ \",\n\"O # $ $ $ $ $ $ < < < < < < < 7 ) ( ( M m m m l k e :XLXLXLXLXLXLXLXLXLX0Xr 7 f f f f f f g g g g g g x x x x x x x b b b b n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.2.2.2.2. .>XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>X*.i.i.i.i.i.i.i.i.i.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.c.i.i.i.&.&.&.&.&.&.&.&.&.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.4.4.3.3.3.3.3.3.3.3.3.2.2.2.2.o.g.KXLXLXLXLXLXLXLXNX[ ] [ [ [ { { { { { [ ) ) ) / ( ( ( ( ( ( ^ ^ ^ M M ^ \",\n\"O # $ $ $ $ $ $ < < < < < < < b [ ) ( M M m m l k ^ vXLXLXLXLXLXLXLXLXLXGXe., f f f f f f g g g g g g g x x x x x x b b b b b n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { { { { 2.2.2.2.2.2.2.2.o.g.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXHXP.&.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.4.3.3.3.3.3.3.3.3.3.3.2.2.2.2...0XLXLXLXLXLXLXLXLXLX].` { { { { { { { 1.1.) ) ) / ( ( ( ( ( ^ ^ ^ ^ M M ^ \",\n\"O # $ $ $ $ $ $ < < < < < < 6 [ [ ) ( ( M M m m g _.LXLXLXLXLXLXLXLXLXLXLX:X; f f f f f f f g g g g g g x x x x x x x b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { { { 1.2.2.2.2.2.2.2. .iXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXhX$.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.4.3.3.3.3.3.3.3.3.3.3.2.2.2.2.} g.KXLXLXLXLXLXLXLXLXLXpX` { { { { 1.1.1.2.2.[ / / ( ( ( ( ( ( ^ ^ ^ M n n ^ \",\n\"O $ $ $ $ $ $ $ < < < < < < b { [ ) ) ( ( M M m s wXLXLXLXLXLXLXLXLXLXLXLXnX^ 7 f f f f f f g g g g g g x x x x x x x b b b N n n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2.2.o.d.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX+X$.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.4.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.' >XLXLXLXLXLXLXLXLXLXLXGXa.} { 1.1.1.2.2.2.2.2.) / ( ( ( ( ( ( ^ ^ M M n n ^ \",\n\"O $ $ $ $ $ $ $ $ < < < < 1 [ { [ [ ) ( ( M M m 6.VXLXLXLXLXLXLXLXLXLXLXLXLX+X; f f f f f f g g g g g g g x x x x x x b b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { 2.2.2.2.2...rXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX5.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.+.O.xXLXLXLXLXLXLXLXLXLXLXLX-XQ 1.1.2.2.2.2.2.2.2.[ ( ( ( ( ( ( ^ ^ ^ M n n n ^ \",\n\"O $ $ $ $ $ $ $ $ < < < $ z 1.{ { [ ) ) ( ( M x (.LXLXLXLXLXLXLXLXLXLXLXLXLXmXc 7 f f f f f f g g g g g g x x x x x x x b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { 1.2.2.2.' XXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX;X*.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.} oXLXLXLXLXLXLXLXLXLXLXLXLXvX} +.2.2.2.2.2.2.2.3.1.( ( ( ( ( ( ^ ^ ^ M n n n ^ \",\n\"O # $ $ $ $ $ $ $ < < < < ) { { { [ [ ) ) ( M c -XLXLXLXLXLXLXLXLXLXLXLXLXLXLX_.; f f f f f f g g g g g g x x x x x x x b b b b b n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { 2.2.{ X.jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXVXp.5.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2...fXLXLXLXLXLXLXLXLXLXLXLXLXKXf.o.2.2.2.2.2.2.2.2.2.) ( ( ( ( ^ ^ ^ M M n n n ^ \",\n\"O # $ $ $ $ $ $ $ < < $ 7 { { { { { [ [ ) ( ( / xXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkXc 7 f f f f f g g g g g g g x x x x x x x b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { { 2.' $XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX0X*.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.4.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.} ).PXLXLXLXLXLXLXLXLXLXLXLXLXLX`...2.2.2.2.2.2.2.2.3.{ ( ( ( ( ^ ^ ^ M M n n n ^ \",\n\"O # $ $ $ $ $ $ $ $ < $ M 1.{ { { { { [ ) ) ! ].LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX).; f f f f f f g g g g g g x x x x x x x b b b N b n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { } s.DXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXoX#.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.4.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.+.o.jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXhXo.2.2.2.2.2.2.2.2.3.2./ ^ ( ( ^ ^ M M n n n n ^ \",\n\"O # $ $ $ $ $ $ $ $ < $ x / ^ ^ ^ ^ ^ ^ ^ ^ d ].LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFX9.7 f f f f f f g g g g g g g x x x x x x x b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { { { ..0XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkX%.5.u.u.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.{ 3.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXa.+.2.2.2.2.2.2.2.2.3.[ ( ( ^ ^ ^ M M n n n n ! \",\n\"O # $ $ $ $ $ $ $ $ < $ f ^ ! ! ! ! ! ! ! ! c ^ AXLXLXLXLXLXLXLXLXLXLXLXLXLXLX8Xr 7 f f f f f f f g g g g g g x x x x x x x b b b N n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { } d.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXP.%.u.u.u.u.u.u.u.u.u.u.i.i.i.i.i.i.i.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.' >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXNXr.+.2.2.2.2.2.2.2.2.2.) ( ( ^ ^ ^ M n n n n b ! \",\n\"O # $ $ $ $ $ $ $ $ $ $ 7 ^ ! ! ! ! ! n n n n y :XLXLXLXLXLXLXLXLXLXLXLXLXLXPX!.; f f f f f f f f g g g g g g x x x x x x x b b b N N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { 3.xXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZXp.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.} s.HXLXLXLXLXLXLXLXLXLXLXLXLXLX4XQ 2.2.2.2.2.2.2.2.2.1.( ( ^ ^ ^ M M n n n n b ! \",\n\"O # $ $ $ $ $ $ $ $ $ $ 6 ! ! n n n n n b b b x /.LXLXLXLXLXLXLXLXLXLXLXLXLXzXc 7 f f f f f f f f g g g g g g g x x x x x x x b b b N n n n n n n n ^ ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { ' XXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>X#.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.t.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.2.{ ' tXLXLXLXLXLXLXLXLXLXLXLXLXLX).} 2.2.2.2.2.2.2.2.2.[ ( ( ^ ^ ^ M M n n n b N ^ \",\n\"O # $ $ $ $ $ $ $ $ $ $ < b n n b b b b v v v g G VXLXLXLXLXLXLXLXLXLXLXLXLX*X; 7 f f f f f f f f f g g g g g g x x x x x x x b b b N N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { { ..dXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXMX5.4.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.2.1.{ } ).PXLXLXLXLXLXLXLXLXLXLXLXDXy.+.2.2.2.2.2.2.2.2.2.) ( ^ ^ ^ M M n n n b b N ! \",\n\"O # $ $ $ $ $ $ $ $ $ $ $ f N v v v v v v j j j e 5XLXLXLXLXLXLXLXLXLXLXLXZX( 6 7 f f f f f f f f f z g g g g g g x x x x x x b b b b N n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { } p.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPXoXO.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.1.1.{ { { ' dXLXLXLXLXLXLXLXLXLXLXLX5X' 2.2.2.2.2.2.2.2.2.1.( ^ ^ ^ M M M n n N b b b ! \",\n\"O # $ $ $ $ $ $ $ $ $ $ $ 6 v v j j j j j z z z f e.KXLXLXLXLXLXLXLXLXLXLX7X; 7 7 7 f f f f f f f f g g g g g g g x x x x x x x b b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { { Q =XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXrXX.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.t.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.1.1.{ { { { ` *XLXLXLXLXLXLXLXLXLXLXKXf.} 2.2.2.2.2.2.2.2.2.[ ( ^ ^ ^ M M n n n N b b b ! \",\n\"+ # $ $ $ $ $ $ $ $ $ $ $ 1 j j j z z z h h h h h B aXLXLXLXLXLXLXLXLXLXLX].: 7 7 7 f f f f f f f f f g g g g g g g x x x x x x b b b b N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { o.mXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXd.@.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.t.t.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.2.1.1.{ { { { { ] a.HXLXLXLXLXLXLXLXLXLXaX] <.1.1.1.2.2.2.2.2.2.) ^ ^ ^ ^ M n n n N b b b b ! \",\n\"+ # $ $ $ $ $ $ $ $ $ $ $ < h z h h h h h h q q 9 :  XLXLXLXLXLXLXLXLXLXCXM 6 7 7 7 7 f f f f f f f f z g g g g g g x x x x x x x b b b N N n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { ' oXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX7XX.t.t.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.t.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.2.2.1.1.{ { { { { { [ Q tXLXLXLXLXLXLXLXLXLX{.~ 9.9.<.<.1.1.1.2.2.1.( ^ ^ ^ M n n n n N b b b N ! \",\n\"UX# $ $ $ $ $ $ $ $ $ $ $ $ 9 h h h q 9 9 9 9 9 9 6 A DXLXLXLXLXLXLXLXLX6Xe 7 7 7 7 7 f f f f f f f f f g g g g g g g x x x x x x b b b b N n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { { ..kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZXp.@.t.t.t.t.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.t.t.t.t.t.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.2.2.2.1.1.1.{ { { { { { { ` Q.PXLXLXLXLXLXLXLXIX8.( 7.7.9.9.9.<.<.1.1.[ ^ ^ ^ M M n n n n N b b b N n \",\n\"UX# $ $ $ $ $ $ $ $ $ $ $ $ 1 q 9 9 9 9 9 8 8 8 8 8 = eXLXLXLXLXLXLXLXPXf.= 7 7 7 7 7 f f f f f f f f f g g g g g g g j x x x x x x x b b b N n n c c c c c c c c n ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { ` &XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX=XX.3.3.3.t.t.t.t.t.t.t.t.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.t.t.@.@.3.3.3.3.@.@.3.3.3.3.3.3.3.3.3.3.3.2.2.2.2.2.2.2.2.2.2.2.2.2.1.1.{ { { { { { { { { [ ' jXLXLXLXLXLXLXLXeXc 6.6.6.7.7.7.7.9.9.<.( ^ ^ M M n n n n n b b b v N n \",\n\"UX@ $ $ $ $ $ $ $ $ $ $ $ $ < 9 8 8 8 8 8 8 8 8 3 3 < J KXLXLXLXLXLXLXdXr 6 7 7 7 7 7 7 f f f f f f f f g g g g j x x x v v b b b b b c c N N n c ~ <.<.<.<.<.1.1.1.~ ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ { { { { { ..hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXfXO.3.3.3.3.3.3.3.3.3.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.3.3.3.3.3.u.p.u.u.u.u.u.p.3.+.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.1.{ { { { { { { { { [ [ [ ` ).LXLXLXLXLXLXPX,Xm G G G 6.6.6.6.7.7.) ^ ^ ^ M M n n n n N b b b v n c \",\n\"UX@ $ $ $ $ $ $ $ $ $ $ $ $ < 8 8 8 8 3 3 3 3 3 3 3 2 * aXLXLXLXLXLXLX).: 7 7 7 7 7 7 7 f f f f f f f f f g g g ( [ ) ) ) ) ) / / / / / / ^ ^ ! I 9XFXCXCXCXCXCXCXZXQ.d ^ ^ ^ ^ / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { ` g.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKXg.O.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.O.g.ZXVXVXVXVXVXVXFXqXE / ) ) [ [ [ [ [ { { { 2.2.2.2.2.2.2.2.2.1.1.{ { { { { { { { [ [ [ [ [ ' kXLXLXLXLXLXaXg S S F F G G G 6.6.6.( ^ ^ M M n n n n n b b b v v n c \",\n\"UXO # # $ $ $ $ $ $ $ $ $ $ $ 3 3 3 3 3 3 3 2 2 2 2 2 X  XLXLXLXLXLXnXc 6 7 7 7 7 7 7 7 7 f f f f f f f f z g g ) [ ) ) ) ) ) ) / / / / / ^ ^ u {.LXLXLXLXLXLXLXLXLXkX` n ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { { Q 0XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgXX.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.X.tXLXLXLXLXLXLXLXLXPX!.R ) ) [ [ [ [ [ { { { { 2.2.2.2.2.2.2.1.1.{ { { { { { { { [ [ [ [ [ [ E $XLXLXLXLXLX Xf A A S S S F F G G G ( ^ ^ M M n n n n b b b b v v n c \",\n\"UXO # # $ $ $ $ $ $ $ $ $ $ $ < 3 3 2 2 2 2 2 2 2 < % $ 0 DXLXLXLXLX:X: 6 7 7 7 7 7 7 7 7 f f f f f f f f f z v [ [ ) ) ) ) ) ) / / / / / ^ d w.HXLXLXLXLXLXLXLXLXLXLX-XI ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { ] s.FXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXoXo.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.O.oXPXLXLXLXLXLXLXLXLXLXpXU ) ) [ [ [ [ [ { { { { 2.2.2.2.2.1.1.{ { { { { { { { { [ [ [ [ [ [ [ ) 2.ZXLXLXLXIXK k Z Z A A A S S S F D ^ ^ M M n n n n b b b b v v v n UX\",\n\"UXO # # $ $ $ $ $ $ $ $ $ $ $ < 2 2 2 2 2 < % % $ $ $ $ X eXLXLXLXGXq.= 6 7 7 7 7 7 7 7 7 7 f f f f f f f f f ( [ [ ) ) ) ) ) ) / / / / / ! ~ kXLXLXLXLXLXLXLXLXLXLXLXFXa.c ^ ^ ^ ^ / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { { Q >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgXX.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.@.4.nXLXLXLXLXLXLXLXLXLXLXKXf.~ ) [ [ [ [ [ { { { { { 2.+.+.1.1.{ { { { { { { { { { [ [ [ [ [ [ [ [ U 1XLXLXLX3X6 C C Z Z Z Z A A A S M ^ n M n n n n N b b b b v v v n UX\",\n\"UX+ # # # $ $ $ $ $ $ $ $ $ $ < < % % $ $ $ $ $ # # # #   P LXLXLXdXe 6 6 7 7 7 7 7 7 7 7 7 f f f f f f f f g ) [ [ ) ) ) ) ) ) / / / / ^ i 4XLXLXLXLXLXLXLXLXLXLXLXLXLXdXU n ^ ^ ^ / / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { ] 3.nXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKXg.o.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3. .1XLXLXLXLXLXLXLXLXLXLXLXLXwXU ) [ [ [ [ [ { { { { { 2.+.1.1.{ { { { { { { { { { [ [ [ [ [ [ [ [ [ ~ a.GXLXLXL 1 V C C C Z Z Z Z A A M ^ M M n n n N b N b b v v v v n UX\",\n\"UXUX# # # $ $ $ $ $ $ $ $ $ $ < $ $ $ # # # # # # # # @ @ X pXFXCX(.= 6 6 6 7 7 7 7 7 7 7 7 7 f f f f f f f N [ [ [ ) ) ) ) ) ) / / / / I {.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLX-XI ^ ^ ^ ^ / / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ { { ` oXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX>X..2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.o.oXPXLXLXLXLXLXLXLXLXLXLXLXLXKX!.~ [ [ [ [ [ { { { { { 2.2.{ { { { { { { { { [ [ [ [ [ [ [ [ [ [ [ [ ) E 6XLXaX< 5 5 0 V V V C C C C l ^ M M n n n n N N b b v v v x b c UX\",\n\"UXUX@ # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < < < j M M f 6 6 6 6 6 7 7 7 7 7 7 7 7 7 f f f f f f ) [ [ [ ) ) ) ) ) ) / / / R w.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXs.c ^ ^ ^ ^ ^ / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ Q rXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX@.+.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.3.3.3.3.3.3.3.3.3.3.3.+.u.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXpXE ) [ [ [ [ { { { { { 2.2.{ { { { { { { { [ [ [ [ [ [ [ [ [ [ [ [ ) ) ~ a.dX/.1 0 0 0 q q q q q q q m ^ M n n n n N N b b v v v x x b c UX\",\n\"UXUX@ # # # $ $ $ $ $ $ $ $ $ $ < < < < < < < 1 1 1 1 1 1 1 1 < 1 1 6 6 6 6 6 7 7 7 7 7 7 7 7 7 f f f f f j [ [ [ [ ) ) ) ) ) ) / / / Y wXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXfXE ! ^ ^ ^ ^ / / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ ] s.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX+X..2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2...6XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPXf.~ [ [ [ [ { { { { { 2.2.2.{ { { { { { [ [ [ [ [ [ [ [ [ [ [ [ ) ) ) ) / U ~ ) ( ( ( ( ^ ^ ^ ^ M M M M n n n n n N b b b v v x x v c c UX\",\n\"UXUXO # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 f f f f ^ [ [ [ [ ) ) ) ) ) ) / / Y '.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX_.u ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ ' &XdXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXdX7X@.+.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.o.XXKXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX:XU [ [ [ [ { { { { { 2.2.2.{ { { { { [ [ [ [ [ [ [ [ [ [ [ ) ) ) ) ) ) / / / ( ( / ( ( ( ^ ^ ^ ^ ^ M M n n n n N b b b v v v x v v c c UX\",\n\"UXUXO # # # # $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 f f f f ) [ [ [ [ ) ) ) ) ) ) / ! q.DXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjXW n ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ ' Q Q Q Q ' ' ' ' ' ' ' ' ' ' ' ' ' ........2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.@.kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX] ] [ [ [ { { { { { 2.2.2.2.{ { { [ [ [ [ [ [ [ [ [ [ [ ) ) ) ) ) ) ) / / / ( ( ( ( ^ ( ^ ^ ^ M M M n n n n n b b b b v v x x v v n UXUX\",\n\"UXUX+ # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 f 7 v [ [ [ [ [ ) ) ) ) ) ) / E hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX$Xu ^ ^ ^ ^ ^ ^ / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2...$XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX[.U [ [ [ { { { { { 2.2.2.2.1.[ [ [ [ [ [ [ [ [ [ [ [ ) ) ) ) ) ) ) / / / / ( ( ( ^ ^ ^ ^ ^ M M M n n n n n b b b b v v v x v x v n UXUX\",\n\"UXUXUX# # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 f f ( [ [ [ [ [ ) ) ) ) ) / U 9XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXf.d ^ ^ ^ ^ ^ / / / / / / / ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { 2.+.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.+.u.nXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXMX1.] [ [ { { { { { 2.2.2.2.2.{ [ [ [ [ [ [ [ [ [ [ ) ) ) ) ) ) ) / / / / ( ( ( ( ^ ^ ^ ^ M M M n n n n n N b b b v v v x x x j x c UXUX\",\n\"UXUXUX@ # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 g [ [ [ [ [ [ ) ) ) ) ) I {.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX` n ^ ^ ^ ^ ^ / / / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { +.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2...0XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX-XU [ [ { { { { { 2.2.2.2.3.2.[ [ [ [ [ [ [ [ ) ) ) ) ) ) ) ) / / ( ( ( ( ( ( ^ ^ ^ ^ M M M n n n n n N b b b v v v x v v x j b c UXUX\",\n\"UXUXUXO # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 n [ [ [ [ [ [ ) ) ) ) ~ q.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX&XI ^ ^ ^ ^ ^ ^ / / / / / / / ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.' XXPXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXBX{ ] [ { { { { { 2.2.2.2.3.3.{ [ [ [ [ [ ) ) ) ) ) ) ) ) ) / / ( ( ( ( ( ( ^ ^ ^ ^ M n M n n n n n N b b b b v v x x v x j j c c UXUX\",\n\"UXUXUX+ # # # # # $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 f ) [ [ [ [ [ [ ) ) ) [ [ 1.bXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXy.c ^ ^ ^ ^ ^ ^ / / / / / / / ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { { { 2.2.2.2.2.2.2.2.2.2.2.2.2.2.{ @.vXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX*XE [ { { { { { 2.2.2.2.3.3.3.[ [ [ [ ) ) ) ) ) ) ) ) ) / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ n n M n n n n N b b b b v v x x v x v j j c UXUXUX\",\n\"UXUXUX+ # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 j [ [ [ [ [ [ ) ) [ [ { { ` _.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXrXU n ^ ^ ^ ^ ^ ^ / / / / / / / ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { { { { { { 1.1.1.1.2.2.2.1.1.Q >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXbX} ] { { { { { 2.2.2.2.3.3.3.2.[ [ ) ) ) ) ) ) ) ) / / / / ( ( ( ( ^ ^ ^ ^ ^ ^ M M M n n n n N b b b b v v x x v x x j j x c UXUXUX\",\n\"UXUXUXUX@ # # # # # $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 ^ [ [ [ [ [ [ [ { { { { { { ` hXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX_.u ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { { } g.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX$X` { { { { { 2.2.2.2.3.3.3.3.[ ) ) ) ) ) ) ) ) / / / / ( ( ( ( ^ ^ ^ ^ ^ ^ M M M n n n n n b b b b v v v x v v x v j g x c UXUXUX\",\n\"UXUXUXUXO # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 f [ [ [ [ [ [ { { { { { { { { ] f.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXCXy.c ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { { { { { { { { @.kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX' [ { { { { 2.2.2.2.3.3.3.3.2.) ) ) ) ) ) ) / / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ M M M n n n n n b b b b v v v v v v x v j j j c c UXUXUX\",\n\"UXUXUXUX+ # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 6 j [ [ [ { { { { { { { { { { { { T 4XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX0XY n ^ ^ ^ ^ ( ^ ^ ^ ^ / / / / / / ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { { { { { { Q 1XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX*X` { { { { { 1.2.2.2.3.3.3.3.4.{ / ) ) ) ) / / / ( ( ( ( ^ ^ ^ ^ ^ ^ ^ ^ M n n n n n n b b b b v v v v v v x v j j j j c UXUXUXUX\",\n\"UXUXUXUXUX# # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 6 ( { { { { { { { { { { { { { { { ] r.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXHXa.c ^ ^ ^ ^ ^ ( ^ ^ ^ ^ / / / / / / ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { { { { { ] Q.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX' { { { { { { { { { 1.2.2.2.3.4.3.[ / ) ) / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ ^ M M n n n n n n b b b b v v v x v v x v j j j j x c UXUXUXUX\",\n\"UXUXUXUXUX@ # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 6 b 1.{ { { { { { { { { { { { { { { W -XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgX~ n ^ ^ ^ ^ ^ ( ( ^ ^ ^ / / / / / / / ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { { { { ' dXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKXQ.` { { { { { { { { { { { { { { 1.2.{ / / / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ ^ M M n n n n n N b b b b v v v v v v x x j j j j j x c UXUXUXUX\",\n\"UXUXUXUXUXO # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 [ { { { { { { { { { { { { { { { [ { AXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXhX~ n ^ ^ ^ ^ ^ ^ ( ( ^ ^ ^ / / / / / / / / ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { { { { { { { { ' dXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX8XW { { { { { { { { { { { { { { { { { ) / / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ M M M n n n n n N b b b b v v v x x v v x j j j j j j c c UXUXUXUX\",\n\"UXUXUXUXUX+ # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < < 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 6 v 1.{ { { { { { { { { { { { { { { W :XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX).d n n ^ ^ ^ ^ ^ ^ ^ ( ^ ^ ^ / / / / / / / / ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ { { { { { [ ` _.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXVXy.] { { { { { { { { { { { { { { { { [ / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ ^ M M M n n n n n N N b b b v v v x x v v x j j j j j j j c UXUXUXUXUX\",\n\"UXUXUXUXUXUX# # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 ( 1.{ { { { { { { { { { { { { { ] a.VXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjXI c n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / / / ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ' fXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX$X` { { { { { { { { { { { { { { { { { / / ( ( ( ( ( ^ ^ ^ ^ ^ ^ ^ ^ M M M n n n n N N b b b v v v v x v v x v j j j j g g j c UXUXUXUXUX\",\n\"UXUXUXUXUXUX@ # # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 ) { { { { { { { { { { { { { { { W *XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX`.y n n n n n n ^ ^ ^ ^ ^ ^ ^ ( ( ^ ^ ^ / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ` g.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXdXW { { { { { { { { { { { { { { { { { ) ( ( ( ( ( ( ^ ^ ^ ^ ^ ( ( M M M n n n n N N b b b b v v v v v v v x j j j j j j g z x c UXUXUXUXUX\",\n\"UXUXUXUXUXUXO # # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 6 j { { { { { { { { { { { { { { { [ } bXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXmX` c n n n n n n n ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ Q rXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX_.` { { { { { { { { { { { { { { { { { ( ( ( ( ( ( ^ ^ ^ ^ ^ ( M M M M n n n n n N b b b b v v v v v v v x v j j g j g j g z c UXUXUXUXUXUX\",\n\"UXUXUXUXUXUX+ # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 6 M 1.{ { { { { { { { { { { { { { ` `.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX+Xy b n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ^ ^ ^ / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ` g.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXfX' { { { { { { { { { { { { { { { { { ) ( ( ( ^ ^ ^ ^ ^ ^ ^ M M M M M n n n n n N b b b b v v b b v v v x j j j g j g j g z g c UXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUX@ # # # # # # # $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < < < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 [ { { { { { { { { { { { { { { { ' lXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXmX~ x b n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ ^ / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ W rXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKXg.] { { { { { { { { { { { { { { { { [ ( ( ( ^ ^ ^ ^ ^ ^ ^ M M M M M n n n n N b b b b b b v v j k q 0 z x j j g j g j j z f x c UXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXO # # # # # # # # $ $ $ $ 2 $ $ # # # # $ $ < . . - * - - > 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 6 j { { { { { { { { { { { { { { { ` ).PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX+Xy b b b n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ ^ / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ ~ g.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX7XW { { { { { { { { { { { { { { { { { / ^ ^ ^ ^ ^ ^ ^ ^ ( M M M M M n c y y y y y y v l l k q 0 0 0 5 5 j x j j j j g j z z h c c UXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUX+ # # # # # # # # $ $ $ $ 2 2 2 % $ # # @ + z -X:X}.}.:X:X8.> 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 6 M 1.{ { { { { { { { { { { { { { ` qXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkX~ x b b b b n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ^ ^ ^ / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) [ [ [ [ [ [ [ [ [ [ [ [ [ [ ) W 0XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnX2.[ { { { { { { { { { { { { { { { { ) ^ ^ ^ ^ ^ ^ ^ ^ ( ( M M n n n c [ -X:X:X:X:X&XS C C C C C C V V V j j j j j j j z z f g c UXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUX@ # # # # # # # # $ $ $ 3 3 2 2 2 $ $ # @ 7 MXLXLXLXLXLXrX; < 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 [ { { { { { { { { { { { { { { ] y.nXCXVXVXVXVXVXVXVXVXVXVXVXVXVXCXCXQ.r b b b b b b b n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ^ ^ ^ ^ / / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ~ y.nXCXVXVXVXCXCXCXCXCXVXVXVXVXVXVXVX).` { { { { { { { { { { { { { { { { [ ^ ^ ^ ^ ^ ^ ^ ( M M M n n n n b u >XLXLXLXLXLXmXm Z Z Z Z Z C C C C j j j j j j z z f f x c UXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUX+ # # # # # # # # # $ $ 8 8 3 3 2 2 % $ # * gXLXLXLXLXLXPXw.. 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 7 6 v 1.{ { { { { { { { { { { { { { ) ) 7.6.6.6.6.G G G F F F l l l k l c x v b b b b b b N n n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ] M A F G G 6.7.7.9.9.q.q.0.0.0.r.r.{ { { { { { { { { { { { { { { { { { / ^ ^ ^ ^ ^ ^ M M M M n n n n n x y.FXLXLXLXLXLXuXg Z A Z Z Z Z Z Z Z j g g j g z z f f f c c UXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUX# # # # # # # # # # $ 8 8 8 3 3 3 2 2 $ . 4XLXLXLXLXLXLX0X: < 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 6 ( 1.{ { { { { { { { { { { { [ m l l k k q 9 8 8 3 3 2 < < $ $ # 7 x x x v b b b b b b b N n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) v 2 3 0 0 q k Z A S D 6.6.7.9.0.r.r.1.{ { { { { { { { { { { { { { { [ ^ ^ ^ ^ ^ M M M M M n n n n n b I tXLXLXLXLXLXLX:Xg A A A A A A A A A j g j g z z f f f g c UXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXO # # # # # # # # # $ 9 q 9 8 8 3 3 2 2 . '.LXLXLXLXLXLXJXw.* 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 f [ { { { { { { { { { { { [ M m m l l k k k q q 0 0 3 3 2 2 $ 1 x x x x x v b b b b b b b N N n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / / / / / / / / / / / / / / / ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) 0 0 0 C Z Z A F G G 6.7.7.9.0.r.r.t.1.{ { { { { { { { { { { { { [ ^ ^ ^ ^ ^ M M M M M n n n n n n x f.PXLXLXLXLXLXLX'.j S S S S S A A A A j j g z z f h f f x c UXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUX+ # # # # # # # # # # 9 k q q 9 8 8 3 3 o w.PXLXLXLXLXLXLXgXe < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 v 1.{ { { { { { { { { { ( m m m l l k k k q q 0 0 3 3 2 2 < g x x x x x x v v b b b b b b b N n n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / ) l 5 0 C Z Z A F G G 6.7.7.9.0.r.r.t.3.1.{ { { { { { { { { { { { ) n ^ ^ M M M M M n n n n n n n b i 6XLXLXLXLXLXLXPXf.m D D S S S S S S S j g z z z h f f f c UXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUX@ # # # # # # # # # 9 l k k q q 8 8 8 < 8.HXLXLXLXLXLXLXLX'.* < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 ( 1.{ { { { { { { { ( M M m m l l k k k q q 0 0 3 3 2 2 7 x x x x x x x x v v b b b b b b b N N n n n n n n n n n n n ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( ^ ^ ^ ^ ^ / / / / / / / / / / / / / / / / / / / / / / / / / / / ) M 0 0 C Z Z A F G G 6.7.9.9.0.r.r.t.u.3.{ { { { { { { { { { { [ ^ ^ ^ M M M M n n n n n n n N b x f.GXLXLXLXLXLXLXCXq.D D D D D D D D D S g z z f f f f f x c UXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUX+ # # # # # # # # # 9 m l l h k q q 8 1 l ZXLXLXLXLXLXLXLXCX6.o 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 ) 1.{ { { { { { ) ( M M m m l l k k k q q 0 0 3 3 2 3 g j j x x x x x x x x v v b b b b b b b N N n n n n n n c u u u u u u u u u u u u u u u u u u u u u I I I ! ( ( ^ ^ ^ / / / / / / / / / / / / / / / / / / / / / / / q 0 C Z Z A F G G 6.7.9.9.0.r.r.t.4.u.3.{ { { { { { { { { { / M M M n n n n n n n n n N b b x ~ cXLXLXLXLXLXLXLXkX_ =.=.=.=.=.=.=.D =.m z z f f f f f f c UXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # # 9 M m v l z k k q 8 f bXLXLXLXLXLXLXLXLX6X: < 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 j { { { { { { [ ( ( M M m m l l k k k q q 0 0 3 3 2 f g g j j j x x x x x x x x v b b b b b b b b N N n n n c a.+X`.`.`.`.`.`.`.`.`.`.`.+X+X+X+X+X+X+X+X+X+X+X+X).~ ( ( ( ( ( ( ( ^ ^ ^ / / / / / / / / / / / / / / / / / m 0 C Z Z A F G G 6.7.9.9.0.r.r.t.u.u.u.3.{ { { { { { { { [ n M n n n n n n n n n N N b b b y &XLXLXLXLXLXLXLXLXqX~ -.-.-.-.=.=.=.=.6.m f f f f f f f g c UXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUX+ # # # # # # # # 7 ( M b m j l z h q w pXLXLXLXLXLXLXLXLXKXw.. 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 M 1.{ { { [ ) ( ( M M m m l l k k k q q 0 0 3 3 8 g g g g j j x x x x x x x x x v v b b b b b b N N N N x ] cXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX).I ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( / ( q C Z Z A F G G 6.7.9.9.0.r.r.t.u.u.u.u.2.{ { { { { { { ( n n n n n n n n n N N b b b b x 0.CXLXLXLXLXLXLXLXLX-X~ -.-.-.-.-.-.-.-.7.M f f f f f f f c c UXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # 7 ^ n n M m l k q 0 < (.KXLXLXLXLXLXLXLXLXhXe < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 [ { { { ) ) ( ( M M m m l l k k k q q 0 0 3 3 f g g g g g g j x x x x x x x x x x v v b b b b b b N b u 7XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXCXy.c ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( / l C Z Z A F G G 6.7.9.9.0.r.r.t.u.u.u.u.u.2.{ { { { { ) n n n n n n n n N N b b b b b v u 6XLXLXLXLXLXLXLXLXSXq.) ) [ [ ;.;.;.-.-.7.M f f f f f f g c UXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # 7 { { ) =.S A C V 5 4 = >XLXLXLXLXLXLXLXLXLX'.* < 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 b 1.{ [ [ ) ) ( M M m m m l k k k q q 0 5 3 9 g g g g g g g g j g x x x x x x x x x v v b b b b b b y ).PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjX] n ^ ^ ^ ^ ^ ^ ^ ( ^ ( ( ( ( ( ( ( ( ( ( ( ( ( ^ ^ ( M C Z Z A F G G 6.7.9.9.0.r.r.t.u.u.u.u.u.u.2.{ { { [ n n n n n n n n N b b b b b b b r f.KXLXLXLXLXLXLXLXLX-X~ >.) [ [ [ [ { { { 1.m f f f f f 7 g c UXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUX+ # # # # # # # # ( 3.<.7.G A Z C 0 5 % f hXLXLXLXLXLXLXLXLXMXm o 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 ( ) ) ( ( ( M M m m m l l k k k q q 8 8 8 f z z g g g g g g g j g x x x x x x x x x x v v b b b x 0.nXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX7XY ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( l Z Z A F G G 6.7.9.9.0.r.r.t.u.u.u.u.u.u.u.1.{ { ( n n n n n n N b b b b b b b v x ~ fXLXLXLXLXLXLXLXLXdX` ) >.) [ [ [ [ { { 1.) f f f f f f f c UXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # $ [ 2.<.6.F A Z C 0 5 $ m mXLXLXLXLXLXLXLXLX5X- < 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z g g g g g g g g g g x x x x x x x x x v v v x u qXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX+XR ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ M Z Z A F G G 6.7.9.0.0.r.t.u.u.u.u.u.u.u.u.u.2.) b n n n b b b b b b b b v v v v y -XLXLXLXLXLXLXLXLXkX[ ( ) >.) [ [ [ [ { { ) f f f f f f 7 x c UXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUX+ # # # # # # # @ 1 2.1.7.G S A C V 5 4 . w.JXLXLXLXLXLXLXLXZXM o 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f z z g g g g g g g g j g g x x x x x x x x x x x ).PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX:Xy ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ m m m M M ( ( ( ( ) ) [ [ [ { { { { { { [ { [ n b b b N b b b b b b v v v v v g q.SXLXLXLXLXLXLXLXHXf.! >.) >.) [ [ [ [ { { j f f f f f 7 f c UXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # @ z 2.<.6.G A Z C 0 5 % * -XLXLXLXLXLXLXLXLX1X= < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z z g g g g g g g g j g x x x x x x x x x r *XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXBXv 1 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ n M ^ ^ ^ n n n n n n n n n n n b b b b b b b b b N N b b b b b b b v v v v v v x y 4XLXLXLXLXLXLXLXLX*X! ,.>.) >.) [ [ [ [ 1.M 7 f f f f 7 7 x c UXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUX+ # # # # # # # # # ( 2.7.6.S A Z V 5 5 % w gXLXLXLXLXLXLXLXFX6.o < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z g g g g g g g g g g g x x x x x x x 1 g mXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX2X- $ g ^ M M n n n n n n n n n n n n M M M M M M M M M M M M M n n n n n n n n n n n n n n n n n b b b b b b b b b b v v v v v v v x g _ mXLXLXLXLXLXLXLXqX~ ( ) >.) >.) [ [ [ <.( f f f f f f 7 f c UXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # # 1 2.<.7.G S Z C 0 5 4 # 8.SXLXLXLXLXLXLXKX8.o < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z z g g g g g g g g j j g x x x v f < X {.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXCX6.. < 1 n n M M M M M M M M M M M M M M M M M M M M M M n n n n n n n n n n n n n n n n n n b b b b b b b b b b b v v v v v v v x x x g / BXLXLXLXLXLXLXBX0.( ,.) >.) >.) [ [ [ [ f f f f f 7 7 7 x c UXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # # j 2.9.6.D A Z V 0 5 4 . }.LXLXLXLXLXLXKX8.o < < < 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f f z z g g g g g g g g j j j j x g < < . x mXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX*X: 1 1 < 7 ^ n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n b b N N b b b b b b b b v v v v v v v v x x x v v g / BXLXLXLXLXLXKX).c ,.( ) >.) >.) [ [ [ v 7 f f f 7 7 7 f c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXO # # # # # # # # # M 2.7.6.S Z C V 5 5 % , tXLXLXLXLXLXKX8.& < < < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z g g g g g g g g g j j x 1 < < 1 * f.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgXy 8 8 6 1 < g n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n b N b b b b b b b b b b v v v v v v v v v x x x x x v j g / BXLXLXLXLXLX4Xu ( ( ( ) >.) >.) [ <.( 7 f f 7 7 7 7 7 x c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # # $ [ 1.6.G A Z C 0 5 4 # m MXLXLXLXLXKX8.& < < < < < 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z g g g g g g g g j 7 < < 1 1 6 e 7XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXf.7 q 9 8 6 1 6 n n n n n n n n n n n n n n n n n n n n n n n n n n n b n b N N b b b b b b b b b b b v v v v v x v v v x x x x x j j j j g / BXLXLXLXLXvX[ M ( ( ( ) >.) >.) [ ) f 7 f 7 7 7 7 7 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX+ # # # # # # # # @ 6 1.9.6.S A C V 5 5 4 & w.7X4X4X4X>XG o < < < < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f f z z g g g g g g f < < 1 1 6 9 6 7.ZXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX7Xy k k q 9 8 6 1 z n b b b n n n n n n n n n n n n n b b b b b b b b b b b b b b b b b b b b b b v v v v v x x v v x x x x v x j j j j j j g M '.{.{.{.*Xa.M ( ( ( ( ) >.) >.[ [ j 7 f 7 7 7 7 7 7 c x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # # @ l 2.7.G A Z C 0 5 4 4 1 = * * X X < < < < < < < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f f z z g g g g g 6 < 1 6 8 9 9 q e *XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXCX0.j l l k k 9 9 6 6 b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b v v v v v v v x x x x x x x v v j j j j j j j j j g 7 f g x N ) 6.( ( ( ( ) >.) >.<.b 7 f 7 7 7 7 7 7 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX+ @ # # # # # # # # # ( 0.6.S A Z V 0 0 9 8 3 2 % # # $ < < < < < < < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f z z z z g f 1 1 6 8 9 9 k k k ! kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX&Xc m m l l k k 9 9 8 j N b b b b b b b b b b b b b b b b b b b b b b b b b b b b v v v v v v v v v v v v v v x x x v x x v j j j j j j j j g g g k Z A S D -.;.-.( ( ( ) >.) <.( 7 7 7 7 7 7 7 7 7 x c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ # # # # # # # # # < <.7.G S Z C k k 9 8 3 2 % # $ < < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f f z z g 6 1 6 8 9 9 k k l l g ).PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXcX[ M D m m l l k k q 9 9 v b b b b b b b b b b b b b b b b b b b b b b b b v v v v v v v v x x x v v v v v x x x v x j j j j j j j j j j g g g g g k C A S D =.-.;.[ ( ( ) >.>.) f 7 7 7 7 7 7 7 7 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ # # # # # # # @ 6 <.6.G m l l k 9 8 3 2 % $ $ $ $ < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f f g 7 1 6 9 9 q k k l l m m c >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXg.! =.D D m m m l l k k 9 h b v v v v v v v v v v v v v v v v v v v v v v v v v x x x x x x x x x x x x x x x x j j j j j j j j j j j g g g g z z z h C Z A S D -.;.:.:.) ( >.) g 7 7 7 7 7 7 7 7 f c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXO @ # # # # # # # # @ M 9.M m v z k 9 8 3 2 % $ $ $ $ $ < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f f f 6 6 9 9 k k k l l m m M m { nXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX8X| -.=.=.=.D m m m l l k k 9 x b v v v v v v v v v v v v v v v v v v x x x x x x x x x x x x x x x x x x x j j j j j j j j j j j g g g g g z z z z f f q C A S D =.-.;.:.:.[ >.m 7 7 7 7 7 7 7 7 7 x c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ # # # # # # # # < b ^ M l z k 9 8 3 2 % $ $ $ $ $ $ < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f f 9 6 9 q k k l l l m m D D D c *XCXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBX)._ -.-.-.=.=.D D m m l l k k z v v v v v v v v v v v v v v v v v v v v v v v v v x x x x x x x x x x j j j j j j j j j j j g g g g g g z z z z f f f f q C Z A S =.-.;.:.0.:.( 7 7 7 7 7 7 7 7 6 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ # # # # # # # # # 1 z m l k 9 8 3 2 % $ $ $ $ $ $ $ < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f f 9 q k k l l m m m D D =.=.=.[ 3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.{ ;.;.-.-.-.=.=.D D m m m l k j v v v v v v v v v v v v v v x x x x x x x x x x x x x x x x j j j j j j j j j j j g g g g g g g g g z z z z z f f f f f h V Z A S D =.9.;.( j 7 7 7 7 7 7 7 7 6 f c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ # # # # # # # # # # < 9 k q 8 3 2 % $ $ $ $ $ $ $ < < < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f f h k k l l m m m D D =.=.=.-.[ 2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.1.;.;.;.-.-.-.=.=.D D m m m l x x x x x x x x x x x x x x x x x x x x x x x j j j j j j j j j j j j j j j g g g g g g g g g g g z z z z z f f f f f f f f 0 C Z A D =.M j 7 7 7 7 7 7 7 7 7 6 7 x x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ # # # # # # # # # # # # < 8 8 3 2 $ $ $ $ $ $ $ $ $ < < < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f f f h l l m m m D D =.=.-.-.-.1.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.1.:.;.;.;.;.-.-.=.=.=.D D m x x x x x x x x x x x x x x x x x x j j j j j j j j j j j j j j j j j j j g g g g g g g g g z z z z z f f f f f f f f f f f f 9 V Z A l h 7 7 7 7 7 7 7 7 7 7 7 6 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ # # # # # # # # # # # # $ 2 2 $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < < < 1 < < < < 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f f f l m m D D =.=.=.-.-.-.;.2.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.3.2.:.:.:.;.;.;.-.-.-.=.=.M j j j j j j j j x x x j j j j j j j j j j j j j j j j j j j j j j j j j j g g g f f z g z z z z f f f f f f f f f f f f f f f f 7 0 q h 7 7 7 7 7 7 7 7 7 7 7 6 6 f c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < < < 6 l w : = = - * * > > 1 1 1 1 1 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 f 7 l m D D =.=.=.-.-.-.;.;.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.3.2.:.:.:.:.;.;.;.-.-.-.=.m g j j j j j j j j j j j j j j j j j j j j j j j j j j j g g f f f B e e e r r y s ( b f z f f f f f f f f f f f f f f f f f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 7 x x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < < x ~.jXdX8X:X{.'.(.w.8.G x f e ; : : = = = 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 m =.=.=.=.-.-.-.;.;.:.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.:.:.:.:.:.;.;.;.-.-.M g g g g g g g j j j j g g g g j j j j j j j j f e e r r y y c ^ 7.q.f.(.'.*X:X8XdXkXoX! f f f f f f f f f f f f f f f f f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < < 6 ) ) 0XLXLXLXLXLXLXPXGXCXMXvXhXqX7X:X{.].f.g 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 h =.=.-.-.-.;.;.;.;.0.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.2.:.:.:.:.:.:.:.;.;.) j j j j j j j j j j j j j j j j j j j j j j z x f._.[.:X7XqXfXkXnXCXGXPXLXLXLXLXLXLXhX[ ) j f f f f f f f f f f f f f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 f c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < M <.) ] jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX$X: 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 v -.-.-.;.;.;.;.:.r.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.:.:.:.:.:.:.:.:.;.v z g g g g g g g g g g g g g g g g g g g g g e Q.KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXBX0./ <.( f f f f f f f f f f f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 f c x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ < < < $ 9 <.) >.^ y.ZXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXq.= 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 M ;.;.;.;.:.:.:.2.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.3.t.t.t.0.:.:.:.:.:.:.:.M f g g g g g g g g g g g g g g g g g g g g g f ) mXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGX!.! >.) [ g f f f f f f f f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 7 x x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ < $ < ( [ ) ) >.! _.PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXnXm 1 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 f ) ;.;.:.:.:.:.r.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.0.:.:.:.:.:.:.( f z z z z z z z z z z z z z z z z z z z z z f c gXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKX].! >.) ) [ ) f f f f f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 7 x x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ h <.[ ) ) >.( ! >XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX:X: 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 j :.:.:.:.:.:.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.r.:.:.:.:.:.) f f f f f f f f f f f f f f z z f f f f f f f r -XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX2Xu ( >.) ) [ <.b 7 f f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 g x UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ < ) [ [ ) ) >.( ( ~ gXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXq.> 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 M 0.:.:.:.0.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.r.:.:.:.:.:.j f f f f f f f f f f f f f f f f f f f f f f w w.GXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXbX7.( ( >.) ) [ [ [ f 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 g c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ # v 1.[ [ ) ) >.( ( M 0.BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXjXx 1 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 [ :.:.:.r.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.r.:.:.:.0.( f f f f f f f f f f f f f f f f f f f f f f f y 0XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXHXf.n ( ( >.) ) [ [ 1.( 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 7 c UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ # 1 { { [ [ ) ) >.( ( ( c (.JXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX-X: 1 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 6 v 0.:.:.r.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.:.:.:.[ f f f f f f f f f f f f f f f f f f f f f f f e _.PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX[.c ( ( ( >.) ) [ [ { { g 7 7 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 1 7 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ ( 1.[ [ [ ) ) >.( ( ( M c *XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXGXf.* 1 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 ) 0.:.r.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.0.:.:.j 7 f f f f f f f f f f f f f f f f f f f f f , 9.ZXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX8Xc M ( ( ( >.) ) [ [ [ 1.) 7 7 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 1 6 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX@ @ @ @ @ # # # # # # # # # # # # # # $ $ $ $ $ $ $ ( 1.[ [ [ ) ) >.( ( ( ( M c 1XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXBX7.> 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 6 7 [ 0.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.0.:.v 7 f f f f f f f f f f f f f f f f f f f f f 7 ! jXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXuX^ M ( ( ( ( >.) ) [ [ [ 1.) 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 7 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX# @ @ @ @ # # # # # # # # # # # # # # # $ $ $ $ # 1 [ { [ [ ) ) >.( ( ( ( M m ! rXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXgXr < 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 6 z 0.u.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.u.r.M 7 7 7 7 7 7 f f f f f f f f f f f f f f f f 7 r 7XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXkX( m M ( ( ( ( >.) ) [ [ { [ f 6 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 6 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX# @ @ @ @ # # # # # # # # # # # # # # # $ $ $ $ # 9 1.[ [ ) ) >.( ( ( ( M M v q.FXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX*X= 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 M <.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.) 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ; ).PXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXFXw.x M M ( ( ( ( >.) ) [ [ { j 6 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 6 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX# @ @ @ @ # # # # # # # # # # # # # # # $ $ $ $ # m <.[ ) ) >.( ( ( ( M M D x *XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXHXe.> 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 , ) BXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX'.x D M M ( ( ( ( >.) ) [ <.M 6 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 6 g s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX$ @ @ @ @ # # # # # # # # # # # # # # # $ $ $ # $ ( [ ) ) >.( ( ( ( M M M m c 6XLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXpX; < 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 r tXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXhXb m M M M ( ( ( ( >.) ) [ ) 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 g s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX# @ @ @ @ # # # # # # # # # # # # # # # # $ $ # 9 <.) ) >.( ( ( ( M M M m m / kXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXPX).- 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 : '.LXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXZX8.v m M M M ( ( ( ( >.) ) ) f 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 1 1 f s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< @ @ @ @ # # # # # # # # # # # # # # # # $ $ # z <.) >.( ( ( ( M M M m m l q.{.}.<X5XpXlXNXDXKXLXLXLXLXLXLXLXFXw.> 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 , 7.BXLXLXLXLXLXLXLXKXDXNXkXpX5X3X}.|.w.j S m M M M ( ( ( ( >.) <.j 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 1 1 1 6 g s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< @ @ @ @ @ # # # # # # # # # # # # # # # # # # m <.) ( ( ( ( M M M m m F =.N x x g g j A H J /. X|.3XsXaXNXPXzXM < 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 x tXKXNXaXsX3X|. X/.J H A j g g g x N ( G m m M M M ( ( ( ( >.<.M 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 1 1 1 1 6 g s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX1 @ @ @ @ @ # # # # # # # # # # # # # # # # # $ ( >.( ( ( ( M M M m m =.=.=.D D S A A Z q 8 1 1 > * * > 3 V J l 6 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 z J V 1 > * * > 1 6 8 q Z A A S S D =.=.=.m m M M M ( ( ( ( >.( 7 6 6 6 6 6 6 6 6 6 6 6 6 1 1 1 1 1 1 1 1 6 s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 @ @ @ @ @ # # # # # # # # # # # # # # # # # 1 >.) ( ( ( M M M m D -.=.=.D D S A A Z Z C V 0 5 5 4 % # @   # 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 <   # # % 4 5 5 0 V C Z Z A A S S D =.=.-.D m M M M ( ( ( >.>.h 1 6 6 6 6 6 6 6 6 1 1 1 1 1 1 1 1 1 1 < 6 s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 @ @ @ @ @ # # # # # # # # # # # # # # # # # q >.( ( ( M M M m -.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % # # < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 # # % 2 4 5 5 0 V C Z Z A A S S D =.=.-.=.m M M M ( ( ( >.l 1 6 6 6 6 6 6 1 1 1 1 1 1 1 1 1 1 1 1 < 6 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 @ @ @ @ @ # # # # # # # # # # # # # # # # # m 7.( ( M M m D -.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % # # < < < < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 $ # % 2 4 5 5 0 V C Z Z A A S S D =.=.-.-.D m M M ( ( >.M 6 6 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < 7 s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX# @ @ @ @ @ # # # # # # # # # # # # # # # $ M ( ( M M M -.-.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % # $ < < < < < < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 < # % 2 4 5 5 0 V C Z Z A A S S D =.=.-.-.-.M M M ( ( M 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< @ @ @ @ @ # # # # # # # # # # # # # # # 3 ,.( M M =.;.-.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % # $ < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1 # % 2 4 5 5 0 V C Z Z A A S S D =.=.-.-.;.-.M M ( ( 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < 1 g s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 @ @ @ @ @ @ # # # # # # # # # # # # # # k 6.M M ;.;.-.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % # < < < < < < < < < < < < < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 $ % 2 4 5 5 0 V C Z Z A A S S D =.=.-.-.;.;.( M ,.k 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < 6 x s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 @ @ @ @ @ @ # # # # # # # # # # # # # # m ,.-.;.;.-.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % $ < < < < < < < < < < < < < < < < 1 1 1 1 1 1 6 6 - - - = = = = = = = = = = = = = = = = , 8 1 1 1 6 6 1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 < $ 2 4 5 5 0 V C Z Z A A S S D =.=.-.-.;.;.-.M m 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < < 6 s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 # @ @ @ @ @ # # # # # # # # # # # # # < ( 0.0.9.;.-.=.=.D D S A A Z Z C V 0 5 5 4 2 % $ < < < < < < < < < < < < < < < < < < < 1 1 < 6 '.8X4X4X4X4X4X4X4X4X4X4X4X4X4X4X4X4X4X7X+Xf 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 < $ 2 4 5 5 0 V C Z Z A A S S D =.=.-.;.9.0.0.( 8 1 1 1 1 1 1 1 1 1 1 1 1 1 < < < < 7 s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< @ @ @ @ @ # # # # # # # # # # # # # < 9 k m =.=.=.6.6.D S S A Z Z C V 0 5 5 4 2 % $ $ $ < < < < < < < < < < < < < < < < < < < <   P KXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXKX/.  < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 % 2 4 5 5 0 V C Z Z A A S D G 6.=.=.=.M m z 8 1 1 1 1 1 1 1 1 1 1 < < < < < < 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 # @ @ @ @ @ # # # # # # # # # # # # @ @ # $ < 3 8 q q k k Z Z Z C C V 5 5 4 2 $ $ $ $ $ $ $ < < < < < < < < < < < < < < < < $ $ X /.DXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLXLX}.. 2 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 % % 4 5 5 0 C C Z Z Z Z k k k k 9 6 1 < < < < 1 1 1 1 1 1 < < < < < < < < < 7 p s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX< @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # $ < 2 3 5 5 5 5 4 2 $ $ $ $ $ $ $ $ $ $ < < < < < < < < < < < < 2 3 3 5 . e.HXLXLXLXLXLXLXLXLXLXLXLXLXLXLXaX7 5 0 0 0 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 % 4 5 5 0 0 8 8 3 1 1 1 1 < < < 1 1 1 1 1 1 1 < < < < < < < < < < < < 1 g s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < < < < < < 0 0 0 0 q 6 w.;X&X&X&X&X&X&X*X*X*X*X*X*X&X8.8 C q C C q 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < < < < < < < < < < < < < < < 6 p s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXa $ @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ < < < < $ < q Z Z Z Z Z Z ) O.o.o.......' ' ' ' ' ' ' Q M Z A A A A A q < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < < < < < < < < < < < < < < < < < < < < 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 # @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ < $ 8 A A A A S S S 0.t.r.r.2.2.2.2.2.2.2.1.1.1.1.) S S S S S S S q < 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < 1 1 1 < < < < < < < < < < < < < < < < < < < < < < < < < < < < < 6 p s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp < @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 3 S S D D D D D D r.t.r.r.2.2.2.2.2.2.2.1.1.1.1.[ D D D D D D D D 8 < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < $ 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 $ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ l 6.=.=.=.=.=.=.-.t.t.r.r.2.2.2.2.2.2.2.1.1.1.1.{ =.=.=.=.=.=.=.-.=.9 < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < $ 1 7 p s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX7 $ @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 8 -.9.-.-.-.;.;.0.t.t.r.r.2.2.2.2.2.2.2.1.1.1.1.{ ;.;.;.;.-.-.-.;.9.m < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < $ < 7 s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX6 # @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ # 1 ( 0.;.;.:.;.0.t.t.r.r.2.2.2.2.2.2.2.1.1.1.1.{ :.;.;.;.;.;.0.;.h < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < $ < 6 p s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp 1 @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ # $ m 0.:.:.:.r.t.t.r.r.2.2.2.2.2.2.2.1.1.1.1.{ { :.:.:.:.0.) 6 $ < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < $ $ $ 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf < @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ # h :.:.:.r.t.t.r.r.2.2.2.2.2.2.2.1.1.1.1.{ { :.:.:.r.( 1 $ < < < < < < < < < < < < < < < < < < < < < < < < < < < < $ < $ $ $ $ $ $ $ $ $ 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf < @ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ # 1 [ r.t.t.t.t.t.2.2.2.2.2.2.2.1.1.1.1.{ { :.:.:.l $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ < < $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf 1 # @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ # 1 ( r.r.r.t.t.3.t.t.t.3.3.2.2.2.2.2.{ { 0.) 6 # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 1 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp 7 $ @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ # $ < 1 1 6 8 9 h z z l m M M ( ( ) ) [ h $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ < 7 p s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXf < # @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ # # # # # # # # # # # # # # # $ $ $ $ # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ # $ 1 f s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp 6 $ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 6 f s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs 7 < # @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ # $ 1 7 p s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXp 7 < # @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ # # $ < 7 p s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs a 6 < $ # @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ # # # $ < < 6 f s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs p 7 < $ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ # $ $ $ $ $ $ $ $ $ $ # # # # $ 1 6 a s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs p f 6 < $ # @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ < 6 f p s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs p f 7 1 < # # @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ < 1 7 f p s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs s p f 7 6 < $ $ # # @ @ @ @ @ # # # # # # # # # # # # # # # # # # # # # # # # # # $ < < 6 7 f p s s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs s s p g f 7 6 1 1 < $ $ $ # # # # # # # # # # # # $ $ $ < < 1 1 6 7 f f p s s s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\",\n\"UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXs s s s s s p p p p f f f f f f f a p p p p s s s s s s s UXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUX\"\n};\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/icons/alt_launcher.xpm",
    "content": "/* XPM */\r\nstatic char * icon48_xpm[] = {\r\n\"48 48 256 2\",\r\n\"  \tc #4B4B3B3B9090\",\r\n\". \tc #0D0D0E0E5454\",\r\n\"X \tc #11110E0E5B5B\",\r\n\"o \tc #17170F0F6363\",\r\n\"O \tc #1D1D13136969\",\r\n\"+ \tc #212114146C6C\",\r\n\"@ \tc #252514147171\",\r\n\"# \tc #282811116C6C\",\r\n\"$ \tc #26260D0D6363\",\r\n\"% \tc #22220B0B5E5E\",\r\n\"& \tc #1C1C0B0B5A5A\",\r\n\"* \tc #1C1C0B0B5252\",\r\n\"= \tc #1B1B05055353\",\r\n\"- \tc #161606064D4D\",\r\n\"; \tc #161605054949\",\r\n\": \tc #111104044848\",\r\n\"> \tc #131304044545\",\r\n\", \tc #131305054242\",\r\n\"< \tc #141410105E5E\",\r\n\"1 \tc #2C2C15157373\",\r\n\"2 \tc #2B2B1B1B7575\",\r\n\"3 \tc #343416167272\",\r\n\"4 \tc #313113136E6E\",\r\n\"5 \tc #222209095757\",\r\n\"6 \tc #1B1B06064D4D\",\r\n\"7 \tc #15150B0B4242\",\r\n\"8 \tc #13130C0C5555\",\r\n\"9 \tc #2E2E1B1B7878\",\r\n\"0 \tc #33331F1F7C7C\",\r\n\"q \tc #343418187878\",\r\n\"w \tc #3B3B1C1C7575\",\r\n\"e \tc #2E2E10106767\",\r\n\"r \tc #1B1B07074747\",\r\n\"t \tc #18180B0B4646\",\r\n\"y \tc #151513136262\",\r\n\"u \tc #1A1A15156464\",\r\n\"i \tc #34341F1F7777\",\r\n\"p \tc #40401E1E8080\",\r\n\"a \tc #42421B1B7A7A\",\r\n\"s \tc #3B3B15157474\",\r\n\"d \tc #2B2B0B0B5B5B\",\r\n\"f \tc #222207075252\",\r\n\"g \tc #373727277A7A\",\r\n\"h \tc #474724248484\",\r\n\"j \tc #393915156E6E\",\r\n\"k \tc #373711116A6A\",\r\n\"l \tc #343413136363\",\r\n\"z \tc #232319196E6E\",\r\n\"x \tc #292919197070\",\r\n\"c \tc #3C3C2C2C8282\",\r\n\"v \tc #444431318585\",\r\n\"b \tc #494934348A8A\",\r\n\"n \tc #505026268A8A\",\r\n\"m \tc #3D3D1B1B6E6E\",\r\n\"M \tc #31310E0E5C5C\",\r\n\"N \tc #2B2B0D0D5353\",\r\n\"B \tc #222207074A4A\",\r\n\"V \tc #52523C3C9292\",\r\n\"C \tc #58583C3C9494\",\r\n\"Z \tc #5D5D44449797\",\r\n\"A \tc #5C5C2E2E9292\",\r\n\"S \tc #676733339595\",\r\n\"D \tc #424228287575\",\r\n\"F \tc #29290A0A4F4F\",\r\n\"G \tc #6C6C4A4A9E9E\",\r\n\"H \tc #72725454A7A7\",\r\n\"J \tc #8C8C6D6DB2B2\",\r\n\"K \tc #343424246E6E\",\r\n\"L \tc #3A3A23236A6A\",\r\n\"P \tc #3A3A1C1C6767\",\r\n\"I \tc #24240A0A4B4B\",\r\n\"U \tc #151518186161\",\r\n\"Y \tc #76766F6FA5A5\",\r\n\"T \tc #ADAD9191CCCC\",\r\n\"R \tc #98988989D3D3\",\r\n\"E \tc #45453B3B8686\",\r\n\"W \tc #3C3C35357979\",\r\n\"Q \tc #363631317575\",\r\n\"! \tc #32322D2D6B6B\",\r\n\"~ \tc #323229296363\",\r\n\"^ \tc #30301F1F6262\",\r\n\"/ \tc #323218185E5E\",\r\n\"( \tc #272707074B4B\",\r\n\") \tc #202028286C6C\",\r\n\"_ \tc #1E1E1D1D6868\",\r\n\"` \tc #9A9A8282BBBB\",\r\n\"' \tc #C8C8B3B3D3D3\",\r\n\"] \tc #B3B3AFAFE7E7\",\r\n\"[ \tc #84847272C6C6\",\r\n\"{ \tc #58585757A3A3\",\r\n\"} \tc #3F3F3C3C8A8A\",\r\n\"| \tc #3B3B3A3A8484\",\r\n\" .\tc #414139397D7D\",\r\n\"..\tc #3D3D39397A7A\",\r\n\"X.\tc #37372E2E6E6E\",\r\n\"o.\tc #2C2C21215A5A\",\r\n\"O.\tc #2E2E1B1B5B5B\",\r\n\"+.\tc #F5F5EFEFF5F5\",\r\n\"@.\tc #656566669A9A\",\r\n\"#.\tc #47474B4B8E8E\",\r\n\"$.\tc #3C3C44447B7B\",\r\n\"%.\tc #444442428080\",\r\n\"&.\tc #45453E3E8181\",\r\n\"*.\tc #40403C3C8181\",\r\n\"=.\tc #3D3D33337474\",\r\n\"-.\tc #3B3B30306E6E\",\r\n\";.\tc #38382D2D6969\",\r\n\":.\tc #303026265D5D\",\r\n\">.\tc #2C2C15155A5A\",\r\n\",.\tc #1F1F1C1C7070\",\r\n\"<.\tc #25251E1E7171\",\r\n\"1.\tc #59595C5C9191\",\r\n\"2.\tc #4D4D53538989\",\r\n\"3.\tc #4C4C49498484\",\r\n\"4.\tc #484845458585\",\r\n\"5.\tc #494941418585\",\r\n\"6.\tc #494940408181\",\r\n\"7.\tc #2F2F1C1C5353\",\r\n\"8.\tc #2B2B28287676\",\r\n\"9.\tc #323231317F7F\",\r\n\"0.\tc #545452528B8B\",\r\n\"q.\tc #51514E4E8989\",\r\n\"w.\tc #4E4E4B4B8C8C\",\r\n\"e.\tc #4C4C47478686\",\r\n\"r.\tc #46463D3D7E7E\",\r\n\"t.\tc #434336367A7A\",\r\n\"y.\tc #2B2B13135555\",\r\n\"u.\tc #47473D3D8D8D\",\r\n\"i.\tc #575757578E8E\",\r\n\"p.\tc #48483E3E7F7F\",\r\n\"a.\tc #46463A3A7D7D\",\r\n\"s.\tc #424235357575\",\r\n\"d.\tc #404034347171\",\r\n\"f.\tc #BFBFCBCBFAFA\",\r\n\"g.\tc #B8B8A8A8DDDD\",\r\n\"h.\tc #5E5E60609292\",\r\n\"j.\tc #565655558C8C\",\r\n\"k.\tc #4B4B44448282\",\r\n\"l.\tc #454539397B7B\",\r\n\"z.\tc #434338387878\",\r\n\"x.\tc #3F3F32326D6D\",\r\n\"c.\tc #3D3D30306969\",\r\n\"v.\tc #3A3A2E2E6363\",\r\n\"b.\tc #36362A2A5C5C\",\r\n\"n.\tc #343424245555\",\r\n\"m.\tc #30301E1E4D4D\",\r\n\"M.\tc #49493C3C8282\",\r\n\"N.\tc #5E5E4F4F8C8C\",\r\n\"B.\tc #56563B3B8B8B\",\r\n\"V.\tc #545407078585\",\r\n\"C.\tc #424234347272\",\r\n\"Z.\tc #9797A4A4F7F7\",\r\n\"A.\tc #444436367676\",\r\n\"S.\tc #7D7D7979D5D5\",\r\n\"D.\tc #464640408A8A\",\r\n\"F.\tc #44444B4B8282\",\r\n\"G.\tc #414107077777\",\r\n\"H.\tc #71716161C1C1\",\r\n\"J.\tc #303039397979\",\r\n\"K.\tc #8E8E8E8EE6E6\",\r\n\"L.\tc #404033338B8B\",\r\n\"P.\tc #4A4A45458C8C\",\r\n\"I.\tc #46463A3A8080\",\r\n\"U.\tc #363629295454\",\r\n\"Y.\tc #303022224848\",\r\n\"T.\tc #424237377575\",\r\n\"R.\tc #2E2E1D1D6363\",\r\n\"E.\tc #79798383EAEA\",\r\n\"W.\tc #74747B7BE4E4\",\r\n\"Q.\tc #6D6D7676D6D6\",\r\n\"!.\tc #6A6A7171CECE\",\r\n\"~.\tc #66666969C6C6\",\r\n\"^.\tc #62626565BCBC\",\r\n\"/.\tc #5F5F6060B5B5\",\r\n\"(.\tc #5B5B5B5BACAC\",\r\n\").\tc #535353539898\",\r\n\"_.\tc #4F4F4F4FA4A4\",\r\n\"`.\tc #54544D4DA4A4\",\r\n\"'.\tc #323204046B6B\",\r\n\"].\tc #303035357979\",\r\n\"[.\tc #313122224343\",\r\n\"{.\tc #5A5A5B5BB7B7\",\r\n\"}.\tc #484846468080\",\r\n\"|.\tc #454541417575\",\r\n\" X\tc #4B4B31318282\",\r\n\".X\tc #47473C3C8484\",\r\n\"XX\tc #3E3E35356E6E\",\r\n\"oX\tc #2F2F26264040\",\r\n\"OX\tc #2B2B23233A3A\",\r\n\"+X\tc #262619195C5C\",\r\n\"@X\tc #252515155A5A\",\r\n\"#X\tc #55555151B3B3\",\r\n\"$X\tc #3C3C2D2D5D5D\",\r\n\"%X\tc #39392F2F5656\",\r\n\"&X\tc #37372D2D5050\",\r\n\"*X\tc #25251F1F3030\",\r\n\"=X\tc #24241D1D4343\",\r\n\"-X\tc #202013135656\",\r\n\";X\tc #41413B3B6C6C\",\r\n\":X\tc #444442429696\",\r\n\">X\tc #212100005E5E\",\r\n\",X\tc #444436367272\",\r\n\"<X\tc #444436366F6F\",\r\n\"1X\tc #424236366868\",\r\n\"2X\tc #3F3F34346161\",\r\n\"3X\tc #3C3C32325A5A\",\r\n\"4X\tc #34342A2A4A4A\",\r\n\"5X\tc #21211B1B2121\",\r\n\"6X\tc #22221C1C6363\",\r\n\"7X\tc #2D2D01015E5E\",\r\n\"8X\tc #20201B1B2525\",\r\n\"9X\tc #49492F2F7B7B\",\r\n\"0X\tc #434334346C6C\",\r\n\"qX\tc #323229294545\",\r\n\"wX\tc #1C1C10104F4F\",\r\n\"eX\tc #222217176363\",\r\n\"rX\tc #37371E1E6B6B\",\r\n\"tX\tc #424232326E6E\",\r\n\"yX\tc #444433336969\",\r\n\"uX\tc #424233336565\",\r\n\"iX\tc #1E1E1A1A1E1E\",\r\n\"pX\tc #161601014C4C\",\r\n\"aX\tc #1C1C11115454\",\r\n\"sX\tc #252503035B5B\",\r\n\"dX\tc #414131316A6A\",\r\n\"fX\tc #22221F1F7878\",\r\n\"gX\tc #272724246767\",\r\n\"hX\tc #1D1D16165E5E\",\r\n\"jX\tc #131305055151\",\r\n\"kX\tc #40402F2F6464\",\r\n\"lX\tc #111107074E4E\",\r\n\"zX\tc #0C0C05054B4B\",\r\n\"xX\tc #22221E1E5757\",\r\n\"cX\tc #1A1A0D0D4D4D\",\r\n\"vX\tc #16160B0B4D4D\",\r\n\"bX\tc #060604044747\",\r\n\"nX\tc #040403034343\",\r\n\"mX\tc #3B3B27276565\",\r\n\"MX\tc #0E0E03034141\",\r\n\"NX\tc #111106064A4A\",\r\n\"BX\tc #0E0E04044646\",\r\n\"VX\tc #111105053B3B\",\r\n\"CX\tc #0D0D01013A3A\",\r\n\"ZX\tc #030305053F3F\",\r\n\"AX\tc #0F0F0F0F4C4C\",\r\n\"SX\tc #020207073B3B\",\r\n\"DX\tc #0D0D03034646\",\r\n\"FX\tc #0B0B02023F3F\",\r\n\"GX\tc #0D0D02023434\",\r\n\"HX\tc #0A0A0E0E4444\",\r\n\"JX\tc #161614145252\",\r\n\"KX\tc #0B0B04044646\",\r\n\"LX\tc #0A0A03034444\",\r\n\"PX\tc #1D1D21215757\",\r\n\"IX\tc #090910104040\",\r\n\"UX\tc #18181E1E5353\",\r\n\"                                                                                                \",\r\n\"  . . . . X X o o o o O + + @ @ @ @ @ @ @ # # # # # # $ $ % % & & & & * = - - - ; : > > , , ,   \",\r\n\"  . . X X < < o o O O + @ 1 2 2 1 1 1 1 1 1 1 1 3 4 # # $ $ $ % % % 5 = = 6 6 - ; ; > > , , 7   \",\r\n\"  . 8 < < < o O O + @ @ 2 9 9 0 0 q q q q q q q w 3 4 4 e e $ $ $ $ % 5 = = 6 6 6 ; ; > > r t   \",\r\n\"  . X < y u O O + @ 1 2 i 0 0 p p p p p p p a a p a s 3 4 4 e e e e d 5 5 f f 6 6 6 ; ; r r t   \",\r\n\"  X < y u O + + @ 2 9 0 g p p h h h h h h h p h h a a s s j k k j l d d 5 5 f f 6 6 r r r r r   \",\r\n\"  X < y O z x x 9 0 g c v b n n n n n n n n n n n h a a s s j j m l M d d N f f B B B B r r r   \",\r\n\"  < y u + z 2 0 c c b V C Z C C A A A A A S S S n h D w w m m m m k l M d d N f F F F B r r r   \",\r\n\"  < y O z z 9 c b V Z G H H H G S G G J J H V v c g g K K K K L P l l l M M N N N N I B B r r   \",\r\n\"  U u + z x i v C H Y J J J J H J T R H V E W W Q Q Q Q ! ! ! ~ ^ ^ / / M M M M M N ( B B r r   \",\r\n\"  ) _ z x 9 g b Z Y ` ' ' ' T T ] [ { } |  .........W W Q Q X.! ~ ~ o.O./ / / / N F ( B B B r   \",\r\n\"  ) ) z x i c V G J ' +.+.+.+.] [ @.#.$.%.%.%.&.*. . .....W =.-.X.;.~ :.o.O.^ >.N F ( B B B B   \",\r\n\"  ) ,.<.2 g v C H J ' +.+.+.+.T Y 1.2.3.4.4.4.5.6.&.&. . ...W =.=.-.;.~ :.o.7.>.N F F ( B I I   \",\r\n\"  ) ,.<.8.9.b C H J T +.+.+.' J @.1.0.q.q.w.e.4.5.6.&.r. . .t.W =.=.-.;.~ :.o.7.y.N F ( ( I I   \",\r\n\"  8.8.8.9.| u.C G J T +.+.' ` Y @.1.i.0.q.q.e.e.5.6.p.r.a. .t.t.s.d.d.-.;.~ :.7.7.y.F F ( I I   \",\r\n\"  9.c c c v b A S H ' f.g.` Y @.h.1.i.j.0.q.q.e.k.6.p.r.a.l.t.z.s.s.d.x.c.v.b.n.m.7.N F F F I   \",\r\n\"  <.g M.N.B.B.n V.J f.R J @.h.h.1.i.i.j.j.0.q.3.k.6.p.r.a.l.l.z.s.C.d.x.x.c.v.b.n.m.y.N F F F   \",\r\n\"  + x i v B.Z Z G g.Z.[ @.2.i.i.j.j.j.j.j.0.q.3.k.6.p.p.a.l.l.A.s.C.C.d.x.c.v.b.n.m.7.y.N N y.  \",\r\n\"  O # 3 w p n Z ` f.S.H D.F.q.0.0.0.0.j.0.q.q.3.k.6.p.r.a.a.l.A.s.s.C.d.x.x.c.v.b.n.m.y.y.y.y.  \",\r\n\"  O # 4 s a G.V.T Z.H.V J.%.e.w.q.0.0.0.0.q.q.e.k.6.p.r.a.a.l.z.A.s.C.d.d.x.c.v.b.n.m.7.>.y.y.  \",\r\n\"  O # 4 s w G.A f.K.H L...4.P.w.w.w.q.q.q.q.e.e.5.6.M.I.I.a.a.l.z.A.s.d.d.x.c.v.v.U.Y.7.O.>.y.  \",\r\n\"  $ # 4 3 s G.G f.S.Z 9.*.D.P.P.w.w.w.w.w.e.e.5.5.M.M.I.I.a.a.l.z.T.s.d.d.x.x.c.v.U.Y.m.R.>.>.  \",\r\n\"  E.E.W.W.W.W.E.Z.E.W.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.!.!.!.!.!.~.~.~.~.~.~.^.^.^.^.^./././.(.{ { )._.`._.  \",\r\n\"  + # 3 w s '.` f.H.V ].*.D.P.P.P.P.P.P.P.5.5.5.M.M.M.I.I.a.l.z.z.T.T.s.d.d.x.c.v.U.Y.[.^ O.>.  \",\r\n\"  ~.~.~.~.~.~.K.Z.S.~.{.^.^.^.^.^.^.^.^././././././.(.(.(.(.(.(.{ { { { { ).).).w.w.}.|.P.u.}   \",\r\n\"   .I.6. X X XT f.H.b ].*.E D.D.D.D.5.5..X.XM.M.I.I.a.a.l.l.z.z.T.T.T.d.XXx.c.v.b.U.oXOXR.+X@X  \",\r\n\"  E.E.E.W.W.W.K.Z.E.W.Q.Q.Q.Q.Q.Q.Q.Q.!.!.!.!.!.!.~.~.~.~.~.~.^.^.^.^.^./././.(.{ { ).).#X_._.  \",\r\n\"  & % $ e '.= H f.H.b 8.W *.E E E .X.X.XI.I.I.I.a.a.l.l.z.z.T.T.T.C.XXXXc.v.$X%X&XY.*X=X2 @X-X  \",\r\n\"  {.{.{.{.{.#X~.Z.W.~.{.{./././././././././.(.(.(.(.(.(.(.{ { { { { { ).).).w.w.3.}.;X%.:X} }   \",\r\n\"  & & % $ e >XV.f.S.C K X.W t. . .l.l.t.t.t.t.A.A.A.,X,X,X,X,X<X;X1X1X2X3X%X&X4XoX*X5Xo.6X-X-X  \",\r\n\"  & & % $ $ >X7X` Z.Z D ! =.=.s.t.t.t.A.A.s.A.,X,X,X,X<X<X<X<X;X1X2X2X3X%X&X4XoXOX8X5X<.@X-X-X  \",\r\n\"  8 & & $ e K 9XJ f.^. XK X.=.=.s.s.s.s.s.C.C.C.C.<X0X0X0X1X1X1X2X2X3X%X&X4XqXOX*X8X=X<.-X-XwX  \",\r\n\"  8 & eXK k.@.M. Xg.E.B.rX~ -.d.d.C.C.C.C.C.tX0X0X0XyXyX1X1XuX2X2X3X%X&X4XqXoXOX8XiX6XeX-X-XwX  \",\r\n\"  6XQ h.Y N.K e pXB.f./.9Xo.;.-.x.d.tXtXtXtXtX0X0XyXyXyXuXuX2X2X3X%X&X4XqXoXOX*XiX=X_ aX-XaXwX  \",\r\n\"  Y Y  .R.@X% sX= 7XT Z.V P :.;.c.x.x.x.tXdXdXdXyXyXuXuX2X2X3X3X%X&X4XqXoXOX*X8X*XfXaXaXaXwXwX  \",\r\n\"  gXhX& * & 5 5 sXjXa ] S.9X/ ~ v.c.dXdXdXdXdXuXuXuXkX2X2X3X%X%X&X4XqXoXOX*X8XiX<.hXwXwXaXwXwX  \",\r\n\"  8 lXlXjX= * 5 5 = zX9X] H.D 7.b.v.v.kXc.kXkXkXkXkX2X$X3X%X&X&X4XqXoXOX*X8XiXxXhXwXcXcXwXwXwX  \",\r\n\"  zXzXlXlXjX= = f f sXD Y ] ~.D 7.n.b.v.v.kXkXkXkX$X$X%X%X&X4XqXoXoXOX*X8X5XgXu cXvXvXcXcXwXwX  \",\r\n\"  bXbXzXlXlX- = * @XX.h.e D T S.D n.m.b.$X$X$X$X$X%X%X&X&X4XqXoXOX*X8X8X*X<.hXvX; ; vXvXvXcXwX  \",\r\n\"  nXbXzXzXlXlX- -XX.Y R.pXpXP J K.Z mXm.n.U.U.U.U.U.4X4XY.oXOX*X8X8X8X=X,.aXvX; > > > t t t cX  \",\r\n\"  nXbXbXzXzXlXaXXXY +Xf = f = 7XtXR R   mXn.Y.[.[.[.[.OX*X*X8X5X*X=X,.u vXvX; > > MXMX, 7 t t   \",\r\n\"  nXnXnXbXzXvX-.Y +XcX6 6 = = = d L B.G H `.X.:.7.m.=X=X=X=X=X6X,.u cXvXNX: BX> MXVXCXVX7 7 7   \",\r\n\"  ZXZXnXbXAXgX@.+XvX; - - - - * @XR.>.sX>.R.i 0 x eXeXeXeXO hXaXcXvXNX: BXMXMXMXVXCXCXCXVX7 7   \",\r\n\"  SXZXZXAXgXN.aXNX: : NXNXNX- * +X+X* 6 6 6 * * * * * * * vXvX- NX: DXBXMXMXFXCXCXCXCXGXVXVX7   \",\r\n\"  SXSXHXgX0.JXKXLXKXKXDX: : NX* @X-X- - - - - - - - - - - NX: DXDXDXMXMXFXFXCXCXCXCXGXGXGXVXVX  \",\r\n\"  SXHXPX3.JXnXnXnXnXbXLXKXKXNXaX-XvX: : NX: : : : : : : BXDXDXLXMXMXFXFXCXCXCXCXGXGXGXGXGXGXGX  \",\r\n\"  IXUX$.AXZXZXZXZXnXnXnXLXLXNXJXvXBXDXBXBXBXBXDXDXDXDXLXDXLXLXFXFXFXFXCXCXCXCXGXGXGXGXGXGXGXGX  \",\r\n\"                                                                                                \"};\r\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n\n   <extension\n         id=\"application\"\n         point=\"org.eclipse.core.runtime.applications\">\n      <application>\n         <run\n               class=\"com.subgraph.vega.application.Application\">\n         </run>\n      </application>\n   </extension>\n   <extension\n         id=\"product\"\n         point=\"org.eclipse.core.runtime.products\">\n      <product\n            application=\"com.subgraph.vega.application.application\"\n            name=\"Subgraph Vega\">\n         <property\n               name=\"windowImages\"\n               value=\"icons/16x16Vega.png,icons/32x32Vega.png,icons/48x48Vega.png,icons/64x64Vega.png,icons/128x128Vega.png\">\n         </property>\n         <property\n               name=\"appName\"\n               value=\"Subgraph Vega\">\n         </property>\n         <property\n               name=\"aboutImage\"\n               value=\"icons/vega_small.png\">\n         </property>\n         <property\n               name=\"aboutText\"\n               value=\"Copyright 2012 Subgraph Technologies, Inc. http://www.subgraph.com\">\n         </property>\n         <property\n               name=\"preferenceCustomization\"\n               value=\"plugin_customization.ini\">\n         </property>\n      </product>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <category\n            id=\"com.subgraph.vega.commands.category.workspaces\"\n            name=\"Workspaces\">\n      </category>\n      <command\n            categoryId=\"com.subgraph.vega.commands.category.workspaces\"\n            id=\"com.subgraph.vega.commands.newWorkspace\"\n            name=\"New Workspace\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.category.workspaces\"\n            id=\"com.subgraph.vega.commands.switchWorkspace\"\n            name=\"Switch Workspace\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.category.workspaces\"\n            id=\"com.subgraph.vega.commands.resetWorkspace\"\n            name=\"Reset Workspace\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.commands.browseHelp\"\n            name=\"Open Online Help\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.commands.browseSubgraph\"\n            name=\"Open Subgraph Website \">\n      </command>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"com.subgraph.vega.application.workspaces.NewWorkspaceHandler\"\n            commandId=\"com.subgraph.vega.commands.newWorkspace\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.application.workspaces.SwitchWorkspaceHandler\"\n            commandId=\"com.subgraph.vega.commands.switchWorkspace\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.application.workspaces.ResetWorkspaceHandler\"\n            commandId=\"com.subgraph.vega.commands.resetWorkspace\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.workspaceLockState\">\n               <equals\n                     value=\"unlocked\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.application.about.AboutHandler\"\n            commandId=\"org.eclipse.ui.help.aboutAction\">\n         <activeWhen>\n            <count\n                  value=\"*\">\n            </count></activeWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.application.about.BrowseHelpHandler\"\n            commandId=\"com.subgraph.vega.commands.browseHelp\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.application.about.BrowseSubgraphHandler\"\n            commandId=\"com.subgraph.vega.commands.browseSubgraph\">\n      </handler>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectiveExtensions\">\n      <perspectiveExtension\n            targetID=\"*\">\n         <view\n               closeable=\"false\"\n               id=\"com.subgraph.vega.views.VegaConsole\"\n               minimized=\"false\"\n               ratio=\"0.5\"\n               relationship=\"fast\">\n         </view>\n      </perspectiveExtension>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"menu:file?before=vega.quit\">\n         <command\n               commandId=\"com.subgraph.vega.commands.resetWorkspace\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"menu:help?before=vega.help\">\n         <command\n               commandId=\"com.subgraph.vega.commands.browseHelp\"\n               style=\"push\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.commands.browseSubgraph\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.services\">\n      <sourceProvider\n            provider=\"com.subgraph.vega.application.workspaces.WorkspaceLockStateSourceProvider\">\n         <variable\n               name=\"vega.workspaceLockState\"\n               priorityLevel=\"workbench\">\n         </variable>\n      </sourceProvider>\n   </extension>\n <extension\n       point=\"org.eclipse.ui.views\">\n    <view\n          class=\"com.subgraph.vega.application.console.VegaConsoleView\"\n          icon=\"icons/console.png\"\n          id=\"com.subgraph.vega.views.VegaConsole\"\n          name=\"Console\"\n          restorable=\"true\">\n    </view>\n </extension>\n <extension\n       point=\"org.eclipse.ui.preferencePages\">\n    <page\n          class=\"com.subgraph.vega.application.preferences.ProxyPreferencePage\"\n          id=\"com.subgraph.vega.preferences.general\"\n          name=\"General\">\n    </page>\n    <page\n          category=\"com.subgraph.vega.preferences.general\"\n          class=\"com.subgraph.vega.application.preferences.UpdatesPreferencePage\"\n          id=\"com.subgraph.vega.preferences.update\"\n          name=\"Updates\">\n    </page>\n </extension>\n <extension\n       point=\"org.eclipse.core.runtime.preferences\">\n    <initializer\n          class=\"com.subgraph.vega.application.preferences.GeneralPreferenceInitializer\">\n    </initializer>\n </extension>\n <extension\n       point=\"org.eclipse.ui.bindings\">\n    <scheme\n          id=\"vega.scheme\"\n          name=\"vega.scheme\">\n    </scheme>\n </extension>\n\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/plugin_customization.ini",
    "content": "org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false\norg.eclipse.ui/KEY_CONFIGURATION_ID=vega.scheme"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/Activator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application;\n\nimport org.apache.http.HttpHost;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.jface.util.IPropertyChangeListener;\nimport org.eclipse.jface.util.PropertyChangeEvent;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.application.preferences.IPreferenceConstants;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.application\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\tprivate ServiceTracker<IConsole, IConsole> consoleTracker;\n\tprivate ServiceTracker<IPathFinder, IPathFinder> pathFinderTracker;\n\tprivate ServiceTracker<IHttpRequestEngineFactory, IHttpRequestEngineFactory> httpRequestEngineFactoryServiceTracker;\n\t\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t\t\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t\t\n\t\tconsoleTracker = new ServiceTracker<IConsole, IConsole>(context, IConsole.class.getName(), null);\n\t\tconsoleTracker.open();\n\t\t\n\t\tpathFinderTracker = new ServiceTracker<IPathFinder, IPathFinder>(context, IPathFinder.class.getName(), null);\n\t\tpathFinderTracker.open();\n\n\t\thttpRequestEngineFactoryServiceTracker = new ServiceTracker<IHttpRequestEngineFactory, IHttpRequestEngineFactory>(context, IHttpRequestEngineFactory.class.getName(), null);\n\t\thttpRequestEngineFactoryServiceTracker.open();\n\n\t\tgetPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\t\t\tconfigureSocks();\n\t\t\t\tconfigureHttpProxy();\n\t\t\t}\n\t\t});\n\t\tconfigureSocks();\n\t\tconfigureHttpProxy();\n\t}\n\n\tprivate void configureSocks() {\n\t\tfinal IPreferenceStore store = getPreferenceStore();\n\t\tif(!store.getBoolean(IPreferenceConstants.P_SOCKS_ENABLED)) {\n\t\t\tSystem.getProperties().remove(\"socksProxyHost\");\n\t\t\tSystem.getProperties().remove(\"socksProxyPort\");\n\t\t\tSystem.getProperties().remove(\"socksEnabled\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tSystem.setProperty(\"socksProxyHost\", store.getString(IPreferenceConstants.P_SOCKS_ADDRESS));\n\t\tSystem.setProperty(\"socksProxyPort\", store.getString(IPreferenceConstants.P_SOCKS_PORT));\n\t\tSystem.setProperty(\"socksEnabled\", \"true\");\n\t}\n\t\n\tprivate void configureHttpProxy() {\n\t\tfinal IPreferenceStore store = getPreferenceStore();\n\t\tfinal IHttpRequestEngineFactory requestEngineFactory = getHttpRequestEngineFactoryService();\n\n\t\tif (store.getBoolean(IPreferenceConstants.P_PROXY_ENABLED)) {\n\t\t\tfinal String proxyAddress = store.getString(IPreferenceConstants.P_PROXY_ADDRESS);\n\t\t\tfinal Integer proxyPort = store.getInt(IPreferenceConstants.P_PROXY_PORT);\n\t\t\trequestEngineFactory.setProxy(new HttpHost(proxyAddress, proxyPort));\n\t\t} else {\n\t\t\trequestEngineFactory.setProxy(null);\n\t\t}\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\t/**\n\t * Returns an image descriptor for the image file at the given\n\t * plug-in relative path\n\t *\n\t * @param path the path\n\t * @return the image descriptor\n\t */\n\tpublic static ImageDescriptor getImageDescriptor(String path) {\n\t\treturn imageDescriptorFromPlugin(PLUGIN_ID, path);\n\t}\n\t\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\t\n\tpublic IConsole getConsole() {\n\t\treturn consoleTracker.getService();\n\t}\n\t\n\tpublic IPathFinder getPathFinder() {\n\t\treturn pathFinderTracker.getService();\n\t}\n\n\tpublic IHttpRequestEngineFactory getHttpRequestEngineFactoryService() {\n\t\treturn httpRequestEngineFactoryServiceTracker.getService();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/Application.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.net.URL;\nimport java.util.logging.Handler;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.core.runtime.Platform;\nimport org.eclipse.equinox.app.IApplication;\nimport org.eclipse.equinox.app.IApplicationContext;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.osgi.service.datalocation.Location;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.PlatformUI;\n\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.application.console.ConsoleHandler;\nimport com.subgraph.vega.application.logging.LogFormatter;\nimport com.subgraph.vega.application.logging.LogHandler;\n\n/**\n * This class controls all aspects of the application's execution\n */\npublic class Application implements IApplication {\n\n\t/* (non-Javadoc)\n\t * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)\n\t */\n\t\n\tpublic Object start(IApplicationContext context) throws Exception {\n\t\tDisplay display = PlatformUI.createDisplay();\n\t\tsetupLogging();\n\t\t\n\t\tif(!lockInstance()) {\n\t\t\tMessageDialog.openError(null, \"Vega already running\", \"An instance of the Vega application is already running.\");\n\t\t\treturn IApplication.EXIT_OK;\n\t\t}\n\t\tif(!setupWorkspace()) {\n\t\t\treturn IApplication.EXIT_OK;\n\t\t}\n\t\tConsoleHandler consoleHandler = new ConsoleHandler(display, Activator.getDefault().getConsole());\n\t\tconsoleHandler.activate();\n\t\t\n\t\ttry {\n\t\t\tint returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());\n\t\t\tif (returnCode == PlatformUI.RETURN_RESTART)\n\t\t\t\treturn IApplication.EXIT_RESTART;\n\t\t\telse\n\t\t\t\treturn IApplication.EXIT_OK;\n\t\t} finally {\n\t\t\tdisplay.dispose();\n\t\t}\n\t\t\n\t}\n\n\tprivate boolean lockInstance() {\n\t\tfinal URL url = getLockLocationURL();\n\t\tif(url != null) {\n\t\t\tfinal Location loc = Platform.getInstanceLocation();\n\t\t\ttry {\n\t\t\t\tif(!loc.isSet()) {\n\t\t\t\t\tloc.set(url, false);\n\t\t\t\t}\n\t\t\t\tif(loc.isLocked()) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tloc.lock();\n\t\t\t\treturn true;\n\t\t\t} catch (IllegalStateException e) {\n\t\t\t\tMessageDialog.openWarning(null, \"Warning\", \"Exception trying to lock Vega instance: \"+ e.getMessage());\n\t\t\t} catch (IOException e) {\n\t\t\t\tMessageDialog.openWarning(null, \"Warning\", \"I/O Exception trying to lock Vega instance: \"+ e.getMessage());\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate URL getLockLocationURL() {\n\t\tfinal IPathFinder pathFinder = Activator.getDefault().getPathFinder();\n\t\tfinal File path = pathFinder.getWorkspaceDirectory();\n\t\ttry {\n\t\t\treturn new URL(\"file:\"+ path.getPath());\n\t\t} catch (MalformedURLException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\tprivate void setupLogging() {\n\t\tLogger rootLogger = Logger.getLogger(\"\");\n\n\t\tIConsole console = Activator.getDefault().getConsole();\n\t\tif(console != null) {\n\t\t\tHandler handler = new LogHandler(console);\n\t\t\thandler.setFormatter(new LogFormatter());\n\t\t\thandler.setLevel(Level.FINEST);\n\t\t\tfor(Handler h: rootLogger.getHandlers())\n\t\t\t\trootLogger.removeHandler(h);\n\t\t\trootLogger.addHandler(handler);\n\t\t}\n\t\t\n\t\trootLogger.setLevel(Level.WARNING);\n\t}\n\n\tprivate boolean setupWorkspace() {\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tif(model == null) {\n\t\t\tMessageDialog.openError(null, \"Initialization Error\", \"Failed to obtain model service\");\n\t\t\treturn false;\n\t\t}\n\t\tif(!model.openDefaultWorkspace()) {\n\t\t\tMessageDialog.openError(null, \"Initialization Error\", \"Could not open workspace\");\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\t/* (non-Javadoc)\n\t * @see org.eclipse.equinox.app.IApplication#stop()\n\t */\n\tpublic void stop() {\n\t\tif (!PlatformUI.isWorkbenchRunning())\n\t\t\treturn;\n\t\tfinal IWorkbench workbench = PlatformUI.getWorkbench();\n\t\tfinal Display display = workbench.getDisplay();\n\t\tdisplay.syncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tif (!display.isDisposed())\n\t\t\t\t\tworkbench.close();\n\t\t\t}\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/ApplicationActionBarAdvisor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application;\n\nimport org.eclipse.jface.action.ActionContributionItem;\nimport org.eclipse.jface.action.ContributionItem;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.IStatusLineManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.action.Separator;\nimport org.eclipse.jface.action.StatusLineManager;\nimport org.eclipse.jface.util.Util;\nimport org.eclipse.ui.IWorkbenchActionConstants;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.actions.ActionFactory;\nimport org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;\nimport org.eclipse.ui.application.ActionBarAdvisor;\nimport org.eclipse.ui.application.IActionBarConfigurer;\n\npublic class ApplicationActionBarAdvisor extends ActionBarAdvisor {\n\n\tprivate ActionContributionItem preferenceItem;\n\tprivate ActionContributionItem quitItem;\n\tprivate ActionContributionItem resetPerspectiveItem;\n\tprivate ActionContributionItem aboutItem;\n\t\t\n    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {\n        super(configurer);\n    }\n\n    protected void makeActions(IWorkbenchWindow window) {\n    \tpreferenceItem = createItem(ActionFactory.PREFERENCES, window);\n    \tquitItem = createItem(ActionFactory.QUIT, window);\n    \tresetPerspectiveItem = createItem(ActionFactory.RESET_PERSPECTIVE, window);\n    \taboutItem = createItem(ActionFactory.ABOUT, window);\n    }\n\n    private ActionContributionItem createItem(ActionFactory factory, IWorkbenchWindow window) {\n    \tfinal IWorkbenchAction action = factory.create(window);\n    \tregister(action);\n    \treturn new ActionContributionItem(action);\n    }\n    \n   \n    protected void fillMenuBar(IMenuManager menuBar) {\n    \tMenuManager fileMenu = new MenuManager(\"&File\", IWorkbenchActionConstants.M_FILE);\n    \tMenuManager winMenu = new MenuManager(\"&Window\", IWorkbenchActionConstants.M_WINDOW);\n        MenuManager helpMenu = new MenuManager(\"&Help\", IWorkbenchActionConstants.M_HELP);\n        \n    \twinMenu.add(preferenceItem);\n    \t\n    \tfinal Separator quitSeparator = new Separator(\"vega.quit\");\n    \tfileMenu.add(quitSeparator);\n    \tfileMenu.add(quitItem);\n    \t\n    \tMenuManager viewMenu = new MenuManager(\"Show View\");\n    \twinMenu.add(viewMenu);\n    \twinMenu.add(resetPerspectiveItem);\n    \tmenuBar.add(fileMenu);\n    \tmenuBar.insertAfter(IWorkbenchActionConstants.M_FILE, winMenu);\n    \tmenuBar.insertAfter(IWorkbenchActionConstants.M_WINDOW, helpMenu);\n\n    \tfinal Separator helpSeparator = new Separator(\"vega.help\");\n    \thelpMenu.add(helpSeparator);\n    \thelpMenu.add(aboutItem);\n    \t\n    \tif(Util.isMac()) {\n    \t\tpreferenceItem.setVisible(false);\n    \t\tquitItem.setVisible(false);\n    \t\tquitSeparator.setVisible(false);\n    \t\taboutItem.setVisible(false);\n    \t\t\n    \t}\n    }\n    \n    protected void fillStatusLine(IStatusLineManager statusLine) {\n    \tContributionItem statusLineItem = com.subgraph.vega.ui.http.Activator.getDefault().getStatusLineContribution();\n    \tstatusLine.appendToGroup(StatusLineManager.END_GROUP, statusLineItem);\n    }\n    \n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/ApplicationWorkbenchAdvisor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application;\n\nimport org.eclipse.ui.application.IWorkbenchConfigurer;\nimport org.eclipse.ui.application.IWorkbenchWindowConfigurer;\nimport org.eclipse.ui.application.WorkbenchAdvisor;\nimport org.eclipse.ui.application.WorkbenchWindowAdvisor;\n\npublic class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {\n\n\tprivate static final String INITIAL_PERSPECTIVE_ID = \"com.subgraph.vega.perspectives.scanner\";\n\n    public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {\n        return new ApplicationWorkbenchWindowAdvisor(configurer);\n    }\n\n\tpublic String getInitialWindowPerspectiveId() {\n\t\treturn INITIAL_PERSPECTIVE_ID;\n\t}\n\n\tpublic void initialize(final IWorkbenchConfigurer configurer) {\n\t\tconfigurer.setSaveAndRestore(true);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/ApplicationWorkbenchWindowAdvisor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application;\n\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.ToolBar;\nimport org.eclipse.ui.IViewReference;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchPreferenceConstants;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.application.ActionBarAdvisor;\nimport org.eclipse.ui.application.IActionBarConfigurer;\nimport org.eclipse.ui.application.IWorkbenchWindowConfigurer;\nimport org.eclipse.ui.application.WorkbenchWindowAdvisor;\nimport org.eclipse.ui.internal.PerspectiveBarManager;\nimport org.eclipse.ui.internal.WorkbenchWindow;\n\nimport com.subgraph.vega.api.vuge.IConstants;\nimport com.subgraph.vega.application.console.VegaConsoleView;\nimport com.subgraph.vega.application.preferences.IPreferenceConstants;\nimport com.subgraph.vega.application.update.UpdateCheckTask;\n\n@SuppressWarnings(\"restriction\")\npublic class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {\n\n    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {\n        super(configurer);\n    }\n\n    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {\n        return new ApplicationActionBarAdvisor(configurer);\n    }\n    \n    public void preWindowOpen() {\n        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();\n        configurer.setInitialSize(new Point(1200, 900));\n        configurer.setShowCoolBar(true);\n        configurer.setShowPerspectiveBar(true);\n        configurer.setShowStatusLine(true);\n        configurer.setShowMenuBar(true);\n        configurer.setShowFastViewBars(true);\n        PlatformUI.getPreferenceStore().setValue(\n\t\t\t\tIWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT);\n\t\tPlatformUI.getPreferenceStore().setValue(\n\t\t\t\tIWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, true);\n\t\tPlatformUI.getPreferenceStore().setValue(\n\t\t\t\tIWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS, \"com.subgraph.vega.perspectives.scanner, com.subgraph.vega.perspectives.proxy\");\n\t\tPlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.DISABLE_NEW_FAST_VIEW, true);\n\n\t\tPlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_OPEN_ON_PERSPECTIVE_BAR, false);\n\t\t// For some reason this seems to do nothing\n\t\tPlatformUI.getPreferenceStore().setValue(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_SIZE, 100);\n\n\n    }\n  \n\tprivate void disablePerspectiveToolbarMenu() {\n    \tfinal PerspectiveBarManager perspectiveBarManager = ((WorkbenchWindow)PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getPerspectiveBar();\n    \tif(perspectiveBarManager != null) {\n    \t\tToolBar toolbar = perspectiveBarManager.getControl();\n    \t\tListener[] listeners = toolbar.getListeners(SWT.MenuDetect);\n    \t\tif(listeners == null) {\n    \t\t\treturn;\n    \t\t}\n    \t\tfor(Listener l: listeners) {\n    \t\t\ttoolbar.removeListener(SWT.MenuDetect, l);\n    \t\t}\n    \t}\n    }\n   \n    @Override\n    public void postWindowOpen() {\n    \tdisablePerspectiveToolbarMenu();\n\n    \tfinal IWorkbenchWindow window = getWindowConfigurer().getWindow();\n    \tif(window == null) {\n    \t\treturn;\n    \t}\n\n    \tfinal IWorkbenchPage activePage = window.getActivePage();\n    \tif(activePage == null) {\n    \t\treturn;\n    \t}\n\n    \tforceActivate(activePage, VegaConsoleView.ID);\n    \tforceActivate(activePage, \"com.subgraph.vega.views.alert\");\n    \t\n    \tmaybePerformUpdateCheck(window.getShell(), IConstants.BUILD_NUMBER);\n    }\n    \n    private void forceActivate(IWorkbenchPage page, String viewID) {\n    \tfinal IViewReference viewReference = page.findViewReference(viewID);\n    \tif(viewReference != null) {\n    \t\t// force activation\n    \t\tviewReference.getView(true);\n    \t}\n    }\n    \n    private void maybePerformUpdateCheck(Shell shell, int buildNumber) {\n\t\tfinal IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();\n\t\tif(preferences.getBoolean(IPreferenceConstants.P_UPDATE_CHECK_ENABLED) && (buildNumber != 0)) {\n\t\t\tfinal UpdateCheckTask task = new UpdateCheckTask(shell, buildNumber);\n\t\t\tfinal Thread thread = new Thread(task);\n\t\t\tthread.start();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/about/AboutDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.about;\n\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.vuge.IConstants;\nimport com.subgraph.vega.application.Activator;\n\npublic class AboutDialog extends TitleAreaDialog {\n\n\tprivate final static String LOGO_IMAGE = \"icons/subgraph.png\";\n\t\n\tprivate String aboutText = \"Vega, the Open Source Web Application Security Platform.\\n\\n\" +\n\t\t\t\t\t\t\t\t\"Version: \" + IConstants.VERSION_STRING + \"\\n\" +\n\t\t\t\t\t\t\t\t\"Build id: 0xC0FFEEEE\\n\" +\n\t\t\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\t\t\t\"(c) Copyright Subgraph Technologies, Inc. and others, 2014. All rights reserved.\\n\" +\n\t\t\t\t\t\t\t\t\"https://subgraph.com\\n\" +\n\t\t\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\t\t\t\"Vega would not have been possible without the generous contributions of the \\nopen source and security research communities.\\n\\n\" +\n\t\t\t\t\t\t\t\t\"With much appreciation, we acknowledge that Vega is built upon the work of many \\nother individuals and projects, and includes code from the following:\\n \" +\n\t\t\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\t\t\t\"the Eclipse Foundation http://www.eclipse.org\\n\" +\n\t\t\t\t\t\t\t\t\"the Apache Software Foundation http://apache.org\\n\" +\n\t\t\t\t\t\t\t\t\"the Mozilla Foundation http://mozilla.org\\n\" +\n\t\t\t\t\t\t\t\t\"Jonathan Headley http://jsoup.org\\n\" +\n\t\t\t\t\t\t\t\t\"Google, Inc. http://www.google.com\\n\" +\n\t\t\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\t\t\t\"The Vega scanner owes much to the innovative work implemented in Skipfish\\nby Michal Zalewski. \\n\" +\n\t\t\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\t\t\t\"The Vega 1.0 team is:\\n\" +\n\t\t\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\t\t\t\"Bruce Leidl\\n\" +\n\t\t\t\t\t\t\t\t\"David Mirza Ahmad\\n\" +\n\t\t\t\t\t\t\t\t\"Tina Salameh\\n\" +\n\t\t\t\t\t\t\t\t\"David McKinney\" +\n\t\t\t\t\t\t\t\t\"\\n\\n\" +\n\t\t\t\t\t\t\t\t\"Vega Beta contributors also included Hugo Fortier and Cade Cairns.\"+\n\t\t\t\t\t\t\t\t\"\\n\\n\"+\n\t\t\t\t\t\t\t\t\"Special thanks to Lars Vogel for his Eclipse RCP tutorials.\\n\";\n\n\t\n\tpublic AboutDialog(Shell parentShell) {\n\t\tsuper(parentShell);\n\t\tsetTitle(\"About Vega\");\n\t\tsetTitleImage(createLogoImage());\n\t}\n\t\n\tprivate Image createLogoImage() {\n\t\tfinal ImageDescriptor descriptor = Activator.getImageDescriptor(LOGO_IMAGE);\n\t\tif(descriptor != null) {\n\t\t\treturn descriptor.createImage();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tComposite composite = (Composite) super.createDialogArea (parent); \n\t\t\n\t    GridData gridData = new GridData();\n\t    gridData.grabExcessHorizontalSpace = true;\n\t    gridData.horizontalAlignment = GridData.FILL;\n\t    gridData.grabExcessVerticalSpace = true; \n\t    gridData.verticalAlignment = GridData.FILL;\n\n\t    Text aboutBox = new Text(composite, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);\n\t    aboutBox.setLayoutData(gridData);\n\t    aboutBox.setText(aboutText);\n\n\t    return composite;\n\t}\n\n\t\n\t@Override\n\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\tButton closeButton = createButton(parent, OK, \"Close\", true);\n\t\tcloseButton.setEnabled(true);\n\t\t    closeButton.addSelectionListener(new SelectionAdapter() {\n\t\t      public void widgetSelected(SelectionEvent e) {\n\t\t        close();\n\t\t      }\n\t\t    });\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/about/AboutHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.about;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\npublic class AboutHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal Shell shell = HandlerUtil.getActiveShell(event);\n\t\tfinal AboutDialog dialog = new AboutDialog(shell);\n\t\tdialog.open();\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/about/AbstractURLOpenHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.about;\n\nimport java.net.MalformedURLException;\nimport java.net.URL;\nimport java.util.logging.Logger;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.browser.IWebBrowser;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\npublic class AbstractURLOpenHandler extends AbstractHandler {\n\tprivate final Logger logger = Logger.getLogger(\"vega\");\n\tprivate final String urlString;\n\t\n\tprotected AbstractURLOpenHandler(String urlString) {\n\t\tthis.urlString = urlString;\n\t}\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbench workbench = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench();\n\t\topenUrl(workbench);\n\t\treturn null;\n\t}\n\t\n\tprivate void openUrl(IWorkbench workbench) {\n\t\ttry {\n\t\t\tfinal IWebBrowser browser = workbench.getBrowserSupport().getExternalBrowser();\n\t\t\tfinal URL url = new URL(urlString);\n\t\t\tbrowser.openURL(url);\n\t\t} catch (PartInitException e) {\n\t\t\tlogger.warning(\"Failed to create browser: \"+ e.getMessage());\n\t\t} catch (MalformedURLException e) {\n\t\t\tlogger.warning(\"Failed to parse URL string \"+ urlString);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/about/BrowseHelpHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.about;\n\npublic class BrowseHelpHandler extends AbstractURLOpenHandler {\n\tprivate final static String URL_STRING = \"http://docs.subgraph.com\";\n\t\n\tpublic BrowseHelpHandler() {\n\t\tsuper(URL_STRING);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/about/BrowseSubgraphHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.about;\n\npublic class BrowseSubgraphHandler extends AbstractURLOpenHandler {\n\tprivate final static String URL_STRING = \"http://www.subgraph.com\";\n\n\tpublic BrowseSubgraphHandler() {\n\t\tsuper(URL_STRING);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/console/ConsoleHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.console;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.ui.console.ConsolePlugin;\nimport org.eclipse.ui.console.MessageConsole;\nimport org.eclipse.ui.console.MessageConsoleStream;\n\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.console.IConsoleDisplay;\n\npublic class ConsoleHandler implements IConsoleDisplay {\n\t\n\tprivate final MessageConsole console;\n\tprivate final MessageConsoleStream outputStream;\n\tprivate final MessageConsoleStream debugStream;\n\tprivate final MessageConsoleStream errorStream;\n\t\n\tpublic ConsoleHandler(Display display, IConsole consoleService) {\n\t\tthis.console = createMessageConsole();\n\t\tthis.outputStream = console.newMessageStream();\n\t\tthis.debugStream = console.newMessageStream();\n\t\tthis.debugStream.setColor(display.getSystemColor(SWT.COLOR_BLUE));\n\t\tthis.errorStream = console.newMessageStream();\n\t\tthis.errorStream.setColor(display.getSystemColor(SWT.COLOR_RED));\n\t\tconsoleService.registerDisplay(this);\n\t}\n\t\n\tpublic void activate() {\n\t\t\n\t}\n\tstatic private MessageConsole createMessageConsole() {\n\t\tMessageConsole console = new MessageConsole(\"Vega Log\", null);\n\t\tConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[] {console});\n\t\treturn console;\n\t}\n\n\t@Override\n\tpublic void printOutput(String output) {\n\t\toutputStream.print(output);\t\t\n\t}\n\t\n\t@Override\n\tpublic void printDebug(String output) {\n\t\tdebugStream.print(output);\t\t\n\t}\n\t\n\t@Override\n\tpublic void printError(String output) {\n\t\terrorStream.print(output);\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/console/VegaConsoleView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.console;\n\nimport java.util.Timer;\nimport java.util.TimerTask;\n\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.ui.IPartListener2;\nimport org.eclipse.ui.IWorkbenchPartReference;\nimport org.eclipse.ui.internal.console.ConsoleView;\n\nimport com.subgraph.vega.api.console.ConsoleOutputEvent;\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.application.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\n@SuppressWarnings(\"restriction\")\npublic class VegaConsoleView extends ConsoleView implements IEventHandler {\n\tpublic final static String ID = \"com.subgraph.vega.views.VegaConsole\";\n\tprivate final static int BLINK_INTERVAL = 500;\n\tprivate enum ConsoleNotifyLevel { NOTIFY_OFF, NOTIFY_OUTPUT, NOTIFY_ERROR };\n\t\n\tprivate final static String CONSOLE_ICON = \"icons/console.png\";\n\tprivate final static String CONSOLE_ERROR = \"icons/console_error.png\";\n\tprivate final static String CONSOLE_NOTIFY = \"icons/console_lightbulb.png\";\n\n\tprivate final Timer consoleBlinkTimer = new Timer();\n\tprivate TimerTask consoleBlinkTask;\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\tprivate IPartListener2 partListener;\n\tprivate boolean isVisible;\n\n\tprivate ConsoleNotifyLevel notifyLevel = ConsoleNotifyLevel.NOTIFY_OFF;\n\n\tpublic void createPartControl(Composite parent) {\n\t\tsuper.createPartControl(parent);\n\t\tfinal IConsole console = Activator.getDefault().getConsole();\n\t\tif(console != null) {\n\t\t\tconsole.addConsoleOutputListener(this);\n\t\t}\n\t\tpartListener = createPartListener();\n\t\tgetSite().getPage().addPartListener(partListener);\n\t}\n\n\tprivate IPartListener2 createPartListener() {\n\t\treturn new IPartListener2() {\n\t\t\t@Override\n\t\t\tpublic void partVisible(IWorkbenchPartReference partRef) {\n\t\t\t\tif(ID.equals(partRef.getId())) {\n\t\t\t\t\tisVisible = true;\n\t\t\t\t\tsetNotifyOff();\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void partHidden(IWorkbenchPartReference partRef) {\n\t\t\t\tif(ID.equals(partRef.getId())) {\n\t\t\t\t\tisVisible = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override public void partOpened(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partInputChanged(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partDeactivated(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partClosed(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partBroughtToTop(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partActivated(IWorkbenchPartReference partRef) {}\n\t\t};\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\tfinal IConsole console = Activator.getDefault().getConsole();\n\t\tif(console != null) {\n\t\t\tconsole.removeConsoleOutputListener(this);\n\t\t}\n\t\tgetSite().getPage().removePartListener(partListener);\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\n\tpublic void startErrorNotify() {\n\t\tif(consoleBlinkTask == null) {\n\t\t\tconsoleBlinkTask = createAlertTask();\n\t\t\tconsoleBlinkTimer.scheduleAtFixedRate(consoleBlinkTask, 0, BLINK_INTERVAL);\n\t\t}\n\t}\n\t\n\tpublic void stopErrorNotify() {\n\t\tif(consoleBlinkTask != null) {\n\t\t\tconsoleBlinkTask.cancel();\n\t\t\tconsoleBlinkTask = null;\n\t\t}\n\t}\n\n\tprivate TimerTask createAlertTask() {\n\t\treturn new TimerTask() {\n\t\t\tprivate boolean state;\n\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tstate = !state;\n\t\t\t\tif(state) {\n\t\t\t\t\tsetLabelImage(imageCache.get(CONSOLE_ERROR));\n\t\t\t\t} else {\n\t\t\t\t\tsetLabelImage(imageCache.get(CONSOLE_ICON));\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate synchronized void setNotifyOff() {\n\t\tif(notifyLevel == ConsoleNotifyLevel.NOTIFY_ERROR) {\n\t\t\tstopErrorNotify();\n\t\t}\n\t\tsetLabelImage(imageCache.get(CONSOLE_ICON));\n\t\tnotifyLevel = ConsoleNotifyLevel.NOTIFY_OFF;\n\t}\n\n\tprivate synchronized void setNotifyOutput() {\n\t\tif(notifyLevel == ConsoleNotifyLevel.NOTIFY_OFF) {\n\t\t\tsetLabelImage(imageCache.get(CONSOLE_NOTIFY));\n\t\t\tnotifyLevel = ConsoleNotifyLevel.NOTIFY_OUTPUT;\n\t\t}\n\t}\n\n\tprivate synchronized void setNotifyError() {\n\t\tif(notifyLevel != ConsoleNotifyLevel.NOTIFY_ERROR) {\n\t\t\tstartErrorNotify();\n\t\t\tnotifyLevel = ConsoleNotifyLevel.NOTIFY_ERROR;\n\t\t}\n\t}\n\n\tprivate void setLabelImage(final Image image) {\n\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(image != null && !image.isDisposed()) {\n\t\t\t\t\tsetTitleImage(image);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif(event instanceof ConsoleOutputEvent) {\n\t\t\thandleConsoleOutput((ConsoleOutputEvent) event);\n\t\t}\n\t}\n\t\n\tprivate void handleConsoleOutput(ConsoleOutputEvent event) {\n\t\tif(!isVisible) {\n\t\t\tif(event.isErrorOutput()) {\n\t\t\t\tsetNotifyError();\n\t\t\t} else {\n\t\t\t\tsetNotifyOutput();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/logging/LogFormatter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.logging;\n\nimport java.io.PrintWriter;\nimport java.io.StringWriter;\nimport java.text.MessageFormat;\nimport java.util.Date;\nimport java.util.logging.Formatter;\nimport java.util.logging.LogRecord;\n\npublic class LogFormatter extends Formatter {\n\t\n\tDate dat = new Date();\n    private final static String format = \"{0,time}\";\n    private MessageFormat formatter;\n    private Object args[] = new Object[1];\n    \n\t@Override\n\tpublic synchronized String format(LogRecord record) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tdat.setTime(record.getMillis());\n\t\targs[0] = dat;\n\t\n\t\tStringBuffer text = new StringBuffer();\n\t\tif(formatter == null) {\n\t\t\tformatter = new MessageFormat(format);\n\t\t}\n\t\tformatter.format(args, text, null);\n\t\tsb.append(text);\n\t\tsb.append(\" [\");\n\t\tsb.append(record.getLevel().getLocalizedName());\n\t\tsb.append(\"] (\");\n\t\tsb.append(record.getLoggerName());\n\t\tsb.append(\") \");\n\t\tsb.append(formatMessage(record));\n\t\tsb.append(\"\\n\");\n\t\t\n\t\tif (record.getThrown() != null) {\n\t\t    try {\n\t\t        StringWriter sw = new StringWriter();\n\t\t        PrintWriter pw = new PrintWriter(sw);\n\t\t        record.getThrown().printStackTrace(pw);\n\t\t        pw.close();\n\t\t\tsb.append(sw.toString());\n\t\t    } catch (Exception ex) {\n\t\t    \tsb.append(\"Exception caused by writing exception backtrace to message!  : \"+ ex.getMessage());\n\t\t    }\n\t\t}\n\t\treturn sb.toString();\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/logging/LogHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.logging;\n\nimport java.util.logging.Handler;\nimport java.util.logging.Level;\nimport java.util.logging.LogRecord;\n\nimport com.subgraph.vega.api.console.IConsole;\n\npublic class LogHandler extends Handler {\n\n\tprivate final IConsole console;\n\t\n\tpublic LogHandler(IConsole console) {\n\t\tthis.console = console;\n\t}\n\t\n\t@Override\n\tpublic void publish(LogRecord record) {\n\t\tString message = getFormatter().format(record);\n\t\tif(record.getLevel().intValue() > Level.INFO.intValue()) {\n\t\t\tconsole.error(message);\n\t\t} else if (record.getLevel().intValue() == Level.FINER.intValue()) {\n\t\t\tconsole.debug(message);\n\t\t} else {\n\t\t\tconsole.write(message);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void flush() {\t\t\n\t}\n\n\t@Override\n\tpublic void close() throws SecurityException {\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/preferences/GeneralPreferenceInitializer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.preferences;\n\nimport org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\nimport org.eclipse.jface.preference.IPreferenceStore;\n\nimport com.subgraph.vega.application.Activator;\n\npublic class GeneralPreferenceInitializer extends\n\t\tAbstractPreferenceInitializer implements IPreferenceConstants {\n\n\t@Override\n\tpublic void initializeDefaultPreferences() {\n\t\tfinal IPreferenceStore store = Activator.getDefault().getPreferenceStore();\n\t\tstore.setDefault(P_SOCKS_ENABLED, false);\n\t\tstore.setDefault(P_SOCKS_ADDRESS, \"127.0.0.1\");\n\t\tstore.setDefault(P_SOCKS_PORT, 9050);\n\t\tstore.setDefault(P_PROXY_ENABLED, false);\n\t\tstore.setDefault(P_PROXY_ADDRESS, \"127.0.0.1\");\n\t\tstore.setDefault(P_PROXY_PORT, 8080);\n\t\t\n\t\tstore.setDefault(P_UPDATE_CHECK_ENABLED, true);\n\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/preferences/IPreferenceConstants.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.preferences;\n\npublic interface IPreferenceConstants {\n\tpublic static final String P_SOCKS_ENABLED = \"vega.preferences.socksEnabled\";\n\tpublic static final String P_SOCKS_ADDRESS = \"vega.preferences.socksAddress\";\n\tpublic static final String P_SOCKS_PORT = \"vega.preferences.socksPort\";\n\t\n\tpublic static final String P_PROXY_ENABLED = \"vega.preferences.proxyEnabled\";\n\tpublic static final String P_PROXY_ADDRESS = \"vega.preferences.proxyAddress\";\n\tpublic static final String P_PROXY_PORT = \"vega.preferences.proxyPort\";\n\t\n\tpublic static final String P_UPDATE_CHECK_ENABLED = \"vega.preferences.updateCheck\";\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/preferences/ProxyPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.preferences;\n\nimport org.eclipse.jface.preference.BooleanFieldEditor;\nimport org.eclipse.jface.preference.FieldEditor;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.preference.IntegerFieldEditor;\nimport org.eclipse.jface.preference.StringFieldEditor;\nimport org.eclipse.jface.util.IPropertyChangeListener;\nimport org.eclipse.jface.util.PropertyChangeEvent;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.ui.IWorkbench;\n\nimport com.subgraph.vega.application.Activator;\nimport com.subgraph.vega.ui.util.preferences.VegaPreferencePage;\n\npublic class ProxyPreferencePage extends VegaPreferencePage implements IPropertyChangeListener, IPreferenceConstants {\n\tprivate Composite parentComposite;\n\tprivate Composite socksConfigControl;\n\tprivate BooleanFieldEditor socksEnableField;\n\tprivate StringFieldEditor socksAddressField;\n\tprivate IntegerFieldEditor socksPortField;\n\tprivate Composite httpProxyConfigControl;\n\tprivate BooleanFieldEditor httpProxyEnableField;\n\tprivate StringFieldEditor httpProxyAddressField;\n\tprivate IntegerFieldEditor httpProxyPortField;\n\n\tpublic ProxyPreferencePage() {\n\t\tsuper(\"External Proxy Options\");\n\t}\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t}\n\n\t@Override\n\tprotected Control createPage(Composite parent) {\n\t\tparentComposite = new SashForm(parent, SWT.VERTICAL);\n\t\tcreateSocksGroup(parentComposite);\n\t\tcreateHttpProxyGroup(parentComposite);\n\t\tupdateEnableState();\n\t\treturn parentComposite;\n\t}\n\n\n\t@Override\n\tprotected void performDefaults() {\n\t\tsuper.performDefaults();\n\t\tupdateEnableState();\n\t}\n\n\t@Override\n\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\tif (event.getProperty().equals(FieldEditor.VALUE)) {\n\t\t\tif (event.getSource() == socksEnableField) {\n\t\t\t\tsetSocksEnableState((Boolean) event.getNewValue());\n\t\t\t} else if (event.getSource() == httpProxyEnableField) {\n\t\t\t\tsetHttpProxyEnableState((Boolean) event.getNewValue());\n\t\t\t}\n\t\t}\n\t\tsuper.propertyChange(event);\n\t}\n\t\n\tprivate Composite createSocksGroup(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"SOCKS proxy\");\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Configure Vega to use a SOCKS proxy for all connections\");\n\n\t\tsocksEnableField = new BooleanFieldEditor(P_SOCKS_ENABLED, \"Enable SOCKS proxy\", rootControl);\n\t\taddField(socksEnableField);\n\t\t\n\t\tsocksConfigControl = new Composite(rootControl, SWT.NONE);\n\t\tsocksConfigControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\n\t\tsocksAddressField = new StringFieldEditor(P_SOCKS_ADDRESS, \"Proxy Address\", socksConfigControl);\n\t\tsocksAddressField.setEmptyStringAllowed(false);\n\t\taddField(socksAddressField);\n\n\t\tsocksPortField = new IntegerFieldEditor(P_SOCKS_PORT, \"Proxy Port\", socksConfigControl);\n\t\tsocksPortField.setValidRange(1, 65535);\n\t\tsocksPortField.setTextLimit(5);\n\t\taddField(socksPortField);\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createHttpProxyGroup(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"External HTTP proxy\");\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Configure Vega to send all requests through an external HTTP proxy\");\n\n\t\thttpProxyEnableField = new BooleanFieldEditor(P_PROXY_ENABLED, \"Enable HTTP proxy\", rootControl);\n\t\taddField(httpProxyEnableField);\n\t\t\n\t\thttpProxyConfigControl = new Composite(rootControl, SWT.NONE);\n\t\thttpProxyConfigControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\n\t\thttpProxyAddressField = new StringFieldEditor(P_PROXY_ADDRESS, \"Proxy Address\", httpProxyConfigControl);\n\t\thttpProxyAddressField.setEmptyStringAllowed(false);\n\t\taddField(httpProxyAddressField);\n\n\t\thttpProxyPortField = new IntegerFieldEditor(P_PROXY_PORT, \"Proxy Port\", httpProxyConfigControl);\n\t\thttpProxyPortField.setValidRange(1, 65535);\n\t\thttpProxyPortField.setTextLimit(5);\n\t\taddField(httpProxyPortField);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate void updateEnableState() {\n\t    final IPreferenceStore store = getPreferenceStore();\n\t\tsetSocksEnableState(store.getBoolean(IPreferenceConstants.P_SOCKS_ENABLED));\n\t\tsetHttpProxyEnableState(store.getBoolean(IPreferenceConstants.P_PROXY_ENABLED));\n\t}\n\n\tprivate void setSocksEnableState(Boolean enable) {\n\t\tsocksAddressField.setEnabled(enable, socksConfigControl);\n\t\tsocksPortField.setEnabled(enable, socksConfigControl);\n\t}\n\n\tprivate void setHttpProxyEnableState(Boolean enable) {\n\t\thttpProxyAddressField.setEnabled(enable, httpProxyConfigControl);\n\t\thttpProxyPortField.setEnabled(enable, httpProxyConfigControl);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/preferences/UpdatesPreferencePage.java",
    "content": "package com.subgraph.vega.application.preferences;\n\nimport org.eclipse.jface.preference.BooleanFieldEditor;\nimport org.eclipse.jface.preference.FieldEditorPreferencePage;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\nimport com.subgraph.vega.application.Activator;\n\npublic class UpdatesPreferencePage extends FieldEditorPreferencePage implements\n\t\tIWorkbenchPreferencePage {\n\n\tpublic UpdatesPreferencePage() {\n\t\tsuper(GRID);\n\t}\n\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t\tsetDescription(\"Automatic Update Check\");\n\n\t}\n\n\t@Override\n\tprotected void createFieldEditors() {\n\t\taddField(new BooleanFieldEditor(IPreferenceConstants.P_UPDATE_CHECK_ENABLED, \"Automatically check for updates\", getFieldEditorParent()));\n\t\t\n\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/update/UpdateCheckTask.java",
    "content": "package com.subgraph.vega.application.update;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.net.URL;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.browser.IWebBrowser;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.RequestEngineException;\nimport com.subgraph.vega.application.Activator;\n\npublic class UpdateCheckTask implements Runnable {\n\n\tprivate final static String REPONSE_UPDATE_AVAILABLE = \"UPDATE\";\n\tprivate final static String DEBIAN_VERSION = \"/etc/debian_version\";\n\tprivate final static String DOWNLOAD_URL = \"http://subgraph.com/vega_download.php\";\n\tprivate final static String UPDATE_MESSAGE = \n\t\t\t\"A new version of Vega is available for download from the Subgraph website.\\n\"+ DOWNLOAD_URL;\n\tprivate final static String DIST_UPDATE_MESSAGE = \n\t\t\t\"A new version of Vega is available. Please use your distro update tools to update. For Debian-based systems such as Kali Linux, run apt-get update and then apt-get upgrade.\";\n\t\n\tprivate final Shell shell;\n\tprivate final int buildNumber;\n\tprivate String versionPrefix = \"\";\n\tprivate boolean distro = false;\n\t\n\tpublic UpdateCheckTask(Shell shell, int buildNumber) {\n\t\tthis.shell = shell;\n\t\tthis.buildNumber = buildNumber;\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\tcheckDebianRelease();\n\t\tfinal IHttpRequestEngine requestEngine = createRequestEngine();\n\t\tfinal IHttpResponse response = sendRequest(requestEngine);\n\t\tif(response != null && !response.getBodyAsString().isEmpty()) {\n\t\t\tprocessResponseBody(response.getBodyAsString());\n\t\t}\n\t}\n\t\n\tprivate IHttpResponse sendRequest(IHttpRequestEngine requestEngine) {\n\t\tfinal HttpHost targetHost = createTargetHost();\n\t\tfinal String uri = createUriPath();\n\t\tfinal HttpUriRequest request = requestEngine.createGetRequest(targetHost, uri);\n\t\tfinal IHttpRequestTask requestTask = requestEngine.sendRequest(request);\n\t\ttry {\n\t\t\treturn requestTask.get(true);\n\t\t} catch (RequestEngineException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate void processResponseBody(String body) {\n\t\tif(!REPONSE_UPDATE_AVAILABLE.equalsIgnoreCase(body)) {\n\t\t\treturn;\n\t\t}\n\n\t\tshell.getDisplay().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tdisplayUpdateDialog();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void displayUpdateDialog() {\n\n\t\tif (distro == false) {\n\t\t\t\n\t\t\n\t\t\tfinal MessageDialog dialog = new MessageDialog(null, \"Update Available\", \n\t\t\t\t\tnull,\n\t\t\t\t\tUPDATE_MESSAGE,\n\t\t\t\t\tMessageDialog.INFORMATION,\n\t\t\t\t\tnew String[] {\"Ok\", \"Open Download Page\"}, \n\t\t\t\t\t0);\n\t\t\tif(dialog.open() == 1) {\n\t\t\t\topenDownloadPage();\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t\n\t\t\tfinal MessageDialog dialog = new MessageDialog(null, \"Updated Vega Package Available\", \n\t\t\t\t\tnull,\n\t\t\t\t\tDIST_UPDATE_MESSAGE,\n\t\t\t\t\tMessageDialog.INFORMATION,\n\t\t\t\t\tnew String[] {\"Ok\"},\n\t\t\t\t\t0);\n\t\t\tdialog.open();\n\n\t\t}\n\t\n\t}\n\t\n\tprivate void openDownloadPage() {\n\t\ttry {\n\t\t\tfinal IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser();\n\t\t\tfinal URL url = new URL(DOWNLOAD_URL);\n\t\t\tbrowser.openURL(url);\n\t\t} catch (Exception e) {\n\t\t}\n\t}\n\n\tprivate IHttpRequestEngine createRequestEngine() {\n\t\tfinal IHttpRequestEngineFactory requestEngineFactory = Activator.getDefault().getHttpRequestEngineFactoryService();\n\t\tfinal IHttpRequestEngineConfig config = requestEngineFactory.createConfig();\n\t\treturn requestEngineFactory.createRequestEngine(IHttpRequestEngine.EngineConfigType.CONFIG_SCANNER, config, null);\n\t}\n\t\n\tprivate HttpHost createTargetHost() {\n\t\treturn new HttpHost(\"support.subgraph.com\", -1, \"https\");\n\t}\n\t\n\tprivate String createUriPath() {\n\t\treturn \"/update-check.php?build=\"+versionPrefix+buildNumber;\n\t}\n\t\n\tprivate void checkDebianRelease() {\n\t\t\n\t\t\n\ttry {\n\t    BufferedReader r = new BufferedReader ( new FileReader ( DEBIAN_VERSION ));\n\t    String l = null;\n\t    while ((l = r.readLine()) != null) {\n\t    \tif (l.startsWith(\"Kali Linux 1.0\")) {\n\t    \t\tversionPrefix = \"kl-1.0-\";\n\t    \t\tdistro = true;\n\t    \t}\t\t\n\t    }}\n\t\tcatch (FileNotFoundException e){\n\t\t}\n\t\tcatch (IOException e){\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/CloseWorkspaceHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\n/**\n * Close workspace handler extends AbstractHandler, an IHandler base class.\n * This handler is set to the Exit menu in ui.application/plugin.xml\n * and is invoked from preWindowShellClose in ApplicationWorkbenchWindowAdvisor \n * @see org.eclipse.core.commands.IHandler\n * @see org.eclipse.core.commands.AbstractHandler\n */\npublic class CloseWorkspaceHandler extends AbstractHandler {\n\tprivate IWorkbenchWindow activeWorkbenchWindow;\n\n\tpublic CloseWorkspaceHandler() {\n\t}\n\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tactiveWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event);\n\t\t\n\t\tif (activeWorkbenchWindow == null) {\n\t\t\t// action has been disposed\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\t/* code to execute before closing follows */\n\t\t\t\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/LastPage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\n\npublic class LastPage extends WizardPage {\n\t\n\tLastPage() {\n\t\tsuper(\"lastPage\");\n\t\tsetTitle(\"New Workspace\");\n\t\tsetDescription(\"Finish creating the Workspace.\");\n\t}\n\n\tpublic void createControl(Composite parent) {\n\t\tfinal Composite container = createComposite(parent);\n\t    createBanner(container, \"Subgraph Vega will now restart with the newly created Workspace.\");\n\t\tsetPageComplete(true);\n\t}\n\t\n\tprivate void createBanner(Composite container, String text) {\n\t\tfinal Label label = new Label(container, SWT.NONE);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\tgd.horizontalSpan = 2;\t\t\n\t\tlabel.setLayoutData(gd);\n\t\tlabel.setText(text);\n\t}\n\t\n\tprivate Composite createComposite(Composite parent) {\n\t\tfinal Composite c = new Composite(parent, SWT.NONE);\n\t    final GridLayout gridLayout = new GridLayout();\n\t    gridLayout.numColumns = 2;\n\t    gridLayout.verticalSpacing = 20;\n\t    c.setLayout(gridLayout);\n\t    setControl(c);\n\t    return c;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/NewWorkspaceDelegate.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.IWorkbenchWindowActionDelegate;\n\npublic class NewWorkspaceDelegate implements IWorkbenchWindowActionDelegate {\n\n\tpublic void dispose() {\n\t}\n\n\tpublic void init(IWorkbenchWindow window) {\n\t}\n\n\tpublic void run(IAction action) {\n\t\tNewWorkspaceHandler.openNewWorkspaceWizard(true /* restart */);\n\t}\n\n\t\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/NewWorkspaceHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.jface.wizard.WizardDialog;\nimport org.eclipse.ui.PlatformUI;\n\npublic class NewWorkspaceHandler extends AbstractHandler{\n\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\topenNewWorkspaceWizard(true);\n\t\treturn null;\n\t}\n\t\n\tpublic static WorkspaceRecord openNewWorkspaceWizard(boolean restart) {\n\t\t\n\t\tNewWorkspaceWizard wizard = new NewWorkspaceWizard();\n\t\twizard.setRestart(restart);\n\t\t\n\t\tWizardDialog dialog = new WizardDialog(null, wizard);\n\n\t\tif (dialog.open() == Window.OK) {\n\t\t\tWorkspaceRecord workspaceRecord =  wizard.getWorkspaceRecord();\n\t\t\tif(restart) {\n\t\t\t\t/* close workspace and restart */\n\t\t\t\t//Activator.getDefault().getModel().getCurrentWorkspace().close();\n\t\t\t\tPlatformUI.getWorkbench().restart();\n\t\t\t}\n\t\t\treturn workspaceRecord;\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/NewWorkspaceWizard.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.jface.wizard.Wizard;\n\nimport com.subgraph.vega.application.Activator;\n\npublic class NewWorkspaceWizard extends Wizard {\n\tprivate WorkspaceNamePage firstPage;\n\tprivate LastPage lastPage;\n\tprivate WorkspaceRecord workspaceRecord;\n\tprivate boolean restart = true;\n\t\n\tpublic void addPages() {\n\t\tsetWindowTitle(\"Create a new Workspace\");\n\t\t\n\t\tImageDescriptor image = Activator.getImageDescriptor(\"icons/workspace_wiz.gif\");\n\n\t\tfirstPage = new WorkspaceNamePage();\n\t\tfirstPage.setImageDescriptor(image);\n\t\t\n\t\tlastPage = new LastPage();\n\t\tlastPage.setImageDescriptor(image);\n\t\t\n\t\taddPage(firstPage);\n\t\taddPage(lastPage);\n\t}\n\t\n\tpublic boolean canFinish() {\n\t\treturn getContainer().getCurrentPage() == lastPage;\n\t}\n\t\n\t@Override\n\tpublic boolean performFinish() {\n\t\tfinal String name = firstPage.getWorkspaceName();\n\t\tsetWorkspaceRecord(WorkspaceChooser.createWorkspace(name, isRestart()));\n\t\treturn true;\n\t}\n\n\tpublic void setWorkspaceRecord(WorkspaceRecord workspaceRecord) {\n\t\tthis.workspaceRecord = workspaceRecord;\n\t}\n\n\tpublic WorkspaceRecord getWorkspaceRecord() {\n\t\treturn workspaceRecord;\n\t}\n\n\tpublic void setRestart(boolean restart) {\n\t\tthis.restart = restart;\n\t}\n\n\tpublic boolean isRestart() {\n\t\treturn restart;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/ResetWorkspaceHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.application.Activator;\n\npublic class ResetWorkspaceHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tif(model != null)\n\t\t\tmodel.resetCurrentWorkspace();\n\t\treturn null;\n\t}\n\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/SwitchWorkspaceDelegate.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.jface.action.IAction;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.IWorkbenchWindowActionDelegate;\n\npublic class SwitchWorkspaceDelegate implements IWorkbenchWindowActionDelegate {\n\n\tpublic void init(IWorkbenchWindow window) {\n\t}\n\n\tpublic void dispose() {\n\t}\n\n\tpublic void run(IAction action) {\n\t\tSwitchWorkspaceHandler.openChoseWorkspaceDialog(true);\n\t}\n\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/SwitchWorkspaceDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\n\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.List;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\n\npublic class SwitchWorkspaceDialog extends Dialog {\n\n\tprivate List list;\n\tprivate int index;\n\tprivate java.util.List<WorkspaceRecord> records;\n\tprivate WorkspaceRecord selectedWorkspaceRecord;\n\t\n\tSwitchWorkspaceDialog(Shell shell, java.util.List<WorkspaceRecord> records) {\n\t\tsuper(shell);\n\t\tthis.records = records;\n\t}\n\t\n\tprotected void configureShell(Shell shell) {\n\t\tsuper.configureShell(shell);\n\t\tshell.setText(\"Switch Workspace\");\n\t}\n\n\t protected Control createDialogArea(Composite parent) {\n\t\t Composite composite = (Composite) super.createDialogArea(parent);\n\t\t Label label = new Label(composite, SWT.NONE);\n\t\t label.setText(\"Choose a workspace to open:\");\n\t\t GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, true);\n\t\t label.setLayoutData(gd);\n\t\t  list = new List(composite, SWT.SINGLE);\n\t\t gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\t list.setLayoutData(gd);\n\t\t for(WorkspaceRecord rec : records) {\n\t\t\t list.add(rec.getName());\n\t\t }\n\t\t list.addSelectionListener(new SelectionListener() {\n\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\t\t\t\t\n\t\t\t}\n\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsetIndex(list.getSelectionIndex());\n\t\t\t\t\n\t\t\t}\n\t\t\t \n\t\t });\n\t\t list.addListener(SWT.MouseDoubleClick, new Listener() {\n\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tsetIndex(list.getSelectionIndex());\n\t\t\t\tokPressed();\t\n\t\t\t}\n\t\t });\n\t\t \n\t\t list.setSelection(0);\n\t\t setIndex(0);\n\t\t \n\t\t composite.setLayout(new GridLayout());\n\t\t return composite;\n\t\t \n\t }\n\t @Override\n\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\tsuper.createButtonsForButtonBar(parent);\n\t\tcreateButton(parent,IDialogConstants.NEXT_ID,\"New workspace >>\",false);\n\t}\n\t @Override\n\tprotected void buttonPressed(int buttonId) {\n\t\tsuper.buttonPressed(buttonId);\n\t\tif(buttonId == IDialogConstants.NEXT_ID) {\n\t\t\tcreateWorkspacePressed();\n\t\t}\n\t}\n\t\n\tprivate void createWorkspacePressed() {\n\t\tsetReturnCode(IDialogConstants.NEXT_ID);\n\t\tclose();\n\t}\n\t\n\t private void setIndex(int index) {\n\t\t this.index = index;\n\t\t setSelectedWorkspaceRecord(records.get(index));\n\t }\n\t \n\t public int getIndex() {\n\t\t return index;\n\t }\n\n\tpublic void setSelectedWorkspaceRecord(WorkspaceRecord selectedWorkspaceRecord) {\n\t\tthis.selectedWorkspaceRecord = selectedWorkspaceRecord;\n\t}\n\n\tpublic WorkspaceRecord getSelectedWorkspaceRecord() {\n\t\treturn selectedWorkspaceRecord;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/SwitchWorkspaceHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport java.util.List;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.ui.PlatformUI;\n\npublic class SwitchWorkspaceHandler extends AbstractHandler {\n\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\topenChoseWorkspaceDialog(true);\n\t\treturn null;\n\t}\n\t\n\tpublic static WorkspaceRecord  openChoseWorkspaceDialog(boolean restart) {\n\t\tWorkspaceChooser chooser = new WorkspaceChooser();\n\t\tList<WorkspaceRecord> workspaces = chooser.findAllWorkspaces();\n\t\tSwitchWorkspaceDialog dialog = new SwitchWorkspaceDialog(null, workspaces);\n\t\tWorkspaceRecord workspaceRecord = null;\n\t\t\n\t\tint dialogButton = dialog.open();\n\n\t\t/* if user clicked \"new workspace\" open the wizard */\n\t\tif(dialogButton == IDialogConstants.NEXT_ID) {\n\t\t\tworkspaceRecord = NewWorkspaceHandler.openNewWorkspaceWizard(restart);\n\t\t\t/* if a new workspace is created the wizard restarts the workbench */\n\t\t}\n\t\t\n\t\telse if(dialogButton == Window.OK) {\n\t\t\tworkspaceRecord = dialog.getSelectedWorkspaceRecord();\n\n\t\t\t/* mark the selected workspace to open in next startup */\n\t\t\tif(restart) {\n\t\t\t\tWorkspaceChooser.markAutostart(workspaceRecord.getPath());\n\t\t\t\tPlatformUI.getWorkbench().restart();\n\t\t\t}\n\t\t}\n\t\treturn workspaceRecord;\n\t}\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/WorkspaceChooser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.FileWriter;\nimport java.io.IOException;\nimport java.net.URL;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class WorkspaceChooser {\n\tprivate final static String NAME_FILE = \".name\";\n\tprivate final static String AUTOSTART_FILE = \".autostart\";\n\n\n\tpublic WorkspaceChooser() {\n\t}\n\n\tpublic URL choose() {\n\n\t\tfinal List<WorkspaceRecord> workspaces = findAllWorkspaces();\n\t\tWorkspaceRecord workspaceRecord;\n\n\t\t/* only one workspace open it */\n\t\tif(workspaces.size() == 1) {\n\t\t\tworkspaceRecord = workspaces.get(0);\n\t\t}\n\t\t/* no workspace create default */\n\t\telse if(workspaces.isEmpty()) {\n\t\t\tworkspaceRecord = createWorkspace(\"Default\", false);\n\t\t}\n\t\t/* more than one select one marked as auto-start */\n\t\telse {\n\t\t\tworkspaceRecord = getAutoStartWorkspace(workspaces);\n\t\t}\n\t\t/* more than one and no auto-start */\n\t\tif(workspaceRecord == null) {\n\t\t\t/* show the dialog with the list of workspaces to select */\n\t\t\tworkspaceRecord = SwitchWorkspaceHandler.openChoseWorkspaceDialog(false);\n\t\t}\n\t\t\n\t\tif(workspaceRecord != null) {\n\t\t\treturn workspaceRecord.getURL();\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tpublic WorkspaceRecord getAutoStartWorkspace(List<WorkspaceRecord> workspaces) {\n\t\tWorkspaceRecord autoStartWorkspace = null;\n\n\t\tfor(WorkspaceRecord rec: workspaces) {\n\t\t\tif(rec.isAutostart()) {\n\n\t\t\t\t/* return the first autos-tart workspace */\n\t\t\t\tif(autoStartWorkspace == null) {\n\t\t\t\t\tautoStartWorkspace = rec;\n\t\t\t\t}\n\t\t\t\t/* but unlink all of them */\n\t\t\t\tif(!unlinkAutostart(rec.getPath())) {\n\t\t\t\t\t// XXX\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn autoStartWorkspace;\n\t}\n\n\tpublic List<WorkspaceRecord> findAllWorkspaces() {\n\t\tfinal File root = getBaseDirectory();\n\t\tList<WorkspaceRecord> workspaces = new ArrayList<WorkspaceRecord>();\n\t\tfor(File dir : root.listFiles()) {\n\t\t\tif(isWorkspace(dir)) {\n\t\t\t\tworkspaces.add(new WorkspaceRecord(getWorkspaceName(dir), dir, isAutostart(dir)));\n\t\t\t}\n\t\t}\n\t\treturn workspaces;\t\t\n\t}\n\n\tprivate boolean isWorkspace(File path) {\n\t\tfinal File nameFile = new File(path, NAME_FILE);\n\t\treturn nameFile.exists();\t\n\t}\n\n\tprivate boolean isAutostart(File path) {\n\t\tfinal File autoStart = new File(path, AUTOSTART_FILE);\n\t\treturn autoStart.exists();\n\t}\n\n\tprivate boolean unlinkAutostart(File path) {\n\t\tfinal File autoStart = new File(path, AUTOSTART_FILE);\n\t\treturn autoStart.delete();\n\t}\n\n\tprivate String getWorkspaceName(File path) {\n\t\tfinal File nameFile = new File(path, NAME_FILE);\n\t\ttry {\n\t\t\treturn readWorkspaceName(nameFile);\n\t\t} catch (IOException e) {\n\t\t\tthrow new WorkspaceOpenException(\"Error reading workspace name file : \" + e.getMessage());\n\t\t}\n\t}\n\n\tprivate String readWorkspaceName(File nameFile) throws IOException {\n\t\tfinal FileReader reader = new FileReader(nameFile);\n\t\tfinal BufferedReader input = new BufferedReader(reader);\n\t\ttry {\n\t\t\treturn input.readLine();\n\t\t} finally {\n\t\t\ttry { input.close(); } catch (IOException ignored) { }\n\t\t}\n\t}\n\n\tstatic public File getBaseDirectory() {\n\t\tfinal File homeDirectory = new File(System.getProperty(\"user.home\"));\n\n\t\tif(!homeDirectory.canWrite()) \n\t\t\tthrow new WorkspaceOpenException(\"Cannot write to home directory \" + homeDirectory.getPath());\n\n\t\tfinal File baseDirectory = new File(homeDirectory, \".vega\"); // FIXME Unix\n\t\tif(!baseDirectory.exists()) {\n\t\t\tif(!baseDirectory.mkdir()) {\n\t\t\t\tthrow new WorkspaceOpenException(\"Could not create directory: \" + baseDirectory.getPath());\n\t\t\t}\n\t\t}\n\t\treturn baseDirectory;\n\t}\n\n\tstatic public WorkspaceRecord createWorkspace(String workspaceName, boolean autostart) {\n\t\tfinal File baseDirectory = getBaseDirectory();\n\t\tint i = 0;\n\t\tFile workspaceDirectory;\n\t\twhile(true) {\n\t\t\tworkspaceDirectory = new File(baseDirectory, String.format(\"%02d\", i));\n\t\t\tif(!workspaceDirectory.exists())\n\t\t\t\tbreak;\n\t\t\ti++;\n\t\t}\n\t\tif(!workspaceDirectory.mkdir()) {\n\t\t\tthrow new WorkspaceOpenException(\"Could not create directory: \" + workspaceDirectory.getPath());\n\t\t}\n\n\t\ttry {\n\t\t\twriteNameFile(workspaceDirectory, workspaceName);\n\t\t} catch (IOException e) {\n\t\t\tthrow new WorkspaceOpenException(\"Error writing name file to workspace directory \" + e.getMessage());\n\t\t}\n\n\t\tif(autostart) {\n\t\t\tmarkAutostart(workspaceDirectory);\n\t\t}\n\t\treturn new WorkspaceRecord(workspaceName, workspaceDirectory, autostart);\n\t}\n\n\tstatic public void markAutostart(File workspacePath) {\n\t\tfinal File autostartFile = new File(workspacePath, AUTOSTART_FILE);\n\t\tif(!autostartFile.exists() && !autostartFile.mkdir()) {\n\t\t\tthrow new WorkspaceOpenException(\"Could not create autostart directory: \" + autostartFile.getPath());\n\t\t}\n\t}\n\n\tstatic public void writeNameFile(File workspaceDirectory, String name) throws IOException {\n\t\tfinal File nameFile = new File(workspaceDirectory, NAME_FILE);\n\t\tfinal FileWriter writer = new FileWriter(nameFile);\n\t\ttry {\n\t\t\twriter.write(name);\n\t\t} finally {\n\t\t\ttry { writer.close(); } catch (IOException ignored) { }\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/WorkspaceLockStateSourceProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.ui.AbstractSourceProvider;\nimport org.eclipse.ui.ISources;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.WorkspaceLockStatusEvent;\nimport com.subgraph.vega.application.Activator;\n\npublic class WorkspaceLockStateSourceProvider extends AbstractSourceProvider {\n\tfinal static String WORKSPACE_LOCK_STATE = \"vega.workspaceLockState\";\n\tfinal static String WORKSPACE_LOCKED = \"locked\";\n\tfinal static String WORKSPACE_UNLOCKED = \"unlocked\";\n\t\n\tprivate boolean isLocked = false;\n\t\n\tpublic WorkspaceLockStateSourceProvider() {\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tmodel.addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceLockStatusEvent)\n\t\t\t\t\thandleWorkspaceLockStatus((WorkspaceLockStatusEvent) event);\t\t\t\t\n\t\t\t}\n\t\t});\t\t\n\t}\n\n\tprivate void handleWorkspaceLockStatus(WorkspaceLockStatusEvent event) {\n\t\tboolean state = event.isLockEvent();\n\t\tif(state != isLocked) {\n\t\t\tisLocked = state;\n\t\t\tfireSourceChanged(ISources.WORKBENCH, WORKSPACE_LOCK_STATE, getCurrentWorkspaceLockState());\n\t\t}\n\t}\n\t\n\t\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tsynchronized public Map<?,?> getCurrentState() {\n\t\tMap<String, String> stateMap = new HashMap<String, String>(1);\n\t\tstateMap.put(WORKSPACE_LOCK_STATE, getCurrentWorkspaceLockState());\n\t\treturn stateMap;\n\t}\n\n\tprivate String getCurrentWorkspaceLockState() {\n\t\tif(isLocked)\n\t\t\treturn WORKSPACE_LOCKED;\n\t\telse\n\t\t\treturn WORKSPACE_UNLOCKED;\n\t}\n\n\t@Override\n\tpublic String[] getProvidedSourceNames() {\n\t\treturn new String[] { WORKSPACE_LOCK_STATE };\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/WorkspaceNamePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\n\npublic class WorkspaceNamePage extends WizardPage {\n\n\tprivate Text workspaceNameText;\n\t\n\tWorkspaceNamePage() {\n\t\tsuper(\"firstPage\");\n\t\tsetTitle(\"New Workspace\");\n\t\tsetDescription(\"Create a new Workspace.\");\n\t\t\n\t\tsetPageComplete(false);\n\t}\n\t\n\tpublic void createControl(Composite parent) {\n\t\tfinal Composite container = createComposite(parent);\n\t    workspaceNameText = createWorkspaceName(container);\n\t}\n\t\n\tpublic String getWorkspaceName() {\n\t\treturn workspaceNameText.getText();\n\t}\n\t\n\tprivate Text createWorkspaceName(Composite container) {\n\t\tcreateLabel(container, \"Workspace Name:\");\n\t\tfinal Text t = createText(container, 16);\n\t\tt.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif(t.getText().length() > 0) {\n\t\t\t\t\tsetErrorMessage(null);\n\t\t\t\t\tsetPageComplete(true);\n\t\t\t\t} else {\n\t\t\t\t\tsetErrorMessage(\"Workspace name is empty.\");\n\t\t\t\t\tsetPageComplete(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn t;\n\t}\n\t\n\tprivate void createLabel(Composite container, String text) {\n\t\tfinal Label label = new Label(container, SWT.NONE);\n\t\tfinal GridData gd = new GridData(SWT.END, SWT.CENTER, false, false);\n\t\tlabel.setLayoutData(gd);\n\t\tlabel.setText(text);\n\t}\n\t\n\tprivate Composite createComposite(Composite parent) {\n\t\tfinal Composite c = new Composite(parent, SWT.NONE);\n\t    final GridLayout gridLayout = new GridLayout();\n\t    gridLayout.numColumns = 2;\n\t    gridLayout.verticalSpacing = 20;\n\t    c.setLayout(gridLayout);\n\t    setControl(c);\n\t    return c;\n\t}\n\tprivate Text createText(Composite container, int limit) {\n\t\tfinal Text text = new Text(container, SWT.BORDER);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\tgd.widthHint = 10 * limit;\n\t\ttext.setLayoutData(gd);\n\t\ttext.setTextLimit(limit);\n\t\treturn text;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/WorkspaceOpenException.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\n/**\n * Unchecked exception thrown when the application is unable to open the\n * workspace.\n * \n * This exception is critical and terminal, once thrown the application exits.\n * \n */\npublic class WorkspaceOpenException extends RuntimeException {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tpublic WorkspaceOpenException(String message) {\n\t\tsuper(message);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/application/workspaces/WorkspaceRecord.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.application.workspaces;\n\nimport java.io.File;\nimport java.net.MalformedURLException;\nimport java.net.URL;\n\npublic class WorkspaceRecord {\n\tprivate final String name;\n\tprivate final File path;\n\tprivate final boolean isAutostart;\n\t\n\tpublic WorkspaceRecord(String name, File path, boolean autostart) {\n\t\tthis.name = name;\n\t\tthis.path = path;\n\t\tthis.isAutostart = autostart;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\tpublic File getPath() {\n\t\treturn path;\n\t}\n\t\n\tpublic boolean isAutostart() {\n\t\treturn isAutostart;\n\t}\n\t\n\tpublic URL getURL() {\n\t\ttry {\n\t\t\treturn new URL(\"file:\" + path.getPath());\n\t\t} catch (MalformedURLException e) {\n\t\t\tthrow new IllegalStateException(\"Could not create URL\");\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/internal/console/ConsoleService.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.console;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.console.ConsoleOutputEvent;\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.console.IConsoleDisplay;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic class ConsoleService implements IConsole {\n\tprivate final static int MAX_BUFFER = 8192;\n\tprivate final List<IConsoleDisplay> displays = new ArrayList<IConsoleDisplay>();\n\tprivate final EventListenerManager eventManager = new EventListenerManager();\n\tprivate StringBuilder outputBuffer = null;\n\tprivate StringBuilder errorBuffer = null;\n\t\n\t@Override\n\tpublic synchronized void write(String output) {\n\t\tif(output == null || output.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tif(!output.endsWith(\"\\n\"))\n\t\t\toutput = output + \"\\n\";\n\t\tif(displays.size() == 0) {\n\t\t\tbufferOutput(output);\n\t\t} else {\n\t\t\tfor(IConsoleDisplay display: displays) {\n\t\t\t\tdisplay.printOutput(output);\n\t\t\t}\n\t\t\teventManager.fireEvent(new ConsoleOutputEvent(output, false));\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized void debug(String output) {\n\t\tif(output == null || output.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tif(!output.endsWith(\"\\n\"))\n\t\t\toutput = output + \"\\n\";\n\t\tif(displays.size() == 0) {\n\t\t\tbufferOutput(output);\n\t\t} else {\n\t\t\tfor(IConsoleDisplay display: displays) {\n\t\t\t\tdisplay.printDebug(output);\n\t\t\t}\n\t\t\teventManager.fireEvent(new ConsoleOutputEvent(output, false));\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic synchronized void error(String output) {\n\t\tif(output == null || output.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tif(!output.endsWith(\"\\n\"))\n\t\t\toutput = output + \"\\n\";\n\t\tif(displays.size() == 0) {\n\t\t\tbufferError(output);\n\t\t} else {\n\t\t\tfor(IConsoleDisplay display: displays) {\n\t\t\t\tdisplay.printError(output);\n\t\t\t}\n\t\t\teventManager.fireEvent(new ConsoleOutputEvent(output, true));\n\t\t}\n\t}\n\t\n\tprivate void bufferOutput(String output) {\n\t\tif(outputBuffer == null)\n\t\t\toutputBuffer = new StringBuilder();\n\t\tappendBuffer(output, outputBuffer);\n\t}\n\n\tprivate void bufferError(String output) {\n\t\tif(errorBuffer == null)\n\t\t\terrorBuffer = new StringBuilder();\n\t\tappendBuffer(output, errorBuffer);\n\t}\n\t\n\tprivate void appendBuffer(String output, StringBuilder buffer) {\n\t\tif(output == null)\n\t\t\treturn;\n\t\tif(output.length() > MAX_BUFFER)\n\t\t\toutput = output.substring(0, MAX_BUFFER);\n\t\tfinal int totalLength = buffer.length() + output.length();\n\t\tif(totalLength > MAX_BUFFER) {\n\t\t\tint trimCount = totalLength - MAX_BUFFER;\n\t\t\tbuffer.delete(0, trimCount);\n\t\t}\n\t\tbuffer.append(output);\n\t}\n\t\n\t@Override\n\tpublic synchronized void registerDisplay(IConsoleDisplay display) {\n\t\tdisplays.add(display);\n\t\tif(displays.size() == 1) {\n\t\t\tif(errorBuffer != null) {\n\t\t\t\tdisplay.printError(errorBuffer.toString());\n\t\t\t\teventManager.fireEvent(new ConsoleOutputEvent(errorBuffer.toString(), true));\n\t\t\t\terrorBuffer = null;\n\t\t\t}\n\t\t\tif(outputBuffer != null) {\n\t\t\t\tdisplay.printOutput(outputBuffer.toString());\n\t\t\t\teventManager.fireEvent(new ConsoleOutputEvent(outputBuffer.toString(), false));\n\t\t\t\toutputBuffer = null;\n\t\t\t}\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic void addConsoleOutputListener(IEventHandler listener) {\n\t\teventManager.addListener(listener);\n\t}\n\n\t@Override\n\tpublic void removeConsoleOutputListener(IEventHandler listener) {\n\t\teventManager.removeListener(listener);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/internal/paths/PathFinder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.paths;\n\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.Reader;\nimport java.util.Properties;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.paths.IPathFinder;\n\npublic class PathFinder implements IPathFinder {\n\tprivate final Logger logger = Logger.getLogger(\"paths\");\n\tprivate final Properties configProperties = new Properties();\n\t\n\t@Override\n\tpublic File getVegaDirectory() {\n\t\tfinal File homeDirectory = new File(System.getProperty(\"user.home\"));\n\t\treturn new File(homeDirectory, \".vega\");\n\t}\n\n\t@Override\n\tpublic File getWorkspaceDirectory() {\n\t\treturn new File(getVegaDirectory(), \"workspaces\");\n\t}\n\t\n\t@Override\n\tpublic File getConfigFilePath() {\n\t\treturn new File(getVegaDirectory(), \"config\");\n\t}\n\t\n\t@Override\n\tpublic File getDataDirectory() {\n\t\tfinal File dataDirectoryFromConfig = getDataDirectoryFromConfig();\n\t\tif(dataDirectoryFromConfig != null)\n\t\t\treturn dataDirectoryFromConfig;\n\t\t\n\t\tif(isRunningInEclipse())\n\t\t\treturn getDataDirectoryForEclipseLaunch();\n\t\telse\n\t\t\treturn getInstallDataDirectory();\n\t}\n\t\n\tprivate boolean isRunningInEclipse() {\n\t\treturn System.getProperty(\"osgi.dev\") != null;\n\t}\n\t\n\tprivate File getDataDirectoryForEclipseLaunch() {\n\t\tfinal String uglyHack = System.getProperty(\"osgi.splashPath\");\n\t\tfinal File splashPathFile = new File(fileURLTrim(uglyHack));\n\t\treturn splashPathFile.getParentFile().getParentFile();\t\t\n\t}\n\n\tprivate File getInstallDataDirectory() {\n\t\tfinal String install = System.getProperty(\"osgi.install.area\");\n\t\treturn new File(fileURLTrim(install));\n\t}\n\t\n\tprivate String fileURLTrim(String fileURL) {\n\t\treturn (fileURL.startsWith(\"file:\")) ? (fileURL.substring(5)) : fileURL;\n\t}\n\t\n\tprivate File getDataDirectoryFromConfig() {\n\t\tloadConfigProperties();\n\t\tString pathProp = configProperties.getProperty(\"vega.scanner.datapath\");\n\t\tif(pathProp != null) {\n\t\t\tfinal File dataDir = new File(pathProp);\n\t\t\tif(dataDir.exists() && dataDir.isDirectory())\n\t\t\t\treturn dataDir;\n\t\t}\n\t\treturn null;\n\t}\n\t\t\t\t\n\t\n\tprivate void loadConfigProperties() {\n\t\tfinal File configFile = getConfigFilePath();\n\t\tif(!configFile.exists() || !configFile.canRead()) {\n\t\t\treturn;\n\t\t}\n\t\tReader r = null;\n\t\ttry {\n\t\t\tr = new FileReader(configFile);\n\t\t\tconfigProperties.clear();\n\t\t\tconfigProperties.load(r);\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error opening config file: \"+ e.getMessage(), e);\n\t\t} finally {\n\t\t\tif(r != null) {\n\t\t\t\ttry {\n\t\t\t\t\tr.close();\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tlogger.log(Level.WARNING, \"Error closing config file: \"+ e.getMessage(), e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/src/com/subgraph/vega/ui/util/ImageCache.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\n\npublic class ImageCache {\n\tprivate final String pluginId;\n\tprivate final Map<ImageDescriptor, Image> imageMap = new HashMap<ImageDescriptor, Image>();\n\tprivate final Map<String, Image> disabledMap = new HashMap<String, Image>();\n\t\n\tpublic ImageCache(String pluginId) {\n\t\tthis.pluginId = pluginId;\n\t}\n\t\n\tpublic Image get(String key) {\n\t\treturn get(getDescriptor(key));\n\t}\n\t\n\tpublic Image getDisabled(String key) {\n\t\tsynchronized (disabledMap) {\n\t\t\tfinal Image image = disabledMap.get(key);\n\t\t\tif(image == null)\n\t\t\t\treturn getDisabledImageAndCache(key);\n\t\t\telse\n\t\t\t\treturn image;\n\t\t}\n\t}\n\t\n\tprivate Image getDisabledImageAndCache(String key) {\n\t\tfinal Image originalImage = get(key);\n\t\tif(originalImage == null)\n\t\t\treturn null;\n\t\tfinal Image newImage = new Image(originalImage.getDevice(), originalImage, SWT.IMAGE_GRAY);\n\t\tdisabledMap.put(key, newImage);\n\t\treturn newImage;\n\t}\n\t\n\tpublic Image get(ImageDescriptor descriptor) {\n\t\tif(descriptor == null)\n\t\t\treturn null;\n\t\tsynchronized (imageMap) {\n\t\t\tfinal Image image = imageMap.get(descriptor);\n\t\t\tif(image == null)\n\t\t\t\treturn getImageAndCache(descriptor);\n\t\t\treturn image;\n\t\t}\n\t}\n\tprivate ImageDescriptor getDescriptor(String key) {\n\t\treturn AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, key);\n\t}\n\t\n\tprivate Image getImageAndCache(ImageDescriptor descriptor) {\n\t\tfinal Image image = descriptor.createImage();\n\t\timageMap.put(descriptor, image);\n\t\treturn image;\n\t}\n\t\n\tpublic void dispose() {\n\t\tsynchronized (imageMap) {\n\t\t\tfor(Image image: imageMap.values())\n\t\t\t\timage.dispose();\n\t\t}\n\t\timageMap.clear();\n\t\tsynchronized (disabledMap) {\n\t\t\tfor(Image image: disabledMap.values())\n\t\t\t\timage.dispose();\n\t\t}\n\t\tdisabledMap.clear();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/vega.product",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?pde version=\"3.5\"?>\n\n<product name=\"Subgraph Vega\" id=\"com.subgraph.vega.application.product\" application=\"com.subgraph.vega.application.application\" version=\"1.0.0.qualifier\" useFeatures=\"true\" includeLaunchers=\"true\">\n\n   <aboutInfo>\n      <image path=\"/com.subgraph.vega.application/icons/vega_small.png\"/>\n      <text>\n         Copyright 2012 Subgraph Technologies, Inc. http://www.subgraph.com\n      </text>\n   </aboutInfo>\n\n   <configIni use=\"default\">\n   </configIni>\n\n   <launcherArgs>\n      <vmArgs>-Xms256m -XX:PermSize=128m -XX:MaxPermSize=256m</vmArgs>\n      <vmArgsLin>-Xmx2048m</vmArgsLin>\n      <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xmx2048m</vmArgsMac>\n      <vmArgsWin>-Xmx1536m</vmArgsWin>\n   </launcherArgs>\n\n   <windowImages i16=\"/com.subgraph.vega.application/icons/16x16Vega.png\" i32=\"/com.subgraph.vega.application/icons/32x32Vega.png\" i48=\"/com.subgraph.vega.application/icons/48x48Vega.png\" i64=\"/com.subgraph.vega.application/icons/64x64Vega.png\" i128=\"/com.subgraph.vega.application/icons/128x128Vega.png\"/>\n\n   <launcher name=\"Vega\">\n      <linux icon=\"/com.subgraph.vega.application/icons/Vega.xpm\"/>\n      <macosx icon=\"/com.subgraph.vega.application/icons/VegaIcons-OSX.icns\"/>\n      <solaris/>\n      <win useIco=\"true\">\n         <ico path=\"/com.subgraph.vega.application/icons/Vega.ico\"/>\n         <bmp/>\n      </win>\n   </launcher>\n\n   <vm>\n   </vm>\n\n   <plugins>\n      <plugin id=\"com.ibm.icu\"/>\n      <plugin id=\"com.subgraph.vega.application\"/>\n      <plugin id=\"org.eclipse.core.commands\"/>\n      <plugin id=\"org.eclipse.core.contenttype\"/>\n      <plugin id=\"org.eclipse.core.databinding\"/>\n      <plugin id=\"org.eclipse.core.databinding.observable\"/>\n      <plugin id=\"org.eclipse.core.databinding.property\"/>\n      <plugin id=\"org.eclipse.core.expressions\"/>\n      <plugin id=\"org.eclipse.core.jobs\"/>\n      <plugin id=\"org.eclipse.core.runtime\"/>\n      <plugin id=\"org.eclipse.equinox.app\"/>\n      <plugin id=\"org.eclipse.equinox.common\"/>\n      <plugin id=\"org.eclipse.equinox.preferences\"/>\n      <plugin id=\"org.eclipse.equinox.registry\"/>\n      <plugin id=\"org.eclipse.equinox.servletbridge.extensionbundle\" fragment=\"true\"/>\n      <plugin id=\"org.eclipse.help\"/>\n      <plugin id=\"org.eclipse.jface\"/>\n      <plugin id=\"org.eclipse.jface.databinding\"/>\n      <plugin id=\"org.eclipse.osgi\"/>\n      <plugin id=\"org.eclipse.swt\"/>\n      <plugin id=\"org.eclipse.swt.cocoa.macosx.x86_64\" fragment=\"true\"/>\n      <plugin id=\"org.eclipse.ui\"/>\n      <plugin id=\"org.eclipse.ui.cocoa\" fragment=\"true\"/>\n      <plugin id=\"org.eclipse.ui.workbench\"/>\n   </plugins>\n\n   <features>\n      <feature id=\"com.subgraph.vega.feature\" version=\"1.0.0.qualifier\"/>\n      <feature id=\"org.eclipse.rcp\"/>\n   </features>\n\n   <configurations>\n      <plugin id=\"com.subgraph.vega.analysis\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.crawler\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.html\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.http.proxy\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.http.requests\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.model\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.model.web\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.requestlog\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.scanner\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.scanner.modules\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"com.subgraph.vega.ui.console\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"org.eclipse.core.runtime\" autoStart=\"true\" startLevel=\"0\" />\n      <plugin id=\"org.eclipse.equinox.ds\" autoStart=\"true\" startLevel=\"0\" />\n   </configurations>\n\n</product>\n"
  },
  {
    "path": "platform/com.subgraph.vega.application/vega.target",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<?pde version=\"3.8\"?><target name=\"vega\" sequenceNumber=\"8\">\n<locations>\n<location path=\"${project_loc}/extra-bundles\" type=\"Directory\"/>\n<location includeAllPlatforms=\"true\" includeConfigurePhase=\"false\" includeMode=\"slicer\" includeSource=\"true\" type=\"InstallableUnit\">\n<unit id=\"org.eclipse.ui.workbench.texteditor\" version=\"3.8.0.v20120523-1310\"/>\n</location>\n<location includeAllPlatforms=\"true\" includeConfigurePhase=\"false\" includeMode=\"slicer\" includeSource=\"true\" type=\"InstallableUnit\">\n<unit id=\"org.eclipse.rcp.sdk.id\" version=\"3.8.2.M20130131-0800\"/>\n<repository location=\"http://download.eclipse.org/eclipse/updates/3.8\"/>\n</location>\n</locations>\n</target>\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.crawler</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/.settings/org.eclipse.pde.core.prefs",
    "content": "#Wed Aug 25 21:23:02 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Crawler\nBundle-SymbolicName: com.subgraph.vega.crawler\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.subgraph.vega.api.crawler,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model.requests,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client,\n org.apache.http.client.methods,\n org.apache.http.util;version=\"4.1.0\"\nService-Component: OSGI-INF/crawler-factory.xml\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/OSGI-INF/crawler-factory.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.crawler-factory\">\n   <implementation class=\"com.subgraph.vega.internal.crawler.WebCrawlerFactory\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.crawler.IWebCrawlerFactory\"/>\n   </service>\n   <reference bind=\"setRequestEngineFactory\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory\" name=\"IHttpRequestEngineFactory\" policy=\"static\" unbind=\"unsetRequestEngineFactory\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/CrawlerPauseLock.java",
    "content": "package com.subgraph.vega.internal.crawler;\n\npublic class CrawlerPauseLock {\n\tprivate boolean isPaused;\n\t\n\tpublic synchronized void pauseCrawler() {\n\t\tisPaused = true;\n\t}\n\t\n\tpublic synchronized void unpauseCrawler() {\n\t\tisPaused = false;\n\t\tnotifyAll();\n\t}\n\t\n\tpublic synchronized boolean isPaused() {\n\t\treturn isPaused;\n\t}\n\t\n\tpublic void checkIfPaused() throws InterruptedException {\n\t\tsynchronized(this) {\n\t\t\twhile(isPaused) {\n\t\t\t\twait();\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/CrawlerTask.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.crawler;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic class CrawlerTask {\n\n\tstatic CrawlerTask createTask(HttpUriRequest request, ICrawlerResponseProcessor responseProcessor, Object argument) {\n\t\treturn new CrawlerTask(request, responseProcessor, argument, false);\n\t}\n\t\n\tstatic CrawlerTask createExitTask() {\n\t\treturn new CrawlerTask(null, null, null, true);\n\t}\n\t\n\tprivate final HttpUriRequest request;\n\tprivate final ICrawlerResponseProcessor responseProcessor;\n\tprivate final Object argument;\n\tprivate IHttpResponse response;\n\tprivate Throwable exception;\n\tprivate final boolean isExitTask;\n\t\n\t\n\t\n\tprivate CrawlerTask(HttpUriRequest request, ICrawlerResponseProcessor responseProcessor, Object argument, boolean isExit) {\n\t\tthis.request = request;\n\t\tthis.responseProcessor = responseProcessor;\n\t\tthis.argument = argument;\n\t\tthis.isExitTask = isExit;\n\t}\n\t\n\tboolean isExitTask() {\n\t\treturn isExitTask;\n\t}\n\t\n\tpublic HttpUriRequest getRequest() {\n\t\treturn request;\n\t}\n\t\n\tpublic Object getArgument() {\n\t\treturn argument;\n\t}\n\t\n\tIHttpResponse getResponse() {\n\t\treturn response;\n\t}\n\t\n\tvoid setResponse(IHttpResponse response) {\n\t\tthis.response = response;\n\t}\n\t\n\tvoid setException(Throwable exception) {\n\t\tthis.exception = exception;\n\t}\n\t\n\tThrowable getException() {\n\t\treturn exception;\n\t}\n\t\n\tboolean causedException() {\n\t\treturn exception != null;\n\t}\n\n\tpublic ICrawlerResponseProcessor getResponseProcessor() {\n\t\treturn responseProcessor;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/HttpResponseProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.crawler;\n\nimport java.io.IOException;\nimport java.util.concurrent.BlockingQueue;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.util.EntityUtils;\n\npublic class HttpResponseProcessor implements Runnable {\n\tprivate final Logger logger = Logger.getLogger(\"crawler\");\n\tprivate final WebCrawler crawler;\n\tprivate final BlockingQueue<CrawlerTask> crawlerRequestQueue;\n\tprivate final BlockingQueue<CrawlerTask> crawlerResponseQueue;\n\tprivate final CountDownLatch latch;\n\tprivate final TaskCounter counter;\n\tprivate final AtomicInteger outstandingTasks;\n\tprivate final boolean stopOnEmptyQueue;\n\tprivate final CrawlerPauseLock pauseLock;\n\tprivate volatile boolean stop;\n\tprivate final Object requestLock = new Object();\n\tprivate volatile HttpUriRequest activeRequest = null;\n\n\tHttpResponseProcessor(WebCrawler crawler, BlockingQueue<CrawlerTask> requestQueue, BlockingQueue<CrawlerTask> responseQueue, CountDownLatch latch, TaskCounter counter, AtomicInteger outstandingTasks, boolean stopOnEmptyQueue, CrawlerPauseLock pauseLock) {\n\t\tthis.crawler = crawler;\n\t\tthis.crawlerRequestQueue = requestQueue;\n\t\tthis.crawlerResponseQueue = responseQueue;\n\t\tthis.latch = latch;\n\t\tthis.counter = counter;\n\t\tthis.outstandingTasks = outstandingTasks;\n\t\tthis.stopOnEmptyQueue = stopOnEmptyQueue;\n\t\tthis.pauseLock = pauseLock;\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\ttry {\n\t\t\trunLoop();\n\t\t} catch (InterruptedException e) {\n\t\t\tThread.currentThread().interrupt();\n\t\t} finally {\n\t\t\tlatch.countDown();\n\t\t}\n\t}\n\n\tvoid stop() {\n\t\tstop = true;\n\t\tif(!crawlerResponseQueue.offer(CrawlerTask.createExitTask())) {\n\t\t\tlogger.warning(\"Failed to add STOP sentinel to crawler response queue\");\n\t\t}\n\t\tsynchronized(requestLock) {\n\t\t\tif(activeRequest != null)\n\t\t\t\tactiveRequest.abort();\n\t\t}\n\t}\n\n\n\tprivate void runLoop() throws InterruptedException {\n\t\twhile(!stop) {\n\t\t\tpauseLock.checkIfPaused();\n\t\t\tCrawlerTask task = crawlerResponseQueue.take();\n\t\t\tif(task.isExitTask()) {\n\t\t\t\tcrawlerRequestQueue.add(CrawlerTask.createExitTask());\n\t\t\t\tcrawlerResponseQueue.add(task);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tHttpUriRequest req = task.getRequest();\n\t\t\tactiveRequest = req;\n\t\t\ttry {\n\t\t\t\tif(task.getResponse() != null) {\n\t\t\t\t\ttask.getResponseProcessor().processResponse(crawler, req, task.getResponse(), task.getArgument());\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.log(Level.WARNING, \"Unexpected exception processing crawler request: \"+ req.getURI(), e);\n\t\t\t} finally {\n\t\t\t\tsynchronized (requestLock) {\n\t\t\t\t\tactiveRequest = null;\n\t\t\t\t}\n\t\t\t\tfinal HttpEntity entity = (task.getResponse() == null) ? (null) : task.getResponse().getRawResponse().getEntity();\n\t\t\t\tif(entity != null)\n\t\t\t\t\ttry {\n\t\t\t\t\t\tEntityUtils.consume(entity);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tlogger.log(Level.WARNING, \"I/O exception consuming request entity content for \"+ req.getURI() + \" : \"+ e.getMessage());\n\t\t\t\t\t}\n\t\t\t}\n\n\t\t\tsynchronized(counter) {\n\t\t\t\tcounter.addCompletedTask();\n\t\t\t}\n\n\t\t\tif(task.getResponse() == null) {\n\t\t\t\tif(task.causedException()) {\n\t\t\t\t\ttask.getResponseProcessor().processException(task.getRequest(), task.getException(), task.getArgument());\n\t\t\t\t} else {\n\t\t\t\t\tfinal Throwable ex = new IllegalStateException(\"Completed queue task has no response and no exception\");\n\t\t\t\t\ttask.getResponseProcessor().processException(task.getRequest(), ex, task.getArgument());\n\t\t\t\t}\n\t\t\t}\n\t\n\t\t\tif(outstandingTasks.decrementAndGet() <= 0) {\n\t\t\t\tif(stopOnEmptyQueue) {\n\t\t\t\t\tcrawlerRequestQueue.add(CrawlerTask.createExitTask());\n\t\t\t\t\tcrawlerResponseQueue.add(CrawlerTask.createExitTask());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/RequestConsumer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.crawler;\n\nimport java.io.InterruptedIOException;\nimport java.util.concurrent.BlockingQueue;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.RequestEngineException;\n\npublic class RequestConsumer implements Runnable {\n\tprivate final Logger logger = Logger.getLogger(\"crawler\");\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate final BlockingQueue<CrawlerTask> crawlerRequestQueue;\n\tprivate final BlockingQueue<CrawlerTask> crawlerResponseQueue;\n\tprivate final CountDownLatch latch;\n\tprivate final CrawlerPauseLock pauseLock;\n\tprivate volatile boolean stop;\n\tprivate final Object requestLock = new Object();\n\tprivate volatile HttpUriRequest activeRequest = null;\n\n\tRequestConsumer(IHttpRequestEngine requestEngine, BlockingQueue<CrawlerTask> requestQueue, BlockingQueue<CrawlerTask> responseQueue, CountDownLatch latch, CrawlerPauseLock pauseLock) {\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.crawlerRequestQueue = requestQueue;\n\t\tthis.crawlerResponseQueue = responseQueue;\n\t\tthis.latch = latch;\n\t\tthis.pauseLock = pauseLock;\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\ttry {\n\t\t\trunLoop();\n\t\t} catch (InterruptedException e) {\n\t\t\tThread.currentThread().interrupt();\n\t\t} finally {\n\t\t\tlatch.countDown();\n\t\t}\t\t\n\t}\n\t\n\tvoid stop() {\n\t\tstop = true;\n\t\tsynchronized (requestLock) {\n\t\t\tif(activeRequest != null)\n\t\t\t\tactiveRequest.abort();\n\t\t}\n\t}\n\t\n\tprivate void runLoop() throws InterruptedException {\n\t\twhile(!stop) {\n\t\t\tpauseLock.checkIfPaused();\n\t\t\tCrawlerTask task = (CrawlerTask) crawlerRequestQueue.take();\n\t\t\t\n\t\t\tif(task.isExitTask()) {\n\t\t\t\t// Put poison pill back in queue so every other RequestConsumer task will see it.\n\t\t\t\tcrawlerRequestQueue.add(task);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlogger.info(\"Retrieving: \" + task.getRequest().getRequestLine().getUri());\n\n\t\t\tif(!sendRequest(task)) {\n\t\t\t\tif(!stop && !task.causedException()) {\n\t\t\t\t\tlogger.log(Level.WARNING, \"No response was receiven for request to \"+ task.getRequest().getURI());\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tcrawlerResponseQueue.put(task);\n\t\t}\n\t}\n\n\tprivate boolean sendRequest(CrawlerTask task) {\n\t\ttry {\n\t\t\tactiveRequest = task.getRequest();\n\t\t\tfinal IHttpResponse response = requestEngine.sendRequest(task.getRequest()).get(true);\n\t\t\ttask.setResponse(response);\n\t\t\treturn response != null;\n\t\t} catch (RequestEngineException e) {\n\t\t\tif(e.getCause() instanceof InterruptedIOException) {\n\t\t\t\tstop = true;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(e.getMessage().contains(\"abort\")) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\ttask.setException(e.getCause());\n\t\t\tlogger.log(Level.WARNING, e.getMessage());\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tsynchronized(requestLock) {\n\t\t\t\tactiveRequest = null;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/TaskCounter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.crawler;\n\npublic class TaskCounter {\n\tprivate int totalTasks;\n\tprivate int completedTasks;\n\t\n\tvoid addNewTask() {\n\t\ttotalTasks += 1;\n\t}\n\t\n\tvoid addCompletedTask() {\n\t\tcompletedTasks += 1;\n\t}\n\t\n\tint getTotalTasks() {\n\t\treturn totalTasks;\n\t}\n\t\n\tint getCompletedTasks() {\n\t\treturn completedTasks;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/WebCrawler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.crawler;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.BlockingQueue;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.LinkedBlockingQueue;\nimport java.util.concurrent.atomic.AtomicInteger;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\n\npublic class WebCrawler implements IWebCrawler {\n\tprivate final static int MAX_QUEUED_REQUESTS = 50000;\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate final Executor executor;\n\tprivate final BlockingQueue<CrawlerTask> requestQueue = new LinkedBlockingQueue<CrawlerTask>(MAX_QUEUED_REQUESTS);\n\tprivate final BlockingQueue<CrawlerTask> responseQueue = new LinkedBlockingQueue<CrawlerTask>();\n\tprivate final List<RequestConsumer> requestConsumers;\n\tprivate final List<HttpResponseProcessor> responseProcessors;\n\tprivate final int requestThreadCount;\n\tprivate final int responseThreadCount;\n\tprivate final CrawlerPauseLock pauseLock;\n\n\tprivate boolean stopOnEmptyQueue = true;\n\tvolatile private CountDownLatch latch;\n\t\n\tvolatile private boolean crawlerRunning;\n\t\n\tprivate TaskCounter counter = new TaskCounter();\n\tprivate AtomicInteger outstandingTasks = new AtomicInteger();\n\t\n\tWebCrawler(IHttpRequestEngine requestEngine, int requestThreadCount, int responseThreadCount) {\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.requestThreadCount = requestThreadCount;\n\t\tthis.responseThreadCount = responseThreadCount;\n\t\tthis.executor = Executors.newFixedThreadPool(requestThreadCount + responseThreadCount);\n\t\tthis.requestConsumers = new ArrayList<RequestConsumer>(requestThreadCount);\n\t\tthis.responseProcessors = new ArrayList<HttpResponseProcessor>(responseThreadCount);\n\t\tthis.pauseLock = new CrawlerPauseLock();\n\t}\n\t\n\t@Override\n\tpublic IHttpRequestEngine getRequestEngine() {\n\t\treturn requestEngine;\n\t}\n\n\t@Override\n\tpublic synchronized void start() {\n\t\tif(crawlerRunning)\n\t\t\tthrow new IllegalStateException(\"Cannot call start() on running crawler instance\");\n\t\n\t\tlatch = new CountDownLatch(requestThreadCount + responseThreadCount);\n\t\t\n\t\tfor(int i = 0; i < responseThreadCount; i++) {\n\t\t\tHttpResponseProcessor responseProcessor = new HttpResponseProcessor(this, requestQueue, responseQueue, latch, counter, outstandingTasks, stopOnEmptyQueue, pauseLock);\n\t\t\tresponseProcessors.add(responseProcessor);\n\t\t\texecutor.execute(responseProcessor);\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < requestThreadCount; i++) {\n\t\t\tRequestConsumer consumer = new RequestConsumer(requestEngine, requestQueue, responseQueue, latch, pauseLock);\n\t\t\trequestConsumers.add(consumer);\n\t\t\texecutor.execute(consumer);\n\t\t}\n\t\tcrawlerRunning = true;\n\t}\n\t\n\tpublic synchronized void stop() throws InterruptedException {\n\t\tif(!crawlerRunning) {\n\t\t\treturn;\n\t\t}\n\t\tsynchronized (pauseLock) {\n\t\t\tif(pauseLock.isPaused()) {\n\t\t\t\tpauseLock.unpauseCrawler();\n\t\t\t}\n\t\t}\n\n\t\tfor(HttpResponseProcessor responseProcessor: responseProcessors)\n\t\t\tresponseProcessor.stop();\n\t\t\n\t\tfor(RequestConsumer consumer: requestConsumers)\n\t\t\tconsumer.stop();\n\t\t\n\t\trequestQueue.clear();\n\t\trequestQueue.put(CrawlerTask.createExitTask());\n\t\tresponseQueue.clear();\n\t\tresponseQueue.put(CrawlerTask.createExitTask());\n\t\tcrawlerRunning = false;\n\t}\n\t\n\t@Override\n\tpublic void pause() {\n\t\tpauseLock.pauseCrawler();\n\t}\n\t\n\t@Override\n\tpublic void unpause() {\n\t\tpauseLock.unpauseCrawler();\n\t}\n\n\t@Override\n\tpublic boolean isPaused() {\n\t\treturn pauseLock.isPaused();\n\t}\n\n\tpublic void waitFinished() throws InterruptedException {\n\t\tlatch.await();\n\t}\n\n\t@Override\n\tpublic void submitTask(HttpUriRequest request, ICrawlerResponseProcessor callback) {\n\t\tsubmitTask(request, callback, null);\n\t}\n\t\n\t@Override\n\tpublic void submitTask(HttpUriRequest request,\n\t\t\tICrawlerResponseProcessor callback, Object argument) {\n\t\tCrawlerTask task = CrawlerTask.createTask(request, callback, argument);\n\t\toutstandingTasks.incrementAndGet();\n\t\tsynchronized(counter) {\n\t\t\tcounter.addNewTask();\n\t\t\ttry {\n\t\t\t\trequestQueue.put(task);\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\tthrow new RuntimeException(\"Interruped submission of request task\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void setStopOnEmptyQueue(boolean value) {\n\t\tstopOnEmptyQueue = value;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.crawler/src/com/subgraph/vega/internal/crawler/WebCrawlerFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.crawler;\n\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.crawler.IWebCrawlerFactory;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\npublic class WebCrawlerFactory implements IWebCrawlerFactory {\n\tprivate final static int DEFAULT_RESPONSE_THREAD_COUNT = 20;\n\tprivate final static int MIN_REQUEST_THREAD_COUNT = 5;\n\tprivate final static int MAX_REQUEST_THREAD_COUNT = 100;\n\tprivate IHttpRequestEngineFactory requestEngineFactory;\n\t\n\t@Override\n\tpublic IWebCrawler create(IRequestOrigin requestOrigin) {\n\t\tfinal IHttpRequestEngine requestEngine = requestEngineFactory.createRequestEngine(IHttpRequestEngine.EngineConfigType.CONFIG_SCANNER, requestEngineFactory.createConfig(), requestOrigin);\n\t\treturn create(requestEngine);\n\t}\n\n\t@Override\n\tpublic IWebCrawler create(IHttpRequestEngine requestEngine) {\n\t\treturn new WebCrawler(requestEngine, getRequestThreadCount(requestEngine), DEFAULT_RESPONSE_THREAD_COUNT);\n\t}\n\n\tprotected void setRequestEngineFactory(IHttpRequestEngineFactory factory) {\n\t\tthis.requestEngineFactory = factory;\n\t}\n\t\n\tprotected void unsetRequestEngineFactory(IHttpRequestEngineFactory factory) {\n\t\tthis.requestEngineFactory = null;\n\t}\n\t\n\tprivate int getRequestThreadCount(IHttpRequestEngine requestEngine) {\n\t\tint connectLimit = requestEngine.getRequestEngineConfig().getMaxConnections();\n\t\tif(connectLimit < MIN_REQUEST_THREAD_COUNT) {\n\t\t\treturn MIN_REQUEST_THREAD_COUNT;\n\t\t} else if(connectLimit > MAX_REQUEST_THREAD_COUNT) {\n\t\t\treturn MAX_REQUEST_THREAD_COUNT;\n\t\t} else {\n\t\t\treturn connectLimit;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry exported=\"true\" kind=\"lib\" path=\"lib/freemarker.jar\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"lib\" path=\"/Users/dma/Downloads/fm2/freemarker.jar\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.export</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Export\nBundle-SymbolicName: com.subgraph.vega.export\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.export.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.8,\n JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nExport-Package: com.subgraph.vega.export\nImport-Package: com.subgraph.vega.api.events,\n com.subgraph.vega.api.html,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.xml,\n org.apache.http;version=\"4.2.3\",\n org.apache.http.client.utils;version=\"4.2.2\",\n org.apache.http.entity;version=\"4.2.3\",\n org.apache.http.protocol;version=\"4.2.3\",\n org.apache.http.util;version=\"4.2.3\"\nBundle-ClassPath: .,\n lib/freemarker.jar\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = plugin.xml,\\\n               META-INF/,\\\n               .,\\\n               lib/,\\\n               icons/\n\\\n               lib/freemarker.jar\nsrc.includes = lib/,\\\n               META-INF/\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/src/com/subgraph/vega/export/Activator.java",
    "content": "package com.subgraph.vega.export;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.api.xml.IXmlRepository;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.export\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\tprivate ServiceTracker<IXmlRepository, IXmlRepository> xmlRepositoryTracker;\n\tprivate ServiceTracker<IPathFinder, IPathFinder> pathFinderTracker;\n\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\t\n\t\t\n\t/*\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tSystem.out.println(\"Starting exporter\");\n\t\t*/\n\t\tsuper.start(context);\n\t\t\n\n\t\tpathFinderTracker = new ServiceTracker<IPathFinder, IPathFinder>(context, IPathFinder.class.getName(), null);\n\t\tpathFinderTracker.open();\n\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\n\t\txmlRepositoryTracker = new ServiceTracker<IXmlRepository, IXmlRepository>(context, IXmlRepository.class.getName(), null);\n\t\txmlRepositoryTracker.open();\n\t\t\n\t\tplugin = this;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\tpublic IPathFinder getPathFinder() {\n\t\treturn pathFinderTracker.getService();\n\t}\n\t\n\t/**\n\t * Returns an image descriptor for the image file at the given\n\t * plug-in relative path\n\t *\n\t * @param path the path\n\t * @return the image descriptor\n\t */\n\tpublic static ImageDescriptor getImageDescriptor(String path) {\n\t\treturn imageDescriptorFromPlugin(PLUGIN_ID, path);\n\t}\n\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\t\n\tpublic IXmlRepository getXmlRepository() {\n\t\treturn xmlRepositoryTracker.getService();\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/src/com/subgraph/vega/export/AlertExporter.java",
    "content": "package com.subgraph.vega.export;\n\nimport java.io.BufferedWriter;\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.OutputStreamWriter;\nimport java.io.Writer;\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.core.runtime.IStatus;\nimport org.eclipse.core.runtime.Status;\nimport org.eclipse.jface.dialogs.ErrorDialog;\nimport org.eclipse.swt.widgets.Display;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.paths.IPathFinder;\n\nimport freemarker.cache.FileTemplateLoader;\nimport freemarker.cache.TemplateLoader;\n\npublic class AlertExporter {\n\tIScanAlertRepository alertRepository;\n\tReportRenderer renderer;\t\n\tprivate final Logger logger = Logger.getLogger(\"alert-exporter\");\n\n\n\tpublic AlertExporter(IWorkspace workspace) {\n\t\talertRepository = workspace.getScanAlertRepository();\n\t\trenderer = new ReportRenderer(createTemplateLoader());\n\t}\n\t\n\tpublic AlertExporter() {\n\t\trenderer = new ReportRenderer(createTemplateLoader());\n\t}\n\t\n\tpublic void exportAlertsbyList(List<IScanAlert> alerts) {\n\t\twriteFile(\"/tmp/test2.html\", renderer.renderList(alerts));\n\t}\n\t\n\tpublic void exportAllAlerts() {\n\t\t\n\t\tList <IScanInstance> scanInstances = alertRepository.getAllScanInstances();\n\t\t\n\t\tfor (IScanInstance s : scanInstances) {\n\t\t\tList<IScanAlert> scanInstanceAlerts = s.getAllAlerts();\n\t\t\twriteFile(\"/tmp/test.html\",renderer.renderList(scanInstanceAlerts));\n\t\t}\n\t}\n\t\n\tpublic void exportbyScanInstance(IScanInstance scanInstance) {\n\t\twriteFile(\"/tmp/test.html\",renderer.reportFromScanInstance(scanInstance));\n\t}\n\t\n\tprivate TemplateLoader createTemplateLoader() {\n\t\tfinal IPathFinder pathFinder = Activator.getDefault().getPathFinder();\n\t\tif(pathFinder == null)\n\t\t\tthrow new IllegalStateException(\"Cannot find templates to render because path finder service is not available\");\n\t\tfinal File templateDirectory = new File(pathFinder.getDataDirectory(), \"templates\");\n\t\ttry {\n\t\t\treturn new FileTemplateLoader(templateDirectory);\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"Failed to open template directory: \"+ e.getMessage());\n\t\t\treturn null;\n\t\t}\n\t\t\n\t}\n\n\tprivate void writeFile(String path, String data) {\n\t\tWriter writer = null;\n\n\t\ttry {\n\t\t    writer = new BufferedWriter(new OutputStreamWriter(\n\t\t          new FileOutputStream(path), \"utf-8\"));\n\t\t    writer.write(data);\n\t\t} catch (IOException e) {\n\t        Status status = new Status(IStatus.ERROR, \"com.subgraph.vega.export\", 0,\n\t        \t\t\"Error writing alerts to file: \" + e.getMessage(), null);\n\t        ErrorDialog.openError(Display.getCurrent().getActiveShell(),\n\t                \"File I/O Error\", \"Alerts export failed.\", status);\n\t\t\tlogger.log(Level.WARNING, \"I/O error on write to file.\" + e.getMessage());\n\t\t} finally {\n\t\t   try {writer.close();} catch (Exception ex) {}\n\t\t}\n\t\t\n\t}\n\t\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.export/src/com/subgraph/vega/export/ReportRenderer.java",
    "content": "package com.subgraph.vega.export;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.io.StringWriter;\nimport java.net.URL;\nimport java.nio.charset.Charset;\nimport java.nio.charset.UnsupportedCharsetException;\nimport java.text.SimpleDateFormat;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.Date;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.logging.Level;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.utils.URLEncodedUtils;\nimport org.apache.http.entity.ContentType;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.util.CharArrayBuffer;\nimport org.eclipse.core.runtime.FileLocator;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.core.runtime.Path;\nimport org.osgi.framework.Bundle;\nimport org.w3c.dom.Document;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlert.Severity;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.xml.IXmlRepository;\n\nimport freemarker.cache.TemplateLoader;\nimport freemarker.core.ParseException;\nimport freemarker.ext.dom.NodeModel;\nimport freemarker.log.Logger;\nimport freemarker.template.Configuration;\nimport freemarker.template.DefaultObjectWrapper;\nimport freemarker.template.MalformedTemplateNameException;\nimport freemarker.template.Template;\nimport freemarker.template.TemplateException;\nimport freemarker.template.TemplateNotFoundException;\n\npublic class ReportRenderer {\n\tprivate final Logger logger = Logger.getLogger(\"report-render\");\n\tprivate Configuration configuration;\n\tprivate final String imageURL;\n\tprivate final String bulletPointURL;\n\tprivate final String bannerPatternURL;\n\tprivate final String bannerLogoURL;\n\tprivate final String titlePatternURL;\n\tprivate final String redArrowURL;\n\tprivate final String sectionGradientURL;\n\tprivate final String linkArrowURL;\n\tprivate final Map<String, Document> alertDocumentCache = new HashMap<String, Document>();\n\tprivate IRequestLog requestLog;\n\t\n\tpublic ReportRenderer(TemplateLoader templateLoader) {\n\t\timageURL = findImage(\"icons/vega_logo.png\");\n\t\tbulletPointURL = findImage(\"icons/doubleArrow.png\");\n\t\tbannerPatternURL = findImage(\"icons/bannerPattern.png\");\n\t\tbannerLogoURL = findImage(\"icons/bannerLogo.png\");\n\t\ttitlePatternURL = findImage(\"icons/titlePattern.png\");\n\t\tredArrowURL = findImage(\"icons/redArrow.png\");\n\t\tsectionGradientURL = findImage(\"icons/sectionGradient.png\");\n\t\tlinkArrowURL = findImage(\"icons/linkArrow.png\");\n\t\t\n\t\tconfiguration = new Configuration();\n\t\tconfiguration.setTemplateLoader(templateLoader);\n\t\tconfiguration.setObjectWrapper(new DefaultObjectWrapper());\n\t\tfinal IWorkspace currentWorkspace = Activator.getDefault().getModel().addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent)\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceCloseEvent)\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceResetEvent)\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tif(currentWorkspace != null)\n\t\t\trequestLog = currentWorkspace.getRequestLog();\n\t}\n\t\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\trequestLog = event.getWorkspace().getRequestLog();\n\t}\n\t\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\trequestLog = null;\n\t}\n\t\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\trequestLog = event.getWorkspace().getRequestLog();\n\t}\n\t\n\tprivate String reportHeader() {\n\t\tString output = \"<html>\\n\" +\n\t                    \"  <head>\" +\n\t\t\t\t        \"    <title>Subgraph Vega Scan Results</title>\" +\n\t                    \"    <style>\" + reportCss() + \"</style>\" + \n\t\t\t\t        \"  </head>\" +\n\t                    \"  <body> \";\n\t\t\n\t\treturn output;\n\t\t\n\t}\n\t\n\tpublic String reportSummary(List<IScanAlert> alerts) {\n\t\t\n\t\tHashMap<Severity,HashMap<String, Integer>> reportSummary = reportScanInstanceSummary(alerts);\n\t\tString output = \"\";\n\t\t\n\t\tif (reportSummary != null && reportSummary.isEmpty() == false) {\n\t\t\t\n\t\t\toutput += \"<div class=summary-page>\\n\";\n\t\t\toutput += \"<a name=summary-page></a>\\n\";\n\n            output += \"<div class=vegabanner id=vegabanner>\\n\";\n            output += \"<img class=bannerLogo width=173px height=24px>\";\n            output += \"<span>Open Source Web Security Platform</span></div>\\n\";\n           \n\t\t\toutput += \"<div class=summary-title-block>\\n\";\n\t\t\toutput += \"<h1>Subgraph Vega Vulnerability Scan Report</h1>\\n\";\n\t\t\toutput += \"</div>\";\n\t\t\toutput += \"<div class=summary-table>\\n\";\n\t\t\toutput += \"<span class=table-title>Summary</span>\\n\";\n\t\t\toutput += \"<table>\\n\";\n\t\t\toutput += \"<col style=\\\"width: 95%;\\\">\\n<col style=\\\"width: 5%;\\\">\\n\";\n\t\t\toutput += \"<thead><th style=\\\"text-align: left;\\\">FINDINGS</th><th>TOTAL</th></thead>\\n<tbody>\\n\";\n\t\t\t\n\t\t\tHashMap<Severity, Integer> severityTotals = new HashMap<Severity, Integer>();\n\t\t\t\n\t\t\tfor (Severity s: Severity.values()) {\n\t\t\t\tseverityTotals.put(s, new Integer(0));\n\t\t\t\t\tfor (String alertTitle : reportSummary.get(s).keySet()) {\n\t\t\t\t\t\tint i = severityTotals.get(s);\n\t\t\t\t\t\tseverityTotals.put(s, new Integer(i + reportSummary.get(s).get(alertTitle).intValue()));\n\t\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tfor (Severity s : Severity.values()) {\n\t\t\t\tif ((reportSummary.get(s) != null) && (reportSummary.get(s).isEmpty() == false)) {\n\t\t\t\t\toutput += \"<tr class=severity-row><td class=severity-name><a href=\\\"#section-\" + s.name() +\"\\\">\"+ this.severityToString(s) + \"</td><td class=severity-\"+s.name() +\">\"+severityTotals.get(s)+\"</td></tr>\\n\";\n\t\t\t\t\tfor (String alertTitle : reportSummary.get(s).keySet()) {\n\t\t\t\t\t\toutput += \"<tr class=alert-row><td>\" + alertTitle + \"</td><td class=alert-count>\" + reportSummary.get(s).get(alertTitle) + \"</td></tr>\\n\";\n\t\t\t\t\t}\t\n\t\t\t\t}\t\n\t\t\t}\n\t\t\t\n\t\t\toutput += \"</tbody>\\n</table></div>\\n\" +\n\t\t\t          \"<div class=detailed-findings><a href=\\\"#alert-0\\\">Detailed Findings</a></div>\" +\n\t\t\t          \"<span class=summary-bottom>\\n<hr>\\n\" +\n\t\t\t\t\t  \"<span class=footertext>Report generated \"+ this.currentDateTimeString() + \" by the Vega open source web application security testing framework.\"+\n                      \"<br />\"+\n                      \"<a href=\\\"https://subgraph.com\\\">https://subgraph.com</a><br />\"+\n                      \"</span></span></div>\\n\";\n\t\t}\t\n\t\treturn output;\n\t}\n\t\n\t\n\t\n\tprivate HashMap<Severity, HashMap<String, Integer>> reportScanInstanceSummary(List<IScanAlert> alerts) {\n\t\t\t\t\n\t\tHashMap<Severity, HashMap<String, Integer>> alertSeverityCounts = new HashMap<Severity, HashMap<String, Integer>>();\n\n\t\tfor (Severity s : Severity.values()){\n\t\t\tHashMap<String, Integer> h = new HashMap<String, Integer>();\n\t\t\talertSeverityCounts.put(s, h);\n\t\t}\n\t\t\n\t\tfor (IScanAlert alert : alerts) {\n\t\t\tHashMap<String,Integer> severityAlertsHashMap;\n\t\t\tseverityAlertsHashMap = alertSeverityCounts.get(alert.getSeverity());\n\t\t\t\n\t\t\tif (severityAlertsHashMap == null) {\n\t\t\t\tHashMap<String, Integer> hm = new HashMap<String, Integer>();\n\t\t\t\thm.put(alert.getTitle(), new Integer(1));\n\t\t\t\talertSeverityCounts.put(alert.getSeverity(), hm);\n\t\t\t} else {\n\t\t\t\tif (severityAlertsHashMap.get(alert.getTitle()) == null) {\n\t\t\t\t\tseverityAlertsHashMap.put(alert.getTitle(), new Integer(1));\n\t\t\t\t} else \n\t\t\t\t{\n\t\t\t\t\tInteger i = severityAlertsHashMap.get(alert.getTitle());\n\t\t\t\t\tseverityAlertsHashMap.put(alert.getTitle(), new Integer(i.intValue() + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\t\t\t\n\n\t\treturn alertSeverityCounts;\n\t}\n\t\n\t\n\n\t\n\tpublic String renderList(List<IScanAlert> alerts) {\n\t\tfinal int maxAlertString = 400; //Activator.getDefault().getPreferenceStore().getInt(IPreferenceConstants.P_MAX_ALERT_STRING);\n\n\t\tMap<String, Object> root = new HashMap<String, Object>();\n\t\tString output = \"\";\n\t\tint i = 0;\n\t\t\n\t\toutput += reportHeader();\n\t\toutput += reportSummary(alerts);\n\t\t\n\t\tList<IScanAlert> alertsArrayList = new ArrayList<IScanAlert>(alerts);\t\n\t\tCollections.sort(alertsArrayList, new Comparator<IScanAlert>(){\n\n\t\t\t@Override\n\t\t\tpublic int compare(IScanAlert alert1, IScanAlert alert2) {\t\t\t\t\n\t\t\t\treturn alert1.getSeverity().compareTo(alert2.getSeverity());\n\t\t\t}\t\n\t\t});\n\n\t\tString severity = \"\";\n\t\tfor (IScanAlert alert : alertsArrayList) {\n\t\t\ttry {\n\t\t\t\t\n\t\t\t\tif (alert.getSeverity().name().equals(severity) == false) {\n\t\t\t\t\toutput += \"<a name=section-\"+alert.getSeverity().name()+\"></a>\";\n\t\t\t\t\tseverity = alert.getSeverity().name();\n\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\tTemplate t = configuration.getTemplate(\"report-alert.ftl\");\n\t\t\t\tDocument xmlRoot = getAlertDocument(alert.getName());\n\t\t\t\tif(xmlRoot == null)\n\t\t\t\t\treturn \"\";\n\t\t\t\tNodeModel nodeModel = NodeModel.wrap(xmlRoot);\n\t\t\t\troot.put(\"doc\", nodeModel);\n\t\t\t\tMap<String,Object> vars = new HashMap<String,Object>();\n\t\t\t\tfor(String k: alert.propertyKeys()) {\n\t\t\t\t\tObject value = alert.getProperty(k);\n\t\t\t\t\tif(value instanceof String) {\n\t\t\t\t\t\tString s = (String) value;\n\t\t\t\t\t\tif(s.length() > maxAlertString) {\n\t\t\t\t\t\t\ts = s.substring(0, maxAlertString) + \"...\";\n\t\t\t\t\t\t} \n\t\t\t\t\t\tvars.put(k, s);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvars.put(k, alert.getProperty(k));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tString severityVar = severityToString(alert.getSeverity());\n\t\t\t\tif(severityVar != null) {\n\t\t\t\t\tvars.put(\"severity\", severityVar);\n\t\t\t\t}\n\t\t\t\tString severityCSSVar = severityToSeverityCSSClass(alert.getSeverity());\n\t\t\t\tif(severityCSSVar != null) {\n\t\t\t\t\tvars.put(\"severityCSS\", severityCSSVar);\n\t\t\t\t}\n\t\t\t\tif(imageURL != null)\n\t\t\t\t\tvars.put(\"imageURL\", imageURL);\n\t\t\t\tif(bulletPointURL != null) {\n\t\t\t\t\tvars.put(\"bulletPointURL\", bulletPointURL);\n\t\t\t\t}\n\t\t\t\tif(bannerPatternURL != null)\n\t\t\t\t\tvars.put(\"bannerPatternURL\", bannerPatternURL);\n\t\t\t\tif(bannerLogoURL != null)\n\t\t\t\t\tvars.put(\"bannerLogoURL\", bannerLogoURL);\n\t\t\t\tif(titlePatternURL != null)\n\t\t\t\t\tvars.put(\"titlePatternURL\", titlePatternURL);\n\t\t\t\tif(redArrowURL != null)\n\t\t\t\t\tvars.put(\"redArrowURL\", redArrowURL);\n\t\t\t\tif(redArrowURL != null)\n\t\t\t\t\tvars.put(\"sectionGradientURL\", sectionGradientURL);\n\t\t\t\tif(linkArrowURL != null)\n\t\t\t\t\tvars.put(\"linkArrowURL\", linkArrowURL);\n\t\t\t\t\n\t\t\t\tif(alert.getRequestId() >= 0 && requestLog != null) {\n\t\t\t\t\tfinal IRequestLogRecord record = requestLog.lookupRecord(alert.getRequestId());\n\t\t\t\t\tif(record != null) {\n\t\t\t\t\t\tif(record.getRequest() instanceof HttpEntityEnclosingRequest) {\n\t\t\t\t\t\t\tvars.put(\"requestText\", renderEntityEnclosingRequest((HttpEntityEnclosingRequest) record.getRequest()));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvars.put(\"requestText\", renderBasicRequest(record.getRequest()));\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t/* TODO: Render the response, with highlights */\n\t\t\t\t\t\t\n\t\t\t\t\t\tvars.put(\"requestId\", Long.toString(alert.getRequestId()));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvars.put(\"num\", Integer.toString(i));\n\t\t\t\t\n\t\t\t\tif (i < alerts.size()-1) {\n\t\t\t\t\tvars.put(\"next\", Integer.toString(i+1));\n\t\t\t\t} else {\n\t\t\t\t\tvars.put(\"next\", null);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tvars.put(\"prev\", Integer.toString(i-1));\n\t\t\t\t} else {\n\t\t\t\t\tvars.put(\"prev\", null);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvars.put(\"datetime\", currentDateTimeString());\n\t\t\t\t\n\t\t\t\tif (alert.getDiscretionaryHostname() != null) {\n\t\t\t\t\tvars.put(\"hostname\", alert.getDiscretionaryHostname());\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlong requestID = alert.getRequestId();\n\t\t\t\tString responseText = renderResponse(requestID);\n\t\t\t\tvars.put(\"responseText\", responseText);\n\t\t\t\t\n\t\t\t\troot.put(\"vars\", vars);\n\t\t\t\t\n\t\t\t\tStringWriter out = new StringWriter();\n\t\t\t\tt.process(root, out);\n\t\t\t\tout.flush();\n\t\t\t\toutput = output.concat(out.toString());\n\t\t\t\ti += 1;\n\t\t\t\t\n\t\t\t} catch (IOException e) {\n\t\t\t\treturn \"I/O error reading alert template file alerts/\"+ alert.getName() + \".xml :<br><br>\"+ e.getMessage();\n\t\t\t} catch (TemplateException e) {\n\t\t\t\treturn \"Error processing alert template file alerts/\"+ alert.getName() +\".xml :<br><br>\"+ e.getMessage();\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\t\n\n\tprivate String renderEntityEnclosingRequest(HttpEntityEnclosingRequest request) {\n\t\tfinal HttpEntity entity = request.getEntity();\n\t\tif(entity == null || !URLEncodedUtils.isEncoded(entity)) {\n\t\t\treturn renderBasicRequest(request);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\tList<NameValuePair> args = URLEncodedUtils.parse(entity);\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(renderBasicRequest(request));\n\t\t\tsb.append(\"\\n[\");\n\t\t\tfor(NameValuePair nvp: args) {\n\t\t\t\tsb.append(nvp.getName());\n\t\t\t\tif(nvp.getValue() != null) {\n\t\t\t\t\tsb.append(\"=\");\n\t\t\t\t\tsb.append(nvp.getValue());\n\t\t\t\t}\n\t\t\t\tsb.append(\"\\n\");\n\t\t\t}\n\t\t\tsb.append(\"]\");\n\t\t\treturn sb.toString();\n\t\t} catch (IOException e) {\n\t\t\treturn renderBasicRequest(request);\n\t\t}\n\t}\n\t\n\tprivate String renderBasicRequest(HttpRequest request) {\n\t\tfinal RequestLine line = request.getRequestLine();\n\t\treturn line.getMethod() +\" \"+ line.getUri();\n\t}\n\tprivate Document getAlertDocument(String name) {\n\t\tif(alertDocumentCache.containsKey(name))\n\t\t\treturn alertDocumentCache.get(name);\n\t\tfinal IXmlRepository xmlRepository = Activator.getDefault().getXmlRepository();\n\t\tif(xmlRepository == null) {\n\t\t\tlogger.warn(\"Could not render alert because xml repository service is not available\");\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tDocument alertDocument = xmlRepository.getDocument(\"alerts/\"+ name + \".xml\");\n\t\tif(alertDocument == null)\n\t\t\talertDocument = xmlRepository.getDocument(\"alerts/default.xml\");\n\t\tif(alertDocument == null) {\n\t\t\tlogger.warn(\"Could not load XML data for alert named '\"+ name + \"'\");\n\t\t\treturn null;\n\t\t}\n\t\talertDocumentCache.put(name, alertDocument);\n\t\treturn alertDocument;\n\t}\n\tprivate String findImage(String imagePath) {\n\t\tBundle b = Activator.getDefault().getBundle();\n\t\tIPath relativePagePath = new Path(imagePath);\n\t\tURL fileInPlugin = FileLocator.find(b, relativePagePath, null);\n\t\ttry {\n\t\t\tURL pageUrl = FileLocator.toFileURL(fileInPlugin);\n\t\t\treturn pageUrl.toString();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\tprivate String severityToString(IScanAlert.Severity s) {\n\t\tswitch(s) {\n\t\tcase HIGH:\n\t\t\treturn \"High\";\n\t\tcase MEDIUM:\n\t\t\treturn \"Medium\";\n\t\tcase LOW:\n\t\t\treturn \"Low\";\n\t\tcase INFO:\n\t\t\treturn \"Info\";\n\t\tcase UNKNOWN:\n\t\t\treturn \"Unknown\";\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate String severityToSeverityCSSClass(IScanAlert.Severity s) {\n\t\tswitch(s) {\n\t\tcase HIGH:\n\t\t\treturn \"highrisk\";\n\t\tcase MEDIUM:\n\t\t\treturn \"medrisk\";\n\t\tcase LOW:\n\t\t\treturn \"lowrisk\";\n\t\tcase INFO:\n\t\t\treturn \"inforisk\";\n\t\tcase UNKNOWN:\n\t\t\treturn \"unknownrisk\";\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate String reportCss() {\n\n\t\tMap<String,Object> vars = new HashMap<String,Object>();\n\t\tMap<String, Object> root = new HashMap<String, Object>();\n\t\t\n\t\ttry {\n\t\t\tTemplate t = configuration.getTemplate(\"report-style.ftl\");\n\t\t\t\n\t\t\tif(imageURL != null)\n\t\t\t\tvars.put(\"imageURL\", imageURL);\n\t\t\tif(bulletPointURL != null)\n\t\t\t\tvars.put(\"bulletPointURL\", bulletPointURL);\n\t\t\tif(bannerPatternURL != null)\n\t\t\t\tvars.put(\"bannerPatternURL\", bannerPatternURL);\n\t\t\tif(bannerLogoURL != null)\n\t\t\t\tvars.put(\"bannerLogoURL\", bannerLogoURL);\n\t\t\tif(titlePatternURL != null)\n\t\t\t\tvars.put(\"titlePatternURL\", titlePatternURL);\n\t\t\tif(redArrowURL != null)\n\t\t\t\tvars.put(\"redArrowURL\", redArrowURL);\n\t\t\tif(redArrowURL != null)\n\t\t\t\tvars.put(\"sectionGradientURL\", sectionGradientURL);\n\t\t\tif(linkArrowURL != null)\n\t\t\t\tvars.put(\"linkArrowURL\", linkArrowURL);\n\t\t\t\n\t\t\troot.put(\"vars\", vars);\n\t\t\tStringWriter out = new StringWriter();\n\t\t\tt.process(root, out);\n\t\t\tout.flush();\n\t\t\treturn out.toString();\n\t\t\t\n\t\t} catch (TemplateNotFoundException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (MalformedTemplateNameException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (ParseException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (TemplateException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\n\n\t\treturn null;\n\t}\n\n\tprivate String currentDateTimeString() {\n\t\t\n\t\tSimpleDateFormat dateFormatter = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss.SSS\");\n\t\tDate date = new Date();\n\t\treturn dateFormatter.format(date);\n\t}\n\n\tpublic String reportFromScanInstance(IScanInstance scanInstance) {\n\n\t\tString output = reportHeader();\n\t\toutput += reportSummary(scanInstance.getAllAlerts());\n\t\toutput += renderList(scanInstance.getAllAlerts());\n\t\toutput = output.concat(\"</body></html>\");\n\t\treturn output;\n\t}\n\t\n\tpublic String renderResponse(long requestID) {\n\t\t\n\t\tString responseString = \"\";\n\t\tString body = \"\";\n\t\t\n\t\tIRequestLogRecord request = requestLog.lookupRecord(requestID);\n\t\tif (request != null) {\n\t\tHttpResponse response = request.getResponse();\n\t\t\n\t\t\tfor(Header h: response.getAllHeaders()) {\n\t\t\t\tresponseString += h + \"\\n\";\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tbody = toString(response.getEntity(), null);\n\t\t\t}\n\t\t\n\t\t\tcatch (ParseException e) {\n\t\t\t\t//\tlogger.log(Level.WARNING, \"Error parsing response headers: \"+ e.getMessage(), e);\n\t\t\t\tbody = \"\";\n\t\t\t} catch (IOException e) {\n\t\t\t\t//\tlogger.log(Level.WARNING, \"IO error extracting response entity for request \"+ request.getRequestLine().getUri() +\" : \"+ e.getMessage(), e);\n\t\t\t\tbody = \"\";\n\t\t\t}\n\t\t} else {\n\t\t\tresponseString = \"Not stored.\";\n\t\t}\n\t\treturn responseString + \"\\n\\n\" + body;\n\t}\n\n\t\n\t   public static String toString(\n\t            final HttpEntity entity, final Charset defaultCharset) throws IOException, ParseException {\n\t        if (entity == null) {\n\t            throw new IllegalArgumentException(\"HTTP entity may not be null\");\n\t        }\n\t        InputStream instream = entity.getContent();\n\t        if (instream == null) {\n\t            return null;\n\t        }\n\t        try {\n\t            if (entity.getContentLength() > Integer.MAX_VALUE) {\n\t                throw new IllegalArgumentException(\"HTTP entity too large to be buffered in memory\");\n\t            }\n\t            int i = (int)entity.getContentLength();\n\t            if (i < 0) {\n\t                i = 4096;\n\t            }\n\t            Charset charset = null;\n\t            try {\n\t                ContentType contentType = ContentType.getOrDefault(entity);\n\t                charset = contentType.getCharset();\n\t            } catch (UnsupportedCharsetException ex) {\n\t            \t// In EntityUtils an exception is thrown here.\n\t            \tcharset = null;\n\t            }\n\t            if (charset == null) {\n\t                charset = defaultCharset;\n\t            }\n\t            if (charset == null) {\n\t                charset = HTTP.DEF_CONTENT_CHARSET;\n\t            }\n\t            Reader reader = new InputStreamReader(instream, charset);\n\t            CharArrayBuffer buffer = new CharArrayBuffer(i);\n\t            char[] tmp = new char[1024];\n\t            int l;\n\t            while((l = reader.read(tmp)) != -1) {\n\t                buffer.append(tmp, 0, l);\n\t            }\n\t            return buffer.toString();\n\t        } finally {\n\t            instream.close();\n\t        }\n\t    }\n\n\t\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.feature/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.feature</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.FeatureBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.FeatureNature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.feature/build.properties",
    "content": "bin.includes = feature.xml\nroot.folder.scripts=../../../../scripts\nroot.folder.xml=../../../../xml\nroot.folder.templates=../../../../templates\nroot.linux.gtk.x86=../../../../rootfiles\nroot.linux.gtk.x86_64=../../../../rootfiles"
  },
  {
    "path": "platform/com.subgraph.vega.feature/feature.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature\n      id=\"com.subgraph.vega.feature\"\n      label=\"Feature\"\n      version=\"1.0.0.qualifier\"\n      provider-name=\"SUBGRAPH\">\n\n   <description url=\"http://www.example.com/description\">\n      [Enter Feature Description here.]\n   </description>\n\n   <copyright url=\"http://www.example.com/copyright\">\n      [Enter Copyright Description here.]\n   </copyright>\n\n   <license url=\"http://www.example.com/license\">\n      [Enter License Description here.]\n   </license>\n\n   <plugin\n         id=\"com.subgraph.vega.application\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.http.proxy\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.google.guava\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.jsoup\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.jface.text\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.text\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.ui.forms\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.apache.commons.codec\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.hexeditor\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.httpeditor\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.model\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.http\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.crawler\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.web\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.api\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.http.requests\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.apache.commons.logging\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.scanner\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.scanner\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.scanner.modules\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.scanner\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.html\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.ui.console\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.ui.workbench.texteditor\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.compare.core\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.eclipse.core.variables\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.analysis\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.util\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.identity\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.macros\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.ui.tags\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.apache.http.core\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"org.apache.http.client\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.sslprobe\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n   <plugin\n         id=\"com.subgraph.vega.export\"\n         download-size=\"0\"\n         install-size=\"0\"\n         version=\"0.0.0\"\n         unpack=\"false\"/>\n\n</feature>\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.html</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/.settings/org.eclipse.pde.core.prefs",
    "content": "#Sun Oct 17 17:17:27 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Html\nBundle-SymbolicName: com.subgraph.vega.html\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nExport-Package: com.subgraph.vega.api.html,\n org.w3c.dom.html2\nImport-Package: org.jsoup,\n org.jsoup.nodes,\n org.jsoup.select\nService-Component: OSGI-INF/html-parser.xml\nRequire-Bundle: org.jsoup;bundle-version=\"0.0.0\"\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/OSGI-INF/html-parser.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.html-parser\">\n   <implementation class=\"com.subgraph.vega.internal.html.HTMLParser\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.html.IHTMLParser\"/>\n   </service>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/api/html/IHTMLParseResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.html;\n\nimport org.jsoup.nodes.Document;\nimport org.w3c.dom.html2.HTMLDocument;\n\npublic interface IHTMLParseResult {\n\tDocument getJsoupDocument();\n\tHTMLDocument getDOMDocument();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/api/html/IHTMLParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.api.html;\n\nimport java.net.URI;\n\npublic interface IHTMLParser {\n\tIHTMLParseResult parseString(String html, URI baseURI);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/api/html/IInnerHtmlProvidingElement.java",
    "content": "package com.subgraph.vega.api.html;\n\npublic interface IInnerHtmlProvidingElement {\n\tString getInnerHtml();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/HTMLParseResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html;\n\nimport org.jsoup.nodes.Document;\nimport org.w3c.dom.html2.HTMLDocument;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.internal.html.dom.HTMLDocumentImpl;\n\npublic class HTMLParseResult implements IHTMLParseResult {\n\t\n\tprivate final Document jsoupDocument;\n\tprivate HTMLDocument cachedDomDocument;\n\t\n\tHTMLParseResult(Document jsoupDocument) {\n\t\tthis.jsoupDocument = jsoupDocument;\n\t}\n\n\t@Override\n\tpublic Document getJsoupDocument() {\n\t\treturn jsoupDocument;\t\t\n\t}\n\n\t@Override\n\tpublic HTMLDocument getDOMDocument() {\n\t\tsynchronized(jsoupDocument) {\n\t\t\tif(cachedDomDocument == null)\n\t\t\t\tcachedDomDocument = HTMLDocumentImpl.createFromJsoup(jsoupDocument);\n\t\t\treturn cachedDomDocument;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/HTMLParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html;\n\nimport java.net.URI;\n\nimport org.jsoup.Jsoup;\nimport org.jsoup.nodes.Document;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.html.IHTMLParser;\n\npublic class HTMLParser implements IHTMLParser {\n\n\t@Override\n\tpublic IHTMLParseResult parseString(String html, URI baseURI) {\n\t\tString base = (baseURI == null) ? (\"\") : (baseURI.toString());\n\t\tDocument jsoupDocument = Jsoup.parse(html, base);\n\t\tif(jsoupDocument == null)\n\t\t\treturn null;\n\t\telse \n\t\t\treturn new HTMLParseResult(jsoupDocument);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/AttrImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.w3c.dom.Attr;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.TypeInfo;\n\n\npublic class AttrImpl extends NodeImpl implements Attr {\n\n\tprivate final String name;\n\tprivate final String value;\n\tprivate final ElementImpl ownerElement;\n\t\n\tAttrImpl(String name, String value, ElementImpl owner, Document ownerDocument) {\n\t\tsuper(null, ownerDocument);\n\t\tthis.name = name;\n\t\tthis.value = value;\n\t\tthis.ownerElement = owner;\n\t}\n\t\n\tpublic String getNodeName() {\n\t\treturn name;\n\t}\n\t\n\t@Override\n\tpublic String getNodeValue() {\n\t\treturn value;\n\t}\n\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn Node.ATTRIBUTE_NODE;\n\t}\n\t\n\t@Override\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic boolean getSpecified() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn value;\n\t}\n\n\t@Override\n\tpublic void setValue(String value) throws DOMException {\n\t\tthrow createReadOnlyException();\t\n\t}\n\n\t@Override\n\tpublic Element getOwnerElement() {\n\t\treturn ownerElement;\n\t}\n\n\t@Override\n\tpublic TypeInfo getSchemaTypeInfo() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic boolean isId() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\t\n\tprivate String nulltoEmpty(String s) {\n\t\treturn (s == null) ? \"\" : s;\n\t}\n\tpublic boolean equals(Object other) {\n\t\tif(!(other instanceof AttrImpl)) \n\t\t\treturn false;\n\t\tAttrImpl that = (AttrImpl) other;\n\t\treturn nulltoEmpty(name).equals(nulltoEmpty(that.name)) && nulltoEmpty(value).equals(nulltoEmpty(that.value));\n\t}\n\t\n\tpublic int hashCode() {\n\t\treturn nulltoEmpty(name).hashCode() * 41 + nulltoEmpty(value).hashCode();\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/CharacterDataImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.w3c.dom.CharacterData;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Node;\n\npublic class CharacterDataImpl extends NodeImpl implements CharacterData {\n\n\tprivate final String data;\n\t\n\t\n\tCharacterDataImpl(org.jsoup.nodes.Node jsoupNode, String data, Document ownerDocument) {\n\t\tsuper(jsoupNode, ownerDocument);\n\t\tthis.data = data;\n\t}\n\t\n\tpublic String getNodeName() {\n\t\treturn \"#cdata-section\";\n\t}\n\t\n\t@Override\n\tpublic String getNodeValue() {\n\t\treturn data;\n\t}\n\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn Node.CDATA_SECTION_NODE;\n\t}\n\t\n\t@Override\n\tpublic String getData() throws DOMException {\n\t\treturn data;\n\t}\n\n\t@Override\n\tpublic void setData(String data) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic int getLength() {\n\t\treturn data.length();\n\t}\n\n\t@Override\n\tpublic String getTextContent() {\n\t\treturn data;\n\t}\n\t\n\t@Override\n\tpublic String substringData(int offset, int count) throws DOMException {\n\t\tString data = getData();\n\t\tif(offset < 0 || offset >= data.length())\n\t\t\tthrow new DOMException(DOMException.INDEX_SIZE_ERR, \"Offset \"+ offset +\" is out of range\");\n\t\tint end = offset + count;\n\t\tif(end < offset)\n\t\t\tend = offset;\n\t\tif(end > data.length())\n\t\t\tend = data.length();\n\t\treturn data.substring(offset, end);\n\t}\n\n\t@Override\n\tpublic void appendData(String arg) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic void insertData(int offset, String arg) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic void deleteData(int offset, int count) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic void replaceData(int offset, int count, String arg)\n\t\t\tthrows DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/CommentImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.w3c.dom.Comment;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Node;\n\npublic class CommentImpl extends CharacterDataImpl implements Comment {\n\t\n\tCommentImpl(org.jsoup.nodes.Comment jsoupComment, Document ownerDocument) {\n\t\tsuper(jsoupComment, jsoupComment.getData(), ownerDocument);\n\t}\n\t\n\tpublic String getNodeName() {\n\t\treturn \"#comment\";\n\t}\n\t\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn Node.COMMENT_NODE;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/DocumentImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.w3c.dom.Attr;\nimport org.w3c.dom.CDATASection;\nimport org.w3c.dom.Comment;\nimport org.w3c.dom.DOMConfiguration;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.DOMImplementation;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.DocumentFragment;\nimport org.w3c.dom.DocumentType;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.EntityReference;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.ProcessingInstruction;\nimport org.w3c.dom.Text;\n\npublic class DocumentImpl extends NodeImpl implements Document {\n\t\n\tprivate final static DOMImplementation implementation = new DomImplementationImpl();\n\t\n\tprotected final org.jsoup.nodes.Document jsoupDocument;\n\tprivate Element cachedOwnerDocument;\n\t\n\tprotected DocumentImpl(org.jsoup.nodes.Document jsoupDocument) {\n\t\tsuper(jsoupDocument, null);\n\t\tthis.jsoupDocument = jsoupDocument;\n\t}\n\t\n\tpublic String getNodeName() {\n\t\treturn \"#document\";\n\t}\n\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn Node.DOCUMENT_NODE;\n\t}\n\t\n\t@Override\n\tpublic DocumentType getDoctype() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic DOMImplementation getImplementation() {\n\t\treturn implementation;\n\t}\n\n\t@Override\n\tpublic Element getDocumentElement() {\n\t\tif(cachedOwnerDocument != null)\n\t\t\treturn cachedOwnerDocument;\n\t\t\n\t\torg.jsoup.nodes.Element htmlElement = jsoupDocument.select(\"html\").first();\n\t\tif(htmlElement == null)\n\t\t\treturn null;\n\t\t\n\t\tcachedOwnerDocument =  HTMLElementImpl.create(jsoupDocument.select(\"html\").first(), getOwnerDocument());\n\t\treturn cachedOwnerDocument;\n\t}\n\n\t@Override\n\tpublic Element createElement(String tagName) throws DOMException {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic DocumentFragment createDocumentFragment() {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic Text createTextNode(String data) {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic Comment createComment(String data) {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic CDATASection createCDATASection(String data) throws DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic ProcessingInstruction createProcessingInstruction(String target,\n\t\t\tString data) throws DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Attr createAttribute(String name) throws DOMException {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic EntityReference createEntityReference(String name)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic NodeList getElementsByTagName(String tagname) {\n\t\tElement e = getDocumentElement();\n\t\tif(e == null)\n\t\t\treturn NodeListImpl.emptyList;\n\t\telse\n\t\t\treturn e.getElementsByTagName(tagname);\n\t}\n\n\t@Override\n\tpublic Node importNode(Node importedNode, boolean deep) throws DOMException {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic Element createElementNS(String namespaceURI, String qualifiedName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Attr createAttributeNS(String namespaceURI, String qualifiedName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic NodeList getElementsByTagNameNS(String namespaceURI, String localName) {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Element getElementById(String elementId) {\n\t\tElement e = getDocumentElement();\n\t\tif(e == null)\n\t\t\treturn null;\n\t\telse {\n\t\t\torg.jsoup.nodes.Element jsoupElement = jsoupDocument.getElementById(elementId);\n\t\t\tif(jsoupElement == null)\n\t\t\t\treturn null;\n\t\t\treturn HTMLElementImpl.create(jsoupElement, this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getInputEncoding() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic String getXmlEncoding() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic boolean getXmlStandalone() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setXmlStandalone(boolean xmlStandalone) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic String getXmlVersion() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setXmlVersion(String xmlVersion) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic boolean getStrictErrorChecking() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setStrictErrorChecking(boolean strictErrorChecking) {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic String getDocumentURI() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setDocumentURI(String documentURI) {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic Node adoptNode(Node source) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic DOMConfiguration getDomConfig() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void normalizeDocument() {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic Node renameNode(Node n, String namespaceURI, String qualifiedName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/DomImplementationImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.DOMImplementation;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.DocumentType;\n\npublic class DomImplementationImpl implements DOMImplementation {\n\n\t@Override\n\tpublic boolean hasFeature(String feature, String version) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic DocumentType createDocumentType(String qualifiedName,\n\t\t\tString publicId, String systemId) throws DOMException {\n\t\tthrow NodeImpl.createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Document createDocument(String namespaceURI, String qualifiedName,\n\t\t\tDocumentType doctype) throws DOMException {\n\t\tthrow NodeImpl.createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Object getFeature(String feature, String version) {\n\t\tthrow NodeImpl.createNoLevel3SupportException();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/ElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.jsoup.nodes.Attribute;\nimport org.jsoup.select.Elements;\nimport org.jsoup.nodes.FormElement;\n\nimport org.w3c.dom.Attr;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.TypeInfo;\n\n\npublic class ElementImpl extends NodeImpl implements Element {\n\tprotected final org.jsoup.nodes.Element jsoupElement;\n\t\n\tprotected ElementImpl(org.jsoup.nodes.Element jsoupElement, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t\tthis.jsoupElement = jsoupElement;\n\t}\n\t\n\tpublic String getNodeName() {\n\t\treturn getTagName();\n\t}\n\t\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn Node.ELEMENT_NODE;\n\t}\n\t\n\torg.jsoup.nodes.Element getJsoupElement() {\n\t\treturn jsoupElement;\n\t}\n\t\n\t@Override\n\tpublic String getTagName() {\n\t\treturn jsoupElement.tagName().toUpperCase();\n\t}\n\n\t@Override\n\tpublic String getTextContent() {\n\t\tfinal short type = getNodeType();\n\t\tswitch(type) {\n\t\tcase Node.TEXT_NODE:\n\t\tcase Node.CDATA_SECTION_NODE:\n\t\tcase Node.COMMENT_NODE:\n\t\t\treturn getNodeValue();\n\t\tdefault:\n\t\t\treturn concatenateChildTextContent();\n\t\t}\n\t}\n\t\n\tprivate String concatenateChildTextContent() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfinal NodeList nlist = getChildNodes();\n\t\tfor(int i = 0; i < nlist.getLength(); i++) {\n\t\t\tNode node = nlist.item(i);\n\t\t\tif((node.getNodeType() != Node.COMMENT_NODE) && (node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE)) {\n\t\t\t\tString text = node.getTextContent();\n\t\t\t\tif(text != null)\n\t\t\t\t\tsb.append(text);\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tElement getElementById(String elementId) {\n\t\torg.jsoup.nodes.Element elementById = jsoupElement.getElementById(elementId);\n\t\tif(elementById == null)\n\t\t\treturn null;\n\t\telse\n\t\t\treturn HTMLElementImpl.create(elementById, getOwnerDocument());\n\t}\n\t\n\t@Override\n\tpublic NamedNodeMap getAttributes() {\n\t\tNamedNodeMapImpl map = new NamedNodeMapImpl();\n\t\tfor(Attribute a: jsoupElement.attributes()) \n\t\t\tmap.addNode(a.getKey(), new AttrImpl(a.getKey(), a.getValue(), this, getOwnerDocument()));\n\t\treturn map;\n\t}\n\t\n\t@Override\n\tpublic boolean hasAttributes() {\n\t\treturn jsoupElement.attributes().size() > 0;\n\t}\n\t\n\t@Override\n\tpublic String getAttribute(String name) {\n\t\tif(jsoupElement.hasAttr(name))\n\t\t\treturn jsoupElement.attr(name);\n\t\telse if(getTagName().equals(\"LABEL\") && name.equals(\"htmlFor\") && jsoupElement.hasAttr(\"for\")) \n\t\t\t\treturn jsoupElement.attr(\"for\");\n\t\telse if(name.equals(\"className\") && jsoupElement.hasAttr(\"class\"))\n\t\t\treturn jsoupElement.attr(\"class\");\n\t\telse\n\t\t\treturn null;\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void setAttribute(String name, String value) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic void removeAttribute(String name) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic Attr getAttributeNode(String name) {\n\t\tif(jsoupElement.hasAttr(name)) {\n\t\t\treturn new AttrImpl(name, getAttribute(name), this, getOwnerDocument());\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic Attr setAttributeNode(Attr newAttr) throws DOMException {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic Attr removeAttributeNode(Attr oldAttr) throws DOMException {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic NodeList getElementsByTagName(String name) {\n\t\tfinal List<NodeImpl> elements = new ArrayList<NodeImpl>();\n\t\t\n\t\t// Special case\n\t\tif(getTagName().equals(\"HTML\") && name.equalsIgnoreCase(\"html\")) {\n\t\t\telements.add(this);\n\t\t\treturn new NodeListImpl(elements);\n\t\t}\n\n\t\t// Special case #2 - to handle jsoup.org.FormElement, which has saved nested elements \n\t\t// see:             \treturn new NodeListImpl(elements);\n\n\t\tif(getTagName().equals(\"FORM\") && \"*\".equals(name)) {\n            Elements fe;\n            fe = ((FormElement) this.jsoupElement).elements();\n            for (org.jsoup.nodes.Element f : fe)\n            {\n            \telements.add(HTMLElementImpl.create(f, getOwnerDocument()));\n            }\n        \treturn new NodeListImpl(elements);\n\n\t\t}\n\t\tfor(org.jsoup.nodes.Element e: jsoupElementsForTag(name)) {\n\t\t\tif(e != jsoupElement)\n\t\t\t\telements.add(HTMLElementImpl.create(e, getOwnerDocument()));\n\t\t}\n\t\treturn new NodeListImpl(elements);\n\t}\n\n\tprivate Elements jsoupElementsForTag(String name) {\n\t\tif(\"*\".equals(name)) {\n\t\t\treturn jsoupElement.getAllElements();\n\t\t}\n\t\telse\n\t\t\treturn jsoupElement.getElementsByTag(name);\n\t}\n\t\n\t@Override\n\tpublic String getAttributeNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic void setAttributeNS(String namespaceURI, String qualifiedName,\n\t\t\tString value) throws DOMException {\n\t\tthrow createNoXMLSupportException();\t\t\n\t}\n\n\t@Override\n\tpublic void removeAttributeNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\t\t\n\t}\n\n\t@Override\n\tpublic Attr getAttributeNodeNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Attr setAttributeNodeNS(Attr newAttr) throws DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic NodeList getElementsByTagNameNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic boolean hasAttribute(String name) {\n\t\treturn jsoupElement.hasAttr(name);\n\t}\n\n\t@Override\n\tpublic boolean hasAttributeNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic TypeInfo getSchemaTypeInfo() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setIdAttribute(String name, boolean isId) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setIdAttributeNS(String namespaceURI, String localName,\n\t\t\tboolean isId) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic void setIdAttributeNode(Attr idAttr, boolean isId)\n\t\t\tthrows DOMException {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLAnchorElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLAnchorElement;\n\npublic class HTMLAnchorElementImpl extends HTMLElementImpl implements HTMLAnchorElement {\n\n\tHTMLAnchorElementImpl(Element jsoupElement, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t}\n\n\t@Override\n\tpublic String getAccessKey() {\n\t\treturn getAttribute(\"accesskey\");\n\t}\n\n\t@Override\n\tpublic void setAccessKey(String accessKey) {\t\t\n\t}\n\n\t@Override\n\tpublic String getCharset() {\n\t\treturn getAttribute(\"charset\");\n\t}\n\n\t@Override\n\tpublic void setCharset(String charset) {\t\t\n\t}\n\n\t@Override\n\tpublic String getCoords() {\n\t\treturn getAttribute(\"coords\");\n\t}\n\n\t@Override\n\tpublic void setCoords(String coords) {\t\t\n\t}\n\n\t@Override\n\tpublic String getHref() {\n\t\treturn getAttribute(\"href\");\n\t}\n\n\t@Override\n\tpublic void setHref(String href) {\t\t\n\t}\n\n\t@Override\n\tpublic String getHreflang() {\n\t\treturn getAttribute(\"hreflang\");\n\t}\n\n\t@Override\n\tpublic void setHreflang(String hreflang) {\t\t\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn getAttribute(\"name\");\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\t\t\n\t}\n\n\t@Override\n\tpublic String getRel() {\n\t\treturn getAttribute(\"rel\");\n\t}\n\n\t@Override\n\tpublic void setRel(String rel) {\t\t\n\t}\n\n\t@Override\n\tpublic String getRev() {\n\t\treturn getAttribute(\"rev\");\n\t}\n\n\t@Override\n\tpublic void setRev(String rev) {\t\t\n\t}\n\n\t@Override\n\tpublic String getShape() {\n\t\treturn getAttribute(\"shape\");\n\t}\n\n\t@Override\n\tpublic void setShape(String shape) {\t\t\n\t}\n\n\t@Override\n\tpublic int getTabIndex() {\n\t\treturn getIntAttribute(\"tabindex\");\n\t}\n\n\t@Override\n\tpublic void setTabIndex(int tabIndex) {\t\t\n\t}\n\n\t@Override\n\tpublic String getTarget() {\n\t\treturn getAttribute(\"target\");\n\t}\n\n\t@Override\n\tpublic void setTarget(String target) {\t\t\n\t}\n\n\t@Override\n\tpublic String getType() {\n\t\treturn getAttribute(\"type\");\n\t}\n\n\t@Override\n\tpublic void setType(String type) {\t\t\n\t}\n\n\t@Override\n\tpublic void blur() {\n\t}\n\n\t@Override\n\tpublic void focus() {\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLCollectionImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.html2.HTMLCollection;\nimport org.w3c.dom.html2.HTMLElement;\n\n\npublic class HTMLCollectionImpl implements HTMLCollection {\n\n\tprivate List<HTMLElementImpl> byIndex = new ArrayList<HTMLElementImpl>();\n\tprivate Map<String, HTMLElement> byId = new HashMap<String, HTMLElement>();\n\tprivate Map<String, HTMLElement> byName = new HashMap<String, HTMLElement>();\n\t\n\tHTMLCollectionImpl(List<HTMLElementImpl> elements) {\n\t\tfor(HTMLElementImpl e: elements) {\n\t\t\taddElement(e);\n\t\t}\n\t}\n\t\n\tHTMLCollectionImpl(List<Element> jsoupElements, Document document) {\n\t\tfor(Element e: jsoupElements) {\n\t\t\tHTMLElementImpl htmlElement = HTMLElementImpl.create(e, document);\n\t\t\taddElement(htmlElement);\n\t\t}\n\t}\n\t\n\tprivate void addElement(HTMLElementImpl element) {\n\t\tString id = element.getAttribute(\"id\");\n\t\tString name = element.getAttribute(\"name\");\n\t\tbyIndex.add(element);\n\t\tif(id != null)\n\t\t\tbyId.put(\"id\", element);\n\t\tif(name != null)\n\t\t\tbyName.put(\"name\", element);\n\t}\n\t\n\t@Override\n\tpublic int getLength() {\n\t\treturn byIndex.size();\n\t}\n\n\t@Override\n\tpublic Node item(int index) {\n\t\tif(index >= 0 && index < byIndex.size())\n\t\t\treturn byIndex.get(index);\n\t\telse\n\t\t\treturn null;\n\t}\n\n\t@Override\n\tpublic Node namedItem(String name) {\n\t\tif(byId.containsKey(name))\n\t\t\treturn byId.get(name);\n\t\treturn byName.get(name);\n\t}\n\t\n\tNodeList toNodeList() {\n\t\tList<NodeImpl> nodes = new ArrayList<NodeImpl>();\n\t\tnodes.addAll(byIndex);\n\t\treturn new NodeListImpl(nodes);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLDocumentImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.jsoup.nodes.Document;\nimport org.jsoup.nodes.Element;\nimport org.jsoup.select.Elements;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.html2.HTMLCollection;\nimport org.w3c.dom.html2.HTMLDocument;\nimport org.w3c.dom.html2.HTMLElement;\n\n\npublic class HTMLDocumentImpl extends DocumentImpl implements HTMLDocument {\n\n\tpublic static HTMLDocumentImpl createFromJsoup(Document jsoupDocument) {\n\t\tHTMLDocumentImpl htmlDocument = new HTMLDocumentImpl(jsoupDocument);\n\t\thtmlDocument.setOwnerDocument(htmlDocument);\n\t\treturn htmlDocument;\n\t}\n\t\n\tHTMLDocumentImpl(org.jsoup.nodes.Document jsoupDocument) {\n\t\tsuper(jsoupDocument);\n\t}\n\n\t@Override\n\tpublic String getTitle() {\n\t\tElements elements = jsoupDocument.getElementsByTag(\"title\");\n\t\tElement titleElement = elements.first();\n\t\tif(titleElement == null)\n\t\t\treturn null;\n\t\telse\n\t\t\treturn titleElement.text();\n\t}\n\n\t@Override\n\tpublic void setTitle(String title) {\n\t\t\n\t}\n\n\t@Override\n\tpublic String getReferrer() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getDomain() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getURL() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic HTMLElement getBody() {\n\t\tElements elements = jsoupDocument.getElementsByTag(\"body\");\n\t\tElement bodyElement = elements.first();\n\t\tif(bodyElement == null)\n\t\t\treturn null;\n\t\telse\n\t\t\treturn new HTMLElementImpl(bodyElement, this);\n\t}\n\n\t@Override\n\tpublic void setBody(HTMLElement body) {\t\t\n\t}\n\n\t@Override\n\tpublic HTMLCollection getImages() {\n\t\treturn selectCollection(\"img\");\n\t}\n\n\t@Override\n\tpublic HTMLCollection getApplets() {\n\t\treturn selectCollection(\"applet, object[classid]\");\n\t}\n\n\t@Override\n\tpublic HTMLCollection getLinks() {\n\t\tList<HTMLElementImpl> links = new ArrayList<HTMLElementImpl>();\n\t\tfor(Element e: jsoupDocument.select(\"a[href], area[href]\")) {\n\t\t\tlinks.add(new HTMLLinkElementImpl(e, getOwnerDocument()));\n\t\t}\n\t\treturn new HTMLCollectionImpl(links);\n\t}\n\n\t@Override\n\tpublic HTMLCollection getForms() {\n\t\treturn selectCollection(\"form\");\n\t}\n\n\t@Override\n\tpublic HTMLCollection getAnchors() {\n\t\treturn selectCollection(\"a[name]\");\n\t}\n\n\t@Override\n\tpublic String getCookie() {\n\t\treturn \"\";\n\t}\n\n\t@Override\n\tpublic void setCookie(String cookie) throws DOMException {\n\t\t\n\t}\n\n\t@Override\n\tpublic void open() {\t\t\n\t}\n\n\t@Override\n\tpublic void close() {\t\t\n\t}\n\n\t@Override\n\tpublic void write(String text) {\n\t\t\n\t}\n\n\t@Override\n\tpublic void writeln(String text) {\n\t}\n\n\t@Override\n\tpublic NodeList getElementsByName(String elementName) {\n\t\treturn selectCollection(\"*[name=\"+ elementName +\"]\").toNodeList();\n\t}\n\t\n\tprivate HTMLCollectionImpl selectCollection(String query) {\n\t\treturn new HTMLCollectionImpl( jsoupDocument.select(query), this);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLElement;\nimport org.w3c.dom.html2.HTMLFormElement;\n\nimport com.subgraph.vega.api.html.IInnerHtmlProvidingElement;\n\n\npublic class HTMLElementImpl extends ElementImpl implements HTMLElement, IInnerHtmlProvidingElement {\n\n\tstatic Element findEnclosingFormElement(Element insideElement) {\n\t\tElement e = insideElement;\n\t\twhile(e != null) {\n\t\t\tif(e.tagName().toUpperCase().equals(\"FORM\"))\n\t\t\t\treturn e;\n\t\t\te = e.parent();\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tstatic Element findEnclosingSelectElement(Element insideElement) {\n\t\t\n\t\tElement e = insideElement;\n\t\twhile(e != null) {\n\t\t\tif(e.tagName().toUpperCase().equals(\"SELECT\"))\n\t\t\t\treturn e;\n\t\t\te = e.parent();\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tstatic HTMLElementImpl create(Element jsoupElement, Document ownerDocument) {\n\t\tfinal String tag = jsoupElement.tagName().toUpperCase();\n\t\tif(tag == null)\n\t\t\tthrow new IllegalArgumentException();\n\t\tif(tag.equals(\"FORM\")) {\n\t\t\treturn new HTMLFormElementImpl(jsoupElement, ownerDocument);\n\t\t} else if(tag.equals(\"INPUT\")) {\n\t\t\tElement jsoupFormElement = findEnclosingFormElement(jsoupElement);\n\t\t\tif(jsoupFormElement == null)\n\t\t\t\treturn new HTMLInputElementImpl(jsoupElement, null, ownerDocument);\n\t\t\tHTMLFormElement form = new HTMLFormElementImpl(jsoupFormElement, ownerDocument);\n\t\t\treturn new HTMLInputElementImpl(jsoupElement, form, ownerDocument);\n\t\t} else if(tag.equals(\"A\")) {\n\t\t\treturn new HTMLAnchorElementImpl(jsoupElement, ownerDocument);\n\t\t} else if(tag.equals(\"OPTION\")) {\n\t\t\treturn new HTMLOptionElementImpl(jsoupElement, ownerDocument);\n\t\t} else if(tag.equals(\"SELECT\")) {\n\t\t\treturn new HTMLSelectElementImpl(jsoupElement, ownerDocument);\n\t\t} else {\n\t\t\treturn new HTMLElementImpl(jsoupElement, ownerDocument);\n\t\t}\n\t}\n\tHTMLElementImpl(Element jsoupElement, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t}\n\n\t@Override\n\tpublic String getId() {\n\t\treturn jsoupElement.attr(\"id\");\n\t}\n\n\t@Override\n\tpublic void setId(String id) {\n\t}\n\n\t@Override\n\tpublic String getTitle() {\n\t\treturn jsoupElement.attr(\"title\");\n\t}\n\n\t@Override\n\tpublic void setTitle(String title) {\t\t\n\t}\n\n\t@Override\n\tpublic String getLang() {\n\t\treturn jsoupElement.attr(\"lang\");\n\t}\n\n\t@Override\n\tpublic void setLang(String lang) {\t\t\n\t}\n\n\t@Override\n\tpublic String getDir() {\n\t\treturn jsoupElement.attr(\"dir\");\n\t}\n\n\t@Override\n\tpublic void setDir(String dir) {\t\t\n\t}\n\n\t@Override\n\tpublic String getClassName() {\n\t\treturn jsoupElement.attr(\"class\");\n\t}\n\n\t@Override\n\tpublic void setClassName(String className) {\t\t\n\t}\n\t\n\tprotected int getIntAttribute(String name) {\n\t\tfinal String str = getAttribute(name);\n\t\tif(str == null)\n\t\t\treturn 0;\n\t\ttry {\n\t\t\treturn Integer.parseInt(str);\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getInnerHtml() {\n\t\treturn jsoupElement.html();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLFormElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.jsoup.nodes.Element;\nimport org.jsoup.nodes.FormElement;\nimport org.jsoup.select.Elements;\n\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLCollection;\nimport org.w3c.dom.html2.HTMLFormElement;\n\npublic class HTMLFormElementImpl extends HTMLElementImpl implements HTMLFormElement {\n\n\tprivate HTMLCollection formElements;\n\n\tHTMLFormElementImpl(Element jsoupElement, Document ownerDocument) {\n\t\t\n\t\tsuper(jsoupElement, ownerDocument);\n\t}\n\n\t@Override\n\tpublic HTMLCollection getElements() {\n\t\tif(formElements != null)\n\t\t\treturn formElements;\n\t\t\n\t\tfinal List<HTMLElementImpl> elementList = new ArrayList<HTMLElementImpl>();\n\t\t\n\t\tElements fe;\n\t\tfe = ((FormElement) jsoupElement).elements();\n\t\t\n\t\tfor(Element e: fe) {\n\t\t\taddFormElementsToList(e, elementList);\n\t\t}\n\t\t\n\t\tformElements = new HTMLCollectionImpl(elementList);\n\t\treturn formElements;\t\t\n\t}\n\t\n\tprivate void addFormElementsToList(Element jsoupElement, List<HTMLElementImpl> formElements) {\n\t\tString tag = jsoupElement.tagName().toUpperCase();\n\t\tif(\"INPUT\".equals(tag)) {\n\t\t\tformElements.add(new HTMLInputElementImpl(jsoupElement, this, getOwnerDocument()));\n\t\t\treturn;\n\t\t} else if(\"SELECT\".equals(tag)) {\n\t\t\tHTMLSelectElementImpl selectElement = new HTMLSelectElementImpl(jsoupElement, this, getOwnerDocument());\n\t\t\t\n\t\t\tformElements.add(selectElement);\n\t\t\tHTMLOptionsCollectionImpl options = selectElement.getOptions();\n\t\t\tfor(int i = 0; i < options.getLength(); i++) {\n\t\t\t\tformElements.add(options.item(i));\n\t\t\t}\n\t\t\treturn;\n\t\t} else {\n\t\t\tformElements.add(new HTMLElementImpl(jsoupElement, getOwnerDocument()));\n\t\t\treturn;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic int getLength() {\n\t\treturn getElements().getLength();\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn jsoupElement.attr(\"name\");\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\t\t\n\t}\n\n\t@Override\n\tpublic String getAcceptCharset() {\n\t\treturn jsoupElement.attr(\"accept\");\n\t}\n\n\t@Override\n\tpublic void setAcceptCharset(String acceptCharset) {\t\t\n\t}\n\n\t@Override\n\tpublic String getAction() {\n\t\treturn jsoupElement.attr(\"action\");\n\t}\n\n\t@Override\n\tpublic void setAction(String action) {\t\t\n\t}\n\n\t@Override\n\tpublic String getEnctype() {\n\t\treturn jsoupElement.attr(\"enctype\");\n\t}\n\n\t@Override\n\tpublic void setEnctype(String enctype) {\t\t\n\t}\n\n\t@Override\n\tpublic String getMethod() {\n\t\treturn jsoupElement.attr(\"method\");\n\t}\n\n\t@Override\n\tpublic void setMethod(String method) {\t\t\n\t}\n\n\t@Override\n\tpublic String getTarget() {\n\t\treturn jsoupElement.attr(\"target\");\n\t}\n\n\t@Override\n\tpublic void setTarget(String target) {\t\t\n\t}\n\n\t@Override\n\tpublic void submit() {\t\t\n\t}\n\n\t@Override\n\tpublic void reset() {\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLInputElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLFormElement;\nimport org.w3c.dom.html2.HTMLInputElement;\n\npublic class HTMLInputElementImpl extends HTMLElementImpl implements HTMLInputElement {\n\n\tprivate final HTMLFormElement form;\n\t\n\tHTMLInputElementImpl(Element jsoupElement, HTMLFormElement form, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t\tthis.form = form;\n\t}\n\n\t@Override\n\tpublic String getDefaultValue() {\n\t\tString type = getType();\n\t\tif(type != null && (type.equals(\"text\") || type.equals(\"file\") || type.equals(\"password\"))) {\n\t\t\treturn jsoupElement.attr(\"value\");\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setDefaultValue(String defaultValue) {\n\t}\n\n\t@Override\n\tpublic boolean getDefaultChecked() {\n\t\tString type = getType();\n\t\tif(type != null && (type.equals(\"checkbox\") || type.equals(\"radio\"))) {\n\t\t\treturn hasAttribute(\"checked\");\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setDefaultChecked(boolean defaultChecked) {\t\t\n\t}\n\n\t@Override\n\tpublic HTMLFormElement getForm() {\n\t\treturn form;\n\t}\n\n\t@Override\n\tpublic String getAccept() {\n\t\treturn getAttribute(\"accept\");\n\t}\n\n\t@Override\n\tpublic void setAccept(String accept) {\n\t}\n\n\t@Override\n\tpublic String getAccessKey() {\n\t\treturn getAttribute(\"accesskey\");\n\t}\n\n\t@Override\n\tpublic void setAccessKey(String accessKey) {\n\t}\n\n\t@Override\n\tpublic String getAlign() {\n\t\treturn getAttribute(\"align\");\n\t}\n\n\t@Override\n\tpublic void setAlign(String align) {\t\t\n\t}\n\n\t@Override\n\tpublic String getAlt() {\n\t\treturn getAttribute(\"alt\");\n\t}\n\n\t@Override\n\tpublic void setAlt(String alt) {\t\t\n\t}\n\n\t@Override\n\tpublic boolean getChecked() {\n\t\treturn hasAttribute(\"checked\");\n\t}\n\n\t@Override\n\tpublic void setChecked(boolean checked) {\t\t\n\t}\n\n\t@Override\n\tpublic boolean getDisabled() {\n\t\treturn hasAttribute(\"disabled\");\n\t}\n\n\t@Override\n\tpublic void setDisabled(boolean disabled) {\t\t\n\t}\n\n\t@Override\n\tpublic int getMaxLength() {\n\t\treturn getIntAttribute(\"maxlength\");\n\t}\n\n\t@Override\n\tpublic void setMaxLength(int maxLength) {\t\t\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn getAttribute(\"name\");\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\t\t\n\t}\n\n\t@Override\n\tpublic boolean getReadOnly() {\n\t\treturn hasAttribute(\"readonly\");\n\t}\n\n\t@Override\n\tpublic void setReadOnly(boolean readOnly) {\t\t\n\t}\n\n\t@Override\n\tpublic int getSize() {\n\t\treturn getIntAttribute(\"size\");\n\t}\n\n\t@Override\n\tpublic void setSize(int size) {\t\t\n\t}\n\n\t@Override\n\tpublic String getSrc() {\n\t\treturn getAttribute(\"src\");\n\t}\n\n\t@Override\n\tpublic void setSrc(String src) {\t\t\n\t}\n\n\t@Override\n\tpublic int getTabIndex() {\n\t\treturn getIntAttribute(\"tabindex\");\n\t}\n\n\t@Override\n\tpublic void setTabIndex(int tabIndex) {\t\t\n\t}\n\n\t@Override\n\tpublic String getType() {\n\t\treturn getAttribute(\"type\");\n\t}\n\n\t@Override\n\tpublic void setType(String type) {\t\t\n\t}\n\n\t@Override\n\tpublic String getUseMap() {\n\t\treturn getAttribute(\"usemap\");\n\t}\n\n\t@Override\n\tpublic void setUseMap(String useMap) {\n\t\t\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn getAttribute(\"value\");\n\t}\n\n\t@Override\n\tpublic void setValue(String value) {\t\t\n\t}\n\n\t@Override\n\tpublic void blur() {\t\t\n\t}\n\n\t@Override\n\tpublic void focus() {\t\t\n\t}\n\n\t@Override\n\tpublic void select() {\t\t\n\t}\n\n\t@Override\n\tpublic void click() {\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLLinkElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLLinkElement;\n\npublic class HTMLLinkElementImpl extends HTMLElementImpl implements HTMLLinkElement {\n\n\tHTMLLinkElementImpl(Element jsoupElement, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t}\n\n\t@Override\n\tpublic boolean getDisabled() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic void setDisabled(boolean disabled) {\n\t}\n\n\t@Override\n\tpublic String getCharset() {\n\t\treturn getAttribute(\"charset\");\n\t}\n\n\t@Override\n\tpublic void setCharset(String charset) {\t\t\n\t}\n\n\t@Override\n\tpublic String getHref() {\n\t\treturn getAttribute(\"href\");\n\t}\n\n\t@Override\n\tpublic void setHref(String href) {\t\t\n\t}\n\n\t@Override\n\tpublic String getHreflang() {\n\t\treturn getAttribute(\"hreflang\");\n\t}\n\n\t@Override\n\tpublic void setHreflang(String hreflang) {\n\t}\n\n\t@Override\n\tpublic String getMedia() {\n\t\treturn getAttribute(\"media\");\n\t}\n\n\t@Override\n\tpublic void setMedia(String media) {\t\t\n\t}\n\n\t@Override\n\tpublic String getRel() {\n\t\treturn getAttribute(\"rel\");\n\t}\n\n\t@Override\n\tpublic void setRel(String rel) {\t\t\n\t}\n\n\t@Override\n\tpublic String getRev() {\n\t\treturn getAttribute(\"rev\");\n\t}\n\n\t@Override\n\tpublic void setRev(String rev) {\t\t\n\t}\n\n\t@Override\n\tpublic String getTarget() {\n\t\treturn getAttribute(\"target\");\n\t}\n\n\t@Override\n\tpublic void setTarget(String target) {\t\t\n\t}\n\n\t@Override\n\tpublic String getType() {\n\t\treturn getAttribute(\"type\");\n\t}\n\n\t@Override\n\tpublic void setType(String type) {\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLOptionElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLFormElement;\nimport org.w3c.dom.html2.HTMLOptionElement;\n\npublic class HTMLOptionElementImpl extends HTMLElementImpl implements HTMLOptionElement {\n\n\tprivate final HTMLSelectElementImpl select;\n\tprivate final HTMLFormElement form;\n\tprivate final int index;\n\t\n\tHTMLOptionElementImpl(Element jsoupElement, HTMLSelectElementImpl select, int index, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t\tthis.select = select;\n\t\tthis.form = select.getForm();\n\t\tthis.index = index;\n\t}\n\t\n\tHTMLOptionElementImpl(Element jsoupElement, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t\tElement formElement = HTMLElementImpl.findEnclosingFormElement(jsoupElement);\n\t\tthis.form = new HTMLFormElementImpl(formElement, ownerDocument);\n\t\tElement selectElement = HTMLElementImpl.findEnclosingSelectElement(jsoupElement);\n\t\tthis.select = new HTMLSelectElementImpl(selectElement, form, ownerDocument);\n\t\tthis.index = calculateIndex(jsoupElement);\n\t}\n\t\n\tprivate int calculateIndex(Element jsoupElement) {\n\t\tElement e = jsoupElement;\n\t\tint index = 0;\n\t\twhile(e.previousElementSibling() != null) {\n\t\t\te = e.previousElementSibling();\n\t\t\tindex += 1;\n\t\t}\n\t\treturn index;\n\t}\n\n\t@Override\n\tpublic HTMLFormElement getForm() {\n\t\treturn form;\n\t}\n\n\t@Override\n\tpublic boolean getDefaultSelected() {\n\t\treturn hasAttribute(\"selected\");\n\t}\n\n\t@Override\n\tpublic void setDefaultSelected(boolean defaultSelected) {\n\t\t\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn getTextContent();\n\t}\n\n\t@Override\n\tpublic int getIndex() {\n\t\treturn index;\n\t}\n\n\t@Override\n\tpublic boolean getDisabled() {\n\t\treturn hasAttribute(\"disabled\");\n\t}\n\n\t@Override\n\tpublic void setDisabled(boolean disabled) {\t\t\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn getAttribute(\"label\");\n\t}\n\n\t@Override\n\tpublic void setLabel(String label) {\t\t\n\t}\n\n\t@Override\n\tpublic boolean getSelected() {\n\t\treturn hasAttribute(\"selected\") || select.getSelectedIndex() == index;\n\t}\n\n\t@Override\n\tpublic void setSelected(boolean selected) {\t\t\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn getAttribute(\"value\");\n\t}\n\n\t@Override\n\tpublic void setValue(String value) {\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLOptionsCollectionImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLOptionElement;\nimport org.w3c.dom.html2.HTMLOptionsCollection;\n\npublic class HTMLOptionsCollectionImpl implements HTMLOptionsCollection {\n\n\tprivate final List<HTMLOptionElementImpl> byIndex = new ArrayList<HTMLOptionElementImpl>();\n\tprivate final Map<String, HTMLOptionElement> byId = new HashMap<String, HTMLOptionElement>();\n\tprivate final Map<String, HTMLOptionElement> byName = new HashMap<String, HTMLOptionElement>();\n\tprivate final HTMLSelectElementImpl select;\n\t\n\tHTMLOptionsCollectionImpl(List<Element> jsoupElements, HTMLSelectElementImpl select, Document document) {\n\t\tthis.select = select;\n\t\tfor(Element e: jsoupElements) {\n\t\t\tint index = byIndex.size();\n\t\t\tHTMLOptionElementImpl htmlElement = new HTMLOptionElementImpl(e, select, index, document);\n\t\t\taddElement(htmlElement);\n\t\t}\n\t}\n\t\n\tprivate void addElement(HTMLOptionElementImpl element) {\n\t\tbyIndex.add(element);\n\t\tfinal String id = element.getAttribute(\"id\");\n\t\tfinal String name = element.getAttribute(\"name\");\n\t\tif(id != null)\n\t\t\tbyId.put(id, element);\n\t\tif(name != null)\n\t\t\tbyName.put(name, element);\n\t}\n\t\n\t\n\t@Override\n\tpublic int getLength() {\n\t\treturn byIndex.size();\n\t}\n\n\t@Override\n\tpublic void setLength(int length) throws DOMException {\n\t\t\n\t}\n\n\t@Override\n\tpublic HTMLOptionElementImpl item(int index) {\n\t\tif(index >= 0 && index < byIndex.size())\n\t\t\treturn byIndex.get(index);\n\t\telse\n\t\t\treturn null;\n\t}\n\n\t@Override\n\tpublic HTMLOptionElement namedItem(String name) {\n\t\tif(byId.containsKey(name))\n\t\t\treturn byId.get(name);\n\t\telse\n\t\t\treturn byName.get(name);\n\t}\n\t\n\tint getSelectedIndex() {\n\t\tfor(HTMLOptionElement option: byIndex) {\n\t\t\tif(option.hasAttribute(\"selected\"))\n\t\t\t\treturn option.getIndex();\n\t\t}\n\t\tif(select.getMultiple())\n\t\t\treturn -1;\n\t\telse\n\t\t\treturn 0;\n\t}\n\t\n\tString getValue() {\n\t\tfor(HTMLOptionElement option: byIndex) {\n\t\t\tif(option.getSelected())\n\t\t\t\treturn option.getValue();\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/HTMLSelectElementImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.html2.HTMLElement;\nimport org.w3c.dom.html2.HTMLFormElement;\nimport org.w3c.dom.html2.HTMLSelectElement;\n\npublic class HTMLSelectElementImpl extends HTMLElementImpl implements HTMLSelectElement {\n\n\tprivate final HTMLFormElement form;\n\tprivate HTMLOptionsCollectionImpl options;\n\t\n\tHTMLSelectElementImpl(Element jsoupElement, HTMLFormElement form, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t\tthis.form = form;\n\t}\n\t\n\tHTMLSelectElementImpl(Element jsoupElement, Document ownerDocument) {\n\t\tsuper(jsoupElement, ownerDocument);\n\t\tElement formElement = HTMLElementImpl.findEnclosingFormElement(jsoupElement);\n\t\tthis.form = new HTMLFormElementImpl(formElement, ownerDocument);\n\t}\n\n\t@Override\n\tpublic String getType() {\n\t\tif(hasAttribute(\"multiple\"))\n\t\t\treturn \"select-multiple\";\n\t\telse\n\t\t\treturn \"select-one\";\n\t}\n\n\t@Override\n\tpublic int getSelectedIndex() {\n\t\treturn getOptions().getSelectedIndex();\n\t}\n\t\n\t@Override\n\tpublic void setSelectedIndex(int selectedIndex) {\t\t\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn getOptions().getValue();\n\t}\n\n\t@Override\n\tpublic void setValue(String value) {\t\t\n\t}\n\n\t@Override\n\tpublic int getLength() {\n\t\treturn getOptions().getLength();\n\t}\n\n\t@Override\n\tpublic void setLength(int length) throws DOMException {\t\t\n\t}\n\n\t@Override\n\tpublic HTMLFormElement getForm() {\n\t\treturn form;\n\t}\n\n\t@Override\n\tpublic HTMLOptionsCollectionImpl getOptions() {\n\t\tif(options == null) {\n\t\t\toptions = new HTMLOptionsCollectionImpl(jsoupElement.select(\"option\"), this, getOwnerDocument());\n\t\t}\n\t\treturn options;\n\t}\n\n\t@Override\n\tpublic boolean getDisabled() {\n\t\treturn hasAttribute(\"disabled\");\n\t}\n\n\t@Override\n\tpublic void setDisabled(boolean disabled) {\t\t\n\t}\n\n\t@Override\n\tpublic boolean getMultiple() {\n\t\treturn hasAttribute(\"multiple\");\n\t}\n\n\t@Override\n\tpublic void setMultiple(boolean multiple) {\t\t\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn getAttribute(\"name\");\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\t\t\n\t}\n\n\t@Override\n\tpublic int getSize() {\n\t\treturn getIntAttribute(\"size\");\n\t}\n\n\t@Override\n\tpublic void setSize(int size) {\t\t\n\t}\n\n\t@Override\n\tpublic int getTabIndex() {\n\t\treturn getIntAttribute(\"tabindex\");\n\t}\n\n\t@Override\n\tpublic void setTabIndex(int tabIndex) {\t\t\n\t}\n\n\t@Override\n\tpublic void add(HTMLElement element, HTMLElement before)\n\t\t\tthrows DOMException {\t\t\n\t}\n\n\t@Override\n\tpublic void remove(int index) {\t\t\n\t}\n\n\t@Override\n\tpublic void blur() {\t\t\n\t}\n\n\t@Override\n\tpublic void focus() {\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/NamedNodeMapImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\n\npublic class NamedNodeMapImpl implements NamedNodeMap {\n\n\tprivate final Map<String, NodeImpl> nodeMap = new HashMap<String, NodeImpl>();\n\tprivate final List<NodeImpl> indexedNodes = new ArrayList<NodeImpl>();\n\t\n\n\tvoid addNode(String name, NodeImpl node) {\n\t\tif(nodeMap.containsKey(name))\n\t\t\treturn;\n\t\tnodeMap.put(name, node);\n\t\tindexedNodes.add(node);\n\t}\n\t\n\t@Override\n\tpublic Node getNamedItem(String name) {\n\t\treturn nodeMap.get(name);\n\t}\n\n\t@Override\n\tpublic Node setNamedItem(Node arg) throws DOMException {\n\t\tthrow NodeImpl.createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic Node removeNamedItem(String name) throws DOMException {\n\t\tthrow NodeImpl.createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic Node item(int index) {\n\t\tif(index >= 0 && index < indexedNodes.size())\n\t\t\treturn indexedNodes.get(index);\n\t\telse\n\t\t\treturn null;\n\t}\n\n\t@Override\n\tpublic int getLength() {\n\t\treturn indexedNodes.size();\n\t}\n\n\t@Override\n\tpublic Node getNamedItemNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow NodeImpl.createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Node setNamedItemNS(Node arg) throws DOMException {\n\t\tthrow NodeImpl.createNoXMLSupportException();\n\t}\n\n\t@Override\n\tpublic Node removeNamedItemNS(String namespaceURI, String localName)\n\t\t\tthrows DOMException {\n\t\tthrow NodeImpl.createNoXMLSupportException();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/NodeImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.jsoup.nodes.DataNode;\nimport org.jsoup.nodes.Element;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.UserDataHandler;\n\n\npublic class NodeImpl implements Node {\n\t\n\tstatic NodeImpl createFromJsoupNode(org.jsoup.nodes.Node node, Document ownerDocument) {\n\n\t\tif(node == null)\n\t\t\treturn null;\n\t\telse if(node instanceof org.jsoup.nodes.Element)\n\t\t\treturn HTMLElementImpl.create((Element) node, ownerDocument);\n\t\telse if(node instanceof org.jsoup.nodes.TextNode)\n\t\t\treturn new TextImpl((org.jsoup.nodes.TextNode) node, ownerDocument);\n\t\telse if(node instanceof org.jsoup.nodes.Comment)\n\t\t\treturn new CommentImpl((org.jsoup.nodes.Comment) node, ownerDocument);\n\t\telse if(node instanceof org.jsoup.nodes.DataNode) \n\t\t\treturn new CharacterDataImpl((DataNode) node, ((DataNode)node).getWholeData(), ownerDocument);\n\t\telse\n\t\t\treturn new NodeImpl(node, ownerDocument);\t\t\n\t}\n\t\n\t\n\tstatic DOMException createReadOnlyException() {\n\t\treturn new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, \"Modifying the DOM is not permitted\");\n\t}\n\t\n\tstatic DOMException createNoLevel3SupportException() {\n\t\treturn new DOMException(DOMException.NOT_SUPPORTED_ERR, \"This implementation does not support DOM Level 3\");\n\t}\n\t\n\tstatic DOMException createNoXMLSupportException() {\n\t\treturn new DOMException(DOMException.NOT_SUPPORTED_ERR, \"No support for XML feature.\");\n\t}\t\n\n\tprivate final org.jsoup.nodes.Node jsoupNode; // Will be null for Attr nodes\n\tprivate Document ownerDocument;\n\tprivate List<Integer> treePosition = new ArrayList<Integer>();\n\t\t\n\t\n\tNodeImpl(org.jsoup.nodes.Node jsoupNode, Document ownerDocument) {\n\t\tthis.jsoupNode = jsoupNode;\n\t\tthis.ownerDocument = ownerDocument;\n\t\tcalculateTreePosition();\n\t}\n\t\n\tvoid calculateTreePosition() {\n\t\torg.jsoup.nodes.Node n = jsoupNode;\n\t\twhile(n != null) {\n\t\t\ttreePosition.add(n.siblingIndex());\n\t\t\tn = n.parent();\n\t\t}\n\t\tCollections.reverse(treePosition);\n\t}\n\t\n\tvoid setOwnerDocument(Document ownerDocument) {\n\t\tthis.ownerDocument = ownerDocument;\n\t}\n\t\n\t@Override\n\tpublic String getNodeName() {\n\t\treturn \"#node\";\n\t}\n\n\t@Override\n\tpublic String getNodeValue() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void setNodeValue(String nodeValue) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn 0;\n\t}\n\n\t@Override\n\tpublic Node getParentNode() {\n\t\tif(jsoupNode == null)\n\t\t\treturn null;\n\t\t\n\t\treturn createFromJsoupNode(jsoupNode.parent(), ownerDocument);\n\t}\n\n\t@Override\n\tpublic NodeList getChildNodes() {\n\t\tif(jsoupNode == null || jsoupNode.childNodes().size() == 0)\n\t\t\treturn NodeListImpl.emptyList;\n\t\t\n\t\tfinal List<NodeImpl> children = new ArrayList<NodeImpl>();\n\t\tfor(org.jsoup.nodes.Node n: jsoupNode.childNodes()) \n\t\t\tchildren.add(createFromJsoupNode(n, ownerDocument));\n\t\treturn new NodeListImpl(children);\n\t}\n\n\t@Override\n\tpublic Node getFirstChild() {\n\t\tfinal NodeList nl = getChildNodes();\n\t\tif(nl.getLength() == 0)\n\t\t\treturn null;\n\t\telse\n\t\t\treturn nl.item(0);\n\t}\n\n\t@Override\n\tpublic Node getLastChild() {\n\t\tfinal NodeList nl = getChildNodes();\n\t\tif(nl.getLength() == 0)\n\t\t\treturn null;\n\t\telse\n\t\t\treturn nl.item(nl.getLength() - 1);\n\t}\n\n\t@Override\n\tpublic Node getPreviousSibling() {\n\t\tif(jsoupNode == null)\n\t\t\treturn null;\n\t\treturn createFromJsoupNode(jsoupNode.previousSibling(), ownerDocument);\n\t}\n\n\t@Override\n\tpublic Node getNextSibling() {\n\t\tif(jsoupNode == null)\n\t\t\treturn null;\n\t\treturn createFromJsoupNode(jsoupNode.nextSibling(), ownerDocument);\n\t}\n\n\t@Override\n\tpublic NamedNodeMap getAttributes() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic Document getOwnerDocument() {\n\t\treturn ownerDocument;\n\t}\n\n\t@Override\n\tpublic Node insertBefore(Node newChild, Node refChild) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic Node replaceChild(Node newChild, Node oldChild) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic Node removeChild(Node oldChild) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic Node appendChild(Node newChild) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic boolean hasChildNodes() {\n\t\treturn getChildNodes().getLength() > 0;\n\t}\n\n\t@Override\n\tpublic Node cloneNode(boolean deep) {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic void normalize() {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic boolean isSupported(String feature, String version) {\n\t\t// ???\n\t\t// TODO Auto-generated method stub\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic String getNamespaceURI() {\n\t\t// TODO Auto-generated method stub\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getPrefix() {\n\t\t// TODO Auto-generated method stub\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void setPrefix(String prefix) throws DOMException {\n\t\tthrow createReadOnlyException();\t\t\n\t}\n\n\t@Override\n\tpublic String getLocalName() {\n\t\t// TODO Auto-generated method stub\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasAttributes() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic String getBaseURI() {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\tList<Integer> getTreePosition() {\n\t\treturn treePosition;\n\t}\n\t\n\t@Override\n\tpublic short compareDocumentPosition(Node other) throws DOMException {\n\t\tif(!(other instanceof NodeImpl))\n\t\t\treturn Node.DOCUMENT_POSITION_DISCONNECTED;\n\t\t\n\t\tList<Integer> thatTree = ((NodeImpl) other).getTreePosition();\n\t\tif(thatTree.isEmpty() || getTreePosition().isEmpty())\n\t\t\treturn Node.DOCUMENT_POSITION_DISCONNECTED;\n\t\t\n\t\tint i = 0;\n\t\twhile(true) {\n\t\t\tif(i == thatTree.size() && i == treePosition.size())\n\t\t\t\treturn 0; // They are the same \n\t\t\tif(i == thatTree.size())\n\t\t\t\treturn Node.DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING;\n\t\t\tif(i == treePosition.size())\n\t\t\t\treturn Node.DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING;\n\t\t\tif(thatTree.get(i) < treePosition.get(i))\n\t\t\t\treturn Node.DOCUMENT_POSITION_PRECEDING;\n\t\t\tif(thatTree.get(i) > treePosition.get(i)) \n\t\t\t\treturn Node.DOCUMENT_POSITION_FOLLOWING;\n\t\t\ti++;\n\t\t}\n\t}\n\t\n\tvoid printTree() {\n\t\tSystem.out.print(getNodeName() + \": [\");\n\t\tfor(int i = 0; i < treePosition.size(); i++) {\n\t\t\tif(i > 0)\n\t\t\t\tSystem.out.print(\", \");\n\t\t\tSystem.out.print(treePosition.get(i));\n\t\t\t\n\t\t}\n\t\tSystem.out.println(\"]\");\n\t}\n\n\t@Override\n\tpublic String getTextContent() throws DOMException {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void setTextContent(String textContent) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\t\t\n\t}\n\n\t@Override\n\tpublic boolean isSameNode(Node other) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic String lookupPrefix(String namespaceURI) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic boolean isDefaultNamespace(String namespaceURI) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic String lookupNamespaceURI(String prefix) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic boolean isEqualNode(Node arg) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic Object getFeature(String feature, String version) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic Object setUserData(String key, Object data, UserDataHandler handler) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\t@Override\n\tpublic Object getUserData(String key) {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n\tpublic boolean equals(Object other) {\n\t\tif(!(other instanceof NodeImpl))\n\t\t\treturn false;\n\t\tNodeImpl that = (NodeImpl) other;\n\t\treturn jsoupNode.equals(that.jsoupNode);\n\t}\n\t\n\tpublic int hashCode() {\n\t\treturn jsoupNode.hashCode();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/NodeListImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\n\npublic class NodeListImpl implements NodeList {\n\n\tstatic final NodeList emptyList = new NodeListImpl(new ArrayList<NodeImpl>(0));\n\t\n\tprivate final List<NodeImpl> nodes;\n\t\n\tpublic NodeListImpl(List<NodeImpl> nodes) {\n\t\tthis.nodes = nodes;\n\t}\n\t\n\t@Override\n\tpublic Node item(int index) {\n\t\tif(index < 0 || index >= nodes.size())\n\t\t\treturn null;\n\t\treturn nodes.get(index);\n\t}\n\n\t@Override\n\tpublic int getLength() {\n\t\treturn nodes.size();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/com/subgraph/vega/internal/html/dom/TextImpl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.html.dom;\n\nimport org.jsoup.nodes.TextNode;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.Text;\n\npublic class TextImpl extends CharacterDataImpl implements Text {\n\n\tTextImpl(TextNode textNode, Document ownerDocument) {\n\t\tsuper(textNode, textNode.getWholeText(), ownerDocument);\n\t}\n\t\n\t@Override\n\tpublic String getNodeName() {\n\t\treturn \"#text\";\n\t}\n\t\n\t@Override\n\tpublic short getNodeType() {\n\t\treturn Node.TEXT_NODE;\n\t}\n\n\t@Override\n\tpublic Text splitText(int offset) throws DOMException {\n\t\tthrow createReadOnlyException();\n\t}\n\n\t@Override\n\tpublic boolean isElementContentWhitespace() {\n\t\treturn getData().trim().length() == 0;\n\t}\n\n\t@Override\n\tpublic String getWholeText() {\n\t\treturn getData();\n\t}\n\n\t@Override\n\tpublic Text replaceWholeText(String content) throws DOMException {\n\t\tthrow createNoLevel3SupportException();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLAnchorElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * The anchor element. See the A element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLAnchorElement extends HTMLElement {\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * The character encoding of the linked resource. See the charset \n     * attribute definition in HTML 4.01.\n     */\n    public String getCharset();\n    /**\n     * The character encoding of the linked resource. See the charset \n     * attribute definition in HTML 4.01.\n     */\n    public void setCharset(String charset);\n\n    /**\n     * Comma-separated list of lengths, defining an active region geometry. \n     * See also <code>shape</code> for the shape of the region. See the \n     * coords attribute definition in HTML 4.01.\n     */\n    public String getCoords();\n    /**\n     * Comma-separated list of lengths, defining an active region geometry. \n     * See also <code>shape</code> for the shape of the region. See the \n     * coords attribute definition in HTML 4.01.\n     */\n    public void setCoords(String coords);\n\n    /**\n     * The absolute URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the linked resource. See the href attribute \n     * definition in HTML 4.01.\n     */\n    public String getHref();\n    /**\n     * The absolute URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the linked resource. See the href attribute \n     * definition in HTML 4.01.\n     */\n    public void setHref(String href);\n\n    /**\n     * Language code of the linked resource. See the hreflang attribute \n     * definition in HTML 4.01.\n     */\n    public String getHreflang();\n    /**\n     * Language code of the linked resource. See the hreflang attribute \n     * definition in HTML 4.01.\n     */\n    public void setHreflang(String hreflang);\n\n    /**\n     * Anchor name. See the name attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Anchor name. See the name attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Forward link type. See the rel attribute definition in HTML 4.01.\n     */\n    public String getRel();\n    /**\n     * Forward link type. See the rel attribute definition in HTML 4.01.\n     */\n    public void setRel(String rel);\n\n    /**\n     * Reverse link type. See the rev attribute definition in HTML 4.01.\n     */\n    public String getRev();\n    /**\n     * Reverse link type. See the rev attribute definition in HTML 4.01.\n     */\n    public void setRev(String rev);\n\n    /**\n     * The shape of the active area. The coordinates are given by \n     * <code>coords</code>. See the shape attribute definition in HTML 4.01.\n     */\n    public String getShape();\n    /**\n     * The shape of the active area. The coordinates are given by \n     * <code>coords</code>. See the shape attribute definition in HTML 4.01.\n     */\n    public void setShape(String shape);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public String getTarget();\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public void setTarget(String target);\n\n    /**\n     * Advisory content type. See the type attribute definition in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * Advisory content type. See the type attribute definition in HTML 4.01.\n     */\n    public void setType(String type);\n\n    /**\n     * Removes keyboard focus from this element.\n     */\n    public void blur();\n\n    /**\n     * Gives keyboard focus to this element.\n     */\n    public void focus();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLAppletElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * An embedded Java applet. See the APPLET element definition in HTML 4.01. \n * This element is deprecated in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLAppletElement extends HTMLElement {\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getAlt();\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setAlt(String alt);\n\n    /**\n     * Comma-separated archive list. See the archive attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getArchive();\n    /**\n     * Comma-separated archive list. See the archive attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setArchive(String archive);\n\n    /**\n     * Applet class file. See the code attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getCode();\n    /**\n     * Applet class file. See the code attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setCode(String code);\n\n    /**\n     * Optional base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] for applet. See the codebase attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getCodeBase();\n    /**\n     * Optional base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] for applet. See the codebase attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setCodeBase(String codeBase);\n\n    /**\n     * Override height. See the height attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getHeight();\n    /**\n     * Override height. See the height attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setHeight(String height);\n\n    /**\n     * Horizontal space, in pixels, to the left and right of this image, \n     * applet, or object. See the hspace attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public int getHspace();\n    /**\n     * Horizontal space, in pixels, to the left and right of this image, \n     * applet, or object. See the hspace attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public void setHspace(int hspace);\n\n    /**\n     * The name of the applet. See the name attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * The name of the applet. See the name attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * The value of the \"object\" attribute. See the object attribute definition\n     *  in HTML 4.01. This attribute is deprecated in HTML 4.01. \n     * @version DOM Level 2\n     */\n    public String getObject();\n    /**\n     * The value of the \"object\" attribute. See the object attribute definition\n     *  in HTML 4.01. This attribute is deprecated in HTML 4.01. \n     * @version DOM Level 2\n     */\n    public void setObject(String object);\n\n    /**\n     * Vertical space, in pixels, above and below this image, applet, or \n     * object. See the vspace attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public int getVspace();\n    /**\n     * Vertical space, in pixels, above and below this image, applet, or \n     * object. See the vspace attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public void setVspace(int vspace);\n\n    /**\n     * Override width. See the width attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * Override width. See the width attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLAreaElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Client-side image map area definition. See the AREA element definition in \n * HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLAreaElement extends HTMLElement {\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01.\n     */\n    public String getAlt();\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01.\n     */\n    public void setAlt(String alt);\n\n    /**\n     * Comma-separated list of lengths, defining an active region geometry. \n     * See also <code>shape</code> for the shape of the region. See the \n     * coords attribute definition in HTML 4.01.\n     */\n    public String getCoords();\n    /**\n     * Comma-separated list of lengths, defining an active region geometry. \n     * See also <code>shape</code> for the shape of the region. See the \n     * coords attribute definition in HTML 4.01.\n     */\n    public void setCoords(String coords);\n\n    /**\n     * The URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the linked resource. See the href attribute definition in \n     * HTML 4.01.\n     */\n    public String getHref();\n    /**\n     * The URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the linked resource. See the href attribute definition in \n     * HTML 4.01.\n     */\n    public void setHref(String href);\n\n    /**\n     * Specifies that this area is inactive, i.e., has no associated action. \n     * See the nohref attribute definition in HTML 4.01.\n     */\n    public boolean getNoHref();\n    /**\n     * Specifies that this area is inactive, i.e., has no associated action. \n     * See the nohref attribute definition in HTML 4.01.\n     */\n    public void setNoHref(boolean noHref);\n\n    /**\n     * The shape of the active area. The coordinates are given by \n     * <code>coords</code>. See the shape attribute definition in HTML 4.01.\n     */\n    public String getShape();\n    /**\n     * The shape of the active area. The coordinates are given by \n     * <code>coords</code>. See the shape attribute definition in HTML 4.01.\n     */\n    public void setShape(String shape);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public String getTarget();\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public void setTarget(String target);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLBRElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Force a line break. See the BR element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLBRElement extends HTMLElement {\n    /**\n     * Control flow of text around floats. See the clear attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getClear();\n    /**\n     * Control flow of text around floats. See the clear attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setClear(String clear);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLBaseElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Document base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]. See the BASE element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLBaseElement extends HTMLElement {\n    /**\n     * The base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]. See the href attribute definition in HTML 4.01.\n     */\n    public String getHref();\n    /**\n     * The base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]. See the href attribute definition in HTML 4.01.\n     */\n    public void setHref(String href);\n\n    /**\n     * The default target frame. See the target attribute definition in HTML \n     * 4.01.\n     */\n    public String getTarget();\n    /**\n     * The default target frame. See the target attribute definition in HTML \n     * 4.01.\n     */\n    public void setTarget(String target);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLBaseFontElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Base font. See the BASEFONT element definition in HTML 4.01. This element \n * is deprecated in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLBaseFontElement extends HTMLElement {\n    /**\n     * Font color. See the color attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getColor();\n    /**\n     * Font color. See the color attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setColor(String color);\n\n    /**\n     * Font face identifier. See the face attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getFace();\n    /**\n     * Font face identifier. See the face attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setFace(String face);\n\n    /**\n     * Computed font size. See the size attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public int getSize();\n    /**\n     * Computed font size. See the size attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public void setSize(int size);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLBodyElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * The HTML document body. This element is always present in the DOM API, even \n * if the tags are not present in the source document. See the BODY element \n * definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLBodyElement extends HTMLElement {\n    /**\n     * Color of active links (after mouse-button down, but before mouse-button \n     * up). See the alink attribute definition in HTML 4.01. This attribute \n     * is deprecated in HTML 4.01.\n     */\n    public String getALink();\n    /**\n     * Color of active links (after mouse-button down, but before mouse-button \n     * up). See the alink attribute definition in HTML 4.01. This attribute \n     * is deprecated in HTML 4.01.\n     */\n    public void setALink(String aLink);\n\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the background texture tile image. See the background attribute \n     * definition in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getBackground();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the background texture tile image. See the background attribute \n     * definition in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setBackground(String background);\n\n    /**\n     * Document background color. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getBgColor();\n    /**\n     * Document background color. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setBgColor(String bgColor);\n\n    /**\n     * Color of links that are not active and unvisited. See the link \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public String getLink();\n    /**\n     * Color of links that are not active and unvisited. See the link \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public void setLink(String link);\n\n    /**\n     * Document text color. See the text attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getText();\n    /**\n     * Document text color. See the text attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setText(String text);\n\n    /**\n     * Color of links that have been visited by the user. See the vlink \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public String getVLink();\n    /**\n     * Color of links that have been visited by the user. See the vlink \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public void setVLink(String vLink);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLButtonElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Push button. See the BUTTON element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLButtonElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getDisabled();\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * The type of button (all lower case). See the type attribute definition \n     * in HTML 4.01.\n     */\n    public String getType();\n\n    /**\n     * The current form control value. See the value attribute definition in \n     * HTML 4.01.\n     */\n    public String getValue();\n    /**\n     * The current form control value. See the value attribute definition in \n     * HTML 4.01.\n     */\n    public void setValue(String value);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLCollection.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Node;\n\n/**\n * An <code>HTMLCollection</code> is a list of nodes. An individual node may \n * be accessed by either ordinal index or the node's <code>name</code> or \n * <code>id</code> attributes. Collections in the HTML DOM are assumed to be \n * live meaning that they are automatically updated when the underlying \n * document is changed. \n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLCollection {\n    /**\n     * This attribute specifies the length or size of the list. \n     */\n    public int getLength();\n\n    /**\n     * This method retrieves a node specified by ordinal index. Nodes are \n     * numbered in tree order (depth-first traversal order).\n     * @param index The index of the node to be fetched. The index origin is \n     *   <code>0</code>.\n     * @return The <code>Node</code> at the corresponding position upon \n     *   success. A value of <code>null</code> is returned if the index is \n     *   out of range. \n     */\n    public Node item(int index);\n\n    /**\n     * This method retrieves a <code>Node</code> using a name. With [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>] \n     * documents, it first searches for a <code>Node</code> with a matching \n     * <code>id</code> attribute. If it doesn't find one, it then searches \n     * for a <code>Node</code> with a matching <code>name</code> attribute, \n     * but only on those elements that are allowed a name attribute. With [<a href='http://www.w3.org/TR/2002/REC-xhtml1-20020801'>XHTML 1.0</a>] \n     * documents, this method only searches for <code>Nodes</code> with a \n     * matching <code>id</code> attribute. This method is case insensitive \n     * in HTML documents and case sensitive in XHTML documents.\n     * @param name The name of the <code>Node</code> to be fetched.\n     * @return The <code>Node</code> with a <code>name</code> or \n     *   <code>id</code> attribute whose value corresponds to the specified \n     *   string. Upon failure (e.g., no node with this name exists), returns \n     *   <code>null</code>.\n     */\n    public Node namedItem(String name);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLDListElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Definition list. See the DL element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLDListElement extends HTMLElement {\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getCompact();\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setCompact(boolean compact);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLDirectoryElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Directory list. See the DIR element definition in HTML 4.01. This element \n * is deprecated in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLDirectoryElement extends HTMLElement {\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getCompact();\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setCompact(boolean compact);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLDivElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Generic block container. See the DIV element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLDivElement extends HTMLElement {\n    /**\n     * Horizontal text alignment. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Horizontal text alignment. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLDocument.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Document;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.DOMException;\n\n/**\n * An <code>HTMLDocument</code> is the root of the HTML hierarchy and holds \n * the entire content. Besides providing access to the hierarchy, it also \n * provides some convenience methods for accessing certain sets of \n * information from the document.\n * <p>The following properties have been deprecated in favor of the \n * corresponding ones for the <code>BODY</code> element:alinkColorbackground\n * bgColorfgColorlinkColorvlinkColorIn DOM Level 2, the method \n * <code>getElementById</code> is inherited from the <code>Document</code> \n * interface where it was moved to.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLDocument extends Document {\n    /**\n     * The title of a document as specified by the <code>TITLE</code> element \n     * in the head of the document. \n     */\n    public String getTitle();\n    /**\n     * The title of a document as specified by the <code>TITLE</code> element \n     * in the head of the document. \n     */\n    public void setTitle(String title);\n\n    /**\n     * Returns the URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the page that linked to this page. The value is an \n     * empty string if the user navigated to the page directly (not through \n     * a link, but, for example, via a bookmark). \n     */\n    public String getReferrer();\n\n    /**\n     * The domain name of the server that served the document, or \n     * <code>null</code> if the server cannot be identified by a domain \n     * name. \n     */\n    public String getDomain();\n\n    /**\n     * The absolute URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the document. \n     */\n    public String getURL();\n\n    /**\n     * The element that contains the content for the document. In documents \n     * with <code>BODY</code> contents, returns the <code>BODY</code> \n     * element. In frameset documents, this returns the outermost \n     * <code>FRAMESET</code> element. \n     */\n    public HTMLElement getBody();\n    /**\n     * The element that contains the content for the document. In documents \n     * with <code>BODY</code> contents, returns the <code>BODY</code> \n     * element. In frameset documents, this returns the outermost \n     * <code>FRAMESET</code> element. \n     */\n    public void setBody(HTMLElement body);\n\n    /**\n     * A collection of all the <code>IMG</code> elements in a document. The \n     * behavior is limited to <code>IMG</code> elements for backwards \n     * compatibility. As suggested by [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>], to include images, authors may use \n     * the <code>OBJECT</code> element or the <code>IMG</code> element. \n     * Therefore, it is recommended not to use this attribute to find the \n     * images in the document but <code>getElementsByTagName</code> with \n     * HTML 4.01 or <code>getElementsByTagNameNS</code> with XHTML 1.0.\n     */\n    public HTMLCollection getImages();\n\n    /**\n     * A collection of all the <code>OBJECT</code> elements that include \n     * applets and <code>APPLET</code> (deprecated) elements in a document. \n     */\n    public HTMLCollection getApplets();\n\n    /**\n     * A collection of all <code>AREA</code> elements and anchor (\n     * <code>A</code>) elements in a document with a value for the \n     * <code>href</code> attribute. \n     */\n    public HTMLCollection getLinks();\n\n    /**\n     * A collection of all the forms of a document. \n     */\n    public HTMLCollection getForms();\n\n    /**\n     *  A collection of all the anchor (<code>A</code>) elements in a document \n     * with a value for the <code>name</code> attribute. For reasons of \n     * backward compatibility, the returned set of anchors only contains \n     * those anchors created with the <code>name</code> attribute, not those \n     * created with the <code>id</code> attribute. Note that in [<a href='http://www.w3.org/TR/2002/REC-xhtml1-20020801'>XHTML 1.0</a>], the \n     * <code>name</code> attribute (see section 4.10) has no semantics and \n     * is only present for legacy user agents: the <code>id</code> attribute \n     * is used instead. Users should prefer the iterator mechanisms provided \n     * by [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>DOM Level 2 Traversal</a>] instead. \n     */\n    public HTMLCollection getAnchors();\n\n    /**\n     *  This mutable string attribute denotes persistent state information \n     * that (1) is associated with the current frame or document and (2) is \n     * composed of information described by the <code>cookies</code> \n     * non-terminal of [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>], Section 4.2.2. \n     * <br> If no persistent state information is available for the current \n     * frame or document document, then this property's value is an empty \n     * string. \n     * <br> When this attribute is read, all cookies are returned as a single \n     * string, with each cookie's name-value pair concatenated into a list \n     * of name-value pairs, each list item being separated by a ';' \n     * (semicolon). \n     * <br> When this attribute is set, the value it is set to should be a \n     * string that adheres to the <code>cookie</code> non-terminal of [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>]; that \n     * is, it should be a single name-value pair followed by zero or more \n     * cookie attribute values. If no domain attribute is specified, then \n     * the domain attribute for the new value defaults to the host portion \n     * of an absolute URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the current frame or document. If no path \n     * attribute is specified, then the path attribute for the new value \n     * defaults to the absolute path portion of the URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the current \n     * frame or document. If no max-age attribute is specified, then the \n     * max-age attribute for the new value defaults to a user agent defined \n     * value. If a cookie with the specified name is already associated with \n     * the current frame or document, then the new value as well as the new \n     * attributes replace the old value and attributes. If a max-age \n     * attribute of 0 is specified for the new value, then any existing \n     * cookies of the specified name are removed from the cookie storage.  \n     * See [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>] for the semantics of persistent state item attribute value \n     * pairs.  The precise nature of a user agent session is not defined by \n     * this specification. \n     */\n    public String getCookie();\n    /**\n     *  This mutable string attribute denotes persistent state information \n     * that (1) is associated with the current frame or document and (2) is \n     * composed of information described by the <code>cookies</code> \n     * non-terminal of [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>], Section 4.2.2. \n     * <br> If no persistent state information is available for the current \n     * frame or document document, then this property's value is an empty \n     * string. \n     * <br> When this attribute is read, all cookies are returned as a single \n     * string, with each cookie's name-value pair concatenated into a list \n     * of name-value pairs, each list item being separated by a ';' \n     * (semicolon). \n     * <br> When this attribute is set, the value it is set to should be a \n     * string that adheres to the <code>cookie</code> non-terminal of [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>]; that \n     * is, it should be a single name-value pair followed by zero or more \n     * cookie attribute values. If no domain attribute is specified, then \n     * the domain attribute for the new value defaults to the host portion \n     * of an absolute URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the current frame or document. If no path \n     * attribute is specified, then the path attribute for the new value \n     * defaults to the absolute path portion of the URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the current \n     * frame or document. If no max-age attribute is specified, then the \n     * max-age attribute for the new value defaults to a user agent defined \n     * value. If a cookie with the specified name is already associated with \n     * the current frame or document, then the new value as well as the new \n     * attributes replace the old value and attributes. If a max-age \n     * attribute of 0 is specified for the new value, then any existing \n     * cookies of the specified name are removed from the cookie storage.  \n     * See [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>] for the semantics of persistent state item attribute value \n     * pairs.  The precise nature of a user agent session is not defined by \n     * this specification. \n     * @exception DOMException\n     *    SYNTAX_ERR: If the new value does not adhere to the cookie syntax \n     *   specified by [<a href='http://www.ietf.org/rfc/rfc2965.txt'>IETF RFC 2965</a>]. \n     */\n    public void setCookie(String cookie)\n                                      throws DOMException;\n\n    /**\n     * Open a document stream for writing. If a document exists in the target, \n     * this method clears it. This method and the ones following allow a \n     * user to add to or replace the structure model of a document using \n     * strings of unparsed HTML. At the time of writing alternate methods \n     * for providing similar functionality for both HTML and XML documents \n     * were being considered (see [<a href='http://www.w3.org/TR/2002/WD-DOM-Level-3-LS-20020725'>DOM Level 3 Load and Save</a>]).\n     */\n    public void open();\n\n    /**\n     * Closes a document stream opened by <code>open()</code> and forces \n     * rendering.\n     */\n    public void close();\n\n    /**\n     * Write a string of text to a document stream opened by \n     * <code>open()</code>. Note that the function will produce a document \n     * which is not necessarily driven by a DTD and therefore might be \n     * produce an invalid result in the context of the document.\n     * @param text The string to be parsed into some structure in the \n     *   document structure model.\n     */\n    public void write(String text);\n\n    /**\n     * Write a string of text followed by a newline character to a document \n     * stream opened by <code>open()</code>. Note that the function will \n     * produce a document which is not necessarily driven by a DTD and \n     * therefore might be produce an invalid result in the context of the \n     * document\n     * @param text The string to be parsed into some structure in the \n     *   document structure model.\n     */\n    public void writeln(String text);\n\n    /**\n     *  With [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>] documents, this method returns the (possibly empty) collection \n     * of elements whose <code>name</code> value is given by \n     * <code>elementName</code>. In [<a href='http://www.w3.org/TR/2002/REC-xhtml1-20020801'>XHTML 1.0</a>] documents, this methods only return the \n     * (possibly empty) collection of form controls with matching name. This \n     * method is case sensitive. \n     * @param elementName The <code>name</code> attribute value for an \n     *   element.\n     * @return The matching elements.\n     */\n    public NodeList getElementsByName(String elementName);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Element;\n\n/**\n *  All HTML element interfaces derive from this class. Elements that only \n * expose the HTML core attributes are represented by the base \n * <code>HTMLElement</code> interface. These elements are as follows: \n * special: SUB, SUP, SPAN, BDOfont: TT, I, B, U, S, STRIKE, BIG, SMALL\n * phrase: EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ACRONYM, ABBRlist: \n * DD, DTNOFRAMES, NOSCRIPTADDRESS, CENTERThe <code>style</code> attribute \n * of an HTML element is accessible through the \n * <code>ElementCSSInlineStyle</code> interface which is defined in the CSS \n * module [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>DOM Level 2 Style Sheets and CSS</a>]. \n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLElement extends Element {\n    /**\n     * The element's identifier. See the id attribute definition in HTML 4.01.\n     */\n    public String getId();\n    /**\n     * The element's identifier. See the id attribute definition in HTML 4.01.\n     */\n    public void setId(String id);\n\n    /**\n     * The element's advisory title. See the title attribute definition in \n     * HTML 4.01.\n     */\n    public String getTitle();\n    /**\n     * The element's advisory title. See the title attribute definition in \n     * HTML 4.01.\n     */\n    public void setTitle(String title);\n\n    /**\n     * Language code defined in RFC 1766. See the lang attribute definition in \n     * HTML 4.01.\n     */\n    public String getLang();\n    /**\n     * Language code defined in RFC 1766. See the lang attribute definition in \n     * HTML 4.01.\n     */\n    public void setLang(String lang);\n\n    /**\n     * Specifies the base direction of directionally neutral text and the \n     * directionality of tables. See the dir attribute definition in HTML \n     * 4.01.\n     */\n    public String getDir();\n    /**\n     * Specifies the base direction of directionally neutral text and the \n     * directionality of tables. See the dir attribute definition in HTML \n     * 4.01.\n     */\n    public void setDir(String dir);\n\n    /**\n     * The class attribute of the element. This attribute has been renamed due \n     * to conflicts with the \"class\" keyword exposed by many languages. See \n     * the class attribute definition in HTML 4.01.\n     */\n    public String getClassName();\n    /**\n     * The class attribute of the element. This attribute has been renamed due \n     * to conflicts with the \"class\" keyword exposed by many languages. See \n     * the class attribute definition in HTML 4.01.\n     */\n    public void setClassName(String className);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLFieldSetElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Organizes form controls into logical groups. See the FIELDSET element \n * definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLFieldSetElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLFontElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Local change to font. See the FONT element definition in HTML 4.01. This \n * element is deprecated in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLFontElement extends HTMLElement {\n    /**\n     * Font color. See the color attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getColor();\n    /**\n     * Font color. See the color attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setColor(String color);\n\n    /**\n     * Font face identifier. See the face attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getFace();\n    /**\n     * Font face identifier. See the face attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setFace(String face);\n\n    /**\n     * Font size. See the size attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getSize();\n    /**\n     * Font size. See the size attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setSize(String size);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLFormElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * The <code>FORM</code> element encompasses behavior similar to a collection \n * and an element. It provides direct access to the contained form controls \n * as well as the attributes of the form element. See the FORM element \n * definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLFormElement extends HTMLElement {\n    /**\n     * Returns a collection of all form control elements in the form. \n     */\n    public HTMLCollection getElements();\n\n    /**\n     * The number of form controls in the form.\n     */\n    public int getLength();\n\n    /**\n     * Names the form. \n     */\n    public String getName();\n    /**\n     * Names the form. \n     */\n    public void setName(String name);\n\n    /**\n     * List of character sets supported by the server. See the accept-charset \n     * attribute definition in HTML 4.01.\n     */\n    public String getAcceptCharset();\n    /**\n     * List of character sets supported by the server. See the accept-charset \n     * attribute definition in HTML 4.01.\n     */\n    public void setAcceptCharset(String acceptCharset);\n\n    /**\n     * Server-side form handler. See the action attribute definition in HTML \n     * 4.01.\n     */\n    public String getAction();\n    /**\n     * Server-side form handler. See the action attribute definition in HTML \n     * 4.01.\n     */\n    public void setAction(String action);\n\n    /**\n     * The content type of the submitted form, generally \n     * \"application/x-www-form-urlencoded\". See the enctype attribute \n     * definition in HTML 4.01. The onsubmit even handler is not guaranteed \n     * to be triggered when invoking this method. The behavior is \n     * inconsistent for historical reasons and authors should not rely on a \n     * particular one. \n     */\n    public String getEnctype();\n    /**\n     * The content type of the submitted form, generally \n     * \"application/x-www-form-urlencoded\". See the enctype attribute \n     * definition in HTML 4.01. The onsubmit even handler is not guaranteed \n     * to be triggered when invoking this method. The behavior is \n     * inconsistent for historical reasons and authors should not rely on a \n     * particular one. \n     */\n    public void setEnctype(String enctype);\n\n    /**\n     * HTTP method [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>] used to submit form. See the method attribute definition \n     * in HTML 4.01.\n     */\n    public String getMethod();\n    /**\n     * HTTP method [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>] used to submit form. See the method attribute definition \n     * in HTML 4.01.\n     */\n    public void setMethod(String method);\n\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public String getTarget();\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public void setTarget(String target);\n\n    /**\n     * Submits the form. It performs the same action as a submit button.\n     */\n    public void submit();\n\n    /**\n     * Restores a form element's default values. It performs the same action \n     * as a reset button.\n     */\n    public void reset();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLFrameElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Document;\n\n/**\n * Create a frame. See the FRAME element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLFrameElement extends HTMLElement {\n    /**\n     * Request frame borders. See the frameborder attribute definition in HTML \n     * 4.01.\n     */\n    public String getFrameBorder();\n    /**\n     * Request frame borders. See the frameborder attribute definition in HTML \n     * 4.01.\n     */\n    public void setFrameBorder(String frameBorder);\n\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a long description of this image or frame. See the \n     * longdesc attribute definition in HTML 4.01.\n     */\n    public String getLongDesc();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a long description of this image or frame. See the \n     * longdesc attribute definition in HTML 4.01.\n     */\n    public void setLongDesc(String longDesc);\n\n    /**\n     * Frame margin height, in pixels. See the marginheight attribute \n     * definition in HTML 4.01.\n     */\n    public String getMarginHeight();\n    /**\n     * Frame margin height, in pixels. See the marginheight attribute \n     * definition in HTML 4.01.\n     */\n    public void setMarginHeight(String marginHeight);\n\n    /**\n     * Frame margin width, in pixels. See the marginwidth attribute definition \n     * in HTML 4.01.\n     */\n    public String getMarginWidth();\n    /**\n     * Frame margin width, in pixels. See the marginwidth attribute definition \n     * in HTML 4.01.\n     */\n    public void setMarginWidth(String marginWidth);\n\n    /**\n     * The frame name (object of the <code>target</code> attribute). See the \n     * name attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * The frame name (object of the <code>target</code> attribute). See the \n     * name attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * When true, forbid user from resizing frame. See the noresize attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getNoResize();\n    /**\n     * When true, forbid user from resizing frame. See the noresize attribute \n     * definition in HTML 4.01.\n     */\n    public void setNoResize(boolean noResize);\n\n    /**\n     * Specify whether or not the frame should have scrollbars. See the \n     * scrolling attribute definition in HTML 4.01.\n     */\n    public String getScrolling();\n    /**\n     * Specify whether or not the frame should have scrollbars. See the \n     * scrolling attribute definition in HTML 4.01.\n     */\n    public void setScrolling(String scrolling);\n\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating the initial frame contents. See the src attribute \n     * definition in HTML 4.01.\n     */\n    public String getSrc();\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating the initial frame contents. See the src attribute \n     * definition in HTML 4.01.\n     */\n    public void setSrc(String src);\n\n    /**\n     * The document this frame contains, if there is any and it is available, \n     * or <code>null</code> otherwise.\n     * @since DOM Level 2\n     */\n    public Document getContentDocument();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLFrameSetElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Create a grid of frames. See the FRAMESET element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLFrameSetElement extends HTMLElement {\n    /**\n     * The number of columns of frames in the frameset. See the cols attribute \n     * definition in HTML 4.01.\n     */\n    public String getCols();\n    /**\n     * The number of columns of frames in the frameset. See the cols attribute \n     * definition in HTML 4.01.\n     */\n    public void setCols(String cols);\n\n    /**\n     * The number of rows of frames in the frameset. See the rows attribute \n     * definition in HTML 4.01.\n     */\n    public String getRows();\n    /**\n     * The number of rows of frames in the frameset. See the rows attribute \n     * definition in HTML 4.01.\n     */\n    public void setRows(String rows);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLHRElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Create a horizontal rule. See the HR element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLHRElement extends HTMLElement {\n    /**\n     * Align the rule on the page. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Align the rule on the page. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Indicates to the user agent that there should be no shading in the \n     * rendering of this element. See the noshade attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getNoShade();\n    /**\n     * Indicates to the user agent that there should be no shading in the \n     * rendering of this element. See the noshade attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setNoShade(boolean noShade);\n\n    /**\n     * The height of the rule. See the size attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getSize();\n    /**\n     * The height of the rule. See the size attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setSize(String size);\n\n    /**\n     * The width of the rule. See the width attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * The width of the rule. See the width attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLHeadElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Document head information. See the HEAD element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLHeadElement extends HTMLElement {\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a metadata profile. See the profile attribute \n     * definition in HTML 4.01.\n     */\n    public String getProfile();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a metadata profile. See the profile attribute \n     * definition in HTML 4.01.\n     */\n    public void setProfile(String profile);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLHeadingElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * For the <code>H1</code> to <code>H6</code> elements. See the H1 element \n * definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLHeadingElement extends HTMLElement {\n    /**\n     * Horizontal text alignment. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Horizontal text alignment. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLHtmlElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Root of an HTML document. See the HTML element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLHtmlElement extends HTMLElement {\n    /**\n     * Version information about the document's DTD. See the version attribute \n     * definition in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getVersion();\n    /**\n     * Version information about the document's DTD. See the version attribute \n     * definition in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setVersion(String version);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLIFrameElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Document;\n\n/**\n * Inline subwindows. See the IFRAME element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLIFrameElement extends HTMLElement {\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Request frame borders. See the frameborder attribute definition in HTML \n     * 4.01.\n     */\n    public String getFrameBorder();\n    /**\n     * Request frame borders. See the frameborder attribute definition in HTML \n     * 4.01.\n     */\n    public void setFrameBorder(String frameBorder);\n\n    /**\n     * Frame height. See the height attribute definition in HTML 4.01.\n     */\n    public String getHeight();\n    /**\n     * Frame height. See the height attribute definition in HTML 4.01.\n     */\n    public void setHeight(String height);\n\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a long description of this image or frame. See the \n     * longdesc attribute definition in HTML 4.01.\n     */\n    public String getLongDesc();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a long description of this image or frame. See the \n     * longdesc attribute definition in HTML 4.01.\n     */\n    public void setLongDesc(String longDesc);\n\n    /**\n     * Frame margin height, in pixels. See the marginheight attribute \n     * definition in HTML 4.01.\n     */\n    public String getMarginHeight();\n    /**\n     * Frame margin height, in pixels. See the marginheight attribute \n     * definition in HTML 4.01.\n     */\n    public void setMarginHeight(String marginHeight);\n\n    /**\n     * Frame margin width, in pixels. See the marginwidth attribute definition \n     * in HTML 4.01.\n     */\n    public String getMarginWidth();\n    /**\n     * Frame margin width, in pixels. See the marginwidth attribute definition \n     * in HTML 4.01.\n     */\n    public void setMarginWidth(String marginWidth);\n\n    /**\n     * The frame name (object of the <code>target</code> attribute). See the \n     * name attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * The frame name (object of the <code>target</code> attribute). See the \n     * name attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Specify whether or not the frame should have scrollbars. See the \n     * scrolling attribute definition in HTML 4.01.\n     */\n    public String getScrolling();\n    /**\n     * Specify whether or not the frame should have scrollbars. See the \n     * scrolling attribute definition in HTML 4.01.\n     */\n    public void setScrolling(String scrolling);\n\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating the initial frame contents. See the src attribute \n     * definition in HTML 4.01.\n     */\n    public String getSrc();\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating the initial frame contents. See the src attribute \n     * definition in HTML 4.01.\n     */\n    public void setSrc(String src);\n\n    /**\n     * Frame width. See the width attribute definition in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * Frame width. See the width attribute definition in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n    /**\n     * The document this frame contains, if there is any and it is available, \n     * or <code>null</code> otherwise.\n     * @since DOM Level 2\n     */\n    public Document getContentDocument();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLImageElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Embedded image. See the IMG element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLImageElement extends HTMLElement {\n    /**\n     * The name of the element (for backwards compatibility). \n     */\n    public String getName();\n    /**\n     * The name of the element (for backwards compatibility). \n     */\n    public void setName(String name);\n\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01.\n     */\n    public String getAlt();\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01.\n     */\n    public void setAlt(String alt);\n\n    /**\n     * Width of border around image. See the  border attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01. Note that the \n     * type of this attribute was <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>]\n     * .\n     */\n    public String getBorder();\n    /**\n     * Width of border around image. See the  border attribute definition in \n     * HTML 4.01. This attribute is deprecated in HTML 4.01. Note that the \n     * type of this attribute was <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>]\n     * .\n     */\n    public void setBorder(String border);\n\n    /**\n     * Height of the image in pixels. See the height attribute definition in \n     * HTML 4.01. Note that the type of this attribute was \n     * <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public int getHeight();\n    /**\n     * Height of the image in pixels. See the height attribute definition in \n     * HTML 4.01. Note that the type of this attribute was \n     * <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public void setHeight(int height);\n\n    /**\n     * Horizontal space to the left and right of this image in pixels. See the \n     * hspace attribute definition in HTML 4.01. This attribute is \n     * deprecated in HTML 4.01. Note that the type of this attribute was \n     * <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public int getHspace();\n    /**\n     * Horizontal space to the left and right of this image in pixels. See the \n     * hspace attribute definition in HTML 4.01. This attribute is \n     * deprecated in HTML 4.01. Note that the type of this attribute was \n     * <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public void setHspace(int hspace);\n\n    /**\n     * Use server-side image map. See the ismap attribute definition in HTML \n     * 4.01.\n     */\n    public boolean getIsMap();\n    /**\n     * Use server-side image map. See the ismap attribute definition in HTML \n     * 4.01.\n     */\n    public void setIsMap(boolean isMap);\n\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a long description of this image or frame. See the \n     * longdesc attribute definition in HTML 4.01.\n     */\n    public String getLongDesc();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a long description of this image or frame. See the \n     * longdesc attribute definition in HTML 4.01.\n     */\n    public void setLongDesc(String longDesc);\n\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating the source of this image. See the src attribute \n     * definition in HTML 4.01.\n     */\n    public String getSrc();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating the source of this image. See the src attribute \n     * definition in HTML 4.01.\n     */\n    public void setSrc(String src);\n\n    /**\n     * Use client-side image map. See the usemap attribute definition in HTML \n     * 4.01.\n     */\n    public String getUseMap();\n    /**\n     * Use client-side image map. See the usemap attribute definition in HTML \n     * 4.01.\n     */\n    public void setUseMap(String useMap);\n\n    /**\n     * Vertical space above and below this image in pixels. See the vspace \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01. Note that the type of this attribute was \"DOMString\" in \n     * DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public int getVspace();\n    /**\n     * Vertical space above and below this image in pixels. See the vspace \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01. Note that the type of this attribute was \"DOMString\" in \n     * DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public void setVspace(int vspace);\n\n    /**\n     * The width of the image in pixels. See the width attribute definition in \n     * HTML 4.01. Note that the type of this attribute was \n     * <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public int getWidth();\n    /**\n     * The width of the image in pixels. See the width attribute definition in \n     * HTML 4.01. Note that the type of this attribute was \n     * <code>DOMString</code> in DOM Level 1 HTML [<a href='http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001'>DOM Level 1</a>].\n     * @version DOM Level 2\n     */\n    public void setWidth(int width);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLInputElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Form control.Depending upon the environment in which the page is being \n * viewed, the value property may be read-only for the file upload input \n * type. For the \"password\" input type, the actual value returned may be \n * masked to prevent unauthorized use. See the INPUT element definition in [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>].\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLInputElement extends HTMLElement {\n    /**\n     * When the <code>type</code> attribute of the element has the value \n     * \"text\", \"file\" or \"password\", this represents the HTML value \n     * attribute of the element. The value of this attribute does not change \n     * if the contents of the corresponding form control, in an interactive \n     * user agent, changes. See the value attribute definition in HTML 4.01.\n     */\n    public String getDefaultValue();\n    /**\n     * When the <code>type</code> attribute of the element has the value \n     * \"text\", \"file\" or \"password\", this represents the HTML value \n     * attribute of the element. The value of this attribute does not change \n     * if the contents of the corresponding form control, in an interactive \n     * user agent, changes. See the value attribute definition in HTML 4.01.\n     */\n    public void setDefaultValue(String defaultValue);\n\n    /**\n     * When <code>type</code> has the value \"radio\" or \"checkbox\", this \n     * represents the HTML checked attribute of the element. The value of \n     * this attribute does not change if the state of the corresponding form \n     * control, in an interactive user agent, changes. See the checked \n     * attribute definition in HTML 4.01.\n     */\n    public boolean getDefaultChecked();\n    /**\n     * When <code>type</code> has the value \"radio\" or \"checkbox\", this \n     * represents the HTML checked attribute of the element. The value of \n     * this attribute does not change if the state of the corresponding form \n     * control, in an interactive user agent, changes. See the checked \n     * attribute definition in HTML 4.01.\n     */\n    public void setDefaultChecked(boolean defaultChecked);\n\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * A comma-separated list of content types that a server processing this \n     * form will handle correctly. See the accept attribute definition in \n     * HTML 4.01.\n     */\n    public String getAccept();\n    /**\n     * A comma-separated list of content types that a server processing this \n     * form will handle correctly. See the accept attribute definition in \n     * HTML 4.01.\n     */\n    public void setAccept(String accept);\n\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01.\n     */\n    public String getAlt();\n    /**\n     * Alternate text for user agents not rendering the normal content of this \n     * element. See the alt attribute definition in HTML 4.01.\n     */\n    public void setAlt(String alt);\n\n    /**\n     * When the <code>type</code> attribute of the element has the value \n     * \"radio\" or \"checkbox\", this represents the current state of the form \n     * control, in an interactive user agent. Changes to this attribute \n     * change the state of the form control, but do not change the value of \n     * the HTML checked attribute of the INPUT element.During the handling \n     * of a click event on an input element with a type attribute that has \n     * the value \"radio\" or \"checkbox\", some implementations may change the \n     * value of this property before the event is being dispatched in the \n     * document. If the default action of the event is canceled, the value \n     * of the property may be changed back to its original value. This means \n     * that the value of this property during the handling of click events \n     * is implementation dependent.\n     */\n    public boolean getChecked();\n    /**\n     * When the <code>type</code> attribute of the element has the value \n     * \"radio\" or \"checkbox\", this represents the current state of the form \n     * control, in an interactive user agent. Changes to this attribute \n     * change the state of the form control, but do not change the value of \n     * the HTML checked attribute of the INPUT element.During the handling \n     * of a click event on an input element with a type attribute that has \n     * the value \"radio\" or \"checkbox\", some implementations may change the \n     * value of this property before the event is being dispatched in the \n     * document. If the default action of the event is canceled, the value \n     * of the property may be changed back to its original value. This means \n     * that the value of this property during the handling of click events \n     * is implementation dependent.\n     */\n    public void setChecked(boolean checked);\n\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getDisabled();\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * Maximum number of characters for text fields, when <code>type</code> \n     * has the value \"text\" or \"password\". See the maxlength attribute \n     * definition in HTML 4.01.\n     */\n    public int getMaxLength();\n    /**\n     * Maximum number of characters for text fields, when <code>type</code> \n     * has the value \"text\" or \"password\". See the maxlength attribute \n     * definition in HTML 4.01.\n     */\n    public void setMaxLength(int maxLength);\n\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * This control is read-only. Relevant only when <code>type</code> has the \n     * value \"text\" or \"password\". See the readonly attribute definition in \n     * HTML 4.01.\n     */\n    public boolean getReadOnly();\n    /**\n     * This control is read-only. Relevant only when <code>type</code> has the \n     * value \"text\" or \"password\". See the readonly attribute definition in \n     * HTML 4.01.\n     */\n    public void setReadOnly(boolean readOnly);\n\n    /**\n     * Size information. The precise meaning is specific to each type of \n     * field. See the size attribute definition in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public int getSize();\n    /**\n     * Size information. The precise meaning is specific to each type of \n     * field. See the size attribute definition in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public void setSize(int size);\n\n    /**\n     * When the <code>type</code> attribute has the value \"image\", this \n     * attribute specifies the location of the image to be used to decorate \n     * the graphical submit button. See the src attribute definition in HTML \n     * 4.01.\n     */\n    public String getSrc();\n    /**\n     * When the <code>type</code> attribute has the value \"image\", this \n     * attribute specifies the location of the image to be used to decorate \n     * the graphical submit button. See the src attribute definition in HTML \n     * 4.01.\n     */\n    public void setSrc(String src);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * The type of control created (all lower case). See the type attribute \n     * definition in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public String getType();\n    /**\n     * The type of control created (all lower case). See the type attribute \n     * definition in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public void setType(String type);\n\n    /**\n     * Use client-side image map. See the usemap attribute definition in HTML \n     * 4.01.\n     */\n    public String getUseMap();\n    /**\n     * Use client-side image map. See the usemap attribute definition in HTML \n     * 4.01.\n     */\n    public void setUseMap(String useMap);\n\n    /**\n     * When the <code>type</code> attribute of the element has the value \n     * \"text\", \"file\" or \"password\", this represents the current contents of \n     * the corresponding form control, in an interactive user agent. \n     * Changing this attribute changes the contents of the form control, but \n     * does not change the value of the HTML value attribute of the element. \n     * When the <code>type</code> attribute of the element has the value \n     * \"button\", \"hidden\", \"submit\", \"reset\", \"image\", \"checkbox\" or \n     * \"radio\", this represents the HTML value attribute of the element. See \n     * the value attribute definition in HTML 4.01.\n     */\n    public String getValue();\n    /**\n     * When the <code>type</code> attribute of the element has the value \n     * \"text\", \"file\" or \"password\", this represents the current contents of \n     * the corresponding form control, in an interactive user agent. \n     * Changing this attribute changes the contents of the form control, but \n     * does not change the value of the HTML value attribute of the element. \n     * When the <code>type</code> attribute of the element has the value \n     * \"button\", \"hidden\", \"submit\", \"reset\", \"image\", \"checkbox\" or \n     * \"radio\", this represents the HTML value attribute of the element. See \n     * the value attribute definition in HTML 4.01.\n     */\n    public void setValue(String value);\n\n    /**\n     * Removes keyboard focus from this element.\n     */\n    public void blur();\n\n    /**\n     * Gives keyboard focus to this element.\n     */\n    public void focus();\n\n    /**\n     * Select the contents of the text area. For <code>INPUT</code> elements \n     * whose <code>type</code> attribute has one of the following values: \n     * \"text\", \"file\", or \"password\".\n     */\n    public void select();\n\n    /**\n     * Simulate a mouse-click. For <code>INPUT</code> elements whose \n     * <code>type</code> attribute has one of the following values: \n     * \"button\", \"checkbox\", \"radio\", \"reset\", or \"submit\".\n     */\n    public void click();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLIsIndexElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * This element is used for single-line text input. See the ISINDEX element \n * definition in HTML 4.01. This element is deprecated in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLIsIndexElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * The prompt message. See the prompt attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getPrompt();\n    /**\n     * The prompt message. See the prompt attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setPrompt(String prompt);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLLIElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * List item. See the LI element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLLIElement extends HTMLElement {\n    /**\n     * List item bullet style. See the type attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * List item bullet style. See the type attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setType(String type);\n\n    /**\n     * Reset sequence number when used in <code>OL</code>. See the value \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public int getValue();\n    /**\n     * Reset sequence number when used in <code>OL</code>. See the value \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public void setValue(int value);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLLabelElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Form field label text. See the LABEL element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLLabelElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * This attribute links this label with another form control by \n     * <code>id</code> attribute. See the for attribute definition in HTML \n     * 4.01.\n     */\n    public String getHtmlFor();\n    /**\n     * This attribute links this label with another form control by \n     * <code>id</code> attribute. See the for attribute definition in HTML \n     * 4.01.\n     */\n    public void setHtmlFor(String htmlFor);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLLegendElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Provides a caption for a <code>FIELDSET</code> grouping. See the LEGEND \n * element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLLegendElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * Text alignment relative to <code>FIELDSET</code>. See the align \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Text alignment relative to <code>FIELDSET</code>. See the align \n     * attribute definition in HTML 4.01. This attribute is deprecated in \n     * HTML 4.01.\n     */\n    public void setAlign(String align);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLLinkElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * The <code>LINK</code> element specifies a link to an external resource, and \n * defines this document's relationship to that resource (or vice versa). \n * See the LINK element definition in HTML 4.01 (see also the \n * <code>LinkStyle</code> interface in the StyleSheet module [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>DOM Level 2 Style Sheets and CSS</a>]).\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLLinkElement extends HTMLElement {\n    /**\n     * Enables/disables the link. This is currently only used for style sheet \n     * links, and may be used to activate or deactivate style sheets. \n     */\n    public boolean getDisabled();\n    /**\n     * Enables/disables the link. This is currently only used for style sheet \n     * links, and may be used to activate or deactivate style sheets. \n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * The character encoding of the resource being linked to. See the charset \n     * attribute definition in HTML 4.01.\n     */\n    public String getCharset();\n    /**\n     * The character encoding of the resource being linked to. See the charset \n     * attribute definition in HTML 4.01.\n     */\n    public void setCharset(String charset);\n\n    /**\n     * The URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the linked resource. See the href attribute definition in \n     * HTML 4.01.\n     */\n    public String getHref();\n    /**\n     * The URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] of the linked resource. See the href attribute definition in \n     * HTML 4.01.\n     */\n    public void setHref(String href);\n\n    /**\n     * Language code of the linked resource. See the hreflang attribute \n     * definition in HTML 4.01.\n     */\n    public String getHreflang();\n    /**\n     * Language code of the linked resource. See the hreflang attribute \n     * definition in HTML 4.01.\n     */\n    public void setHreflang(String hreflang);\n\n    /**\n     * Designed for use with one or more target media. See the media attribute \n     * definition in HTML 4.01.\n     */\n    public String getMedia();\n    /**\n     * Designed for use with one or more target media. See the media attribute \n     * definition in HTML 4.01.\n     */\n    public void setMedia(String media);\n\n    /**\n     * Forward link type. See the rel attribute definition in HTML 4.01.\n     */\n    public String getRel();\n    /**\n     * Forward link type. See the rel attribute definition in HTML 4.01.\n     */\n    public void setRel(String rel);\n\n    /**\n     * Reverse link type. See the rev attribute definition in HTML 4.01.\n     */\n    public String getRev();\n    /**\n     * Reverse link type. See the rev attribute definition in HTML 4.01.\n     */\n    public void setRev(String rev);\n\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public String getTarget();\n    /**\n     * Frame to render the resource in. See the target attribute definition in \n     * HTML 4.01.\n     */\n    public void setTarget(String target);\n\n    /**\n     * Advisory content type. See the type attribute definition in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * Advisory content type. See the type attribute definition in HTML 4.01.\n     */\n    public void setType(String type);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLMapElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Client-side image map. See the MAP element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLMapElement extends HTMLElement {\n    /**\n     * The list of areas defined for the image map. \n     */\n    public HTMLCollection getAreas();\n\n    /**\n     * Names the map (for use with <code>usemap</code>). See the name \n     * attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Names the map (for use with <code>usemap</code>). See the name \n     * attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLMenuElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Menu list. See the MENU element definition in HTML 4.01. This element is \n * deprecated in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLMenuElement extends HTMLElement {\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getCompact();\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setCompact(boolean compact);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLMetaElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * This contains generic meta-information about the document. See the META \n * element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLMetaElement extends HTMLElement {\n    /**\n     * Associated information. See the content attribute definition in HTML \n     * 4.01.\n     */\n    public String getContent();\n    /**\n     * Associated information. See the content attribute definition in HTML \n     * 4.01.\n     */\n    public void setContent(String content);\n\n    /**\n     * HTTP response header name [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>]. See the http-equiv attribute definition in \n     * HTML 4.01.\n     */\n    public String getHttpEquiv();\n    /**\n     * HTTP response header name [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>]. See the http-equiv attribute definition in \n     * HTML 4.01.\n     */\n    public void setHttpEquiv(String httpEquiv);\n\n    /**\n     * Meta information name. See the name attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Meta information name. See the name attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Select form of content. See the scheme attribute definition in HTML \n     * 4.01.\n     */\n    public String getScheme();\n    /**\n     * Select form of content. See the scheme attribute definition in HTML \n     * 4.01.\n     */\n    public void setScheme(String scheme);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLModElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Notice of modification to part of a document. See the INS and DEL element \n * definitions in HTML 4.01. \n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLModElement extends HTMLElement {\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a document that describes the reason for the change. \n     * See the cite attribute definition in HTML 4.01.\n     */\n    public String getCite();\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a document that describes the reason for the change. \n     * See the cite attribute definition in HTML 4.01.\n     */\n    public void setCite(String cite);\n\n    /**\n     * The date and time of the change. See the datetime attribute definition \n     * in HTML 4.01.\n     */\n    public String getDateTime();\n    /**\n     * The date and time of the change. See the datetime attribute definition \n     * in HTML 4.01.\n     */\n    public void setDateTime(String dateTime);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLOListElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Ordered list. See the OL element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLOListElement extends HTMLElement {\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getCompact();\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setCompact(boolean compact);\n\n    /**\n     * Starting sequence number. See the start attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public int getStart();\n    /**\n     * Starting sequence number. See the start attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setStart(int start);\n\n    /**\n     * Numbering style. See the type attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * Numbering style. See the type attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setType(String type);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLObjectElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Document;\n\n/**\n * Generic embedded object.In principle, all properties on the object element \n * are read-write but in some environments some properties may be read-only \n * once the underlying object is instantiated. See the OBJECT element \n * definition in [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>].\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLObjectElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * Applet class file. See the <code>code</code> attribute for \n     * HTMLAppletElement. \n     */\n    public String getCode();\n    /**\n     * Applet class file. See the <code>code</code> attribute for \n     * HTMLAppletElement. \n     */\n    public void setCode(String code);\n\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Aligns this object (vertically or horizontally) with respect to its \n     * surrounding text. See the align attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Space-separated list of archives. See the archive attribute definition \n     * in HTML 4.01.\n     */\n    public String getArchive();\n    /**\n     * Space-separated list of archives. See the archive attribute definition \n     * in HTML 4.01.\n     */\n    public void setArchive(String archive);\n\n    /**\n     * Width of border around the object. See the border attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getBorder();\n    /**\n     * Width of border around the object. See the border attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setBorder(String border);\n\n    /**\n     * Base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] for <code>classid</code>, <code>data</code>, and \n     * <code>archive</code> attributes. See the codebase attribute definition\n     *  in HTML 4.01.\n     */\n    public String getCodeBase();\n    /**\n     * Base URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] for <code>classid</code>, <code>data</code>, and \n     * <code>archive</code> attributes. See the codebase attribute definition\n     *  in HTML 4.01.\n     */\n    public void setCodeBase(String codeBase);\n\n    /**\n     * Content type for data downloaded via <code>classid</code> attribute. \n     * See the codetype attribute definition in HTML 4.01.\n     */\n    public String getCodeType();\n    /**\n     * Content type for data downloaded via <code>classid</code> attribute. \n     * See the codetype attribute definition in HTML 4.01.\n     */\n    public void setCodeType(String codeType);\n\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] specifying the location of the object's data. See the data \n     * attribute definition in HTML 4.01.\n     */\n    public String getData();\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] specifying the location of the object's data. See the data \n     * attribute definition in HTML 4.01.\n     */\n    public void setData(String data);\n\n    /**\n     * Declare (for future reference), but do not instantiate, this object. \n     * See the declare attribute definition in HTML 4.01.\n     */\n    public boolean getDeclare();\n    /**\n     * Declare (for future reference), but do not instantiate, this object. \n     * See the declare attribute definition in HTML 4.01.\n     */\n    public void setDeclare(boolean declare);\n\n    /**\n     * Override height. See the height attribute definition in HTML 4.01.\n     */\n    public String getHeight();\n    /**\n     * Override height. See the height attribute definition in HTML 4.01.\n     */\n    public void setHeight(String height);\n\n    /**\n     * Horizontal space, in pixels, to the left and right of this image, \n     * applet, or object. See the hspace attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public int getHspace();\n    /**\n     * Horizontal space, in pixels, to the left and right of this image, \n     * applet, or object. See the hspace attribute definition in HTML 4.01. \n     * This attribute is deprecated in HTML 4.01.\n     */\n    public void setHspace(int hspace);\n\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Message to render while loading the object. See the standby attribute \n     * definition in HTML 4.01.\n     */\n    public String getStandby();\n    /**\n     * Message to render while loading the object. See the standby attribute \n     * definition in HTML 4.01.\n     */\n    public void setStandby(String standby);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * Content type for data downloaded via <code>data</code> attribute. See \n     * the type attribute definition in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * Content type for data downloaded via <code>data</code> attribute. See \n     * the type attribute definition in HTML 4.01.\n     */\n    public void setType(String type);\n\n    /**\n     * Use client-side image map. See the usemap attribute definition in HTML \n     * 4.01.\n     */\n    public String getUseMap();\n    /**\n     * Use client-side image map. See the usemap attribute definition in HTML \n     * 4.01.\n     */\n    public void setUseMap(String useMap);\n\n    /**\n     * Vertical space, in pixels, above and below this image, applet, or \n     * object. See the vspace attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public int getVspace();\n    /**\n     * Vertical space, in pixels, above and below this image, applet, or \n     * object. See the vspace attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setVspace(int vspace);\n\n    /**\n     * Override width. See the width attribute definition in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * Override width. See the width attribute definition in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n    /**\n     * The document this object contains, if there is any and it is available, \n     * or <code>null</code> otherwise.\n     * @since DOM Level 2\n     */\n    public Document getContentDocument();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLOptGroupElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Group options together in logical subdivisions. See the OPTGROUP element \n * definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLOptGroupElement extends HTMLElement {\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getDisabled();\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * Assigns a label to this option group. See the label attribute definition\n     *  in HTML 4.01.\n     */\n    public String getLabel();\n    /**\n     * Assigns a label to this option group. See the label attribute definition\n     *  in HTML 4.01.\n     */\n    public void setLabel(String label);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLOptionElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * A selectable choice. See the OPTION element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLOptionElement extends HTMLElement {\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * Represents the value of the HTML selected attribute. The value of this \n     * attribute does not change if the state of the corresponding form \n     * control, in an interactive user agent, changes. See the selected \n     * attribute definition in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public boolean getDefaultSelected();\n    /**\n     * Represents the value of the HTML selected attribute. The value of this \n     * attribute does not change if the state of the corresponding form \n     * control, in an interactive user agent, changes. See the selected \n     * attribute definition in HTML 4.01.\n     * @version DOM Level 2\n     */\n    public void setDefaultSelected(boolean defaultSelected);\n\n    /**\n     * The text contained within the option element. \n     */\n    public String getText();\n\n    /**\n     * The index of this <code>OPTION</code> in its parent <code>SELECT</code>\n     * , starting from 0.\n     * @version DOM Level 2\n     */\n    public int getIndex();\n\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getDisabled();\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * Option label for use in hierarchical menus. See the label attribute \n     * definition in HTML 4.01.\n     */\n    public String getLabel();\n    /**\n     * Option label for use in hierarchical menus. See the label attribute \n     * definition in HTML 4.01.\n     */\n    public void setLabel(String label);\n\n    /**\n     * Represents the current state of the corresponding form control, in an \n     * interactive user agent. Changing this attribute changes the state of \n     * the form control, but does not change the value of the HTML selected \n     * attribute of the element.\n     */\n    public boolean getSelected();\n    /**\n     * Represents the current state of the corresponding form control, in an \n     * interactive user agent. Changing this attribute changes the state of \n     * the form control, but does not change the value of the HTML selected \n     * attribute of the element.\n     */\n    public void setSelected(boolean selected);\n\n    /**\n     * The current form control value. See the value attribute definition in \n     * HTML 4.01.\n     */\n    public String getValue();\n    /**\n     * The current form control value. See the value attribute definition in \n     * HTML 4.01.\n     */\n    public void setValue(String value);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLOptionsCollection.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.Node;\nimport org.w3c.dom.DOMException;\n\n/**\n *  An <code>HTMLOptionsCollection</code> is a list of nodes representing HTML \n * option element. An individual node may be accessed by either ordinal \n * index or the node's <code>name</code> or <code>id</code> attributes.  \n * Collections in the HTML DOM are assumed to be live meaning that they are \n * automatically updated when the underlying document is changed. \n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n * @since DOM Level 2\n */\npublic interface HTMLOptionsCollection {\n    /**\n     *  This attribute specifies the length or size of the list. \n     */\n    public int getLength();\n    /**\n     *  This attribute specifies the length or size of the list. \n     * @exception DOMException\n     *    NOT_SUPPORTED_ERR: if setting the length is not allowed by the \n     *   implementation. \n     */\n    public void setLength(int length)\n                          throws DOMException;\n\n    /**\n     *  This method retrieves a node specified by ordinal index. Nodes are \n     * numbered in tree order (depth-first traversal order). \n     * @param index The index of the node to be fetched. The index origin is \n     *   0.\n     * @return The <code>Node</code> at the corresponding position upon \n     *   success. A value of <code>null</code> is returned if the index is \n     *   out of range. \n     */\n    public Node item(int index);\n\n    /**\n     * This method retrieves a <code>Node</code> using a name. It first \n     * searches for a <code>Node</code> with a matching <code>id</code> \n     * attribute. If it doesn't find one, it then searches for a \n     * <code>Node</code> with a matching <code>name</code> attribute, but \n     * only on those elements that are allowed a name attribute. This method \n     * is case insensitive in HTML documents and case sensitive in XHTML \n     * documents.\n     * @param name The name of the <code>Node</code> to be fetched.\n     * @return The <code>Node</code> with a <code>name</code> or \n     *   <code>id</code> attribute whose value corresponds to the specified \n     *   string. Upon failure (e.g., no node with this name exists), returns \n     *   <code>null</code>.\n     */\n    public Node namedItem(String name);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLParagraphElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Paragraphs. See the P element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLParagraphElement extends HTMLElement {\n    /**\n     * Horizontal text alignment. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Horizontal text alignment. See the align attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLParamElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Parameters fed to the <code>OBJECT</code> element. See the PARAM element \n * definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLParamElement extends HTMLElement {\n    /**\n     * The name of a run-time parameter. See the name attribute definition in \n     * HTML 4.01.\n     */\n    public String getName();\n    /**\n     * The name of a run-time parameter. See the name attribute definition in \n     * HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Content type for the <code>value</code> attribute when \n     * <code>valuetype</code> has the value \"ref\". See the type attribute \n     * definition in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * Content type for the <code>value</code> attribute when \n     * <code>valuetype</code> has the value \"ref\". See the type attribute \n     * definition in HTML 4.01.\n     */\n    public void setType(String type);\n\n    /**\n     * The value of a run-time parameter. See the value attribute definition \n     * in HTML 4.01.\n     */\n    public String getValue();\n    /**\n     * The value of a run-time parameter. See the value attribute definition \n     * in HTML 4.01.\n     */\n    public void setValue(String value);\n\n    /**\n     * Information about the meaning of the <code>value</code> attribute \n     * value. See the valuetype attribute definition in HTML 4.01.\n     */\n    public String getValueType();\n    /**\n     * Information about the meaning of the <code>value</code> attribute \n     * value. See the valuetype attribute definition in HTML 4.01.\n     */\n    public void setValueType(String valueType);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLPreElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Preformatted text. See the PRE element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLPreElement extends HTMLElement {\n    /**\n     * Fixed width for content. See the width attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public int getWidth();\n    /**\n     * Fixed width for content. See the width attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setWidth(int width);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLQuoteElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * For the <code>Q</code> and <code>BLOCKQUOTE</code> elements. See the Q \n * element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLQuoteElement extends HTMLElement {\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a source document or message. See the cite attribute \n     * definition in HTML 4.01.\n     */\n    public String getCite();\n    /**\n     * A URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating a source document or message. See the cite attribute \n     * definition in HTML 4.01.\n     */\n    public void setCite(String cite);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLScriptElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Script statements. See the SCRIPT element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLScriptElement extends HTMLElement {\n    /**\n     * The script content of the element. \n     */\n    public String getText();\n    /**\n     * The script content of the element. \n     */\n    public void setText(String text);\n\n    /**\n     * Reserved for future use. \n     */\n    public String getHtmlFor();\n    /**\n     * Reserved for future use. \n     */\n    public void setHtmlFor(String htmlFor);\n\n    /**\n     * Reserved for future use. \n     */\n    public String getEvent();\n    /**\n     * Reserved for future use. \n     */\n    public void setEvent(String event);\n\n    /**\n     * The character encoding of the linked resource. See the charset \n     * attribute definition in HTML 4.01.\n     */\n    public String getCharset();\n    /**\n     * The character encoding of the linked resource. See the charset \n     * attribute definition in HTML 4.01.\n     */\n    public void setCharset(String charset);\n\n    /**\n     * Indicates that the user agent can defer processing of the script. See \n     * the defer attribute definition in HTML 4.01.\n     */\n    public boolean getDefer();\n    /**\n     * Indicates that the user agent can defer processing of the script. See \n     * the defer attribute definition in HTML 4.01.\n     */\n    public void setDefer(boolean defer);\n\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating an external script. See the src attribute definition \n     * in HTML 4.01.\n     */\n    public String getSrc();\n    /**\n     * URI [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>] designating an external script. See the src attribute definition \n     * in HTML 4.01.\n     */\n    public void setSrc(String src);\n\n    /**\n     * The content type of the script language. See the type attribute \n     * definition in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * The content type of the script language. See the type attribute \n     * definition in HTML 4.01.\n     */\n    public void setType(String type);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLSelectElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.DOMException;\n\n/**\n * The select element allows the selection of an option. The contained options \n * can be directly accessed through the select element as a collection. See \n * the SELECT element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLSelectElement extends HTMLElement {\n    /**\n     * The type of this form control. This is the string \"select-multiple\" \n     * when the multiple attribute is <code>true</code> and the string \n     * \"select-one\" when <code>false</code>.\n     */\n    public String getType();\n\n    /**\n     * The ordinal index of the selected option, starting from 0. The value -1 \n     * is returned if no element is selected. If multiple options are \n     * selected, the index of the first selected option is returned. \n     */\n    public int getSelectedIndex();\n    /**\n     * The ordinal index of the selected option, starting from 0. The value -1 \n     * is returned if no element is selected. If multiple options are \n     * selected, the index of the first selected option is returned. \n     */\n    public void setSelectedIndex(int selectedIndex);\n\n    /**\n     *  The current form control value (i.e. the value of the currently \n     * selected option), if multiple options are selected this is the value \n     * of the first selected option. \n     */\n    public String getValue();\n    /**\n     *  The current form control value (i.e. the value of the currently \n     * selected option), if multiple options are selected this is the value \n     * of the first selected option. \n     */\n    public void setValue(String value);\n\n    /**\n     *  The number of options in this <code>SELECT</code>. \n     * @version DOM Level 2\n     */\n    public int getLength();\n    /**\n     *  The number of options in this <code>SELECT</code>. \n     * @exception DOMException\n     *    NOT_SUPPORTED_ERR: if setting the length is not allowed by the \n     *   implementation. \n     * @version DOM Level 2\n     */\n    public void setLength(int length)\n                      throws DOMException;\n\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * The collection of <code>OPTION</code> elements contained by this \n     * element. \n     * @version DOM Level 2\n     */\n    public HTMLOptionsCollection getOptions();\n\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getDisabled();\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * If true, multiple <code>OPTION</code> elements may be selected in this \n     * <code>SELECT</code>. See the multiple attribute definition in HTML \n     * 4.01.\n     */\n    public boolean getMultiple();\n    /**\n     * If true, multiple <code>OPTION</code> elements may be selected in this \n     * <code>SELECT</code>. See the multiple attribute definition in HTML \n     * 4.01.\n     */\n    public void setMultiple(boolean multiple);\n\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * Number of visible rows. See the size attribute definition in HTML 4.01.\n     */\n    public int getSize();\n    /**\n     * Number of visible rows. See the size attribute definition in HTML 4.01.\n     */\n    public void setSize(int size);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * Add a new element to the collection of <code>OPTION</code> elements for \n     * this <code>SELECT</code>. This method is the equivalent of the \n     * <code>appendChild</code> method of the <code>Node</code> interface if \n     * the <code>before</code> parameter is <code>null</code>. It is \n     * equivalent to the <code>insertBefore</code> method on the parent of \n     * <code>before</code> in all other cases. This method may have no \n     * effect if the new element is not an <code>OPTION</code> or an \n     * <code>OPTGROUP</code>.\n     * @param element The element to add.\n     * @param before The element to insert before, or <code>null</code> for \n     *   the tail of the list.\n     * @exception DOMException\n     *   NOT_FOUND_ERR: Raised if <code>before</code> is not a descendant of \n     *   the <code>SELECT</code> element. \n     */\n    public void add(HTMLElement element, \n                    HTMLElement before)\n                    throws DOMException;\n\n    /**\n     * Remove an element from the collection of <code>OPTION</code> elements \n     * for this <code>SELECT</code>. Does nothing if no element has the \n     * given index.\n     * @param index The index of the item to remove, starting from 0.\n     */\n    public void remove(int index);\n\n    /**\n     * Removes keyboard focus from this element.\n     */\n    public void blur();\n\n    /**\n     * Gives keyboard focus to this element.\n     */\n    public void focus();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLStyleElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n *  Style information. See the STYLE element definition in HTML 4.01, the CSS \n * module [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>DOM Level 2 Style Sheets and CSS</a>] and the <code>LinkStyle</code> interface in the StyleSheets \n * module [<a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>DOM Level 2 Style Sheets and CSS</a>]. \n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLStyleElement extends HTMLElement {\n    /**\n     * Enables/disables the style sheet. \n     */\n    public boolean getDisabled();\n    /**\n     * Enables/disables the style sheet. \n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * Designed for use with one or more target media. See the media attribute \n     * definition in HTML 4.01.\n     */\n    public String getMedia();\n    /**\n     * Designed for use with one or more target media. See the media attribute \n     * definition in HTML 4.01.\n     */\n    public void setMedia(String media);\n\n    /**\n     * The content type of the style sheet language. See the type attribute \n     * definition in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * The content type of the style sheet language. See the type attribute \n     * definition in HTML 4.01.\n     */\n    public void setType(String type);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTableCaptionElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Table caption See the CAPTION element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTableCaptionElement extends HTMLElement {\n    /**\n     * Caption alignment with respect to the table. See the align attribute \n     * definition in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Caption alignment with respect to the table. See the align attribute \n     * definition in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTableCellElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * The object used to represent the <code>TH</code> and <code>TD</code> \n * elements. See the TD element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTableCellElement extends HTMLElement {\n    /**\n     * The index of this cell in the row, starting from 0. This index is in \n     * document tree order and not display order.\n     */\n    public int getCellIndex();\n\n    /**\n     * Abbreviation for header cells. See the abbr attribute definition in \n     * HTML 4.01.\n     */\n    public String getAbbr();\n    /**\n     * Abbreviation for header cells. See the abbr attribute definition in \n     * HTML 4.01.\n     */\n    public void setAbbr(String abbr);\n\n    /**\n     * Horizontal alignment of data in cell. See the align attribute definition\n     *  in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Horizontal alignment of data in cell. See the align attribute definition\n     *  in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Names group of related headers. See the axis attribute definition in \n     * HTML 4.01.\n     */\n    public String getAxis();\n    /**\n     * Names group of related headers. See the axis attribute definition in \n     * HTML 4.01.\n     */\n    public void setAxis(String axis);\n\n    /**\n     * Cell background color. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getBgColor();\n    /**\n     * Cell background color. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setBgColor(String bgColor);\n\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public String getCh();\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public void setCh(String ch);\n\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public String getChOff();\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public void setChOff(String chOff);\n\n    /**\n     * Number of columns spanned by cell. See the colspan attribute definition \n     * in HTML 4.01.\n     */\n    public int getColSpan();\n    /**\n     * Number of columns spanned by cell. See the colspan attribute definition \n     * in HTML 4.01.\n     */\n    public void setColSpan(int colSpan);\n\n    /**\n     * List of <code>id</code> attribute values for header cells. See the \n     * headers attribute definition in HTML 4.01.\n     */\n    public String getHeaders();\n    /**\n     * List of <code>id</code> attribute values for header cells. See the \n     * headers attribute definition in HTML 4.01.\n     */\n    public void setHeaders(String headers);\n\n    /**\n     * Cell height. See the height attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getHeight();\n    /**\n     * Cell height. See the height attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setHeight(String height);\n\n    /**\n     * Suppress word wrapping. See the nowrap attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getNoWrap();\n    /**\n     * Suppress word wrapping. See the nowrap attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setNoWrap(boolean noWrap);\n\n    /**\n     * Number of rows spanned by cell. See the rowspan attribute definition in \n     * HTML 4.01.\n     */\n    public int getRowSpan();\n    /**\n     * Number of rows spanned by cell. See the rowspan attribute definition in \n     * HTML 4.01.\n     */\n    public void setRowSpan(int rowSpan);\n\n    /**\n     * Scope covered by header cells. See the scope attribute definition in \n     * HTML 4.01.\n     */\n    public String getScope();\n    /**\n     * Scope covered by header cells. See the scope attribute definition in \n     * HTML 4.01.\n     */\n    public void setScope(String scope);\n\n    /**\n     * Vertical alignment of data in cell. See the valign attribute definition \n     * in HTML 4.01.\n     */\n    public String getVAlign();\n    /**\n     * Vertical alignment of data in cell. See the valign attribute definition \n     * in HTML 4.01.\n     */\n    public void setVAlign(String vAlign);\n\n    /**\n     * Cell width. See the width attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * Cell width. See the width attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTableColElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Regroups the <code>COL</code> and <code>COLGROUP</code> elements. See the \n * COL element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTableColElement extends HTMLElement {\n    /**\n     * Horizontal alignment of cell data in column. See the align attribute \n     * definition in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Horizontal alignment of cell data in column. See the align attribute \n     * definition in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public String getCh();\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public void setCh(String ch);\n\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public String getChOff();\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public void setChOff(String chOff);\n\n    /**\n     * Indicates the number of columns in a group or affected by a grouping. \n     * See the span attribute definition in HTML 4.01.\n     */\n    public int getSpan();\n    /**\n     * Indicates the number of columns in a group or affected by a grouping. \n     * See the span attribute definition in HTML 4.01.\n     */\n    public void setSpan(int span);\n\n    /**\n     * Vertical alignment of cell data in column. See the valign attribute \n     * definition in HTML 4.01.\n     */\n    public String getVAlign();\n    /**\n     * Vertical alignment of cell data in column. See the valign attribute \n     * definition in HTML 4.01.\n     */\n    public void setVAlign(String vAlign);\n\n    /**\n     * Default column width. See the width attribute definition in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * Default column width. See the width attribute definition in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTableElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.DOMException;\n\n/**\n * The create* and delete* methods on the table allow authors to construct and \n * modify tables. [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>] specifies that only one of each of the \n * <code>CAPTION</code>, <code>THEAD</code>, and <code>TFOOT</code> elements \n * may exist in a table. Therefore, if one exists, and the createTHead() or \n * createTFoot() method is called, the method returns the existing THead or \n * TFoot element. See the TABLE element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTableElement extends HTMLElement {\n    /**\n     * Returns the table's <code>CAPTION</code>, or void if none exists. \n     * @version DOM Level 2\n     */\n    public HTMLTableCaptionElement getCaption();\n    /**\n     * Returns the table's <code>CAPTION</code>, or void if none exists. \n     * @exception DOMException\n     *    HIERARCHY_REQUEST_ERR: if the element is not a <code>CAPTION</code>. \n     * @version DOM Level 2\n     */\n    public void setCaption(HTMLTableCaptionElement caption)\n                          throws DOMException;\n\n    /**\n     * Returns the table's <code>THEAD</code>, or <code>null</code> if none \n     * exists. \n     * @version DOM Level 2\n     */\n    public HTMLTableSectionElement getTHead();\n    /**\n     * Returns the table's <code>THEAD</code>, or <code>null</code> if none \n     * exists. \n     * @exception DOMException\n     *    HIERARCHY_REQUEST_ERR: if the element is not a <code>THEAD</code>. \n     * @version DOM Level 2\n     */\n    public void setTHead(HTMLTableSectionElement tHead)\n                          throws DOMException;\n\n    /**\n     * Returns the table's <code>TFOOT</code>, or <code>null</code> if none \n     * exists. \n     * @version DOM Level 2\n     */\n    public HTMLTableSectionElement getTFoot();\n    /**\n     * Returns the table's <code>TFOOT</code>, or <code>null</code> if none \n     * exists. \n     * @exception DOMException\n     *    HIERARCHY_REQUEST_ERR: if the element is not a <code>TFOOT</code>. \n     * @version DOM Level 2\n     */\n    public void setTFoot(HTMLTableSectionElement tFoot)\n                          throws DOMException;\n\n    /**\n     * Returns a collection of all the rows in the table, including all in \n     * <code>THEAD</code>, <code>TFOOT</code>, all <code>TBODY</code> \n     * elements. \n     */\n    public HTMLCollection getRows();\n\n    /**\n     * Returns a collection of the table bodies (including implicit ones).\n     */\n    public HTMLCollection getTBodies();\n\n    /**\n     * Specifies the table's position with respect to the rest of the \n     * document. See the align attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Specifies the table's position with respect to the rest of the \n     * document. See the align attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Cell background color. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getBgColor();\n    /**\n     * Cell background color. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setBgColor(String bgColor);\n\n    /**\n     * The width of the border around the table. See the border attribute \n     * definition in HTML 4.01.\n     */\n    public String getBorder();\n    /**\n     * The width of the border around the table. See the border attribute \n     * definition in HTML 4.01.\n     */\n    public void setBorder(String border);\n\n    /**\n     * Specifies the horizontal and vertical space between cell content and \n     * cell borders. See the cellpadding attribute definition in HTML 4.01.\n     */\n    public String getCellPadding();\n    /**\n     * Specifies the horizontal and vertical space between cell content and \n     * cell borders. See the cellpadding attribute definition in HTML 4.01.\n     */\n    public void setCellPadding(String cellPadding);\n\n    /**\n     * Specifies the horizontal and vertical separation between cells. See the \n     * cellspacing attribute definition in HTML 4.01.\n     */\n    public String getCellSpacing();\n    /**\n     * Specifies the horizontal and vertical separation between cells. See the \n     * cellspacing attribute definition in HTML 4.01.\n     */\n    public void setCellSpacing(String cellSpacing);\n\n    /**\n     * Specifies which external table borders to render. See the frame \n     * attribute definition in HTML 4.01.\n     */\n    public String getFrame();\n    /**\n     * Specifies which external table borders to render. See the frame \n     * attribute definition in HTML 4.01.\n     */\n    public void setFrame(String frame);\n\n    /**\n     * Specifies which internal table borders to render. See the rules \n     * attribute definition in HTML 4.01.\n     */\n    public String getRules();\n    /**\n     * Specifies which internal table borders to render. See the rules \n     * attribute definition in HTML 4.01.\n     */\n    public void setRules(String rules);\n\n    /**\n     * Description about the purpose or structure of a table. See the summary \n     * attribute definition in HTML 4.01.\n     */\n    public String getSummary();\n    /**\n     * Description about the purpose or structure of a table. See the summary \n     * attribute definition in HTML 4.01.\n     */\n    public void setSummary(String summary);\n\n    /**\n     * Specifies the desired table width. See the width attribute definition \n     * in HTML 4.01.\n     */\n    public String getWidth();\n    /**\n     * Specifies the desired table width. See the width attribute definition \n     * in HTML 4.01.\n     */\n    public void setWidth(String width);\n\n    /**\n     * Create a table header row or return an existing one.\n     * @return A new table header element (<code>THEAD</code>).\n     */\n    public HTMLElement createTHead();\n\n    /**\n     * Delete the header from the table, if one exists.\n     */\n    public void deleteTHead();\n\n    /**\n     * Create a table footer row or return an existing one.\n     * @return A footer element (<code>TFOOT</code>).\n     */\n    public HTMLElement createTFoot();\n\n    /**\n     * Delete the footer from the table, if one exists.\n     */\n    public void deleteTFoot();\n\n    /**\n     * Create a new table caption object or return an existing one.\n     * @return A <code>CAPTION</code> element.\n     */\n    public HTMLElement createCaption();\n\n    /**\n     * Delete the table caption, if one exists.\n     */\n    public void deleteCaption();\n\n    /**\n     * Insert a new empty row in the table. The new row is inserted \n     * immediately before and in the same section as the current \n     * <code>index</code>th row in the table. If <code>index</code> is -1 or \n     * equal to the number of rows, the new row is appended. In addition, \n     * when the table is empty the row is inserted into a <code>TBODY</code> \n     * which is created and inserted into the table.A table row cannot be \n     * empty according to [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>].\n     * @param index The row number where to insert a new row. This index \n     *   starts from 0 and is relative to the logical order (not document \n     *   order) of all the rows contained inside the table.\n     * @return The newly created row.\n     * @exception DOMException\n     *   INDEX_SIZE_ERR: Raised if the specified index is greater than the \n     *   number of rows or if the index is a negative number other than -1.\n     * @version DOM Level 2\n     */\n    public HTMLElement insertRow(int index)\n                                 throws DOMException;\n\n    /**\n     * Delete a table row.\n     * @param index The index of the row to be deleted. This index starts \n     *   from 0 and is relative to the logical order (not document order) of \n     *   all the rows contained inside the table. If the index is -1 the \n     *   last row in the table is deleted.\n     * @exception DOMException\n     *   INDEX_SIZE_ERR: Raised if the specified index is greater than or \n     *   equal to the number of rows or if the index is a negative number \n     *   other than -1.\n     * @version DOM Level 2\n     */\n    public void deleteRow(int index)\n                          throws DOMException;\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTableRowElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.DOMException;\n\n/**\n * A row in a table. See the TR element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTableRowElement extends HTMLElement {\n    /**\n     * This is in logical order and not in document order. The \n     * <code>rowIndex</code> does take into account sections (\n     * <code>THEAD</code>, <code>TFOOT</code>, or <code>TBODY</code>) within \n     * the table, placing <code>THEAD</code> rows first in the index, \n     * followed by <code>TBODY</code> rows, followed by <code>TFOOT</code> \n     * rows.\n     * @version DOM Level 2\n     */\n    public int getRowIndex();\n\n    /**\n     * The index of this row, relative to the current section (\n     * <code>THEAD</code>, <code>TFOOT</code>, or <code>TBODY</code>), \n     * starting from 0.\n     * @version DOM Level 2\n     */\n    public int getSectionRowIndex();\n\n    /**\n     * The collection of cells in this row. \n     * @version DOM Level 2\n     */\n    public HTMLCollection getCells();\n\n    /**\n     * Horizontal alignment of data within cells of this row. See the align \n     * attribute definition in HTML 4.01.\n     */\n    public String getAlign();\n    /**\n     * Horizontal alignment of data within cells of this row. See the align \n     * attribute definition in HTML 4.01.\n     */\n    public void setAlign(String align);\n\n    /**\n     * Background color for rows. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public String getBgColor();\n    /**\n     * Background color for rows. See the bgcolor attribute definition in HTML \n     * 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setBgColor(String bgColor);\n\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public String getCh();\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public void setCh(String ch);\n\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public String getChOff();\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public void setChOff(String chOff);\n\n    /**\n     * Vertical alignment of data within cells of this row. See the valign \n     * attribute definition in HTML 4.01.\n     */\n    public String getVAlign();\n    /**\n     * Vertical alignment of data within cells of this row. See the valign \n     * attribute definition in HTML 4.01.\n     */\n    public void setVAlign(String vAlign);\n\n    /**\n     * Insert an empty <code>TD</code> cell into this row. If \n     * <code>index</code> is -1 or equal to the number of cells, the new \n     * cell is appended.\n     * @param index The place to insert the cell, starting from 0.\n     * @return The newly created cell.\n     * @exception DOMException\n     *   INDEX_SIZE_ERR: Raised if the specified <code>index</code> is greater \n     *   than the number of cells or if the index is a negative number other \n     *   than -1.\n     * @version DOM Level 2\n     */\n    public HTMLElement insertCell(int index)\n                                  throws DOMException;\n\n    /**\n     * Delete a cell from the current row.\n     * @param index The index of the cell to delete, starting from 0. If the \n     *   index is -1 the last cell in the row is deleted.\n     * @exception DOMException\n     *   INDEX_SIZE_ERR: Raised if the specified <code>index</code> is greater \n     *   than or equal to the number of cells or if the index is a negative \n     *   number other than -1.\n     * @version DOM Level 2\n     */\n    public void deleteCell(int index)\n                           throws DOMException;\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTableSectionElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\nimport org.w3c.dom.DOMException;\n\n/**\n * The <code>THEAD</code>, <code>TFOOT</code>, and <code>TBODY</code> \n * elements. \n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTableSectionElement extends HTMLElement {\n    /**\n     * Horizontal alignment of data in cells. See the <code>align</code> \n     * attribute for HTMLTheadElement for details. \n     */\n    public String getAlign();\n    /**\n     * Horizontal alignment of data in cells. See the <code>align</code> \n     * attribute for HTMLTheadElement for details. \n     */\n    public void setAlign(String align);\n\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public String getCh();\n    /**\n     * Alignment character for cells in a column. See the char attribute \n     * definition in HTML 4.01.\n     */\n    public void setCh(String ch);\n\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public String getChOff();\n    /**\n     * Offset of alignment character. See the charoff attribute definition in \n     * HTML 4.01.\n     */\n    public void setChOff(String chOff);\n\n    /**\n     * Vertical alignment of data in cells. See the <code>valign</code> \n     * attribute for HTMLTheadElement for details. \n     */\n    public String getVAlign();\n    /**\n     * Vertical alignment of data in cells. See the <code>valign</code> \n     * attribute for HTMLTheadElement for details. \n     */\n    public void setVAlign(String vAlign);\n\n    /**\n     * The collection of rows in this table section. \n     */\n    public HTMLCollection getRows();\n\n    /**\n     * Insert a row into this section. The new row is inserted immediately \n     * before the current <code>index</code>th row in this section. If \n     * <code>index</code> is -1 or equal to the number of rows in this \n     * section, the new row is appended.\n     * @param index The row number where to insert a new row. This index \n     *   starts from 0 and is relative only to the rows contained inside \n     *   this section, not all the rows in the table.\n     * @return The newly created row.\n     * @exception DOMException\n     *   INDEX_SIZE_ERR: Raised if the specified index is greater than the \n     *   number of rows of if the index is a negative number other than -1.\n     * @version DOM Level 2\n     */\n    public HTMLElement insertRow(int index)\n                                 throws DOMException;\n\n    /**\n     * Delete a row from this section.\n     * @param index The index of the row to be deleted, or -1 to delete the \n     *   last row. This index starts from 0 and is relative only to the rows \n     *   contained inside this section, not all the rows in the table.\n     * @exception DOMException\n     *   INDEX_SIZE_ERR: Raised if the specified index is greater than or \n     *   equal to the number of rows or if the index is a negative number \n     *   other than -1.\n     * @version DOM Level 2\n     */\n    public void deleteRow(int index)\n                          throws DOMException;\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTextAreaElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Multi-line text field. See the TEXTAREA element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTextAreaElement extends HTMLElement {\n    /**\n     * Represents the contents of the element. The value of this attribute \n     * does not change if the contents of the corresponding form control, in \n     * an interactive user agent, changes.\n     * @version DOM Level 2\n     */\n    public String getDefaultValue();\n    /**\n     * Represents the contents of the element. The value of this attribute \n     * does not change if the contents of the corresponding form control, in \n     * an interactive user agent, changes.\n     * @version DOM Level 2\n     */\n    public void setDefaultValue(String defaultValue);\n\n    /**\n     * Returns the <code>FORM</code> element containing this control. Returns \n     * <code>null</code> if this control is not within the context of a \n     * form. \n     */\n    public HTMLFormElement getForm();\n\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public String getAccessKey();\n    /**\n     * A single character access key to give access to the form control. See \n     * the accesskey attribute definition in HTML 4.01.\n     */\n    public void setAccessKey(String accessKey);\n\n    /**\n     * Width of control (in characters). See the cols attribute definition in \n     * HTML 4.01.\n     */\n    public int getCols();\n    /**\n     * Width of control (in characters). See the cols attribute definition in \n     * HTML 4.01.\n     */\n    public void setCols(int cols);\n\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public boolean getDisabled();\n    /**\n     * The control is unavailable in this context. See the disabled attribute \n     * definition in HTML 4.01.\n     */\n    public void setDisabled(boolean disabled);\n\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public String getName();\n    /**\n     * Form control or object name when submitted with a form. See the name \n     * attribute definition in HTML 4.01.\n     */\n    public void setName(String name);\n\n    /**\n     * This control is read-only. See the readonly attribute definition in \n     * HTML 4.01.\n     */\n    public boolean getReadOnly();\n    /**\n     * This control is read-only. See the readonly attribute definition in \n     * HTML 4.01.\n     */\n    public void setReadOnly(boolean readOnly);\n\n    /**\n     * Number of text rows. See the rows attribute definition in HTML 4.01.\n     */\n    public int getRows();\n    /**\n     * Number of text rows. See the rows attribute definition in HTML 4.01.\n     */\n    public void setRows(int rows);\n\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public int getTabIndex();\n    /**\n     * Index that represents the element's position in the tabbing order. See \n     * the tabindex attribute definition in HTML 4.01.\n     */\n    public void setTabIndex(int tabIndex);\n\n    /**\n     * The type of this form control. This the string \"textarea\".\n     */\n    public String getType();\n\n    /**\n     * Represents the current contents of the corresponding form control, in \n     * an interactive user agent. Changing this attribute changes the \n     * contents of the form control, but does not change the contents of the \n     * element. If the entirety of the data can not fit into a single \n     * <code>DOMString</code>, the implementation may truncate the data.\n     */\n    public String getValue();\n    /**\n     * Represents the current contents of the corresponding form control, in \n     * an interactive user agent. Changing this attribute changes the \n     * contents of the form control, but does not change the contents of the \n     * element. If the entirety of the data can not fit into a single \n     * <code>DOMString</code>, the implementation may truncate the data.\n     */\n    public void setValue(String value);\n\n    /**\n     * Removes keyboard focus from this element.\n     */\n    public void blur();\n\n    /**\n     * Gives keyboard focus to this element.\n     */\n    public void focus();\n\n    /**\n     * Select the contents of the <code>TEXTAREA</code>.\n     */\n    public void select();\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLTitleElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * The document title. See the TITLE element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLTitleElement extends HTMLElement {\n    /**\n     * The specified title as a string. \n     */\n    public String getText();\n    /**\n     * The specified title as a string. \n     */\n    public void setText(String text);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.html/src/org/w3c/dom/html2/HTMLUListElement.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage org.w3c.dom.html2;\n\n/**\n * Unordered list. See the UL element definition in HTML 4.01.\n * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.\n */\npublic interface HTMLUListElement extends HTMLElement {\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public boolean getCompact();\n    /**\n     * Reduce spacing between list items. See the compact attribute definition \n     * in HTML 4.01. This attribute is deprecated in HTML 4.01.\n     */\n    public void setCompact(boolean compact);\n\n    /**\n     * Bullet style. See the type attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public String getType();\n    /**\n     * Bullet style. See the type attribute definition in HTML 4.01. This \n     * attribute is deprecated in HTML 4.01.\n     */\n    public void setType(String type);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.http.proxy</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/.settings/org.eclipse.pde.core.prefs",
    "content": "#Sun Aug 22 19:14:51 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Proxy\nBundle-SymbolicName: com.subgraph.vega.http.proxy\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nImport-Package: com.subgraph.vega.api.analysis,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.http.proxy,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.conditions,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.scope,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.util,\n com.subgraph.vega.http.requests.custom,\n org.apache.commons.codec;version=\"1.4.0\",\n org.apache.commons.codec.binary;version=\"1.4.0\",\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client,\n org.apache.http.client.methods,\n org.apache.http.client.utils;version=\"4.2.1\",\n org.apache.http.entity;version=\"4.0.0\",\n org.apache.http.impl;version=\"4.0.0\",\n org.apache.http.impl.client;version=\"4.2.1\",\n org.apache.http.impl.io;version=\"4.0.0\",\n org.apache.http.io;version=\"4.0.0\",\n org.apache.http.message;version=\"4.0.0\",\n org.apache.http.params;version=\"4.0.0\",\n org.apache.http.protocol;version=\"4.0.0\",\n org.apache.http.util;version=\"4.0.0\"\nService-Component: OSGI-INF/proxy-service.xml\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/OSGI-INF/proxy-service.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega-proxy\">\n   <implementation class=\"com.subgraph.vega.internal.http.proxy.HttpProxyService\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.http.proxy.IHttpProxyService\"/>\n   </service>\n   <reference bind=\"setModel\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.model.IModel\" name=\"IModel\" policy=\"static\" unbind=\"unsetModel\"/>\n   <reference bind=\"setRequestEngineFactory\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory\" name=\"IHttpRequestEngineFactory\" policy=\"static\" unbind=\"unsetRequestEngineFactory\"/>\n   <reference bind=\"setModuleRepository\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry\" name=\"IScannerModuleRegistry\" policy=\"static\" unbind=\"unsetModuleRepository\"/>\n   <reference bind=\"setContentAnalyzerFactory\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.analysis.IContentAnalyzerFactory\" name=\"IContentAnalyzerFactory\" policy=\"static\" unbind=\"unsetContentAnalyzerFactory\"/>\n   <reference bind=\"setPathFinder\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.paths.IPathFinder\" name=\"IPathFinder\" policy=\"static\" unbind=\"unsetPathFinder\"/>\n   <reference bind=\"setScanner\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.scanner.IScanner\" name=\"IScanner\" policy=\"static\" unbind=\"unsetScanner\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ConnectionTask.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.ConnectionClosedException;\nimport org.apache.http.HttpException;\nimport org.apache.http.protocol.BasicHttpContext;\nimport org.apache.http.protocol.HttpContext;\n\npublic class ConnectionTask implements Runnable {\n\tprivate final Logger logger = Logger.getLogger(\"proxy\");\n\n\tprivate final VegaHttpService httpService;\n\tprivate final VegaHttpServerConnection connection;\n\tprivate final HttpProxyListener proxy;\n\n\tConnectionTask(VegaHttpService httpService, VegaHttpServerConnection connection, HttpProxyListener proxy) {\n\t\tthis.httpService = httpService;\n\t\tthis.connection = connection;\n\t\tthis.proxy = proxy;\n\t}\n\n\t/**\n\t * Shutdown the connection by forcing it to close. This will break the connection out from any blocking operations\n\t * involving the socket.\n\t */\n\tpublic synchronized void shutdown() {\n\t\ttry {\n\t\t\tconnection.shutdown();\n\t\t} catch (IOException e) {\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void run() {\n\t\ttry {\n\t\t\tprocessingLoop();\n\t\t} catch (ConnectionClosedException e) {\n\t\t\tlogger.info(\"Client closed connection to proxy\");\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.INFO, \"IOException processing client request in proxy\", e);\n\t\t} catch (HttpException e) {\n\t\t\tlogger.log(Level.WARNING, \"HTTP protocol error processing client request in proxy\", e);\n\t\t} catch (Exception e) {\n\t\t\tlogger.log(Level.WARNING, \"Unexpected exception processing client request in proxy\", e);\n\t\t} finally {\n\t\t\tproxy.notifyClose(this);\n\t\t\tif (connection.isOpen()) {\n\t\t\t\ttry {\n\t\t\t\t\tconnection.shutdown();\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void processingLoop() throws IOException, HttpException {\n\t\twhile(!Thread.interrupted() && connection.isOpen()) {\n\t\t\tHttpContext ctx = new BasicHttpContext();\n\t\t\thttpService.handleRequest(connection, ctx);\n\t\t\tprocessRequestContext(ctx);\n\t\t}\n\t}\n\n\tprivate void processRequestContext(HttpContext context) throws IOException {\n\t\tfinal ProxyTransaction transaction = (ProxyTransaction) context.getAttribute(HttpProxyListener.PROXY_HTTP_TRANSACTION);\n\t\tif(transaction != null) {\n\t\t\tproxy.completeRequest(transaction);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/HttpInterceptor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.HttpResponse;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.proxy.HttpInterceptorLevel;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptorEventHandler;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction.TransactionDirection;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.conditions.ConditionSetChanged;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\n\nimport com.subgraph.vega.internal.http.proxy.ProxyTransaction;\n\npublic class HttpInterceptor implements IHttpInterceptor {\n\tprivate static final String propertyInterceptorLevelRequest = \"vega.preferences.proxy.interceptor.level.request\"; \n\tprivate static final String propertyInterceptorLevelResponse = \"vega.preferences.proxy.interceptor.level.response\"; \n\tprivate final Object interceptorLock = new Object(); /**< Lock for contents of object */\n\tprivate final List<IHttpInterceptorEventHandler> eventHandlerList;\n\tprivate HttpInterceptorLevel interceptorLevelRequest = HttpInterceptorLevel.DISABLED;\n\tprivate HttpInterceptorLevel interceptorLevelResponse = HttpInterceptorLevel.DISABLED; \n\tprivate IHttpConditionSet breakpointSetRequest; \n\tprivate IHttpConditionSet breakpointSetResponse; \n\tprivate final ArrayList<ProxyTransaction> transactionQueue = new ArrayList<ProxyTransaction>(); /**< Queue of intercepted transactions pending processing */\n\tprivate IWorkspace currentWorkspace;\n\tprivate boolean isEnabled = true;\n\t\n\tHttpInterceptor(IModel model) {\n\t\teventHandlerList = new ArrayList<IHttpInterceptorEventHandler>();\n\t\tcurrentWorkspace = model.addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if(event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tloadInterceptorLevelRequest();\n\t\tloadInterceptorLevelResponse();\n\t\tbreakpointSetRequest = createConditionSet(model, true);\n\t\tbreakpointSetResponse = createConditionSet(model, false);\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tcurrentWorkspace = event.getWorkspace();\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tcurrentWorkspace = null;\n\t}\n\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tcurrentWorkspace = event.getWorkspace();\n\t\tloadInterceptorLevelRequest();\t\t\n\t\tloadInterceptorLevelResponse();\n\t}\n\n\tprivate void loadInterceptorLevelRequest() {\n\t\tinterceptorLevelRequest = HttpInterceptorLevel.fromValue(currentWorkspace.getIntegerProperty(propertyInterceptorLevelRequest));\n\t\tif (interceptorLevelRequest == null) {\n\t\t\tinterceptorLevelRequest = HttpInterceptorLevel.DISABLED;\n\t\t}\n\t}\n\n\tprivate void loadInterceptorLevelResponse() {\n\t\tinterceptorLevelResponse = HttpInterceptorLevel.fromValue(currentWorkspace.getIntegerProperty(propertyInterceptorLevelResponse));\n\t\tif (interceptorLevelResponse == null) {\n\t\t\tinterceptorLevelResponse = HttpInterceptorLevel.DISABLED;\n\t\t}\n\t}\n\t\n\tprivate IHttpConditionSet createConditionSet(IModel model, boolean isRequestSet) {\n\t\tfinal String name = (isRequestSet) ? (IHttpConditionManager.CONDITION_SET_BREAKPOINTS_REQUEST) : (IHttpConditionManager.CONDITION_SET_BREAKPOINTS_RESPONSE);\n\t\treturn model.addConditionSetTracker(name, createConditionSetChangedHandler(isRequestSet));\n\t}\n\n\tprivate IEventHandler createConditionSetChangedHandler(final boolean isRequestSet) {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof ConditionSetChanged) \n\t\t\t\t\tonConditionSetChanged((ConditionSetChanged) event, isRequestSet);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void onConditionSetChanged(ConditionSetChanged event, boolean isRequestSet) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tfinal TransactionDirection direction;\n\t\t\tif(isRequestSet) {\n\t\t\t\tbreakpointSetRequest = event.getConditionSet();\n\t\t\t\tdirection = TransactionDirection.DIRECTION_REQUEST;\n\t\t\t} else {\n\t\t\t\tbreakpointSetResponse = event.getConditionSet();\n\t\t\t\tdirection = TransactionDirection.DIRECTION_RESPONSE;\n\t\t\t}\n\t\t\treleaseOnChange(direction);\n\t\t}\n\t}\n\n\tprivate boolean intercept(ProxyTransaction transaction) {\n\t\tif (transaction.hasResponse() == false) \n\t\t\treturn interceptByLevelAndBreakpointSet(transaction, interceptorLevelRequest, breakpointSetRequest);\n\t\telse\n\t\t\treturn interceptByLevelAndBreakpointSet(transaction, interceptorLevelResponse, breakpointSetResponse);\t\t\t\t\n\t}\n\t\n\tprivate boolean interceptByLevelAndBreakpointSet(ProxyTransaction transaction, HttpInterceptorLevel level, IHttpConditionSet breakpointSet) {\n\t\tswitch(level) {\n\t\tcase ENABLED_ALL:\n\t\t\treturn true;\n\t\tcase DISABLED:\n\t\t\treturn false;\n\t\tcase ENABLED_BREAKPOINTS:\n\t\t\treturn interceptOnBreakpointSet(breakpointSet, transaction);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate boolean interceptOnBreakpointSet(IHttpConditionSet breakpointSet, ProxyTransaction transaction) {\n\t\tfinal HttpResponse response = (transaction.hasResponse()) ? (transaction.getResponse().getRawResponse()) : (null);\n\t\tsynchronized(interceptorLock) {\n\t\t\treturn (breakpointSet == null) ? (false) : (breakpointSet.matchesAny(transaction.getRequest(), response));\n\t\t}\n\t}\n\n\t/**\n\t * @return True if the transaction was intercepted and added to the queue for processing, false if it can immediately\n\t * be handled.\n\t */\n\tpublic boolean handleTransaction(ProxyTransaction transaction) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tif (isEnabled == true && eventHandlerList.size() != 0 && intercept(transaction) != false) {\n\t\t\t\ttransaction.setPending(this);\n\t\t\t\ttransactionQueue.add(transaction);\n\t\t\t\tint idx = transactionQueue.size() - 1;\n\t\t\t\tfor (IHttpInterceptorEventHandler handler: eventHandlerList) {\n\t\t\t\t\thandler.notifyQueue(transaction, idx);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setEnabled(boolean enabled) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tif (isEnabled != enabled) {\n\t\t\t\tisEnabled = enabled;\n\t\t\t\tif (isEnabled == false) {\n\t\t\t\t\tforwardAll();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isEnabled() {\n\t\tsynchronized(interceptorLock) {\n\t\t\treturn isEnabled;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void addEventHandler(IHttpInterceptorEventHandler eventHandler) {\n\t\tsynchronized(interceptorLock) {\n\t\t\teventHandlerList.add(eventHandler);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void removeEventHandler(IHttpInterceptorEventHandler eventHandler) {\n\t\tsynchronized(interceptorLock) {\n\t\t\teventHandlerList.remove(eventHandler);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setInterceptLevel(TransactionDirection direction, HttpInterceptorLevel level) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tif (direction == TransactionDirection.DIRECTION_REQUEST) {\n\t\t\t\tinterceptorLevelRequest = level;\n\t\t\t\tcurrentWorkspace.setIntegerProperty(propertyInterceptorLevelRequest, level.getSerializeValue());\n\t\t\t} else {\n\t\t\t\tinterceptorLevelResponse = level;\n\t\t\t\tcurrentWorkspace.setIntegerProperty(propertyInterceptorLevelResponse, level.getSerializeValue());\n\t\t\t}\n\t\t\treleaseOnChange(direction);\n\t\t}\n\t}\n\n\t@Override\n\tpublic HttpInterceptorLevel getInterceptLevel( TransactionDirection direction) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tif (direction == TransactionDirection.DIRECTION_REQUEST) {\n\t\t\t\treturn interceptorLevelRequest;\n\t\t\t} else {\n\t\t\t\treturn interceptorLevelResponse;\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic int transactionQueueSize() {\n\t\tsynchronized(interceptorLock) {\n\t\t\treturn transactionQueue.size();\n\t\t}\n\t}\n\n\t@Override\n\tpublic IProxyTransaction[] getTransactions() {\n\t\tsynchronized(interceptorLock) {\n\t\t\treturn transactionQueue.toArray(new IProxyTransaction[transactionQueue.size()]);\n\t\t}\n\t}\n\n\t@Override\n\tpublic IProxyTransaction transactionQueueGet(int idx) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tif (transactionQueue.size() <= idx) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn transactionQueue.get(idx);\n\t\t}\n\t}\n\n\t/**\n\t * Notification that a proxy transaction queued by this interceptor was handled. The transaction is removed from the\n\t * transaction queue. \n\t * \n\t * @param transaction Transaction\n\t */\n\tpublic void notifyHandled(ProxyTransaction transaction) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tfinal int idx = transactionQueue.indexOf(transaction);\n\t\t\ttransactionQueue.remove(idx);\n\t\t\tif (transactionQueue.size() == 0) {\n\t\t\t\tfor (IHttpInterceptorEventHandler handler: eventHandlerList) {\n\t\t\t\t\thandler.notifyEmpty();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (IHttpInterceptorEventHandler handler: eventHandlerList) {\n\t\t\t\t\thandler.notifyRemove(idx);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate IHttpConditionSet getBreakpointSet(TransactionDirection direction) {\n\t\tsynchronized(interceptorLock) {\n\t\t\tif (direction == TransactionDirection.DIRECTION_REQUEST) {\n\t\t\t\treturn breakpointSetRequest;\n\t\t\t} else {\n\t\t\t\treturn breakpointSetResponse;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Release transactions that no longer match interception criteria following a configuration change. Must be invoked\n\t * with interceptorLock synchronized.\n\t */\n\tprivate void releaseOnChange(TransactionDirection direction) {\n\t\tfinal HttpInterceptorLevel level = getInterceptLevel(direction);\n\t\tif (level != HttpInterceptorLevel.ENABLED_ALL) {\n\t\t\tif (level != HttpInterceptorLevel.DISABLED) {\n\t\t\t\tfinal IHttpConditionSet breakpointSet = getBreakpointSet(direction);\n\t\t\t\tfor (int idx = 0; idx < transactionQueue.size(); idx++) {\n\t\t\t\t\tProxyTransaction transaction = transactionQueue.get(idx);\n\t\t\t\t\tif (transaction.hasResponse() == (direction == TransactionDirection.DIRECTION_RESPONSE)) {\n\t\t\t\t\t\tif (interceptOnBreakpointSet(breakpointSet, transaction) == false) {\n\t\t\t\t\t\t\ttransaction.doForward();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (int idx = 0; idx < transactionQueue.size(); idx++) {\n\t\t\t\t\tProxyTransaction transaction = transactionQueue.get(idx);\n\t\t\t\t\tif (transaction.hasResponse() == (direction == TransactionDirection.DIRECTION_RESPONSE)) {\n\t\t\t\t\t\ttransaction.doForward();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Forward all pending transactions. Must be invoked with interceptorLock synchronized.\n\t */\n\tprivate void forwardAll() {\n\t\tfor (int idx = 0; idx < transactionQueue.size(); idx++) {\n\t\t\tProxyTransaction transaction = transactionQueue.get(idx);\n\t\t\ttransaction.doDrop();\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/HttpProxyListener.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.net.ServerSocket;\nimport java.net.Socket;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.impl.DefaultConnectionReuseStrategy;\nimport org.apache.http.impl.DefaultHttpResponseFactory;\nimport org.apache.http.params.BasicHttpParams;\nimport org.apache.http.params.CoreConnectionPNames;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.BasicHttpProcessor;\nimport org.apache.http.protocol.HttpRequestHandlerRegistry;\nimport org.apache.http.protocol.ResponseConnControl;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListener;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptProxyEventHandler;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.internal.http.proxy.ssl.SSLContextRepository;\n\npublic class HttpProxyListener implements IHttpProxyListener {\n\tstatic final String PROXY_CONTEXT_REQUEST = \"proxy.request\";\n\tstatic final String PROXY_CONTEXT_RESPONSE = \"proxy.response\";\n\tstatic final String PROXY_HTTP_HOST = \"proxy.host\";\n\tstatic final String PROXY_HTTP_TRANSACTION = \"proxy.transaction\";\n\tprivate final Logger logger = Logger.getLogger(\"proxy\");\n\tprivate IHttpProxyListenerConfig config;\n\tprivate final ProxyTransactionManipulator transactionManipulator;\n\tprivate final HttpInterceptor interceptor;\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate final List<IHttpInterceptProxyEventHandler> eventHandlers;\n\tprivate ServerSocket serverSocket;\n\tprivate HttpParams params;\n\tprivate VegaHttpService httpService;\n\tprivate ExecutorService executor;\n\tprivate Thread proxyThread;\n\tprivate final List<ConnectionTask> connectionList;\n\n\tpublic HttpProxyListener(IHttpProxyListenerConfig config, ProxyTransactionManipulator transactionManipulator, HttpInterceptor interceptor, IHttpRequestEngine requestEngine, SSLContextRepository sslContextRepository) {\n\t\tthis.config = config;\n\t\tthis.transactionManipulator = transactionManipulator;\n\t\tthis.interceptor = interceptor;\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.eventHandlers = new ArrayList<IHttpInterceptProxyEventHandler>();\n\n\t\tthis.params = new BasicHttpParams();\n\t\tthis.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 0)\n\t\t.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)\n//\t\t.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)\n\t\t.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);\n\n\t\tBasicHttpProcessor inProcessor = new BasicHttpProcessor();\n\t\tinProcessor.addInterceptor(new ResponseConnControl());\n\t\tinProcessor.addInterceptor(new ResponseContentCustom());\n\t\t\n\t\tHttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry();\n\t\tregistry.register(\"*\", new ProxyRequestHandler(this, logger, requestEngine));\n\n\t\thttpService = new VegaHttpService(inProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory(), registry, params, sslContextRepository);\n\t\t\n\t\tconnectionList = new ArrayList<ConnectionTask>();\n\t}\n\n\t@Override\n\tpublic IHttpProxyListenerConfig getConfig() {\n\t\treturn config;\n\t}\n\n\t@Override\n\tpublic IHttpRequestEngine getRequestEngine() {\n\t\treturn requestEngine;\n\t}\n\n\t@Override\n\tpublic void start() {\n\t\texecutor = Executors.newCachedThreadPool(); // REVISIT: potentially sloppy to just recreate this here\n\t\ttry {\n\t\t\tlogger.info(\"Listening on \" + config.getListenerAddress());\n\t\t\tserverSocket = new ServerSocket(config.getPort(), config.getBacklog(), config.getInetAddress());\n\t\t\tproxyThread = new Thread(createProxyLoopRunnable());\n\t\t\tproxyThread.start();\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"IO error creating listening socket on \" + config.getListenerAddress() + \": \"+ e.getMessage(), e);\n\t\t}\n\t}\n\n\tprivate Runnable createProxyLoopRunnable() {\n\t\treturn new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tproxyAcceptLoop();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void proxyAcceptLoop() {\n\t\twhile(!Thread.interrupted()) {\n\t\t\tSocket s;\n\t\t\ttry {\n\t\t\t\ts = serverSocket.accept();\n\t\t\t} catch (IOException e) {\n\t\t\t\tif (!Thread.interrupted()) {\n\t\t\t\t\tlogger.log(Level.WARNING, \"IO error processing incoming connection: \"+ e.getMessage(), e);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tlogger.fine(\"Connection accepted from \"+ s.getRemoteSocketAddress());\n\t\t\tVegaHttpServerConnection c = new VegaHttpServerConnection(params);\n\t\t\ttry {\n\t\t\t\tc.bind(s, params);\n\t\t\t} catch (IOException e) {\n\t\t\t\tlogger.log(Level.WARNING, \"Unexpected error: \" + e.getMessage(), e);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfinal ConnectionTask task = new ConnectionTask(httpService, c, HttpProxyListener.this);\n\t\t\tsynchronized (connectionList) {\n\t\t\t\tconnectionList.add(task);\n\t\t\t}\n\t\t\texecutor.execute(task);\n\t\t}\n\n\t\tsynchronized (connectionList) {\n\t\t\tfor (ConnectionTask task: connectionList) {\n\t\t\t\ttask.shutdown();\n\t\t\t}\n\t\t}\n\n\t\texecutor.shutdownNow();\n\t}\n\n\t@Override\n\tpublic void stop() {\n\t\tproxyThread.interrupt();\n\t\ttry {\n\t\t\t// close the socket to interrupt accept() in proxyAcceptLoop()\n\t\t\tserverSocket.close();\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"Unexpected exception closing server socket: \" + e.getMessage(), e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void registerEventHandler(IHttpInterceptProxyEventHandler handler) {\n\t\tsynchronized(eventHandlers) {\n\t\t\teventHandlers.add(handler);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void unregisterEventHandler(IHttpInterceptProxyEventHandler handler) {\n\t\tsynchronized(eventHandlers) {\n\t\t\teventHandlers.remove(handler);\n\t\t}\n\t}\n\n\tpublic boolean handleTransaction(ProxyTransaction transaction) throws InterruptedException {\n\t\tif (transaction.hasResponse() == false) {\n\t\t\ttransactionManipulator.process(transaction.getRequest());\n\t\t} else {\n\t\t\ttransactionManipulator.process(transaction.getResponse().getRawResponse());\n\t\t}\n\n\t\tboolean rv = interceptor.handleTransaction(transaction);\n\t\tif (rv == true) {\n\t\t\ttransaction.await();\n\t\t}\n\t\treturn rv;\n\t}\n\n\tvoid completeRequest(ProxyTransaction transaction) {\n\t\tsynchronized(eventHandlers) {\n\t\t\tfor(IHttpInterceptProxyEventHandler h: eventHandlers)\n\t\t\t\th.handleRequest(transaction);\n\t\t}\n\t}\n\n\tpublic void notifyClose(ConnectionTask task) {\n\t\tsynchronized (connectionList) {\n\t\t\tconnectionList.remove(task);\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/HttpProxyListenerConfig.java",
    "content": "package com.subgraph.vega.internal.http.proxy;\n\nimport java.net.InetAddress;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\n\npublic class HttpProxyListenerConfig implements IHttpProxyListenerConfig {\n\tprivate InetAddress inetAddress;\n\tprivate int port;\n\tprivate int backlog = 10;\n\n\t@Override\n\tpublic InetAddress getInetAddress() {\n\t\treturn inetAddress;\n\t}\n\n\t@Override\n\tpublic void setInetAddress(InetAddress address) {\n\t\tthis.inetAddress = address;\t\t\n\t}\n\n\t@Override\n\tpublic int getPort() {\n\t\treturn port;\n\t}\n\n\t@Override\n\tpublic void setPort(int port) {\n\t\tthis.port = port;\n\t}\n\n\t@Override\n\tpublic int getBacklog() {\n\t\treturn backlog;\n\t}\n\n\t@Override\n\tpublic void setBacklog(int backlog) {\n\t\tthis.backlog = backlog;\n\t}\n\n\t@Override\n\tpublic String getListenerAddress() {\n\t\treturn \"[\" + inetAddress.getHostAddress() + \"]:\" + port;\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn getListenerAddress();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/HttpProxyService.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.impl.client.BasicCookieStore;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.analysis.IContentAnalyzerFactory;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptProxyEventHandler;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListener;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyServiceEventHandler;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyTransactionManipulator;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.requests.IRequestOriginProxy;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.api.scanner.IScanner;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\nimport com.subgraph.vega.internal.http.proxy.ssl.ProxySSLInitializationException;\nimport com.subgraph.vega.internal.http.proxy.ssl.SSLContextRepository;\n\npublic class HttpProxyService implements IHttpProxyService {\n\tprivate final Logger logger = Logger.getLogger(HttpProxyService.class.getName());\n\tprivate final List<IHttpProxyServiceEventHandler> eventHandlers;\n\tprivate boolean isRunning = false;\n\tprivate boolean isPassthrough = false;\n\tprivate IModel model;\n\tprivate IHttpRequestEngineFactory requestEngineFactory;\n\tprivate IHttpRequestEngineConfig requestEngineConfig;\n\tprivate IContentAnalyzerFactory contentAnalyzerFactory;\n\tprivate IScannerModuleRegistry moduleRepository;\n\tprivate IScanner scanner;\n\tprivate CookieStore cookieStore;\n\tprivate IPathFinder pathFinder;\n\tprivate IContentAnalyzer contentAnalyzer;\n\tprivate List<IResponseProcessingModule> responseProcessingModules;\n\tprivate IWorkspace currentWorkspace;\n\tprivate Map<String, IHttpProxyListenerConfig> listenerConfigMap = new HashMap<String, IHttpProxyListenerConfig>();\n\tprivate Map<String, HttpProxyListener> listenerMap = new ConcurrentHashMap<String, HttpProxyListener>();\n\tprivate final IHttpInterceptProxyEventHandler listenerEventHandler;\n\tprivate final ProxyTransactionManipulator transactionManipulator;\n\tprivate ProxyScanner proxyScanner;\n\tprivate HttpInterceptor interceptor;\n\tprivate SSLContextRepository sslContextRepository;\n\t\n\tpublic HttpProxyService() {\n\t\teventHandlers = new ArrayList<IHttpProxyServiceEventHandler>();\n\t\tlistenerEventHandler = new IHttpInterceptProxyEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleRequest(IProxyTransaction transaction) {\n\t\t\t\tprocessTransaction(transaction);\n\t\t\t}\n\t\t};\n\t\ttransactionManipulator = new ProxyTransactionManipulator();\n\t}\n\n\tpublic void activate() {\n\t\tinterceptor = new HttpInterceptor(model);\n\t\tcookieStore = new BasicCookieStore();\n\t\tproxyScanner = new ProxyScanner(scanner, cookieStore, model);\n\n\t\ttry {\n\t\t\tsslContextRepository = SSLContextRepository.createInstance(pathFinder.getVegaDirectory());\n\t\t} catch (ProxySSLInitializationException e) {\n\t\t\tsslContextRepository = null;\n\t\t\tlogger.warning(\"Failed to initialize SSL support in proxy.  SSL interception will be disabled. (\"+ e.getMessage() + \")\");\n\t\t}\n\t}\n\n\t@Override\n\tpublic void registerEventHandler(IHttpProxyServiceEventHandler handler) {\n\t\teventHandlers.add(handler);\n\t}\n\n\t@Override\n\tpublic void unregisterEventHandler(IHttpProxyServiceEventHandler handler) {\n\t\teventHandlers.remove(handler);\n\t}\n\n\t@Override\n\tpublic boolean isRunning() {\n\t\treturn isRunning;\n\t}\n\n\t@Override\n\tpublic boolean isPassthrough() {\n\t\tsynchronized(this) {\n\t\t\treturn isPassthrough;\n\t\t}\n\t}\n\n\t@Override\n\tpublic IHttpProxyListenerConfig createListenerConfig() {\n\t\treturn new HttpProxyListenerConfig();\n\t}\n\n\t@Override\n\tpublic void setListenerConfigs(IHttpProxyListenerConfig[] listenerConfigs) {\n\t\t// remove existing listeners that are not in the list\n\t\tfor (Iterator<Map.Entry<String, IHttpProxyListenerConfig>> iter = listenerConfigMap.entrySet().iterator(); iter.hasNext();) {\n\t\t\tfinal Map.Entry<String, IHttpProxyListenerConfig> entry = iter.next();\n\t\t\tfinal String k = entry.getKey();\n\t\t\tint idx;\n\t\t\tfor (idx = 0; idx < listenerConfigs.length; idx++) {\n\t\t\t\tif (k.compareTo(((IHttpProxyListenerConfig)listenerConfigs[idx]).toString()) == 0) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (idx == listenerConfigs.length) {\n\t\t\t\tif (isRunning != false) {\n\t\t\t\t\tHttpProxyListener listener = listenerMap.remove(k); \n\t\t\t\t\tstopListener(listener);\n\t\t\t\t}\n\t\t\t\titer.remove();\n\t\t\t}\n\t\t}\n\n\t\t// create listeners for any new addresses\n\t\tfor (int idx = 0; idx < listenerConfigs.length; idx++) {\n\t\t\tfinal IHttpProxyListenerConfig config = listenerConfigs[idx];\n\t\t\tfinal String key = config.toString();\n\t\t\tif (listenerConfigMap.get(key) == null) {\n\t\t\t\tlistenerConfigMap.put(key, config);\n\t\t\t\tif (isRunning != false) {\n\t\t\t\t\tstartListener(config);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// notify event handlers\n\t\tfor (IHttpProxyServiceEventHandler handler: eventHandlers) {\n\t\t\thandler.notifyConfigChange(listenerMap.size());\n\t\t}\n\t}\n\n\t@Override\n\tpublic IHttpProxyListenerConfig[] getListenerConfigs() {\n\t\treturn listenerMap.keySet().toArray(new IHttpProxyListenerConfig[0]);\n\t}\n\n\t@Override\n\tpublic IHttpProxyListener[] getListeners() {\n\t\treturn listenerMap.values().toArray(new IHttpProxyListener[0]);\n\t}\n\n\t@Override\n\tpublic int getListenerConfigsCount() {\n\t\treturn listenerMap.size();\n\t}\n\n\t@Override\n\tpublic void setPassthrough(boolean enabled) {\n\t\tsynchronized(this) {\n\t\t\tisPassthrough = enabled;\n\t\t\tinterceptor.setEnabled(!enabled);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void start() {\n\t\tcurrentWorkspace = model.getCurrentWorkspace();\n\t\tif(currentWorkspace == null) \n\t\t\tthrow new IllegalStateException(\"Cannot start proxy because no workspace is currently open\");\n\t\tcurrentWorkspace.lock();\n\t\tisRunning = true;\n\n\t\tresponseProcessingModules = loadModules();\n\t\tcontentAnalyzer = contentAnalyzerFactory.createContentAnalyzer(currentWorkspace.getScanAlertRepository().getProxyScanInstance());\n\t\tcontentAnalyzer.setResponseProcessingModules(responseProcessingModules);\n\t\tcontentAnalyzer.setDefaultAddToRequestLog(true);\n\t\tcontentAnalyzer.setAddLinksToModel(true);\n\n\t\tproxyScanner.reloadModules();\n\t\t\n\t\tfor (IHttpProxyListenerConfig config: listenerConfigMap.values()) {\n\t\t\tstartListener(config);\n\t\t}\n\n\t\tfor (IHttpProxyServiceEventHandler handler: eventHandlers) {\n\t\t\thandler.notifyStart(listenerMap.size());\n\t\t}\n\t}\n\n\tprivate void startListener(IHttpProxyListenerConfig config) {\n\t\tIRequestOriginProxy requestOrigin = currentWorkspace.getRequestLog().getRequestOriginProxy(config.getInetAddress(), config.getPort());\n\t\tIHttpRequestEngine requestEngine = requestEngineFactory.createRequestEngine(IHttpRequestEngine.EngineConfigType.CONFIG_PROXY, requestEngineConfig, requestOrigin);\n\t\trequestEngine.setCookieStore(cookieStore);\n\t\tHttpProxyListener listener = new HttpProxyListener(config, transactionManipulator, interceptor, requestEngine, sslContextRepository);\n\t\tlistener.registerEventHandler(listenerEventHandler);\n\t\tlistenerMap.put(config.toString(), listener);\n\t\tlistener.start();\n\t\tfor (IHttpProxyServiceEventHandler handler: eventHandlers) {\n\t\t\thandler.notifyStartListener(listener);\n\t\t}\n\t}\n\t\n\tprivate void stopListener(IHttpProxyListener listener) {\n\t\tlistener.unregisterEventHandler(listenerEventHandler);\n\t\tlistener.stop();\n\t\tfor (IHttpProxyServiceEventHandler handler: eventHandlers) {\n\t\t\thandler.notifyStopListener(listener);\n\t\t}\n\t}\n\t\n\tprivate List<IResponseProcessingModule> loadModules() {\n\t\tif(responseProcessingModules == null) {\n\t\t\treturn moduleRepository.getResponseProcessingModules();\n\t\t} else {\n\t\t\treturn moduleRepository.updateResponseProcessingModules(responseProcessingModules);\n\t\t}\n\t}\n\n\tprivate void processTransaction(IProxyTransaction transaction) {\n\t\tsynchronized(this) {\n\t\t\tif(transaction.getResponse() == null || contentAnalyzer == null || isPassthrough) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tif(proxyScanner.isEnabled()) {\n\t\t\t\tproxyScanner.processRequest(transaction.getRequest());\n\t\t\t}\n\t\t\tcontentAnalyzer.processResponse(transaction.getResponse());\n\t\t} catch (RuntimeException e) {\n\t\t\tlogger.log(Level.WARNING, \"Exception processing transaction response: \"+ e.getMessage(), e);\n\t\t}\n\t}\n\t@Override\n\tpublic void stop() {\n\t\tif(currentWorkspace == null)\n\t\t\tthrow new IllegalStateException(\"No workspace is open\");\n\t\tisRunning = false;\n\t\tproxyScanner.setEnabled(false);\n\n\t\tfor (Iterator<Map.Entry<String, HttpProxyListener>> iter = listenerMap.entrySet().iterator(); iter.hasNext();) {\n\t\t\tfinal Map.Entry<String, HttpProxyListener> entry = iter.next();\n\t\t\tstopListener(entry.getValue());\n\t\t\titer.remove();\n\t\t}\n\t\tlistenerMap.clear();\n\n\t\tcontentAnalyzer = null;\n\t\tcurrentWorkspace.unlock();\n\n\t\tfor (IHttpProxyServiceEventHandler handler: eventHandlers) {\n\t\t\thandler.notifyStop();\n\t\t}\n\t}\n\n\t@Override\n\tpublic IHttpProxyTransactionManipulator getTransactionManipulator() {\n\t\treturn transactionManipulator;\n\t}\n\n\t@Override\n\tpublic IHttpInterceptor getInterceptor() {\n\t\treturn interceptor;\n\t}\n\n\tprotected void setModel(IModel model) {\n\t\tthis.model = model;\n\t}\n\n\tprotected void unsetModel(IModel model) {\n\t\tthis.model = null;\n\t}\n\n\tprotected void setContentAnalyzerFactory(IContentAnalyzerFactory factory) {\n\t\tthis.contentAnalyzerFactory = factory;\n\t}\n\t\n\tprotected void unsetContentAnalyzerFactory(IContentAnalyzerFactory factory) {\n\t\tthis.contentAnalyzerFactory = null;\n\t}\n\n\tprotected void setRequestEngineFactory(IHttpRequestEngineFactory factory) {\n\t\tthis.requestEngineFactory = factory;\n\t\trequestEngineConfig = requestEngineFactory.createConfig();\n\t}\n\n\tprotected void unsetRequestEngineFactory(IHttpRequestEngineFactory factory) {\n\t\tthis.requestEngineFactory = null;\n\t\trequestEngineConfig = null;\n\t}\n\t\n\tprotected void setModuleRepository(IScannerModuleRegistry moduleRepository) {\n\t\tthis.moduleRepository = moduleRepository;\n\t}\n\t\n\tprotected void unsetModuleRepository(IScannerModuleRegistry moduleRepository) {\n\t\tthis.moduleRepository = null;\n\t}\n\n\tprotected void setPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = pathFinder;\n\t}\n\n\tprotected void unsetPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = null;\n\t}\n\t\n\tprotected void setScanner(IScanner scanner) {\n\t\tthis.scanner = scanner;\n\t}\n\t\n\tprotected void unsetScanner(IScanner scanner) {\n\t\tthis.scanner = null;\n\t}\n\n\t@Override\n\tpublic List<IResponseProcessingModule> getResponseProcessingModules() {\n\t\tresponseProcessingModules = loadModules();\n\t\tif(responseProcessingModules == null) {\n\t\t\treturn Collections.emptyList();\n\t\t} else {\n\t\t\treturn responseProcessingModules;\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isProxyScanEnabled() {\n\t\treturn proxyScanner.isEnabled();\n\t}\n\n\t@Override\n\tpublic void setProxyScanEnabled(boolean enabled) {\n\t\tproxyScanner.setEnabled(enabled);\n\t}\n\n\t@Override\n\tpublic IScannerConfig getProxyScanConfig() {\n\t\treturn proxyScanner.getConfig();\n\t}\n\n\t@Override\n\tpublic List<IBasicModuleScript> getProxyScanModules() {\n\t\treturn proxyScanner.getInjectionModules();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ProxyRequestHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpMessage;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.message.BasicHttpResponse;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.protocol.HttpContext;\nimport org.apache.http.protocol.HttpRequestHandler;\nimport org.apache.http.util.EntityUtils;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.RequestEngineException;\nimport com.subgraph.vega.http.requests.custom.VegaHttpEntityEnclosingUriRequest;\nimport com.subgraph.vega.http.requests.custom.VegaHttpUriRequest;\n\npublic class ProxyRequestHandler implements HttpRequestHandler {\n\n\t/**\n\t * Hop-by-hop headers to be removed by this proxy.\n\t */\n\tprivate final static String[] HOP_BY_HOP_HEADERS = {\n\t\t// Hop-by-hop headers specified in RFC2616 section 13.5.1.\n\t\tHTTP.CONN_DIRECTIVE, // \"Connection\"\n\t\tHTTP.CONN_KEEP_ALIVE, // \"Keep-Alive\"\n\t\t\"Proxy-Authenticate\",\n\t\t\"Proxy-Authorization\",\n\t\t\"TE\",\n\t\t\"Trailers\",\n\t\tHTTP.TRANSFER_ENCODING, // \"Transfer-Encoding\"\n\t\t\"Upgrade\",\n\n\t\t// Not part of the RFC but should not be forwarded; see http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/web-proxy-connection-header.html\n\t\t\"Proxy-Connection\",\n\t};\n\n\tprivate final Logger logger;\n\tprivate final HttpProxyListener httpProxy;\n\tprivate final IHttpRequestEngine requestEngine;\n\n\tProxyRequestHandler(HttpProxyListener httpProxy, Logger logger, IHttpRequestEngine requestEngine) {\n\t\tthis.httpProxy = httpProxy;\n\t\tthis.logger = logger;\n\t\tthis.requestEngine = requestEngine;\n\t}\n\n\t@Override\n\tpublic void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {\n\t\tfinal ProxyTransaction transaction = new ProxyTransaction(requestEngine, context);\n\t\tcontext.setAttribute(HttpProxyListener.PROXY_HTTP_TRANSACTION, transaction);\n\n\t\ttry {\n\t\t\tif (handleRequest(transaction, request) == false) {\n\t\t\t\tresponse.setStatusCode(503);\n\t\t\t\ttransaction.signalComplete(false);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfinal HttpUriRequest uriRequest = transaction.getRequest();\n\t\t\tfinal IHttpRequestTask requestTask = requestEngine.sendRequest(uriRequest);\n\t\t\ttransaction.setRequestTask(requestTask);\n\t\t\ttransaction.signalForward();\n\t\t\tIHttpResponse r = null;\n\t\t\ttry {\n\t\t\t\tr = requestTask.get(false);\n\t\t\t} finally {\n\t\t\t\ttransaction.setRequestTask(null);\n\t\t\t}\n\t\t\tif(r == null) {\n\t\t\t\tresponse.setStatusCode(503);\n\t\t\t\ttransaction.signalComplete(false);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (handleResponse(transaction, r) == false) {\n\t\t\t\tresponse.setStatusCode(503);\n\t\t\t\ttransaction.signalComplete(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tHttpResponse httpResponse = copyResponse(r.getRawResponse());\n\t\t\tremoveHeaders(httpResponse);\n\t\t\tresponse.setStatusLine(httpResponse.getStatusLine());\n\t\t\tresponse.setHeaders(httpResponse.getAllHeaders());\n\t\t\tresponse.setEntity(httpResponse.getEntity());\n\t\t\ttransaction.signalForward();\n\t\t} catch (InterruptedException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error processing request: \" + e.getMessage(), e);\n\t\t\tresponse.setStatusCode(503);\n\t\t} catch (RequestEngineException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error processing request: \" + e.getMessage());\n\t\t\tresponse.setStatusCode(502);\n\t\t} catch (ProtocolException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error processing request: \" + e.getMessage(), e);\n\t\t\tresponse.setStatusCode(400);\n\t\t} catch (Exception e) {\n\t\t\tlogger.log(Level.WARNING, \"Error processing request: \" + e.getMessage(), e);\n\t\t\tresponse.setStatusCode(500);\n\t\t} finally {\n\t\t\ttransaction.signalComplete(false);\n\t\t}\n\t}\n\n\tprivate HttpEntity copyEntity(HttpEntity entity) {\n\t\ttry {\n\t\t\tif(entity == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tfinal ByteArrayEntity newEntity = new ByteArrayEntity(EntityUtils.toByteArray(entity));\n\t\t\tnewEntity.setContentEncoding(entity.getContentEncoding());\n\t\t\tnewEntity.setContentType(entity.getContentType());\n\t\t\treturn newEntity;\n\t\t} catch (IOException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate HttpUriRequest copyToUriRequest(HttpRequest request) throws ProtocolException {\n\t\tURI uri;\n\t\tfinal String hostStr = removePath(request.getRequestLine().getUri());\n\t\ttry {\n\t\t\turi = new URI(hostStr);\n\t\t} catch (URISyntaxException e) {\n    \t\tthrow new ProtocolException(\"Invalid URI: \" + hostStr, e);\n\t\t}\n\t\t// ensuring we have scheme and host also prevents the proxy from connecting back to itself\n\t\tif (uri.getScheme() == null) {\n\t\t\tthrow new ProtocolException(\"No scheme in proxy request URI\");\n\t\t}\n\t\tif (uri.getHost() == null) {\n\t\t\tthrow new ProtocolException(\"No host in proxy request URI\");\n\t\t}\n\t\t\n\t\tfinal HttpHost host = URIUtils.extractHost(uri);\n\t\tfinal HttpUriRequest uriRequest = createRequestCopy(host, request);\n\t\turiRequest.setParams(request.getParams());\n\t\turiRequest.setHeaders(request.getAllHeaders());\n\t\treturn uriRequest;\n\t}\n\t\n\tprivate String removeSchemeAndHost(String line) {\n\t\tfinal int idx = findPathStart(line);\n\t\tif(idx == -1) {\n\t\t\treturn \"\";\n\t\t} else {\n\t\t\treturn line.substring(idx);\n\t\t}\n\t}\n\t\n\tprivate String removePath(String line) {\n\t\tfinal int idx = findPathStart(line);\n\t\tif(idx == -1) {\n\t\t\treturn line;\n\t\t} else {\n\t\t\treturn line.substring(0, idx);\n\t\t}\n\t}\n\t\n\t\n\tprivate int findPathStart(String line) {\n\t\tint idx = line.indexOf(\"://\");\n\t\tif(idx == -1 || ((idx + 3) >= line.length())) {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tidx += 3;\n\t\t}\n\t\twhile(line.charAt(idx) == '/') idx++;\n\t\treturn line.indexOf('/', idx);\n\t}\n\n\tprivate HttpUriRequest createRequestCopy(HttpHost host, HttpRequest request) {\n\t\tfinal String method = request.getRequestLine().getMethod();\n\t\tfinal String uriLine = removeSchemeAndHost(request.getRequestLine().getUri());\n\t\tif(request instanceof HttpEntityEnclosingRequest) {\n\t\t\tfinal VegaHttpEntityEnclosingUriRequest r = new VegaHttpEntityEnclosingUriRequest(host, method, uriLine);\n\t\t\tr.setEntity(copyEntity(((HttpEntityEnclosingRequest) request).getEntity()));\n\t\t\treturn r;\n\t\t}\n\t\treturn new VegaHttpUriRequest(host, method, uriLine);\n\t}\n\t\n\tprivate HttpResponse copyResponse(HttpResponse originalResponse) {\n\t\tHttpResponse r = new BasicHttpResponse(originalResponse.getStatusLine());\n\t\tr.setHeaders(originalResponse.getAllHeaders());\n\t\tr.setEntity(originalResponse.getEntity());\n\t\treturn r;\n\t}\n\n\tprivate void removeHeaders(HttpMessage message) {\n\t\tfor(String hdr: HOP_BY_HOP_HEADERS) { \n\t\t\tmessage.removeHeaders(hdr);\n\t\t}\n\t}\n\n\tprivate boolean handleRequest(ProxyTransaction transaction, HttpRequest request) throws InterruptedException, ProtocolException {\n\t\tremoveHeaders(request);\n\t\ttransaction.setRequest(copyToUriRequest(request));\n\t\tif (httpProxy.handleTransaction(transaction) == true) {\n\t\t\treturn transaction.getForward();\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate boolean handleResponse(ProxyTransaction transaction, IHttpResponse response) throws InterruptedException {\n\t\ttransaction.setResponse(response);\n\t\tif (httpProxy.handleTransaction(transaction) == true) {\n\t\t\treturn transaction.getForward();\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ProxyScanner.java",
    "content": "package com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.net.URI;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpHost;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.client.utils.URLEncodedUtils;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.IProxyScan;\nimport com.subgraph.vega.api.scanner.IScanner;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic class ProxyScanner {\n\tprivate final Logger logger = Logger.getLogger(HttpProxyService.class.getName());\n\t\n\tprivate final IScanner scanner;\n\tprivate final CookieStore cookieStore;\n\tprivate final ProxyScannerScopeTracker scopeTracker;\n\t\n\t\n\tprivate IProxyScan proxyScan;\n\tprivate boolean isEnabled = false;\n\t\n\tProxyScanner(IScanner scanner, CookieStore cookieStore, IModel model) {\n\t\tthis.scanner = scanner;\n\t\tthis.cookieStore = cookieStore;\n\t\tthis.scopeTracker = new ProxyScannerScopeTracker(model, this);\n\t}\n\t\n\tvoid reloadModules() {\n\t\tif(proxyScan != null) {\n\t\t\tproxyScan.reloadModules();\n\t\t}\n\t}\n\n\tboolean isEnabled() {\n\t\treturn isEnabled;\n\t}\n\t\n\tvoid setEnabled(boolean value) {\n\t\treloadModules();\n\t\tisEnabled = value;\n\t}\n\t\n\tList<IBasicModuleScript> getInjectionModules() {\n\t\tif(proxyScan == null) {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t\treturn proxyScan.getInjectionModules();\n\t}\n\n\tIScannerConfig getConfig() {\n\t\tif(proxyScan == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn proxyScan.getConfig();\n\t}\n\t\n\tvoid processRequest(HttpUriRequest request) {\n\t\tif(proxyScan == null) {\n\t\t\tthrow new IllegalStateException(\"Cannot process request because no proxy scan is currently active\");\n\t\t}\n\t\tif(request.getMethod().equalsIgnoreCase(\"GET\")) {\n\t\t\thandleProxyScanGetRequest(request);\n\t\t} else if(request.getMethod().equalsIgnoreCase(\"POST\")) {\n\t\t\thandleProxyScanPostRequest(request);\n\t\t}\n\t}\n\t\n\t\n\tvoid handleWorkspaceChanged(IWorkspace newWorkspace) {\n\t\tif(proxyScan != null) {\n\t\t\tproxyScan.stop();\n\t\t}\n\t\tisEnabled = false;\n\t\tif(newWorkspace != null) {\n\t\t\tproxyScan = scanner.createProxyScan(newWorkspace, cookieStore);\n\t\t}\n\t}\n\t\n\t\n\tprivate void handleProxyScanGetRequest(HttpUriRequest request) {\n\t\t\n\t\tfinal List<NameValuePair> params = URLEncodedUtils.parse(request.getURI(), \"UTF-8\");\n\t\tif(params.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tfinal URI target = request.getURI();\n\t\tif(isTargetInScope(target)) {\n\t\t\tproxyScan.scanGetTarget(requestToURI(request), params);\n\t\t}\n\t}\n\n\tprivate void handleProxyScanPostRequest(HttpUriRequest request) {\n\t\tif(!(request instanceof HttpEntityEnclosingRequest)) {\n\t\t\treturn;\n\t\t}\n\t\tfinal HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();\n\t\tList<NameValuePair> params;\n\t\ttry {\n\t\t\tparams = URLEncodedUtils.parse(entity);\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"Exception reading request entity\", e);\n\t\t\treturn;\n\t\t}\n\t\tif(params.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tfinal URI target = request.getURI();\n\t\tif(isTargetInScope(target)) {\n\t\t\tproxyScan.scanPostTarget(requestToURI(request), params);\n\t\t}\n\t}\n\n\tprivate VegaURI requestToURI(HttpUriRequest request) {\n\t\tfinal URI u = request.getURI();\n\t\tfinal HttpHost targetHost = URIUtils.extractHost(u);\n\t\treturn new VegaURI(targetHost, u.getPath(), u.getQuery());\n\t}\n\n\tprivate boolean isTargetInScope(URI target) {\n\t\tfinal ITargetScope activeScope = scopeTracker.getCurrentActiveScope();\n\t\tif(activeScope == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn activeScope.filter(target);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ProxyScannerScopeTracker.java",
    "content": "package com.subgraph.vega.internal.http.proxy;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.scope.ActiveScopeChangedEvent;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\n\npublic class ProxyScannerScopeTracker {\n\t\n\tprivate final IEventHandler scopeChangeHandler;\n\tprivate final ProxyScanner proxyScanner;\n\tprivate IWorkspace currentWorkspace;\n\tprivate ITargetScope currentActiveScope;\n\t\n\tProxyScannerScopeTracker(IModel model, ProxyScanner proxyScanner) {\n\t\tthis.proxyScanner = proxyScanner;\n\t\tthis.scopeChangeHandler = createScopeChangeListener();\n\t\tsetCurrentWorkspace(model.addWorkspaceListener(createWorkspaceListener()));\n\t}\n\t\n\tITargetScope getCurrentActiveScope() {\n\t\treturn currentActiveScope;\n\t}\n\n\tprivate IEventHandler createWorkspaceListener() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate IEventHandler createScopeChangeListener() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof ActiveScopeChangedEvent) {\n\t\t\t\t\tcurrentActiveScope = ((ActiveScopeChangedEvent)event).getActiveScope();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tsetCurrentWorkspace(event.getWorkspace());\n\t}\n\t\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tsetCurrentWorkspace(event.getWorkspace());\n\t\t\n\t}\n\t\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tsetCurrentWorkspace(null);\n\t}\n\t\n\tprivate void setCurrentWorkspace(IWorkspace workspace) {\n\t\tfinal IWorkspace oldWorkspace = currentWorkspace;\n\t\tcurrentWorkspace = workspace;\n\t\tcurrentActiveScope = setScopeChangeListener(oldWorkspace, workspace);\n\t\tproxyScanner.handleWorkspaceChanged(workspace);\n\t}\n\t\n\tprivate ITargetScope setScopeChangeListener(IWorkspace oldWorkspace, IWorkspace newWorkspace) {\n\t\tif(oldWorkspace != null) {\n\t\t\toldWorkspace.getTargetScopeManager().removeActiveScopeChangeListener(scopeChangeHandler);\n\t\t}\n\t\tif(newWorkspace != null) {\n\t\t\treturn newWorkspace.getTargetScopeManager().addActiveScopeChangeListener(scopeChangeHandler);\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ProxyTransaction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.util.concurrent.locks.Condition;\nimport java.util.concurrent.locks.Lock;\nimport java.util.concurrent.locks.ReentrantLock;\n\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.protocol.HttpContext;\n\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\nimport com.subgraph.vega.api.http.proxy.IProxyTransactionEventHandler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\n\npublic class ProxyTransaction implements IProxyTransaction {\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate final HttpContext context;\n\tprivate IProxyTransactionEventHandler eventHandler;\n\tprivate HttpUriRequest request;\n\tprivate IHttpResponse response;\n    private HttpInterceptor interceptor; \n    private IHttpRequestTask requestTask;\n    private boolean isPending = false;\n    private boolean doForward = false;\n    private Lock lock = new ReentrantLock();\n    private Condition cv = lock.newCondition();\n\n\tProxyTransaction(IHttpRequestEngine requestEngine, HttpContext context) {\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.context = context;\n\t}\n\n\tpublic IHttpRequestEngine getRequestEngine() {\n\t\treturn requestEngine;\n\t}\n\n\tpublic HttpContext getContext() {\n\t\treturn context;\n\t}\n\n\tpublic synchronized void setResponse(IHttpResponse response) {\n\t\tthis.response = response;\n\t}\n\n\tpublic void await() throws InterruptedException {\n \t\tlock.lock();\n\t\ttry {\n\t\t\twhile (isPending == true) {\n\t\t\t\tcv.await();\n\t\t\t}\n\t\t} catch (InterruptedException e) {\n\t\t\ttry {\n\t\t\t\tif (interceptor != null) {\n\t\t\t\t\tinterceptor.notifyHandled(this);\n\t\t\t\t\tinterceptor = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tisPending = false;\n\t\t\t\tdoForward = false;\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t\tfinally {\n\t\t\ttry {\n\t\t\t\tif (interceptor != null) {\n\t\t\t\t\tinterceptor.notifyHandled(this);\n\t\t\t\t\tinterceptor = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tlock.unlock();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic synchronized void setPending(HttpInterceptor interceptor) {\n\t\tthis.interceptor = interceptor;\n\t\tisPending = true;\n\t\tdoForward = false;\n\t}\n\n\tpublic synchronized void setUnqueued() {\n\t\tinterceptor = null;\n\t}\n\n\tpublic synchronized boolean getForward() {\n\t\treturn doForward;\n\t}\n\n\t@Override\n\tpublic synchronized void setEventHandler(IProxyTransactionEventHandler eventHandler) {\n\t\tthis.eventHandler = eventHandler;\n\t}\n\n\t@Override\n\tpublic synchronized void setRequest(HttpUriRequest request) {\n\t\tthis.request = request;\n\t}\n\n\t@Override\n\tpublic synchronized boolean hasRequest() {\n\t\treturn (request != null);\n\t}\n\n\t@Override\n\tpublic synchronized HttpUriRequest getRequest() {\n\t\treturn request;\n\t}\n\n\t@Override\n\tpublic synchronized boolean hasResponse() {\n\t\treturn (response != null);\n\t}\n\n\t@Override\n\tpublic synchronized IHttpResponse getResponse() {\n\t\treturn response;\n\t}\n\n\t@Override\n\tpublic void doForward() {\n\t\tlock.lock();\n\t\ttry {\n\t\t\tif (isPending == true) {\n\t\t\t\tisPending = false;\n\t\t\t\tdoForward = true;\n\t\t\t\tcv.signal();\n\t\t\t}\n\t\t}\n\t\tfinally {\n\t\t\tlock.unlock();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void doDrop() {\n\t\tlock.lock();\n\t\ttry {\n\t\t\tif (isPending == true) {\n\t\t\t\tisPending = false;\n\t\t\t\tdoForward = false;\n\t\t\t\tcv.signal();\n\t\t\t} else {\n\t\t\t\tif (requestTask != null) {\n\t\t\t\t\trequestTask.abort();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally {\n\t\t\tlock.unlock();\n\t\t}\n\t}\n\t\n\t/**\n\t * Signal that the pending transaction is about to be forwarded.\n\t */\n\tpublic synchronized void signalForward() {\n\t\tif (eventHandler != null) {\n\t\t\teventHandler.notifyForward();\n\t\t}\n\t}\n\n\t/**\n\t * Signal that the transaction is complete.\n\t * @param dropped Boolean indicating whether the transaction was dropped.\n\t */\n\tpublic synchronized void signalComplete(boolean dropped) {\n\t\tif (eventHandler != null) {\n\t\t\teventHandler.notifyComplete(dropped);\n\t\t}\t\t\n\t}\n\n\t/**\n\t * Set the task being used to send a request.\n\t * @param requestTask Request task.\n\t */\n\tpublic synchronized void setRequestTask(IHttpRequestTask requestTask) {\n\t\tthis.requestTask = requestTask;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ProxyTransactionManipulator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.message.BasicHeader;\nimport org.apache.http.params.HttpProtocolParams;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyTransactionManipulator;\n\npublic class ProxyTransactionManipulator implements IHttpProxyTransactionManipulator {\n\t/**\n\t * Conditional request headers. \n\t */\n\tprivate final static String[] CONDITIONAL_REQUEST_HEADERS = {\n\t\t\"If-Match\",\n\t\t\"If-Modified-Since\",\n\t\t\"If-None-Match\",\n\t\t\"If-Range\",\n\t\t\"If-Unmodified-Since\"\n\t};\n\t\n\tprivate String userAgent;\n\tprivate boolean userAgentOverride;\n\tprivate boolean disableBrowserCache;\n\tprivate boolean disableProxyCache;\n\n\tpublic ProxyTransactionManipulator() {\n\t}\n\n\t@Override\n\tpublic synchronized void setUserAgent(String userAgent) {\n\t\tthis.userAgent = userAgent;\n\t}\n\n\t@Override\n\tpublic synchronized void setUserAgentOverride(boolean override) {\n\t\tthis.userAgentOverride = override;\n\t}\n\n\t@Override\n\tpublic synchronized void setBrowserCacheDisable(boolean disable) {\n\t\tthis.disableBrowserCache = disable;\n\t}\n\n\t@Override\n\tpublic synchronized void setProxyCacheDisable(boolean disable) {\n\t\tthis.disableProxyCache = disable;\n\t}\n\n\t@Override\n\tpublic synchronized void process(HttpRequest request) {\n\t\tif (userAgent != null) {\n\t\t\tif (userAgentOverride != false) {\n\t\t\t\trequest.setHeader(new BasicHeader(\"User-Agent\", userAgent));\n\t\t\t} else {\n\t\t\t\tHttpProtocolParams.setUserAgent(request.getParams(), userAgent);\n\t\t\t}\n\t\t}\n\n\t\tif (disableBrowserCache) {\n\t\t\tfor (String header: CONDITIONAL_REQUEST_HEADERS) { \n\t\t\t\trequest.removeHeaders(header);\n\t\t\t}\n\t\t}\n\n\t\tif (disableProxyCache) {\n\t\t\t// instruct HTTP/1.1 caches to do an end-to-end reload\n\t\t\trequest.setHeader(new BasicHeader(\"Cache-Control\", \"no-cache\"));\n\n\t\t\t// instruct HTTP/1.0 caches to (hopefully) do an end-to-end reload\n\t\t\trequest.setHeader(new BasicHeader(\"Pragma\", \"no-cache\"));\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized void process(HttpResponse response) {\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ResponseContentCustom.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpResponseInterceptor;\nimport org.apache.http.HttpStatus;\nimport org.apache.http.HttpVersion;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.protocol.HttpContext;\n\n/**\n * Custom version of ResponseContent interceptor for outgoing responses. Instead of disallowing Content-Length or\n * Transfer-Encoding headers, overwrite them with valid values. Also ensure they are not set when the response\n * does not contain an entity body.\n */\npublic class ResponseContentCustom implements HttpResponseInterceptor {\n\t\n    public ResponseContentCustom() {\n        super();\n    }\n    \n    public void process(final HttpResponse response, final HttpContext context)  throws HttpException, IOException {\n        if (response == null) {\n            throw new IllegalArgumentException(\"HTTP response may not be null\");\n        }\n\n        ProtocolVersion ver = response.getStatusLine().getProtocolVersion();\n        HttpEntity entity = response.getEntity();\n\n        if (entity != null) {\n            long len = entity.getContentLength();\n\n            if (entity.isChunked() && !ver.lessEquals(HttpVersion.HTTP_1_0)) {\n            \tresponse.removeHeaders(HTTP.CONTENT_LEN);\n            \tresponse.setHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);\n            } else if (len >= 0) {\n            \tresponse.removeHeaders(HTTP.TRANSFER_ENCODING);\n            \tresponse.setHeader(HTTP.CONTENT_LEN, Long.toString(entity.getContentLength()));\n            }\n\n            // Specify a content type if known\n            if (entity.getContentType() != null && !response.containsHeader(HTTP.CONTENT_TYPE)) {\n                response.addHeader(entity.getContentType()); \n            }\n\n            // Specify a content encoding if known\n            if (entity.getContentEncoding() != null && !response.containsHeader(HTTP.CONTENT_ENCODING)) {\n                response.addHeader(entity.getContentEncoding()); \n            }\n        } else {\n            int status = response.getStatusLine().getStatusCode();\n            if (status != HttpStatus.SC_NO_CONTENT \n                    && status != HttpStatus.SC_NOT_MODIFIED\n                    && status != HttpStatus.SC_RESET_CONTENT) {\n                response.setHeader(HTTP.CONTENT_LEN, \"0\");\n            }\n        }\n    }\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/VegaHttpRequestFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.MethodNotSupportedException;\nimport org.apache.http.RequestLine;\nimport org.apache.http.impl.DefaultHttpRequestFactory;\nimport org.apache.http.message.BasicHttpRequest;\n\n/**\n * Specialized HttpRequestFactory which allows requests with the 'CONNECT' method for supporting \n * SSL interception.\n */\npublic class VegaHttpRequestFactory extends DefaultHttpRequestFactory {\n\t\n\tprivate boolean isConnectMethod(String method) {\n\t\treturn (method != null && method.equalsIgnoreCase(\"CONNECT\"));\n\t}\n\t\n\t@Override\n\tpublic HttpRequest newHttpRequest(final RequestLine requestLine) throws MethodNotSupportedException {\n\t\tif(isConnectMethod(requestLine.getMethod())) {\n\t\t\treturn new BasicHttpRequest(requestLine);\n\t\t} else {\n\t\t\treturn super.newHttpRequest(requestLine);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic HttpRequest newHttpRequest(final String method, final String uri) throws MethodNotSupportedException {\n\t\tif(isConnectMethod(method)) {\n\t\t\treturn new BasicHttpRequest(method, uri);\n\t\t} else {\n\t\t\treturn super.newHttpRequest(method, uri);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/VegaHttpRequestParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.ConnectionClosedException;\nimport org.apache.http.Header;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpRequestFactory;\nimport org.apache.http.ParseException;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.RequestLine;\nimport org.apache.http.impl.io.AbstractMessageParser;\nimport org.apache.http.io.HttpMessageParser;\nimport org.apache.http.io.SessionInputBuffer;\nimport org.apache.http.message.BasicRequestLine;\nimport org.apache.http.message.LineParser;\nimport org.apache.http.message.ParserCursor;\nimport org.apache.http.params.CoreConnectionPNames;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.util.CharArrayBuffer;\n\n/**\n * HTTP request parser based on HttpRequestParser and AbstractMessageParser. Attaches scheme and host information to a \n * request line URI when the connection is performing SSL MITM so the request still contains an absoluteURI as it would\n * for an ordinary proxy request.\n */\npublic class VegaHttpRequestParser implements HttpMessageParser<HttpRequest> {\n\tprivate final VegaHttpServerConnection conn;\n    private final SessionInputBuffer sessionBuffer;\n    private final HttpRequestFactory requestFactory;\n    private final CharArrayBuffer lineBuf;\n    private final LineParser lineParser;\n    private final int maxHeaderCount;\n    private final int maxLineLen;\n\n    public VegaHttpRequestParser(final VegaHttpServerConnection conn, final SessionInputBuffer buffer, final LineParser parser, final HttpRequestFactory requestFactory, final HttpParams params) {\n        if (requestFactory == null) {\n            throw new IllegalArgumentException(\"Request factory may not be null\");\n        }\n        this.conn = conn;\n        this.sessionBuffer = buffer;\n        this.lineParser = parser;\n        this.requestFactory = requestFactory;\n        this.lineBuf = new CharArrayBuffer(128);\n        this.maxHeaderCount = params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1);\n        this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);\n    }\n\n    private RequestLine parseRequestLine(final SessionInputBuffer sessionBuffer) throws IOException, HttpException, ParseException {\n        lineBuf.clear();\n        int i = sessionBuffer.readLine(lineBuf);\n        if (i == -1) {\n            throw new ConnectionClosedException(\"Client closed connection\");\n        }\n        ParserCursor cursor = new ParserCursor(0, lineBuf.length());\n        return lineParser.parseRequestLine(lineBuf, cursor);\n    }\n    \n    @Override\n    public HttpRequest parse() throws IOException, HttpException {\n    \tRequestLine requestLine;\n        try {\n        \trequestLine = parseRequestLine(sessionBuffer);\n        } catch (ParseException px) {\n            throw new ProtocolException(px.getMessage(), px);\n        }\n\n        List<CharArrayBuffer> headerLines = new ArrayList<CharArrayBuffer>();\n        Header[] headers = AbstractMessageParser.parseHeaders(sessionBuffer, maxHeaderCount, maxLineLen, lineParser, headerLines);\n\n        if (conn.isSslConnection()) {\n        \tURI uri;\n        \ttry {\n        \t\turi = new URI(requestLine.getUri());\n        \t} catch (URISyntaxException e) {\n        \t\tthrow new ProtocolException(\"Invalid URI: \" + requestLine.getUri(), e);\n        \t}\n            if (uri.getScheme() == null) {\n            \tfinal Header hostHeader = getFirstHeader(headers, HTTP.TARGET_HOST);\n            \tfinal StringBuilder buf = new StringBuilder();\n            \tif (hostHeader != null) {\n            \t\t// REVISIT: does using the Host header value instead of the SSL host risk opening another connection?\n            \t\tbuf.append(\"https://\");\n            \t\tbuf.append(hostHeader.getValue());\n            \t} else {\n            \t\tbuf.append(conn.getSslHost().toURI());\n            \t}\n            \tbuf.append(uri.getRawPath());\n            \tif (uri.getRawQuery() != null) {\n            \t\tbuf.append(\"?\");\n            \t\tbuf.append(uri.getRawQuery());\n            \t}\n\n            \trequestLine = new BasicRequestLine(requestLine.getMethod(), buf.toString(), requestLine.getProtocolVersion());\n            }\n        }\n\n        HttpRequest message = requestFactory.newHttpRequest(requestLine);\n        message.setHeaders(headers);\n        return message;\n    }\n\n    private Header getFirstHeader(Header[] headers, String name) {\n        for (int i = 0; i < headers.length; i++) {\n            if (headers[i].getName().equalsIgnoreCase(name)) {\n                return headers[i];\n            }\n        }\n        return null;\n    }\n    \n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/VegaHttpServerConnection.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.net.Socket;\n\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpRequestFactory;\nimport org.apache.http.impl.SocketHttpServerConnection;\nimport org.apache.http.io.HttpMessageParser;\nimport org.apache.http.io.SessionInputBuffer;\nimport org.apache.http.message.BasicLineParser;\nimport org.apache.http.params.HttpConnectionParams;\nimport org.apache.http.params.HttpParams;\n\n/**\n * Specialized HttpServerConnection which overrides createHttpRequestFactor() to return\n * an HttpRequestFactory instance which can process the 'CONNECT' method for supporting\n * SSL interception.\n */\npublic class VegaHttpServerConnection extends SocketHttpServerConnection {\n\tprivate HttpRequest cachedRequest;\n\tprivate final HttpParams params;\n\tprivate HttpHost sslHost; /** Information about SSL host */\n\n\tpublic VegaHttpServerConnection(HttpParams params) {\n\t\tthis.params = params;\n\t}\n\n\t@Override\n\tprotected HttpRequestFactory createHttpRequestFactory() {\n\t\treturn new VegaHttpRequestFactory();\n\t}\n\n\t@Override\n    protected HttpMessageParser<HttpRequest> createRequestParser(final SessionInputBuffer buffer, final HttpRequestFactory requestFactory, final HttpParams params) {\n        return new VegaHttpRequestParser(this, buffer, new BasicLineParser(), requestFactory, params);\n    }\n\n\tpublic boolean isSslConnection() {\n\t\treturn (sslHost != null);\n\t}\n\n\tpublic HttpHost getSslHost() {\n\t\treturn sslHost;\n\t}\n\t\n\tpublic void rebindWithSSL(Socket socket, HttpHost httpHost) throws IOException {\n\t\tsslHost = new HttpHost(httpHost);\n\t\tbind(socket, params);\n\t}\n\n\tpublic void bind(final Socket socket, final HttpParams params) throws IOException {\n\t\tif (socket == null) {\n\t\t\tthrow new IllegalArgumentException(\"Socket may not be null\");\n\t\t}\n\t\tif (params == null) {\n\t\t\tthrow new IllegalArgumentException(\"HTTP parameters may not be null\");\n\t\t}\n\n\t\tsocket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));\n\t\tsocket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));\n\n\t\tint linger = HttpConnectionParams.getLinger(params);\n\t\tif (linger >= 0) {\n\t\t\tsocket.setSoLinger(linger > 0, linger);\n\t\t}\n\n\t\tsuper.bind(socket, params);\n\t}\n\n\tHttpRequest peekRequestHeader() throws HttpException, IOException {\n\t\tif(cachedRequest != null) \n\t\t\tthrow new IllegalStateException(\"A cached peeked request already exists\");\n\t\tcachedRequest = super.receiveRequestHeader();\n\t\treturn cachedRequest;\n\t}\n\n\tvoid dropCachedPeekRequest() {\n\t\tif(cachedRequest == null)\n\t\t\tthrow new IllegalStateException(\"Cannot drop cached peek request, because no request is cached.\");\n\t\tcachedRequest = null;\n\t}\n\n\t@Override\n\tpublic HttpRequest receiveRequestHeader() throws HttpException, IOException {\n\t\tif(cachedRequest != null) {\n\t\t\tfinal HttpRequest result = cachedRequest;\n\t\t\tcachedRequest = null;\n\t\t\treturn result;\n\t\t}\n\t\treturn super.receiveRequestHeader();\n\t}\n\n\tpublic Socket getSocket() {\n\t\treturn super.getSocket();\n\t}\n\n\tpublic String toString() {\n\t\tStringBuffer buffer = new StringBuffer();\n\t\tbuffer.append(\"[\");\n\t\tif (isOpen()) {\n\t\t\tbuffer.append(getRemotePort());\n\t\t} else {\n\t\t\tbuffer.append(\"closed\");\n\t\t}\n\t\tbuffer.append(\"]\");\n\t\treturn buffer.toString();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/VegaHttpService.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy;\n\nimport java.io.IOException;\nimport java.net.Socket;\n\nimport javax.net.ssl.SSLContext;\nimport javax.net.ssl.SSLHandshakeException;\nimport javax.net.ssl.SSLSocket;\nimport javax.net.ssl.SSLSocketFactory;\n\nimport org.apache.http.ConnectionReuseStrategy;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpResponseFactory;\nimport org.apache.http.HttpStatus;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HttpContext;\nimport org.apache.http.protocol.HttpProcessor;\nimport org.apache.http.protocol.HttpRequestHandlerResolver;\nimport org.apache.http.protocol.HttpService;\nimport org.apache.http.util.EncodingUtils;\n\nimport com.subgraph.vega.internal.http.proxy.ssl.SSLContextRepository;\n\n/**\n * Specialized HttpService which handles SSL connections.\n */\npublic class VegaHttpService {\n\tprivate final static int DEFAULT_SSL_PORT = 443;\n\n\tprivate final HttpResponseFactory responseFactory;\n\tprivate final HttpProcessor processor;\n\tprivate final HttpService delegatedHttpService;\n\tprivate final SSLContextRepository sslContextRepository;\n\tprivate final boolean sslEnabled;\n\n\tpublic VegaHttpService(HttpProcessor proc, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams params, SSLContextRepository sslContextRepository) {\n\t\tthis.delegatedHttpService = new HttpService(proc, connStrategy, responseFactory, handlerResolver, params);\n\t\tthis.sslContextRepository = sslContextRepository;\n\t\tthis.sslEnabled = (sslContextRepository != null);\n\t\tthis.responseFactory = responseFactory;\n\t\tthis.processor = proc;\n\t}\n\n\tpublic void handleRequest(final VegaHttpServerConnection conn, final HttpContext context) throws IOException, HttpException {\n\t\tif(!sslEnabled) {\n\t\t\tdelegatedHttpService.handleRequest(conn, context);\n\t\t\treturn;\n\t\t}\n\n\t\tfinal HttpRequest peekRequest = conn.peekRequestHeader();\n\n\t\tif(isCertificateDownload(peekRequest)) {\n\t\t\tconn.dropCachedPeekRequest();\n\t\t\tsendCertificateDownloadResponse(conn, context);\n\t\t} else if(isConnectMethodRequest(peekRequest)) {\n\t\t\tconn.dropCachedPeekRequest();\n\t\t\thandleConnect(conn, peekRequest, context);\n\t\t} else {\n\t\t\tdelegatedHttpService.handleRequest(conn, context);\n\t\t}\n\t}\n\n\tprivate void handleConnect(VegaHttpServerConnection conn, HttpRequest request, HttpContext context) throws IOException, HttpException {\n\t\tfinal HttpHost host = createHostForConnectUri(request.getRequestLine().getUri());\n\t\tfinal SSLSocket sslSocket = createSSLSocketForHost(host, conn.getSocket());\n\n\t\tsendResponseOk(conn, context);\n\t\tconn.rebindWithSSL(sslSocket, host);\n\n\t\ttry {\n\t\t\tsslSocket.startHandshake();\n\t\t} catch (SSLHandshakeException e) {\n\t\t\tconn.close();\n\t\t\treturn;\n\t\t}\n\t\tdelegatedHttpService.handleRequest(conn, context);\n\t}\n\n\tprivate HttpHost createHostForConnectUri(String uri) {\n\t\tfinal String[] parts = uri.split(\":\");\n\t\tfinal String hostname = parts[0].toLowerCase();\n\t\tfinal int port = (parts.length < 2) ? (DEFAULT_SSL_PORT) : (stringToSSLPort(parts[1]));\n\t\treturn new HttpHost(hostname, port, \"https\");\n\t}\n\n\tprivate int stringToSSLPort(String s) {\n\t\tif(s == null || s.isEmpty())\n\t\t\treturn DEFAULT_SSL_PORT;\n\t\ttry {\n\t\t\treturn Integer.parseInt(s);\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn DEFAULT_SSL_PORT;\n\t\t}\n\t}\n\n\tprivate void sendCertificateDownloadResponse(VegaHttpServerConnection connection, HttpContext context) throws HttpException, IOException {\n\t\tfinal String pem = sslContextRepository.getCaCertificatePem();\n\t\tfinal byte[] body = EncodingUtils.getAsciiBytes(pem);\n\t\tByteArrayEntity entity = new ByteArrayEntity(body);\n\t\tentity.setContentType(\"application/x-x509-ca-cert; charset=US-ASCII\");\n\t\tsendResponseOk(connection, context, entity);\n\t}\n\n\tprivate void sendResponseOk(VegaHttpServerConnection connection, HttpContext context) throws HttpException, IOException {\n\t\tsendResponseOk(connection, context, null);\n\t}\n\n\tprivate void sendResponseOk(VegaHttpServerConnection connection, HttpContext context, HttpEntity entity) throws HttpException, IOException {\n\t\tfinal ProtocolVersion version = new ProtocolVersion(\"HTTP\", 1, 0);\n\t\tfinal HttpResponse response = responseFactory.newHttpResponse(version, HttpStatus.SC_OK, context);\n\t\tif(entity != null)\n\t\t\tresponse.setEntity(entity);\n\t\tprocessor.process(response, context);\n\t\tconnection.sendResponseHeader(response);\n\t\tconnection.sendResponseEntity(response);\n\t\tconnection.flush();\n\t}\n\n\tprivate SSLSocket createSSLSocketForHost(HttpHost host, Socket socket) throws IOException {\n\t\tfinal SSLContext ctx = sslContextRepository.getContextForName(host.getHostName());\n\t\tif(ctx == null) {\n\t\t\tthrow new IOException(\"Failed to create SSLContext for host \"+ host.getHostName());\n\t\t}\n\t\tSSLSocketFactory sslSocketFactory = ctx.getSocketFactory();\n\t\tSSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, host.getHostName(), host.getPort(), true);\n\t\tsslSocket.setUseClientMode(false);\n\t\treturn sslSocket;\n\t}\n\n\tprivate boolean isConnectMethodRequest(HttpRequest request) {\n\t\tfinal String method = request.getRequestLine().getMethod();\n\t\treturn (method != null && method.equalsIgnoreCase(\"CONNECT\"));\n\t}\n\n\tprivate boolean isCertificateDownload(HttpRequest request) {\n\t\treturn request.getRequestLine().getUri().toLowerCase().equals(\"http://vega/ca.crt\");\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/CertificateCreator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy.ssl;\n\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.security.GeneralSecurityException;\nimport java.security.KeyPair;\nimport java.security.KeyPairGenerator;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.PrivateKey;\nimport java.security.PublicKey;\nimport java.security.Signature;\nimport java.security.cert.CertificateException;\nimport java.security.cert.X509Certificate;\nimport java.util.Date;\nimport java.util.HashSet;\nimport java.util.Set;\nimport java.util.Vector;\n\nimport javax.security.auth.x500.X500Principal;\n\nimport org.apache.commons.codec.binary.Base64;\n\nimport sun.security.util.ObjectIdentifier;\nimport sun.security.x509.AlgorithmId;\nimport sun.security.x509.AuthorityKeyIdentifierExtension;\nimport sun.security.x509.BasicConstraintsExtension;\nimport sun.security.x509.CertificateAlgorithmId;\nimport sun.security.x509.CertificateExtensions;\nimport sun.security.x509.CertificateIssuerName;\nimport sun.security.x509.CertificateSerialNumber;\nimport sun.security.x509.CertificateSubjectName;\nimport sun.security.x509.CertificateValidity;\nimport sun.security.x509.CertificateVersion;\nimport sun.security.x509.CertificateX509Key;\nimport sun.security.x509.ExtendedKeyUsageExtension;\nimport sun.security.x509.KeyIdentifier;\nimport sun.security.x509.KeyUsageExtension;\nimport sun.security.x509.NetscapeCertTypeExtension;\nimport sun.security.x509.SubjectKeyIdentifierExtension;\nimport sun.security.x509.X500Name;\nimport sun.security.x509.X509CertImpl;\nimport sun.security.x509.X509CertInfo;\n\n\n/**\n * This class creates new certificates, optionally signing them with a CA certificate \n * which is generated and stored persistently in a <code>KeyStore</code> through the \n * <code>CertificateStore</code> class.\n */\npublic class CertificateCreator {\n\tprivate final static String CA_SUBJECT_NAME = \"cn=Vega Proxy Certificate Authority,ou=Vega Web Vulnerability Scanner,o=Subgraph,l=Montreal,st=Quebec,c=CA\";\n\tprivate final static String SIGNATURE_ALGORITHM = \"SHA1withRSA\";\n\tprivate final static long DEFAULT_VALIDITY = 60L * 60L * 24L * 365L * 5L * 1000L; // 5 years in microseconds\n\n\tprivate final CertificateStore certificateStore;\n\tprivate final KeyPairGenerator keyGenerator;\n\tprivate final Set<BigInteger> serials = new HashSet<BigInteger>();\n\tprivate final X500Principal caSubject;\n\tprivate KeyPair fixedKeyPair;\n\n\tprivate PrivateKey caPrivateKey;\n\tprivate PublicKey caPublicKey;\n\tprivate X509Certificate caCertificate;\n\tprivate String caPemCertificate;\n\n\tprivate boolean useFixedKeys = false;\n\tprivate boolean useSelfSigned = false;\n\n\tpublic CertificateCreator(CertificateStore certificateStore) throws CertificateException, IOException {\n\t\tthis.certificateStore = certificateStore;\n\t\tkeyGenerator = createKeyGenerator();\n\t\tcaSubject = new X500Principal(CA_SUBJECT_NAME);\n\t\tinitialize();\n\t}\n\n\tprivate void initialize() throws IOException, CertificateException {\n\t\tif(certificateStore.containsCaCertificate()) {\n\t\t\tcaCertificate = certificateStore.getCaCertificate();\n\t\t\tcaPrivateKey = certificateStore.getCaPrivateKey();\n\t\t\tcaPublicKey = caCertificate.getPublicKey();\n\t\t\tcaPemCertificate = createPemCertificate(caCertificate);\n\t\t\treturn;\n\t\t}\n\t\tfinal KeyPair caKeyPair = keyGenerator.generateKeyPair();\n\t\tcaPublicKey = caKeyPair.getPublic();\n\t\tcaPrivateKey = caKeyPair.getPrivate();\n\t\tcaCertificate = generateCertificate(caSubject, caKeyPair.getPublic(), caSubject, caPublicKey, caPrivateKey, true);\n\t\tcertificateStore.saveCaCertificate(caCertificate, caPrivateKey);\n\t\tcaPemCertificate = createPemCertificate(caCertificate);\n\t}\n\n\tprivate String createPemCertificate(X509Certificate certificate) throws CertificateException {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfinal Base64 b64 = new Base64(64);\n\n\t\tsb.append(\"-----BEGIN CERTIFICATE-----\\r\\n\");\n\t\tsb.append(b64.encodeToString(certificate.getEncoded()));\n\t\tsb.append(\"-----END CERTIFICATE-----\\r\\n\");\n\t\treturn sb.toString();\n\t}\n\n\tprivate KeyPairGenerator createKeyGenerator() throws CertificateException {\n\t\ttry {\n\t\t\tfinal KeyPairGenerator kpg = KeyPairGenerator.getInstance(\"RSA\");\n\t\t\tkpg.initialize(1024);\n\t\t\treturn kpg;\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\tthrow new CertificateException(\"Failed to create RSA key pair generator.\"+ e.getMessage());\n\t\t}\n\t}\n\n\tpublic String getCaCertificatePem() {\n\t\treturn caPemCertificate;\n\t}\n\n\tpublic HostCertificateData createCertificateDataFor(String name) throws CertificateException {\n\t\tfinal X500Principal subject = getSubjectForCommonName(name);\n\t\tfinal KeyPair subjectKeys = getKeyPairForNewCertificate();\n\t\tif(useSelfSigned) {\n\t\t\treturn createSelfSignedCertificateDataFor(subject, subjectKeys);\n\t\t} else {\n\t\t\treturn createCaSignedCertificateDataFor(subject, subjectKeys);\n\t\t}\n\t}\n\n\tprivate HostCertificateData createCaSignedCertificateDataFor(X500Principal subject, KeyPair subjectKeys) throws CertificateException {\n\t\tfinal X509Certificate[] chain = new X509Certificate[2];\n\t\tchain[0] = generateCertificate(subject, subjectKeys.getPublic(), caSubject, caPublicKey, caPrivateKey, false);\n\t\tchain[1] = caCertificate;\n\t\treturn new HostCertificateData(subject.getName(), subjectKeys.getPrivate(), chain);\n\t}\n\n\tprivate HostCertificateData createSelfSignedCertificateDataFor(X500Principal subject, KeyPair subjectKeys) throws CertificateException {\n\t\tfinal X509Certificate[] chain = new X509Certificate[1];\n\t\tchain[0] = generateCertificate(subject, subjectKeys.getPublic(), subject, subjectKeys.getPublic(), subjectKeys.getPrivate(), false);\n\t\treturn new HostCertificateData(subject.getName(), subjectKeys.getPrivate(), chain);\n\t}\n\n\tprivate KeyPair getKeyPairForNewCertificate() {\n\t\tif(useFixedKeys)\n\t\t\treturn getFixedKeyPair();\n\t\telse\n\t\t\treturn keyGenerator.generateKeyPair();\n\t}\n\n\tprivate synchronized KeyPair getFixedKeyPair() {\n\t\tif(fixedKeyPair == null) {\n\t\t\tfixedKeyPair = keyGenerator.generateKeyPair();\n\t\t}\n\t\treturn fixedKeyPair;\n\t}\n\n\tprivate X500Principal getSubjectForCommonName(String name) {\n\t\treturn new X500Principal(\"cn=\"+ name + \",ou=Vega Generated Certificate,o=Subgraph\");\n\t}\n\n\tprivate BigInteger getNextSerialNumber() {\n\t\tBigInteger serial = BigInteger.valueOf(System.currentTimeMillis());\n\t\tsynchronized(serials) {\n\t\t\twhile(serials.contains(serial))\n\t\t\t\tserial = serial.add(BigInteger.ONE);\n\t\t\tserials.add(serial);\n\t\t\treturn serial;\n\t\t}\n\t}\n\n\tprivate X509Certificate generateCertificate(X500Principal subject, PublicKey subjectPublic, X500Principal issuer, PublicKey issuerPublicKey, PrivateKey issuerPrivateKey, boolean isCaCert) throws CertificateException {\t\n\t\ttry {\n\t\t\tfinal Date notBefore = new Date();\n\t\t\tfinal Date notAfter = new Date(notBefore.getTime() + DEFAULT_VALIDITY);\n\t\t\tfinal CertificateSigner signer = createCertificateSigner(issuer, issuerPrivateKey);\n\t\t\tfinal CertificateValidity validity = new CertificateValidity(notBefore, notAfter);\n\t\t\tfinal X509CertInfo info = createCertificateInfo(subject, subjectPublic, issuer, issuerPublicKey, validity, signer);\n\t\t\tfinal CertificateExtensions extensions = (isCaCert) ? (getCACertificateExtensions()) : (getCertificateExtensions(subjectPublic, issuerPublicKey));\n\t\t\tinfo.set(X509CertInfo.EXTENSIONS, extensions);\n\t\t\tfinal X509CertImpl cert = new X509CertImpl(info);\n\t\t\tcert.sign(issuerPrivateKey, SIGNATURE_ALGORITHM);\n\t\t\treturn cert;\n\t\t} catch (Exception e) {\n\t\t\tthrow new CertificateException(\"Failed to generate certificate: \"+ e.getMessage(), e);\n\t\t}\n\t}\n\n\tprivate CertificateSigner createCertificateSigner(X500Principal issuer, PrivateKey issuerPrivate) throws IOException, GeneralSecurityException {\n\t\tfinal X500Name issuerName = new X500Name(issuer.getName());\n\t\tfinal Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);\n\t\tsignature.initSign(issuerPrivate);\n\t\treturn new CertificateSigner(signature, issuerName);\n\t}\n\n\tprivate X509CertInfo createCertificateInfo(X500Principal subject, PublicKey subjectPublic, X500Principal issuer, PublicKey issuerPublic, CertificateValidity validity, CertificateSigner signer) throws IOException, GeneralSecurityException {\n\t\tfinal BigInteger serialNumber = getNextSerialNumber();\n\t\tfinal X500Name subjectName = new X500Name(subject.getName());\n\t\tfinal X509CertInfo info = new X509CertInfo();\n\t    \n\t\t// Java 8 introduces more changes to the Sun X.509 classes\n\t\t// TODO: do this right\n\t\t\n\t    double ver = javaVersionAsFloat();\n\n\t\t// Add all mandatory attributes\n\n\t\tinfo.set(X509CertInfo.VERSION, new CertificateVersion(\n\t\t\t\tCertificateVersion.V3));\n\t\tinfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(\n\t\t\t\tserialNumber));\n\t\tAlgorithmId algID = signer.getAlgorithmId();\n\t\tinfo.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(\n\t\t\t\talgID));\n\n\n\t\tif (ver >= 1.8) {\n\t\t\tinfo.set(X509CertInfo.SUBJECT, subjectName);\n\t\t\tinfo.set(X509CertInfo.ISSUER, signer.getSigner());\n\t\t} else {\n\t\t\tinfo.set(X509CertInfo.ISSUER, new CertificateIssuerName(signer.getSigner()));\n\t\t\tinfo.set(X509CertInfo.SUBJECT, new CertificateSubjectName(subjectName));\t\t\t\t\n\t\t}\n\t\t\n\t\tinfo.set(X509CertInfo.KEY, new CertificateX509Key(subjectPublic));\n\t\tinfo.set(X509CertInfo.VALIDITY, validity);\n\t\t\n\t\treturn info;\n\t}\n\n\tprivate double javaVersionAsFloat() {\n\t \n\t\tint count = 0;\n\t\tint position = 0;\n\t\tdouble ver = 0;\n\t\tString versionProperty = System.getProperty(\"java.version\");\n\n\t    for (; position < versionProperty.length() && count < 2; position++) {\n\t        if (versionProperty.charAt(position) == '.') {\n\t            count++;\n\t        }\n\t    }\n\t    position--;\n\n\t    ver = Double.parseDouble(versionProperty.substring(0, position));\n\t    \n\t    return ver;\n\t    \n\t}\n\n\tprivate static CertificateExtensions getCACertificateExtensions() throws IOException {\n\t\tCertificateExtensions ext = new CertificateExtensions();\n\n\t\t// Basic Constraints\n\t\text.set(BasicConstraintsExtension.NAME, new BasicConstraintsExtension(\n\t\t\t\t/* isCritical */true, /* isCA */true, 0));\n\n\t\treturn ext;\n\t}\n\n\tprivate static CertificateExtensions getCertificateExtensions(\n\t\t\tPublicKey pubKey, PublicKey caPubKey) throws IOException {\n\t\tCertificateExtensions ext = new CertificateExtensions();\n\n\t\text.set(SubjectKeyIdentifierExtension.NAME,\n\t\t\t\tnew SubjectKeyIdentifierExtension(new KeyIdentifier(pubKey)\n\t\t\t\t.getIdentifier()));\n\n\t\text.set(AuthorityKeyIdentifierExtension.NAME,\n\t\t\t\tnew AuthorityKeyIdentifierExtension(\n\t\t\t\t\t\tnew KeyIdentifier(caPubKey), null, null));\n\n\t\t// Basic Constraints\n\t\text.set(BasicConstraintsExtension.NAME, new BasicConstraintsExtension(\n\t\t\t\t/* isCritical */true, /* isCA */false, /* pathLen */5));\n\n\t\t// Netscape Cert Type Extension\n\t\tboolean[] ncteOk = new boolean[8];\n\t\tncteOk[0] = true; // SSL_CLIENT\n\t\tncteOk[1] = true; // SSL_SERVER\n\t\tNetscapeCertTypeExtension ncte = new NetscapeCertTypeExtension(ncteOk);\n\t\tncte = new NetscapeCertTypeExtension(false, ncte.getExtensionValue());\n\t\text.set(NetscapeCertTypeExtension.NAME, ncte);\n\n\t\t// Key Usage Extension\n\t\tboolean[] kueOk = new boolean[9];\n\t\tkueOk[0] = true;\n\t\tkueOk[2] = true;\n\t\t// \"digitalSignature\", // (0),\n\t\t// \"nonRepudiation\", // (1)\n\t\t// \"keyEncipherment\", // (2),\n\t\t// \"dataEncipherment\", // (3),\n\t\t// \"keyAgreement\", // (4),\n\t\t// \"keyCertSign\", // (5),\n\t\t// \"cRLSign\", // (6),\n\t\t// \"encipherOnly\", // (7),\n\t\t// \"decipherOnly\", // (8)\n\t\t// \"contentCommitment\" // also (1)\n\t\tKeyUsageExtension kue = new KeyUsageExtension(kueOk);\n\t\text.set(KeyUsageExtension.NAME, kue);\n\n\t\t// Extended Key Usage Extension\n\t\tint[] serverAuthOidData = { 1, 3, 6, 1, 5, 5, 7, 3, 1 };\n\t\tObjectIdentifier serverAuthOid = new ObjectIdentifier(serverAuthOidData);\n\t\tint[] clientAuthOidData = { 1, 3, 6, 1, 5, 5, 7, 3, 2 };\n\t\tObjectIdentifier clientAuthOid = new ObjectIdentifier(clientAuthOidData);\n\t\tVector<ObjectIdentifier> v = new Vector<ObjectIdentifier>();\n\t\tv.add(serverAuthOid);\n\t\tv.add(clientAuthOid);\n\t\tExtendedKeyUsageExtension ekue = new ExtendedKeyUsageExtension(false, v);\n\t\text.set(ExtendedKeyUsageExtension.NAME, ekue);\n\n\t\treturn ext;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/CertificateSigner.java",
    "content": "package com.subgraph.vega.internal.http.proxy.ssl;\n\nimport java.security.NoSuchAlgorithmException;\nimport java.security.Signature;\n\nimport sun.security.x509.AlgorithmId;\nimport sun.security.x509.X500Name;\n\npublic class CertificateSigner {\n    private final X500Name agent;\n    private final AlgorithmId algid;\n\n    public AlgorithmId getAlgorithmId() {\n            return algid;\n    }\n\n    public X500Name getSigner() {\n            return agent;\n    }\n\n    CertificateSigner(Signature sig, X500Name agent) {\n            this.agent = agent;\n            try {\n                    this.algid = AlgorithmId.get(sig.getAlgorithm());\n            } catch (NoSuchAlgorithmException e) {\n                    throw new RuntimeException(\"Algorithm not found: \"+ e.getMessage());\n            }\n    }\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/CertificateStore.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy.ssl;\n\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.security.GeneralSecurityException;\nimport java.security.KeyStore;\nimport java.security.KeyStoreException;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.PrivateKey;\nimport java.security.cert.Certificate;\nimport java.security.cert.CertificateException;\nimport java.security.cert.X509Certificate;\n\n/**\n * A CertificateStore object manages creation of and access to a KeyStore\n * object which stores an authority certificate which will be used to sign\n * certificates which are used to intercept SSL connections made though\n * the proxy. \n */\npublic class CertificateStore {\n\tprivate final static String STORE_FILENAME = \"ca.p12\";\n\tprivate final static String STORE_TYPE = \"PKCS12\";\n\tprivate final static String STORE_KEY = \"CA\";\n\n\tprivate final File storeFile;\n\n\tprivate final char[] password;\n\tprivate final KeyStore keyStore;\n\tprivate PrivateKey caPrivateKey;\n\tprivate X509Certificate caCertificate;\n\n\tCertificateStore(File storageDirectory, String password) throws GeneralSecurityException, IOException {\n\t\tstoreFile = new File(storageDirectory, STORE_FILENAME);\n\t\tthis.password = password.toCharArray();\n\t\tkeyStore = KeyStore.getInstance(STORE_TYPE);\n\t\tinitKeyStore();\n\t}\n\n\tprivate void initKeyStore() throws GeneralSecurityException, IOException {\n\t\tif(!storeFile.exists() || !loadFromFile()) {\n\t\t\tkeyStore.load(null, password);\n\t\t}\n\t}\n\n\tprivate boolean loadFromFile() throws GeneralSecurityException, IOException {\n\t\tInputStream input = null;\n\t\ttry {\n\t\t\tinput = new FileInputStream(storeFile);\n\t\t\tkeyStore.load(input, password);\n\t\t\tcaPrivateKey = (PrivateKey) keyStore.getKey(STORE_KEY, password);\n\t\t\tfinal Certificate[] chain = keyStore.getCertificateChain(STORE_KEY);\n\t\t\tcaCertificate = (X509Certificate) chain[0];\n\t\t\treturn true;\n\t\t} catch (FileNotFoundException e) {\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tif(input != null)\n\t\t\t\tinput.close();\n\t\t}\n\t}\n\n\tpublic boolean containsCaCertificate() {\n\t\treturn (caPrivateKey != null && caCertificate != null);\t\t\n\t}\n\n\tpublic PrivateKey getCaPrivateKey() {\n\t\treturn caPrivateKey;\n\t}\n\n\tpublic X509Certificate getCaCertificate() {\n\t\treturn caCertificate;\n\t}\n\n\tpublic void saveCaCertificate(X509Certificate certificate, PrivateKey privateKey) throws CertificateException {\n\t\tfinal Certificate[] chain = new Certificate[1];\n\t\tchain[0] = certificate;\n\t\ttry {\n\t\t\tkeyStore.setKeyEntry(STORE_KEY, privateKey, password, chain);\n\t\t\tfinal OutputStream output = new FileOutputStream(storeFile);\n\t\t\twriteKeyStore(output);\n\t\t\tstoreFile.setWritable(false, false);\n\t\t\tstoreFile.setReadable(false, false);\n\t\t\tstoreFile.setReadable(true, true);\n\t\t\tcaCertificate = certificate;\n\t\t\tcaPrivateKey = privateKey;\n\t\t} catch (KeyStoreException e) {\n\t\t\tthrow new CertificateException(\"Failed to store CA certificate in key store: \"+ e.getMessage());\n\t\t} catch (FileNotFoundException e) {\n\t\t\tthrow new CertificateException(\"Could not open key store file '\" + storeFile + \"' for writing.\");\n\t\t}\n\t}\n\n\tprivate void writeKeyStore(OutputStream output) throws CertificateException {\n\t\ttry {\n\t\t\tkeyStore.store(output, password);\n\t\t} catch (KeyStoreException e) {\n\t\t\tthrow new CertificateException(\"Failed to store CA certificate in key store: \"+ e.getMessage());\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\tthrow new CertificateException(\"Failed to find algorithm for serializing certificate data: \"+ e.getMessage());\n\t\t} catch (CertificateException e) {\n\t\t\tthrow new CertificateException(\"Attempt to store invalid certificate: \"+ e.getMessage());\n\t\t} catch (IOException e) {\n\t\t\tthrow new CertificateException(\"I/O error writing to certificate store file: \"+ e.getMessage());\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\toutput.close();\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new CertificateException(\"I/O error closing certificate store\", e);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/HostCertificateData.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy.ssl;\n\nimport java.security.PrivateKey;\nimport java.security.cert.X509Certificate;\n\n/**\n * A simple data class which associates a hostname with a temporary <code>PrivateKey</code> and\n * <code>X509Certificate</code> chain which has been generated (and optionally signed with a generated CA\n * certificate) to intercept an SSL connection to the given hostname.\n */\npublic class HostCertificateData {\n\tprivate final String hostname;\n\tprivate final PrivateKey privateKey;\n\tprivate final X509Certificate[] certificateChain;\n\t\n\tHostCertificateData(String hostname, PrivateKey privateKey, X509Certificate[] certificateChain) {\n\t\tthis.hostname = hostname;\n\t\tthis.privateKey = privateKey;\n\t\tthis.certificateChain = certificateChain;\n\t}\n\n\tString getHostname() {\n\t\treturn hostname;\n\t}\n\n\tPrivateKey getPrivateKey() {\n\t\treturn privateKey;\n\t}\n\n\tX509Certificate[] getCertificateChain() {\n\t\treturn certificateChain;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/ProxySSLInitializationException.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy.ssl;\n\npublic class ProxySSLInitializationException extends Exception {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tProxySSLInitializationException(String message) {\n\t\tsuper(message);\n\t}\n\n\tProxySSLInitializationException(String message, Throwable throwable) {\n\t\tsuper(message, throwable);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/SSLContextRepository.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy.ssl;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.security.GeneralSecurityException;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport javax.net.ssl.KeyManager;\nimport javax.net.ssl.SSLContext;\nimport javax.net.ssl.X509KeyManager;\n\n/**\n * SSLContextRepository is the public interface to the subsystem which generates certificates\n * for intercepting SSL connections through the proxy.  This class will create suitable \n * <code>SSLContext</code> instances on demand for a requested hostname, including dynamically\n * generating a validly signed SSL certificate, and caches the <code>SSLContext</code> objects\n * for future requests for SSL connections to the same hostname.\n */\npublic class SSLContextRepository {\n\t/**\n\t * Creates a new instance of this class configured to persistently store the proxy CA certificate\n\t * in the given directory.  If a <code>KeyStore</code> container already exists in this directory,\n\t * the proxy CA certificate will be loaded from the container, otherwise a new CA certificate will \n\t * be generated and stored in a container in this directory.\n\t * \n\t * @param storeDirectory The path to store a <code>KeyStore</code> containing the proxy CA certificate.\n\t * @return A new instance of this class.\n\t * \n\t * @throws ProxySSLInitializationException If the SSL subsystem could not be initialized, indicating that\n\t *         SSL support must be disabled in the proxy.\n\t */\n\tpublic static SSLContextRepository createInstance(File storeDirectory) throws ProxySSLInitializationException {\n\t\treturn new SSLContextRepository(storeDirectory);\n\t}\n\n\tprivate final static Logger logger = Logger.getLogger(\"proxy\");\n\tprivate final File storeDirectory;\n\tprivate final Map<String, SSLContext> contextMap;\n\tprivate final CertificateCreator certificateCreator;\n\tprivate CertificateStore certificateStore;\n\t\n\t/**\n\t * Returns the proxy certificate authority certificate in a PEM encoded format.\n\t * \n\t * @return The CA certificate for the proxy PEM encoded as a String.\n\t */\n\tpublic String getCaCertificatePem() {\n\t\treturn certificateCreator.getCaCertificatePem();\n\t}\n\t\n\t/**\n\t * Returns an <code>SSLContext</code> instance for a connection identified by the\n\t * specified hostname.  The returned <code>SSLContext</code> is configured to present\n\t * a validly signed <code>X509Certificate</code> chain for the given hostname to the \n\t * connecting client.\n\t * \n\t * @param hostname The hostname for which a signed certificate chain will be generated.\n\t * \n\t * @return An <code>SSLContext</code> which is suitable for intercepting an SSL connection to\n\t *         <code>hostname</code>, or <code>null</code> if an error occurs while creating a new\n\t *         context.\n\t *        \n\t */\n\tpublic synchronized SSLContext getContextForName(String hostname) {\n\t\tif(contextMap.containsKey(hostname))\n\t\t\treturn contextMap.get(hostname);\n\n\t\ttry {\n\t\t\tfinal SSLContext ctx = createContextForName(hostname);\n\t\t\tcontextMap.put(hostname, ctx);\n\t\t\treturn ctx;\n\t\t} catch (GeneralSecurityException e) {\n\t\t\tlogger.log(Level.WARNING, \"Could not create security context for SSL connection\", e);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate SSLContextRepository(File storeDirectory) throws ProxySSLInitializationException {\n\t\tthis.storeDirectory = storeDirectory;\n\t\tcontextMap = new HashMap<String, SSLContext>();\n\t\tcertificateCreator = createCertificateCreator();\n\t}\n\n\tprivate CertificateCreator createCertificateCreator() throws ProxySSLInitializationException {\n\t\ttry {\n\t\t\tcertificateStore = new CertificateStore(storeDirectory, \"foo\");\n\t\t\treturn new CertificateCreator(certificateStore);\n\t\t} catch (GeneralSecurityException e) {\n\t\t\tthrow new ProxySSLInitializationException(\"Failed to create certificate creator: \"+ e.getMessage(), e);\n\t\t} catch (IOException e) {\n\t\t\tthrow new ProxySSLInitializationException(\"I/O error creating certificate creator: \"+ e.getMessage(), e);\n\t\t}\n\t}\n\n\tprivate SSLContext createContextForName(String name) throws GeneralSecurityException {\n\t\tfinal HostCertificateData hostCertificateData = certificateCreator.createCertificateDataFor(name);\n\t\tfinal X509KeyManager km = new VegaX509KeyManager(hostCertificateData);\n\t\tfinal SSLContext ctx = SSLContext.getInstance(\"SSLv3\");\n\t\tctx.init(new KeyManager[] {km}, null, null);\n\t\treturn ctx;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.proxy/src/com/subgraph/vega/internal/http/proxy/ssl/VegaX509KeyManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.proxy.ssl;\n\nimport java.net.Socket;\nimport java.security.Principal;\nimport java.security.PrivateKey;\nimport java.security.cert.X509Certificate;\n\nimport javax.net.ssl.X509KeyManager;\n\n/**\n * An <code>X509KeyManager</code> implementation which always returns a single certificate\n * chain. An instance of this class is used to initialize an <code>SSLContext</code> for an\n * intercepted SSL connection to a single host.\n *  \n *  @see SSLContext\n *  @see HostCertificateDatas\n *\n */\npublic class VegaX509KeyManager implements X509KeyManager {\n\n\tprivate final HostCertificateData data;\n\n\tpublic VegaX509KeyManager(HostCertificateData data) {\n\t\tthis.data = data;\n\t}\n\n\t@Override\n\tpublic String chooseClientAlias(String[] keyType, Principal[] issuers,\n\t\t\tSocket socket) {\n\t\tthrow new UnsupportedOperationException(\"Not implemented\");\n\t}\n\n\tpublic String chooseServerAlias(String keyType, Principal[] issuers,\n\t\t\tSocket socket) {\n\t\treturn data.getHostname();\n\t}\n\n\tpublic X509Certificate[] getCertificateChain(String alias) {\n\t\treturn copy(data.getCertificateChain());\n\t}\n\n\tpublic String[] getClientAliases(String keyType, Principal[] issuers) {\n\t\tthrow new UnsupportedOperationException(\"Not implemented\");\n\t}\n\n\tpublic PrivateKey getPrivateKey(String alias) {\n\t\treturn data.getPrivateKey();\n\t}\n\n\tpublic String[] getServerAliases(String keyType, Principal[] issuers) {\n\t\treturn new String[] { data.getHostname() };\n\t}\n\n\tprivate X509Certificate[] copy(X509Certificate[] certs) {\n\t\tif (certs == null)\n\t\t\treturn null;\n\t\tX509Certificate[] copy = new X509Certificate[certs.length];\n\t\tSystem.arraycopy(certs, 0, copy, 0, certs.length);\n\t\treturn copy;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.http.requests</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/.settings/org.eclipse.pde.core.prefs",
    "content": "#Mon Sep 13 10:40:39 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Http Requests\nBundle-SymbolicName: com.subgraph.vega.http.requests\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.subgraph.vega.api.events,\n com.subgraph.vega.api.html,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model.macros,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.tags,\n com.subgraph.vega.api.util,\n org.apache.commons.logging;version=\"1.1.1\",\n org.apache.http,\n org.apache.http.client,\n org.apache.http.client.methods,\n org.apache.http.client.params,\n org.apache.http.client.protocol,\n org.apache.http.client.utils;version=\"4.2.2\",\n org.apache.http.conn,\n org.apache.http.conn.params,\n org.apache.http.conn.routing;version=\"4.2.1\",\n org.apache.http.conn.scheme,\n org.apache.http.conn.ssl,\n org.apache.http.cookie;version=\"4.2.1\",\n org.apache.http.cookie.params;version=\"4.2.2\",\n org.apache.http.entity;version=\"4.0.0\",\n org.apache.http.impl.client,\n org.apache.http.impl.conn,\n org.apache.http.impl.conn.tsccm,\n org.apache.http.impl.cookie;version=\"4.2.2\",\n org.apache.http.impl.io;version=\"4.0.0\",\n org.apache.http.io;version=\"4.0.0\",\n org.apache.http.message;version=\"4.0.0\",\n org.apache.http.params;version=\"4.0.0\",\n org.apache.http.protocol;version=\"4.0.0\",\n org.apache.http.util;version=\"4.0.0\",\n org.w3c.dom.html2\nService-Component: OSGI-INF/request-engine-factory.xml\nExport-Package: com.subgraph.vega.http.requests.builder,\n com.subgraph.vega.http.requests.custom\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/OSGI-INF/request-engine-factory.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.request-engine-factory\">\n   <implementation class=\"com.subgraph.vega.internal.http.requests.HttpRequestEngineFactory\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory\"/>\n   </service>\n   <reference bind=\"setHTMLParser\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.html.IHTMLParser\" name=\"IHTMLParser\" policy=\"static\" unbind=\"unsetHTMLParser\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/builder/HttpHeaderBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.http.requests.builder;\n\nimport org.apache.http.Header;\nimport org.apache.http.message.BasicHeader;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\n\npublic class HttpHeaderBuilder implements IHttpHeaderBuilder {\n\tprivate String name;\n\tprivate String value;\n\t\n\tpublic HttpHeaderBuilder(String name, String value) {\n\t\tthis.name = name;\n\t\tthis.value = value;\n\t}\n\n\tpublic HttpHeaderBuilder(Header header) {\n\t\tname = header.getName();\n\t\tvalue = header.getValue();\n\t}\n\n\t@Override\n\tpublic void setFromHeader(Header header) {\n\t\tname = header.getName();\n\t\tvalue = header.getValue();\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic void setValue(String value) {\n\t\tthis.value = value;\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn value;\n\t}\n\n\t@Override\n\tpublic Header buildHeader() {\n\t\treturn new BasicHeader(name, value);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/builder/HttpMessageBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.http.requests.builder;\n\nimport java.util.ArrayList;\nimport java.util.Iterator;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HTTP;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpMessageBuilder;\n\npublic class HttpMessageBuilder implements IHttpMessageBuilder {\n\tprivate HttpParams params;\n\tprivate ProtocolVersion protocolVersion;\n\tprivate final ArrayList<HttpHeaderBuilder> headerList = new ArrayList<HttpHeaderBuilder>();\n\tprivate HttpEntity entity;\n\n\t@Override\n\tpublic void clear() {\n\t\tparams = null;\n\t\tprotocolVersion = null;\n\t\theaderList.clear();\n\t\tentity = null;\n\t}\n\n\t@Override\n\tpublic void setParams(HttpParams params) {\n\t\tthis.params = params;\n\t}\n\n\t@Override\n\tpublic HttpParams getParams() {\n\t\treturn params;\n\t}\n\n\t@Override\n\tpublic void setProtocolVersion(ProtocolVersion protocolVersion) {\n\t\tthis.protocolVersion = protocolVersion; \n\t}\n\n\t@Override\n\tpublic ProtocolVersion getProtocolVersion() {\n\t\treturn protocolVersion;\n\t}\n\n\t@Override\n\tpublic void setHeaders(Header[] headers) {\n\t\theaderList.clear();\n\t\tfor (Header h: headers) {\n\t\t\theaderList.add(new HttpHeaderBuilder(h));\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic HttpHeaderBuilder addHeader(String name, String value) {\n\t\tHttpHeaderBuilder header = new HttpHeaderBuilder(name, value);\n\t\theaderList.add(header);\n\t\treturn header;\n\t}\n\n\t@Override\n\tpublic HttpHeaderBuilder setHeader(String name, String value) {\n        for (int i = 0; i < headerList.size(); i++) {\n        \tHttpHeaderBuilder h = headerList.get(i);\n            if (name.equalsIgnoreCase(h.getName())) {\n            \th.setName(name);\n            \th.setValue(value);\n            \treturn h;\n            }\n        }\n        return addHeader(name, value);\n\t}\n\n\t@Override\n\tpublic void removeHeader(IHttpHeaderBuilder header) {\n\t\theaderList.remove(header);\n\t}\n\n\t@Override\n\tpublic void removeHeaders(final String name) {\n        for (Iterator<HttpHeaderBuilder> i = headerList.iterator(); i.hasNext(); ) {\n        \tIHttpHeaderBuilder header = i.next();\n            if (name.equalsIgnoreCase(header.getName())) {\n                i.remove();\n            }\n        }\n\t}\n\t\n\t@Override\n\tpublic void clearHeaders() {\n\t\theaderList.clear();\n\t}\n\t\n\t@Override\n\tpublic void swapHeader(int idx1, int idx2) {\n\t\tif (idx1 < headerList.size() && idx2 < headerList.size() && idx1 != idx2) {\n\t\t\tHttpHeaderBuilder tmp = headerList.set(idx1, headerList.get(idx2));\n\t\t\theaderList.set(idx2, tmp);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic int getHeaderIdxOf(IHttpHeaderBuilder header) {\n\t\treturn headerList.indexOf(header);\n\t}\n\n\t@Override\n\tpublic int getHeaderCnt() {\n\t\treturn headerList.size();\n\t}\n\n\t@Override\n\tpublic IHttpHeaderBuilder getHeader(int idx) {\n\t\treturn headerList.get(idx);\n\t}\n\n\t@Override\n\tpublic IHttpHeaderBuilder[] getHeaders() {\n\t\treturn headerList.toArray(new HttpHeaderBuilder[headerList.size()]);\n\t}\n\n\t@Override\n\tpublic void setEntity(HttpEntity entity) {\n\t\tthis.entity = entity;\n\t\tsetHeadersEntity();\n\t}\n\n\t@Override\n\tpublic HttpEntity getEntity() {\n\t\treturn entity;\n\t}\n\n\tprotected void setHeadersEntity() {\n\t\tif (entity != null) {\n\t        if (entity.isChunked() || entity.getContentLength() < 0) {\n                setHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);\n                removeHeaders(HTTP.CONTENT_LEN);\n\t        } else {\n                setHeader(HTTP.CONTENT_LEN, Long.toString(entity.getContentLength()));\n                removeHeaders(HTTP.TRANSFER_ENCODING);\n\t        }\n\n            if (entity.getContentType() != null) {\n            \tfinal Header h = entity.getContentType();  \n                setHeader(h.getName(), h.getValue());\n            }\n\n            if (entity.getContentEncoding() != null) {\n            \tfinal Header h = entity.getContentEncoding();  \n                setHeader(h.getName(), h.getValue());\n            }\n\t\t} else {\n            removeHeaders(HTTP.CONTENT_LEN);\n            removeHeaders(HTTP.TRANSFER_ENCODING);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/builder/HttpRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.http.requests.builder;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.params.BasicHttpParams;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.params.HttpProtocolParams;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.http.requests.custom.VegaHttpEntityEnclosingUriRequest;\nimport com.subgraph.vega.http.requests.custom.VegaHttpUriRequest;\n\npublic class HttpRequestBuilder extends HttpMessageBuilder implements IHttpRequestBuilder {\n\tprivate String scheme = \"http\";\n\tprivate String host = \"\";\n\tprivate int hostPort = 80;\n\tprivate String method = \"\";\n\tprivate String path = \"\";\n\n\t@Override\n\tpublic synchronized void clear() {\n\t\tsuper.clear();\n\t\tscheme = \"http\";\n\t\thost = \"\";\n\t\thostPort = 80;\n\t\tmethod = \"\";\n\t\tpath = \"\";\n\t}\n\n\t@Override\n\tpublic synchronized void setFromRequest(IRequestLogRecord record) throws URISyntaxException {\n\t\tsetFromRequest(record.getRequest());\n\t\tsetFromHttpHost(record.getHttpHost());\n\t}\n\n\t@Override\n\tpublic synchronized void setFromRequest(HttpRequest request) throws URISyntaxException {\n\t\tsetParams(request.getParams().copy());\n\t\tif(request instanceof HttpUriRequest) {\n\t\t\tsetSchemeAndHostFromUri(((HttpUriRequest) request).getURI());\n\t\t}\n\t\tsetFromRequestLine(request.getRequestLine());\n\t\tsetHeaders(request.getAllHeaders());\n\n\t\tif (request instanceof HttpEntityEnclosingRequest) {\n\t\t\tsetEntity(((HttpEntityEnclosingRequest) request).getEntity());\n\t\t} else {\n\t\t\tsetEntity(null);\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized void setFromRequestLine(RequestLine requestLine) throws URISyntaxException {\n\t\tmethod = requestLine.getMethod();\n\t\tpath = requestLine.getUri();\n\t\tsetProtocolVersion(requestLine.getProtocolVersion());\n\t}\n\n\t@Override\n\tpublic synchronized void setFromUri(URI uri) {\n\t\tsetSchemeAndHostFromUri(uri);\n\t\tsetPathFromUri(uri);\n\t}\n\n\tprivate void setSchemeAndHostFromUri(URI uri) {\n\t\tfinal HttpHost httpHost = URIUtils.extractHost(uri);\n\t\tif(httpHost == null) {\n\t\t\treturn;\n\t\t}\n\t\tif(httpHost.getSchemeName() != null) {\n\t\t\tscheme = httpHost.getSchemeName();\n\t\t\tif(httpHost.getHostName() != null) {\n\t\t\t\thost = httpHost.getHostName();\n\t\t\t\thostPort = httpHost.getPort();\n\t\t\t\tif(hostPort == -1) {\n\t\t\t\t\thostPort = getSchemeDefaultPort(scheme);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void setPathFromUri(URI uri) {\n\t\tpath = uri.getRawPath();\n\t\tif (path != null) {\n\t\t\tif (path.length() == 0 || path.charAt(0) != '/') {\n\t\t\t\tpath = '/' + path;\n\t\t\t}\n\t\t} else {\n\t\t\tpath = \"\";\n\t\t}\n\t\tif (uri.getRawQuery() != null) {\n\t\t\tpath += '?' + uri.getRawQuery();\n\t\t}\n\t\tif (uri.getRawFragment() != null) {\n\t\t\tpath += '#' + uri.getRawFragment();\n\t\t}\t\t\n\t}\n\t\n\t@Override\n\tpublic synchronized void setFromHttpHost(HttpHost host) {\n\t\tscheme = host.getSchemeName();\n\t\tif (scheme == null) {\n\t\t\tscheme = \"http\";\n\t\t}\n\n\t\tthis.host = host.getHostName();\n\t\thostPort = host.getPort();\n\t\tif (hostPort == -1) {\n\t\t\thostPort = getSchemeDefaultPort(scheme);\n\t\t}\n\t}\n\t\n\tprivate int getSchemeDefaultPort(final String scheme) {\n\t\tif (scheme.equals(\"https\")) {\n\t\t\treturn 443;\n\t\t} else {\n\t\t\treturn 80;\n\t\t}\n\t}\n\t\n\tprivate boolean isSchemeDefaultPort(final String scheme, int port) {\n\t\tif (scheme.equals(\"https\")) {\n\t\t\tif (port == 443) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (port == 80) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic synchronized void setScheme(String scheme) {\n\t\tif (scheme != null) {\n\t\t\tthis.scheme = scheme.trim();\n\t\t} else {\n\t\t\tthis.scheme = \"http\";\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized String getScheme() {\n\t\treturn scheme;\n\t}\n\n\t@Override\n\tpublic synchronized void setHost(String host) {\n\t\tif (host != null) {\n\t\t\tthis.host = host.trim();\n\t\t} else {\n\t\t\tthis.host = null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized String getHost() {\n\t\treturn host;\n\t}\n\n\t@Override\n\tpublic synchronized void setHostPort(int port) {\n\t\tif (port != -1) {\n\t\t\tthis.hostPort = port;\n\t\t} else {\n\t\t\tthis.hostPort = 80;\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized int getHostPort() {\n\t\treturn hostPort;\n\t}\n\n\t@Override\n\tpublic synchronized void setMethod(String method) {\n\t\tif (method != null) {\n\t\t\tthis.method = method.trim();\n\t\t} else {\n\t\t\tthis.method = null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized String getMethod() {\n\t\treturn method;\n\t}\n\n\t@Override\n\tpublic synchronized String getPath() {\n\t\treturn path;\n\t}\n\n\t@Override\n\tpublic synchronized void setPath(String path) {\n\t\tif (path != null) {\n\t\t\tString tmp = path.trim();\n\t\t\tif (tmp.length() == 0 || tmp.charAt(0) != '/') {\n\t\t\t\ttmp = '/' + tmp;\n\t\t\t}\n\t\t\tthis.path = tmp;\n\t\t} else {\n\t\t\tthis.path = null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized String getRequestLine() {\n\t\tfinal StringBuilder buf = new StringBuilder();\n\t\tif (method != null) {\n\t\t\tbuf.append(method);\n\t\t}\n\t\tif (path != null) {\n\t\t\tif (buf.length() != 0) {\n\t\t\t\tbuf.append(' ');\n\t\t\t}\n\t\t\tbuf.append(path);\n\t\t}\n\t\tProtocolVersion protocolVersion = getProtocolVersion();\n\t\tif (protocolVersion != null) {\n\t\t\tif (buf.length() != 0) {\n\t\t\t\tbuf.append(' ');\n\t\t\t}\n\t\t\tbuf.append(protocolVersion.toString());\n\t\t}\n\t\treturn buf.toString();\n\t}\n\n\t@Override\n\tpublic synchronized HttpUriRequest buildRequest(boolean setHeadersEntity) throws URISyntaxException {\n\t\tfinal HttpUriRequest request = createRequest( buildHost() );\n\t\t\n\t\tHttpParams params = getParams();\n\t\tif (params == null) {\n\t\t\tparams = new BasicHttpParams();\n\t\t}\n\t\tProtocolVersion protocolVersion = getProtocolVersion();\n\t\tif (protocolVersion != null) {\n\t\t\tHttpProtocolParams.setVersion(request.getParams(), protocolVersion);\n\t\t}\n\t\trequest.setParams(params);\n\n\t\tif (setHeadersEntity) {\n\t\t\tsetHeadersEntity();\n\t\t}\n\t\tIHttpHeaderBuilder[] headers = getHeaders();\n\t\tfor (IHttpHeaderBuilder h: headers) {\n\t\t\trequest.addHeader(h.buildHeader());\n\t\t}\n\n\t\treturn request;\n\t}\n\t\n\tprivate HttpHost buildHost() {\n\t\tif (host == null || host.length() == 0) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid host\");\n\t\t}\n\t\tif(isSchemeDefaultPort(scheme, hostPort)) {\n\t\t\treturn new HttpHost(host, -1, scheme);\n\t\t} else {\n\t\t\treturn new HttpHost(host, hostPort, scheme);\n\t\t}\n\t}\n\n\tprivate HttpUriRequest createRequest(HttpHost host) {\n\t\tfinal String requestPath = (path == null) ? \"\" : path;\n\t\tfinal HttpEntity entity = getEntity();\n\t\tif(entity != null) {\n\t\t\treturn createEntityEnclosingRequest(host, requestPath, entity);\n\t\t} else {\n\t\t\treturn new VegaHttpUriRequest(host, method, requestPath);\n\t\t}\n\t}\n\t\n\tprivate HttpUriRequest createEntityEnclosingRequest(HttpHost host, String requestPath, HttpEntity entity) {\n\t\tfinal VegaHttpEntityEnclosingUriRequest request = new VegaHttpEntityEnclosingUriRequest(host, method, requestPath);\n\t\trequest.setEntity(entity);\n\t\treturn request;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/builder/HttpResponseBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.http.requests.builder;\n\nimport org.apache.http.HttpResponse;\nimport org.apache.http.StatusLine;\nimport org.apache.http.message.BasicHttpResponse;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic class HttpResponseBuilder extends HttpMessageBuilder implements IHttpResponseBuilder {\n\tprivate int statusCode = -200;\n\tprivate String reasonPhrase = \"\";\n\t\n\t@Override\n\tpublic synchronized void clear() {\n\t\tsuper.clear();\n\t\tstatusCode = 200;\n\t\treasonPhrase = \"\";\n\t}\n\n\t@Override\n\tpublic synchronized void setFromResponse(IRequestLogRecord record) {\n\t\tsetFromResponse(record.getResponse());\n\t}\n\n\t@Override\n\tpublic synchronized void setFromResponse(HttpResponse response) {\n\t\tsetFromStatusLine(response.getStatusLine());\n\t\tsetHeaders(response.getAllHeaders());\n\t\tsetEntity(response.getEntity());\n\t}\n\n\t@Override\n\tpublic synchronized void setFromStatusLine(StatusLine statusLine) {\n\t\tsetProtocolVersion(statusLine.getProtocolVersion());\n\t\tstatusCode = statusLine.getStatusCode();\n\t\treasonPhrase = statusLine.getReasonPhrase();\n\t}\n\n\t@Override\n\tpublic synchronized String getStatusLine() {\n\t\tif (getProtocolVersion() != null) {\n\t\t\treturn getProtocolVersion().toString() + \" \" + Integer.toString(statusCode) + \" \" + reasonPhrase;\n\t\t} else {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized HttpResponse buildResponse() {\n\t\tBasicHttpResponse response = new BasicHttpResponse(getProtocolVersion(), statusCode, reasonPhrase);\n\t\t\n\t\tsetHeadersEntity();\n\t\tIHttpHeaderBuilder[] headers = getHeaders();\n\t\tfor (IHttpHeaderBuilder h: headers) {\n\t\t\tresponse.addHeader(h.buildHeader());\n\t\t}\n\n\t\tresponse.setEntity(getEntity());\n\t\t\n\t\treturn response;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/custom/IEncodableHttpRequest.java",
    "content": "package com.subgraph.vega.http.requests.custom;\n\nimport com.subgraph.vega.internal.http.requests.config.IRequestEncodingStrategy;\n\npublic interface IEncodableHttpRequest {\n\tvoid encodeWith(IRequestEncodingStrategy encodingStrategy);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/custom/VegaHttpEntityEnclosingUriRequest.java",
    "content": "package com.subgraph.vega.http.requests.custom;\n\nimport java.net.URI;\n\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpVersion;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpEntityEnclosingRequestBase;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.message.BasicRequestLine;\n\nimport com.subgraph.vega.api.util.UriTools;\nimport com.subgraph.vega.internal.http.requests.config.IRequestEncodingStrategy;\n\npublic class VegaHttpEntityEnclosingUriRequest extends HttpEntityEnclosingRequestBase implements IEncodableHttpRequest {\n\n\tpublic static VegaHttpEntityEnclosingUriRequest createFrom(HttpHost host, HttpEntityEnclosingRequest request) {\n\t\tfinal VegaHttpEntityEnclosingUriRequest newRequest = new VegaHttpEntityEnclosingUriRequest(host, request.getRequestLine());\n\t\tnewRequest.setEntity(request.getEntity());\n\t\tnewRequest.setHeaders(request.getAllHeaders());\n\t\treturn newRequest;\n\t}\n\n\tprivate final HttpHost targetHost;\n\tprivate final RequestLine requestLine;\n\tprivate RequestLine encodedRequestLine;\n\n\tpublic VegaHttpEntityEnclosingUriRequest(String methodName, URI uri) {\n\t\tthis(URIUtils.extractHost(uri), methodName, uriToRequestUri(uri));\n\t}\n\t\n\tprivate static String uriToRequestUri(URI uri) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tif(uri.getPath() != null) {\n\t\t\tsb.append(uri.getPath());\n\t\t}\n\t\t\n\t\tif(uri.getQuery() != null) {\n\t\t\tif(sb.length() == 0) {\n\t\t\t\tsb.append(\"/\");\n\t\t\t}\n\t\t\tsb.append('?');\n\t\t\tsb.append(uri.getQuery());\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static RequestLine createRequestLine(String method, String requestUri) {\n\t\tif(requestUri == null || requestUri.isEmpty()) {\n\t\t\treturn new BasicRequestLine(method, \"/\", HttpVersion.HTTP_1_1);\n\t\t} else {\n\t\t\treturn new BasicRequestLine(method, requestUri, HttpVersion.HTTP_1_1);\n\t\t}\n\t}\n\n\tpublic VegaHttpEntityEnclosingUriRequest(HttpHost targetHost, String methodName, String requestUri) {\n\t\tthis(targetHost, createRequestLine(methodName, requestUri));\n\t}\n\t\n\tpublic VegaHttpEntityEnclosingUriRequest(HttpHost targetHost, RequestLine requestLine) {\n\t\tthis.targetHost = targetHost;\n\t\tthis.requestLine = requestLine;\n\t\tsetURI(UriTools.createUriFromTargetAndLine(targetHost, requestLine.getUri()));\n\t}\n\t\n\t@Override\n\tpublic RequestLine getRequestLine() {\n\t\tif(encodedRequestLine != null) {\n\t\t\treturn encodedRequestLine;\n\t\t} else {\n\t\t\treturn requestLine;\n\t\t}\n\t}\n\n\tpublic HttpHost getTargetHost() {\n\t\treturn targetHost;\n\t}\n\t\n\tpublic String getScheme() {\n\t\treturn targetHost.getSchemeName();\n\t}\n\n\t@Override\n\tpublic String getMethod() {\n\t\treturn requestLine.getMethod();\n\t}\n\n\t@Override\n\tpublic void encodeWith(IRequestEncodingStrategy encodingStrategy) {\n\t\tencodedRequestLine = encodingStrategy.encodeRequestLine(requestLine);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/http/requests/custom/VegaHttpUriRequest.java",
    "content": "package com.subgraph.vega.http.requests.custom;\n\nimport java.net.URI;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpVersion;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpRequestBase;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.message.BasicRequestLine;\n\nimport com.subgraph.vega.api.util.UriTools;\nimport com.subgraph.vega.internal.http.requests.config.IRequestEncodingStrategy;\n\npublic class VegaHttpUriRequest extends HttpRequestBase implements IEncodableHttpRequest {\n\t\n\tpublic static VegaHttpUriRequest createFrom(HttpHost host, HttpRequest request) {\n\t\tfinal VegaHttpUriRequest newRequest = new VegaHttpUriRequest(host, request.getRequestLine());\n\t\tnewRequest.setHeaders(request.getAllHeaders());\n\t\treturn newRequest;\n\t}\n\n\tprivate final HttpHost targetHost;\n\tprivate final RequestLine requestLine;\n\tprivate RequestLine encodedRequestLine;\n\n\tpublic VegaHttpUriRequest(String methodName, URI uri) {\n\t\tthis(URIUtils.extractHost(uri), methodName, uriToRequestUri(uri));\n\t}\n\t\n\tprivate static String uriToRequestUri(URI uri) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tif(uri.getPath() != null) {\n\t\t\tsb.append(uri.getPath());\n\t\t}\n\t\t\n\t\tif(uri.getQuery() != null) {\n\t\t\tif(sb.length() == 0) {\n\t\t\t\tsb.append(\"/\");\n\t\t\t}\n\t\t\tsb.append('?');\n\t\t\tsb.append(uri.getQuery());\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate static RequestLine createRequestLine(String method, String requestUri) {\n\t\tif(requestUri == null || requestUri.isEmpty()) {\n\t\t\treturn new BasicRequestLine(method, \"/\", HttpVersion.HTTP_1_1);\n\t\t} else {\n\t\t\treturn new BasicRequestLine(method, requestUri, HttpVersion.HTTP_1_1);\n\t\t}\n\t}\n\n\tpublic VegaHttpUriRequest(HttpHost targetHost, String methodName, String requestUri) {\n\t\tthis(targetHost, createRequestLine(methodName, requestUri));\n\t}\n\n\tpublic VegaHttpUriRequest(HttpHost targetHost, RequestLine requestLine) {\n\t\tthis.targetHost = targetHost;\n\t\tthis.requestLine = requestLine;\n\t\tsetURI(UriTools.createUriFromTargetAndLine(targetHost, requestLine.getUri()));\n\t}\n\t\n\tpublic HttpHost getTargetHost() {\n\t\treturn targetHost;\n\t}\n\n\tpublic String getScheme() {\n\t\treturn targetHost.getSchemeName();\n\t}\n\n\t@Override\n\tpublic RequestLine getRequestLine() {\n\t\tif(encodedRequestLine != null) {\n\t\t\treturn encodedRequestLine;\n\t\t} else {\n\t\t\treturn requestLine;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getMethod() {\n\t\treturn requestLine.getMethod();\n\t}\n\n\t@Override\n\tpublic void encodeWith(IRequestEncodingStrategy encodingStrategy) {\n\t\tencodedRequestLine = encodingStrategy.encodeRequestLine(requestLine);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/BasicHttpClientFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.security.cert.CertificateException;\nimport java.security.cert.X509Certificate;\n\nimport javax.net.ssl.SSLException;\nimport javax.net.ssl.SSLSession;\nimport javax.net.ssl.SSLSocket;\n\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.conn.ClientConnectionManager;\nimport org.apache.http.conn.scheme.PlainSocketFactory;\nimport org.apache.http.conn.scheme.Scheme;\nimport org.apache.http.conn.scheme.SchemeRegistry;\nimport org.apache.http.conn.ssl.SSLSocketFactory;\nimport org.apache.http.conn.ssl.TrustStrategy;\nimport org.apache.http.conn.ssl.X509HostnameVerifier;\nimport org.apache.http.impl.client.DefaultHttpClient;\nimport org.apache.http.params.HttpParams;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.internal.http.requests.client.VegaHttpClient;\nimport com.subgraph.vega.internal.http.requests.config.IHttpClientConfigurer;\nimport com.subgraph.vega.internal.http.requests.config.RequestEngineConfig;\nimport com.subgraph.vega.internal.http.requests.connection.SocksSupportingThreadSafeClientConnectionManager;\n\npublic class BasicHttpClientFactory {\n\n\tstatic class AllowAllHostnameVerifierPlus implements X509HostnameVerifier {\n\t\t\n\t    public  void verify(\n\t            final String host,\n\t            final SSLSocket ssl)\n\t             {\n\t        // Allow everything - so never blowup.\n\t             }\n\n\t\t@Override\n\t\tpublic boolean verify(String arg0, SSLSession arg1) {\n\t\t\t// TODO Auto-generated method stub\n\t\t\treturn true;\n\t\t}\n\n\t\t@Override\n\t\tpublic void verify(String host, X509Certificate cert)\n\t\t\t\tthrows SSLException {\n\t\t\t// TODO Auto-generated method stub\n\t\t\t\n\t\t}\n\n\t\t@Override\n\t\tpublic void verify(String host, String[] cns, String[] subjectAlts)\n\t\t\t\tthrows SSLException {\n\t\t\t// TODO Auto-generated method stub\n\t\t\t\n\t\t}\t\n\t}\n\t\n\tstatic HttpClient createHttpClient(IHttpRequestEngine.EngineConfigType type) {\n\t\tfinal IHttpClientConfigurer configurer = RequestEngineConfig.getHttpClientConfigurer(type);\n\t\tfinal HttpParams params = configurer.createHttpParams();\n\t\tfinal ClientConnectionManager ccm = createConnectionManager(params);\n\t\tfinal DefaultHttpClient client = new VegaHttpClient(ccm, params);\n\t\tconfigurer.configureHttpClient(client);\n\t\treturn client;\n\t}\n\n\t\n\tprivate static ClientConnectionManager createConnectionManager(HttpParams params) {\n\t\tfinal SchemeRegistry sr = createSchemeRegistry();\n\t\treturn new SocksSupportingThreadSafeClientConnectionManager(sr);\n\t}\n\t\n\tprivate static SchemeRegistry createSchemeRegistry() {\n\t\tfinal SchemeRegistry sr = new SchemeRegistry();\n\t\tsr.register(new Scheme(\"http\", 80, PlainSocketFactory.getSocketFactory()));\n\t\ttry {\n\t\t\tSSLSocketFactory ssf = new SSLSocketFactoryPlus(new TrustStrategy() {\n\t\t\t\t@Override\n\t\t\t\tpublic boolean isTrusted(X509Certificate[] chain, String authType)\n\t\t\t\t\t\tthrows CertificateException {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}, new AllowAllHostnameVerifierPlus());\n\t\t\tsr.register(new Scheme(\"https\", 443, ssf));\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Unexpected exception creating SSLSocketFactory\", e);\n\t\t}\n\t\treturn sr;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/CookieMatcher.java",
    "content": "package com.subgraph.vega.internal.http.requests;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Date;\nimport java.util.List;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.params.HttpClientParams;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.cookie.CookieOrigin;\nimport org.apache.http.cookie.CookieSpec;\nimport org.apache.http.cookie.CookieSpecRegistry;\nimport org.apache.http.impl.client.AbstractHttpClient;\n\npublic class CookieMatcher {\n\tprivate final AbstractHttpClient client;\n\t\n\tCookieMatcher(AbstractHttpClient client) {\n\t\tthis.client = client;\n\t}\n\t\t\t\n\tpublic List<Cookie> getCookiesForRequest(HttpHost targetHost,\n\t\t\tHttpRequest request) {\n\t\tCookieSpecRegistry registry = client.getCookieSpecs();\n\t\tfinal String policy = HttpClientParams.getCookiePolicy(request.getParams());\n\t\tfinal CookieOrigin origin = getCookieOrigin(targetHost, request);\n\t\tfinal CookieSpec cookieSpec = registry.getCookieSpec(policy, request.getParams());\n\t\tfinal List<Cookie> matchedCookies = new ArrayList<Cookie>();\n\t\tfinal Date now = new Date();\n\t\tfor(Cookie cookie: client.getCookieStore().getCookies()) {\n\t\t\tif(cookieSpec.match(cookie, origin) && !cookie.isExpired(now)) {\n\t\t\t\tmatchedCookies.add(cookie);\n\t\t\t}\n\t\t}\n\t\treturn Collections.unmodifiableList(matchedCookies);\n\t}\n\t\n\tprivate CookieOrigin getCookieOrigin(HttpHost host, HttpRequest request) {\n\t\tfinal int port = getPortForHost(host);\n\t\tfinal String path = getPathForRequest(request);\n\t\treturn new CookieOrigin(host.getHostName(), port, path, isSecureScheme(host));\n\t}\n\t\n\tprivate int getPortForHost(HttpHost host) {\n\t\tif(host.getPort() > 0) {\n\t\t\treturn host.getPort();\n\t\t}\n\t\tfinal String scheme = host.getSchemeName();\n\t\tif(\"http\".equalsIgnoreCase(scheme)) {\n\t\t\treturn 80;\n\t\t} else if(\"https\".equalsIgnoreCase(scheme)) {\n\t\t\treturn 443;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tprivate boolean isSecureScheme(HttpHost host) {\n\t\treturn \"https\".equalsIgnoreCase(host.getSchemeName());\n\t}\n\t\n\tprivate String getPathForRequest(HttpRequest request) {\n\t\tif(request instanceof HttpUriRequest) {\n\t\t\tfinal URI requestURI = ((HttpUriRequest) request).getURI();\n\t\t\treturn requestURI.getPath();\n\t\t} else {\n\t\t\treturn request.getRequestLine().getUri();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/EngineHttpResponse.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.net.URI;\nimport java.nio.charset.Charset;\nimport java.nio.charset.UnsupportedCharsetException;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.ParseException;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.entity.ContentType;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.util.CharArrayBuffer;\nimport org.apache.http.util.EntityUtils;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IHttpResponseCookie;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.api.model.tags.ITag;\nimport com.subgraph.vega.http.requests.custom.VegaHttpEntityEnclosingUriRequest;\nimport com.subgraph.vega.http.requests.custom.VegaHttpUriRequest;\n\npublic class EngineHttpResponse implements IHttpResponse {\n\tprivate final Logger logger = Logger.getLogger(\"request-engine\");\n\tprivate final URI requestUri;\n\tprivate final HttpHost host;\n\tprivate final HttpRequest originalRequest;\n\tprivate final List<Cookie> requestCookies;\n\tprivate final List<IHttpResponseCookie> responseCookies;\n\tprivate final IRequestOrigin requestOrigin;\n\tprivate /*final*/ HttpResponse rawResponse;\n\tprivate final long requestTime;\n\tprivate final IHTMLParser htmlParser;\n\tprivate final List<ITag> tagList = new ArrayList<ITag>();\n\n\tprivate String cachedString;\n\tprivate PageFingerprint cachedFingerprint;\n\tprivate boolean htmlParseFailed;\n\tprivate IHTMLParseResult htmlParseResult;\n\tprivate boolean isMostlyAsciiTestDone;\n\tprivate boolean isMostlyAscii;\n\tprivate long requestId = -1;\n\n\tEngineHttpResponse(URI uri, HttpHost host, HttpRequest originalRequest, \n\t\t\tList<Cookie> requestCookies, List<IHttpResponseCookie> responseCookies, \n\t\t\tIRequestOrigin requestOrigin, HttpResponse rawResponse, long requestTime, IHTMLParser htmlParser) {\n\t\tthis.requestUri = uri;\n\t\tthis.host = host;\n\t\tthis.originalRequest = cloneOriginalRequest(host, originalRequest);\n\t\tthis.requestCookies = requestCookies;\n\t\tthis.responseCookies = responseCookies;\n\t\tthis.requestOrigin = requestOrigin;\n\t\tthis.rawResponse = rawResponse;\n\t\tthis.requestTime = requestTime;\n\t\tthis.htmlParser = htmlParser;\n\t}\n\n\tprivate static HttpRequest cloneOriginalRequest(HttpHost host, HttpRequest request) {\n\t\tif(request instanceof HttpEntityEnclosingRequest) {\n\t\t\treturn VegaHttpEntityEnclosingUriRequest.createFrom(host, (HttpEntityEnclosingRequest) request);\n\t\t} else {\n\t\t\treturn VegaHttpUriRequest.createFrom(host, request);\n\t\t}\n\t}\n\n\t@Override\n\tpublic HttpRequest getOriginalRequest() {\n\t\treturn originalRequest;\n\t}\n\n\t@Override\n\tpublic List<Cookie> getSentCookies() {\n\t\treturn requestCookies;\n\t}\n\n\t@Override\n\tpublic List<IHttpResponseCookie> getResponseCookies() {\n\t\treturn responseCookies;\n\t}\n\n\t@Override\n\tpublic synchronized void setRawResponse(HttpResponse response) {\n\t\trawResponse = response;\n\t}\n\n\t@Override\n\tpublic synchronized HttpResponse getRawResponse() {\n\t\treturn rawResponse;\n\t}\n\t\n\t@Override\n\tpublic String getBodyAsString() {\n\t\tsynchronized (rawResponse) {\n\t\t\t\n\t\t\tif(cachedString != null) {\n\t\t\t\treturn cachedString;\n\t\t\t}\n\t\t\t\n\t\t\tif(rawResponse.getEntity() == null) {\n\t\t\t\tcachedString = \"\";\n\t\t\t\treturn cachedString;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tcachedString = toString(rawResponse.getEntity(), null);\n\t\t\t} catch (ParseException e) {\n\t\t\t\tlogger.log(Level.WARNING, \"Error parsing response headers: \"+ e.getMessage(), e);\n\t\t\t\tcachedString = \"\";\n\t\t\t} catch (IOException e) {\n\t\t\t\tlogger.log(Level.WARNING, \"IO error extracting response entity for request \"+ originalRequest.getRequestLine().getUri() +\" : \"+ e.getMessage(), e);\n\t\t\t\tcachedString = \"\";\n\t\t\t}\n\t\t\treturn cachedString;\n\t\t}\n\t}\n\n\t /**\n\t * [*] Copied from EntityUtils to make a small change\n\t * \n     * Get the entity content as a String, using the provided default character set\n     * if none is found in the entity.\n     * If defaultCharset is null, the default \"ISO-8859-1\" is used.\n     *\n     * @param entity must not be null\n     * @param defaultCharset character set to be applied if none found in the entity\n     * @return the entity content as a String. May be null if\n     *   {@link HttpEntity#getContent()} is null.\n     * @throws ParseException if header elements cannot be parsed\n     * @throws IllegalArgumentException if entity is null or if content length > Integer.MAX_VALUE\n     * @throws IOException if an error occurs reading the input stream\n     */\n    public static String toString(\n            final HttpEntity entity, final Charset defaultCharset) throws IOException, ParseException {\n        if (entity == null) {\n            throw new IllegalArgumentException(\"HTTP entity may not be null\");\n        }\n        InputStream instream = entity.getContent();\n        if (instream == null) {\n            return null;\n        }\n        try {\n            if (entity.getContentLength() > Integer.MAX_VALUE) {\n                throw new IllegalArgumentException(\"HTTP entity too large to be buffered in memory\");\n            }\n            int i = (int)entity.getContentLength();\n            if (i < 0) {\n                i = 4096;\n            }\n            Charset charset = null;\n            try {\n                ContentType contentType = ContentType.getOrDefault(entity);\n                charset = contentType.getCharset();\n            } catch (UnsupportedCharsetException ex) {\n            \t// In EntityUtils an exception is thrown here.\n            \tcharset = null;\n            }\n            if (charset == null) {\n                charset = defaultCharset;\n            }\n            if (charset == null) {\n                charset = HTTP.DEF_CONTENT_CHARSET;\n            }\n            Reader reader = new InputStreamReader(instream, charset);\n            CharArrayBuffer buffer = new CharArrayBuffer(i);\n            char[] tmp = new char[1024];\n            int l;\n            while((l = reader.read(tmp)) != -1) {\n                buffer.append(tmp, 0, l);\n            }\n            return buffer.toString();\n        } finally {\n            instream.close();\n        }\n    }\n\n\t@Override\n\tpublic IHTMLParseResult getParsedHTML() {\n\t\tsynchronized(rawResponse) {\n\t\t\tif(htmlParseFailed)\n\t\t\t\treturn null;\n\t\t\tif(htmlParseResult != null)\n\t\t\t\treturn htmlParseResult;\n\t\t\tfinal String body = getBodyAsString();\n\t\t\tif(body == null) {\n\t\t\t\thtmlParseFailed = true;\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\thtmlParseResult = htmlParser.parseString(body, requestUri);\n\t\t\tif(htmlParseResult == null) \n\t\t\t\thtmlParseFailed = true;\n\t\t\treturn htmlParseResult;\n\t\t}\n\t}\n\n\t@Override\n\tpublic HttpHost getHost() {\n\t\treturn host;\n\t}\n\n\t@Override\n\tpublic int getResponseCode() {\n\t\treturn rawResponse.getStatusLine().getStatusCode();\n\t}\n\n\t@Override\n\tpublic boolean isFetchFail() {\n\t\tfinal int code = getResponseCode();\n\t\treturn code == 503 || code == 504;\n\t}\n\n\t@Override\n\tpublic boolean isMostlyAscii() {\n\t\tif(isMostlyAsciiTestDone) {\n\t\t\treturn isMostlyAscii;\n\t\t}\n\t\t\n\t\tfinal String body = getBodyAsString();\n\n\t\tif(body == null || body.isEmpty()) {\n\t\t\tisMostlyAscii = true;\n\t\t\tisMostlyAsciiTestDone = true;\n\t\t\treturn true;\n\t\t}\n\n\t\tint total = (body.length() > 200) ? (200) : (body.length());\n\t\tint printable = 0;\n\t\t\n\t\tfor(int i = 0; i < total; i++) {\n\t\t\tchar c = body.charAt(i);\n\t\t\tif((c >= 0x20 && c <= 0x7F) || Character.isWhitespace(c))\n\t\t\t\tprintable += 1;\n\t\t}\n\t\tisMostlyAscii = ((printable * 100) / total) > 90;\n\t\tisMostlyAsciiTestDone = true;\n\t\treturn isMostlyAscii;\n\t}\n\n\t@Override\n\tpublic IPageFingerprint getPageFingerprint() {\n\t\tif(cachedFingerprint == null)\n\t\t\tcachedFingerprint = PageFingerprint.generateFromCodeAndString(getResponseCode(), getBodyAsString());\n\t\treturn cachedFingerprint;\n\t}\n\n\t@Override\n\tpublic ResponseStatus getResponseStatus() {\n\t\t// XXX\n\t\treturn ResponseStatus.RESPONSE_OK;\n\t}\n\n\t@Override\n\tpublic long getRequestMilliseconds() {\n\t\treturn requestTime;\n\t}\n\n\t@Override\n\tpublic boolean lockResponseEntity() {\n\t\tfinal HttpEntity entity = rawResponse.getEntity();\n\t\tif(entity == null)\n\t\t\treturn false;\n\t\ttry {\n\t\t\tfinal ByteArrayEntity newEntity = new ByteArrayEntity(EntityUtils.toByteArray(entity));\n\t\t\tnewEntity.setContentType(entity.getContentType());\n\t\t\tnewEntity.setContentEncoding(entity.getContentEncoding());\n\t\t\trawResponse.setEntity(newEntity);\n\t\t\tEntityUtils.consume(entity);\n\t\t\treturn true;\n\t\t} catch (IOException e) {\n\t\t\tlogger.warning(\"Error loading entity for \"+ getRequestUri().toString() +\" : \"+ e.getMessage());\n\t\t\treturn false;\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic void setRequestId(long requestId) {\n\t\tthis.requestId = requestId;\n\t}\n\n\t@Override\n\tpublic long getRequestId() {\n\t\treturn requestId;\n\t}\n\n\t@Override\n\tpublic IRequestOrigin getRequestOrigin() {\n\t\treturn requestOrigin;\n\t}\n\n\t@Override\n\tpublic URI getRequestUri() {\n\t\treturn requestUri;\n\t}\n\n\t@Override\n\tpublic List<ITag> getTags() {\n\t\treturn Collections.unmodifiableList(new ArrayList<ITag>(tagList));\n\t}\n\n\t@Override\n\tpublic void addTag(ITag tag) {\n\t\ttagList.add(tag);\n\t}\n\n\t@Override\n\tpublic void removeTag(ITag tag) {\n\t\ttagList.remove(tag);\n\t}\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpMacroContext.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.util.Map;\n\nimport com.subgraph.vega.api.http.requests.IHttpMacroContext;\n\npublic class HttpMacroContext implements IHttpMacroContext {\n\tprivate Map<String, String> dict;\n\n\tpublic HttpMacroContext() {\n\t}\n\t\n\t@Override\n\tpublic void setDict(Map<String, String> dict) {\n\t\tthis.dict = dict;\n\t}\n\n\t@Override\n\tpublic Map<String, String> getDict() {\n\t\treturn dict;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpMacroExecutor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URISyntaxException;\nimport java.util.Collection;\nimport java.util.Iterator;\n\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.protocol.HttpContext;\n\nimport com.subgraph.vega.api.http.requests.IHttpMacroContext;\nimport com.subgraph.vega.api.http.requests.IHttpMacroExecutor;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItem;\nimport com.subgraph.vega.http.requests.builder.HttpRequestBuilder;\n\npublic class HttpMacroExecutor implements IHttpMacroExecutor {\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate final IHttpMacro macro;\n\tprivate final Collection<IHttpMacroItem> macroItems;\n\tprivate IHttpMacroContext macroContext;\n\tprivate Iterator<IHttpMacroItem> macroItemIterator;\n\n\tpublic HttpMacroExecutor(IHttpRequestEngine requestEngine, IHttpMacro macro, IHttpMacroContext macroContext) {\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.macro = macro;\n\t\tmacroItems = macro.getMacroItems();\n\t\tthis.macroContext = macroContext;\n\t\tmacroItemIterator = macroItems.iterator();\n\t}\n\n\t@Override\n\tpublic IHttpMacro getMacro() {\n\t\treturn macro;\n\t}\n\n\t@Override\n\tpublic IHttpRequestEngine getRequestEngine() {\n\t\treturn requestEngine;\n\t}\n\n\t@Override\n\tpublic IHttpMacroContext getMacroContext() {\n\t\treturn macroContext;\n\t}\n\n\t@Override\n\tpublic boolean hasNext() {\n\t\treturn macroItemIterator.hasNext();\n\t}\n\t\n\t@Override\n\tpublic IHttpRequestTask sendNextRequest(HttpContext context) throws URISyntaxException, UnsupportedEncodingException {\n\t\tif (!macroItemIterator.hasNext()) {\n\t\t\treturn null;\n\t\t}\n\t\tIHttpMacroItem macroItem = macroItemIterator.next();\n\t\tfinal HttpRequestBuilder builder = new HttpRequestBuilder();\n\t\tmacroItem.setRequestBuilder(builder,  macroContext);\n\t\t// hack: remove content headesr\n\t\tbuilder.removeHeaders(HTTP.CONTENT_LEN);\n\t\tbuilder.removeHeaders(HTTP.CONTENT_TYPE);\n\t\tHttpUriRequest request = builder.buildRequest(false);\n\t\treturn requestEngine.sendRequest(request, context);\n\t}\n\n\t@Override\n\tpublic IHttpRequestTask sendNextRequest() throws URISyntaxException, UnsupportedEncodingException {\n\t\tif (!macroItemIterator.hasNext()) {\n\t\t\treturn null;\n\t\t}\n\t\tIHttpMacroItem macroItem = macroItemIterator.next();\n\t\tfinal HttpRequestBuilder builder = new HttpRequestBuilder();\n\t\tmacroItem.setRequestBuilder(builder,  macroContext);\n\t\t// hack: remove content headesr\n\t\tbuilder.removeHeaders(HTTP.CONTENT_LEN);\n\t\tbuilder.removeHeaders(HTTP.CONTENT_TYPE);\n\t\tHttpUriRequest request = builder.buildRequest(false);\n\t\treturn requestEngine.sendRequest(request);\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpRequestEngine.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Future;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.methods.HttpGet;\nimport org.apache.http.client.methods.HttpPost;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.impl.client.AbstractHttpClient;\nimport org.apache.http.protocol.BasicHttpContext;\nimport org.apache.http.protocol.HttpContext;\nimport org.apache.http.protocol.SyncBasicHttpContext;\n\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.http.requests.IHttpMacroContext;\nimport com.subgraph.vega.api.http.requests.IHttpMacroExecutor;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestModifier;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.RequestTaskStartEvent;\nimport com.subgraph.vega.api.http.requests.RequestTaskStopEvent;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.http.requests.custom.IEncodableHttpRequest;\nimport com.subgraph.vega.http.requests.custom.VegaHttpEntityEnclosingUriRequest;\nimport com.subgraph.vega.http.requests.custom.VegaHttpUriRequest;\nimport com.subgraph.vega.internal.http.requests.client.VegaDecompressingHttpClient;\nimport com.subgraph.vega.internal.http.requests.config.IRequestEncodingStrategy;\nimport com.subgraph.vega.internal.http.requests.config.RequestEngineConfig;\n\npublic class HttpRequestEngine implements IHttpRequestEngine {\n\tpublic final static String VEGA_SENT_REQUEST = \"vega.sent-request\"; /** Key under which a copy of sent request with actual sent headers is stored in HttpContext */\n\tprivate final static boolean isDecompressingClient = true;\n\tprivate final IRequestEncodingStrategy encodingStrategy;\n\tprivate final ExecutorService executor;\n\tprivate final HttpClient client;\n\tprivate final HttpClient decompressingClient;\n\tprivate final IHttpRequestEngineConfig config;\n\tprivate final IRequestOrigin requestOrigin;\n\tprivate final IHTMLParser htmlParser;\n\tprivate final RateLimiter rateLimit;\n\tprivate final CookieMatcher cookieMatcher;\n\tprivate final HttpContext httpContext;\n\tprivate final List<IHttpRequestModifier> requestModifierList;\n\tprivate final EventListenerManager requestEventManager;\n\tprivate final List<HttpRequestTask> requestInProgressList;\n\t\n\tHttpRequestEngine(EngineConfigType type, ExecutorService executor, HttpClient client, IHttpRequestEngineConfig config, IRequestOrigin requestOrigin, IHTMLParser htmlParser) {\n\t\tthis.encodingStrategy = RequestEngineConfig.getRequestEncodingStrategy(type);\n\t\tthis.executor = executor;\n\t\tthis.client = client;\n\t\tthis.decompressingClient = new VegaDecompressingHttpClient(client);\n\t\tthis.config = config;\n\t\tthis.requestOrigin = requestOrigin;\n\t\tthis.htmlParser = htmlParser;\n\t\trateLimit = new RateLimiter(config.getRequestsPerMinute());\n\t\tcookieMatcher = new CookieMatcher(getClientDowncast());\n\t\thttpContext = new SyncBasicHttpContext(null);\n\n\t\trequestModifierList = new ArrayList<IHttpRequestModifier>();\n\t\trequestEventManager = new EventListenerManager();\n\t\trequestInProgressList = new ArrayList<HttpRequestTask>();\n\t}\n\n\t@Override\n\tpublic IHttpRequestEngineConfig getRequestEngineConfig() {\n\t\treturn config;\n\t}\n\n\t@Override\n\tpublic IRequestOrigin getRequestOrigin() {\n\t\treturn requestOrigin;\n\t}\n\n\t@Override\n\tpublic HttpClient getHttpClient() {\n\t\treturn client;\n\t}\n\n\t@Override\n\tpublic HttpContext getHttpContext() {\n\t\treturn httpContext;\n\t}\n\n\t@Override\n\tpublic CookieStore getCookieStore() {\n\t\treturn getClientDowncast().getCookieStore();\n\t}\n\n\t@Override\n\tpublic void setCookieStore(CookieStore cookieStore) {\n\t\tgetClientDowncast().setCookieStore(cookieStore);\n\t}\n\n\tprivate AbstractHttpClient getClientDowncast() {\n\t\tif(client instanceof AbstractHttpClient) {\n\t\t\treturn (AbstractHttpClient)client;\n\t\t}\n\t\tthrow new IllegalArgumentException(\"HttpClient instance is not expected type\");\n\t}\n\n\t@Override\n\tpublic void addRequestModifier(IHttpRequestModifier modifier) {\n\t\trequestModifierList.add(modifier);\n\t}\n\n\t@Override\n\tpublic void addRequestListener(IEventHandler listener) {\n\t\trequestEventManager.addListener(listener);\n\t}\n\n\t@Override\n\tpublic void removeRequestListener(IEventHandler listener) {\n\t\trequestEventManager.removeListener(listener);\n\t}\n\n\t@Override\n\tpublic IHttpRequestTask[] getRequestList() {\n\t\tsynchronized(this) {\n\t\t\treturn requestInProgressList.toArray(new IHttpRequestTask[0]);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic IHttpRequestTask sendRequest(HttpUriRequest request, HttpContext context) {\n\t\tif(request instanceof IEncodableHttpRequest) {\n\t\t\t((IEncodableHttpRequest) request).encodeWith(encodingStrategy);\n\t\t}\n\t\tfor (IHttpRequestModifier modifier: requestModifierList) {\n\t\t\tmodifier.process(request, context);\n\t\t}\n\t\t\n\t\tHttpRequestTask requestTask = new HttpRequestTask(\n\t\t\t\tthis,\n\t\t\t\t(isDecompressingClient) ? (decompressingClient) : (client),\n\t\t\t\trateLimit, \n\t\t\t\trequest, \n\t\t\t\trequestOrigin, \n\t\t\t\tcontext, \n\t\t\t\tconfig, \n\t\t\t\thtmlParser);\n\t\t\n\t\tFuture<IHttpResponse> future = executor.submit(requestTask);\n\t\trequestTask.setFuture(future);\n\t\treturn requestTask;\n\t}\n\n\t@Override\n\tpublic IHttpRequestTask sendRequest(HttpUriRequest request) {\n\t\treturn sendRequest(request, new BasicHttpContext(httpContext));\n\t}\n\t\n\t@Override\n\tpublic IHttpMacroContext createMacroContext() {\n\t\treturn new HttpMacroContext();\n\t}\n\n\t@Override\n\tpublic IHttpMacroExecutor createMacroExecutor(IHttpMacro macro, IHttpMacroContext context) {\n\t\treturn new HttpMacroExecutor(this, macro, context);\n\t}\n\n\tpublic void addRequestInProgress(HttpRequestTask requestTask) {\n\t\tsynchronized(this) {\n\t\t\trequestInProgressList.add(requestTask);\n\t\t\trequestEventManager.fireEvent(new RequestTaskStartEvent(requestTask));\n\t\t}\n\t}\n\t\n\tpublic void removeRequestInProgress(HttpRequestTask requestTask) {\n\t\tsynchronized(this) {\n\t\t\trequestInProgressList.remove(requestTask);\n\t\t\trequestEventManager.fireEvent(new RequestTaskStopEvent(requestTask));\n\t\t}\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createGetRequest(HttpHost target, String uri) {\n\t\treturn new VegaHttpUriRequest(target, HttpGet.METHOD_NAME, uri);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createPostRequest(HttpHost target, String uri) {\n\t\treturn new VegaHttpEntityEnclosingUriRequest(target, HttpPost.METHOD_NAME, uri);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createRawRequest(HttpHost target,\n\t\t\tRequestLine requestLine) {\n\t\treturn new VegaHttpUriRequest(target, requestLine);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createRawEntityEnclosingRequest(HttpHost target,\n\t\t\tRequestLine requestLine) {\n\t\treturn new VegaHttpEntityEnclosingUriRequest(target, requestLine);\n\t}\n\n\t@Override\n\tpublic List<Cookie> getCookiesForRequest(HttpHost targetHost,\n\t\t\tHttpRequest request) {\n\t\treturn cookieMatcher.getCookiesForRequest(targetHost, request);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpRequestEngineConfig.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpResponseProcessor;\n\npublic class HttpRequestEngineConfig implements IHttpRequestEngineConfig {\n\tprivate final static int DEFAULT_REQUESTS_PER_MINUTE = 1000;\n\tprivate boolean forceIdentityEncoding = false;\n\tprivate boolean decompressGzipEncoding = true;\n\tprivate boolean undoURLEncoding = false;\n\tprivate int requestsPerMinute = DEFAULT_REQUESTS_PER_MINUTE;\n\tprivate int maxConnections = DEFAULT_MAX_CONNECTIONS;\n\tprivate int maxConnectionsPerRoute = DEFAULT_MAX_CONNECTIONS_PER_ROUTE;\n\tprivate int maximumResponseKilobytes = 0; // 0 means no limit\n\tprivate final List<IHttpResponseProcessor> responseProcessors = new ArrayList<IHttpResponseProcessor>();\n\t\n\t@Override\n\tpublic void setForceIdentityEncoding(boolean value) {\n\t\tforceIdentityEncoding = value;\t\t\n\t}\n\n\t@Override\n\tpublic void setDecompressGzipEncoding(boolean value) {\n\t\tdecompressGzipEncoding = value;\t\t\n\t}\n\n\t@Override\n\tpublic boolean getForceIdentityEncoding() {\n\t\treturn forceIdentityEncoding;\n\t}\n\n\t@Override\n\tpublic boolean getDecompressGzipEncoding() {\n\t\treturn decompressGzipEncoding;\n\t}\n\n\t@Override\n\tpublic void setUndoURLEncoding(boolean value) {\n\t\tundoURLEncoding = value;\n\t}\n\n\t@Override\n\tpublic boolean getUndoURLEncoding() {\n\t\treturn undoURLEncoding;\n\t}\n\n\t@Override\n\tpublic void registerResponseProcessor(IHttpResponseProcessor processor) {\n\t\tsynchronized(responseProcessors) {\n\t\t\tresponseProcessors.add(processor);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IHttpResponseProcessor> getResponseProcessors() {\n\t\tsynchronized(responseProcessors) {\n\t\t\treturn Collections.unmodifiableList(responseProcessors);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setRequestsPerMinute(int rpm) {\n\t\trequestsPerMinute = rpm;\t\t\n\t}\n\n\t@Override\n\tpublic int getRequestsPerMinute() {\n\t\treturn requestsPerMinute;\n\t}\n\n\t@Override\n\tpublic void setMaxConnections(int value) {\n\t\tmaxConnections = value;\n\t}\n\n\t@Override\n\tpublic int getMaxConnections() {\n\t\treturn maxConnections;\n\t}\n\n\t@Override\n\tpublic void setMaxConnectionsPerRoute(int value) {\n\t\tmaxConnectionsPerRoute = value;\n\t}\n\n\t@Override\n\tpublic int getMaxConnectionsPerRoute() {\n\t\treturn maxConnectionsPerRoute;\n\t}\n\n\t@Override\n\tpublic void setMaximumResponseKilobytes(int kb) {\n\t\tmaximumResponseKilobytes = kb;\n\t}\n\n\t@Override\n\tpublic int getMaximumResponseKilobytes() {\n\t\treturn maximumResponseKilobytes;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpRequestEngineFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.conn.ClientConnectionManager;\nimport org.apache.http.conn.params.ConnRoutePNames;\nimport org.apache.http.impl.conn.PoolingClientConnectionManager;\n\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.http.requests.builder.HttpRequestBuilder;\nimport com.subgraph.vega.http.requests.builder.HttpResponseBuilder;\n\npublic class HttpRequestEngineFactory implements IHttpRequestEngineFactory {\n\tprivate final ExecutorService executor = Executors.newCachedThreadPool();\n\tprivate IHTMLParser htmlParser;\n\tprivate HttpHost proxy;\n\n\t@Override\n\tpublic void setProxy(HttpHost proxy) {\n\t\tthis.proxy = proxy;\n\t}\n\n\t@Override\n\tpublic IHttpRequestEngineConfig createConfig() {\n\t\treturn new HttpRequestEngineConfig();\n\t}\n\n\t@Override\n\tpublic IHttpRequestEngine createRequestEngine(IHttpRequestEngine.EngineConfigType type, IHttpRequestEngineConfig config, IRequestOrigin requestOrigin) {\n\t\tfinal HttpClient client = BasicHttpClientFactory.createHttpClient(type);\n\t\tif(proxy != null) {\n\t\t\tclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);\n\t\t}\n\t\tconfigureClient(client, config);\n\t\treturn new HttpRequestEngine(type, executor, client, config, requestOrigin, htmlParser);\n\t}\n\t\n\t@Override\n\tpublic IHttpRequestBuilder createRequestBuilder() {\n\t\treturn new HttpRequestBuilder();\n\t}\n\n\t@Override\n\tpublic IHttpResponseBuilder createResponseBuilder() {\n\t\treturn new HttpResponseBuilder();\n\t}\n\n\tprivate void configureClient(HttpClient client, IHttpRequestEngineConfig config) {\n\t\tfinal ClientConnectionManager connectionManager = client.getConnectionManager();\n\t\tif(connectionManager instanceof PoolingClientConnectionManager) {\n\t\t\tPoolingClientConnectionManager ccm = (PoolingClientConnectionManager) connectionManager;\n\t\t\tccm.setMaxTotal(config.getMaxConnections());\n\t\t\tccm.setDefaultMaxPerRoute(config.getMaxConnectionsPerRoute());\n\t\t}\n\t}\n\n\tprotected void setHTMLParser(IHTMLParser htmlParser) {\n\t\tthis.htmlParser = htmlParser;\n\t}\n\t\n\tprotected void unsetHTMLParser(IHTMLParser htmlParser) {\n\t\tthis.htmlParser = null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpRequestTask.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.io.EOFException;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Date;\nimport java.util.List;\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.ExecutionException;\nimport java.util.concurrent.Future;\nimport java.util.logging.Logger;\n\nimport org.apache.http.Header;\nimport org.apache.http.HeaderIterator;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.protocol.ClientContext;\nimport org.apache.http.cookie.ClientCookie;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.cookie.CookieOrigin;\nimport org.apache.http.cookie.CookieSpec;\nimport org.apache.http.cookie.MalformedCookieException;\nimport org.apache.http.cookie.SM;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.protocol.ExecutionContext;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.protocol.HttpContext;\n\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IHttpResponseCookie;\nimport com.subgraph.vega.api.http.requests.IHttpResponseProcessor;\nimport com.subgraph.vega.api.http.requests.RequestEngineException;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\nclass HttpRequestTask implements IHttpRequestTask, Callable<IHttpResponse> {\n\tprivate final static Logger logger = Logger.getLogger(\"request-engine\");\n\tprivate Future<IHttpResponse> future;\n\tprivate final HttpRequestEngine requestEngine;\n\tprivate final HttpClient client;\n\tprivate final RateLimiter rateLimit;\n\tprivate final HttpUriRequest request;\n\tprivate final IRequestOrigin requestOrigin;\n\tprivate final HttpContext context;\n\tprivate final IHttpRequestEngineConfig config;\n\tprivate final IHTMLParser htmlParser;\n\tprivate Date timeCompleted;\n\n\tpublic HttpRequestTask(HttpRequestEngine requestEngine, HttpClient client, RateLimiter rateLimit, HttpUriRequest request, IRequestOrigin requestOrigin, HttpContext context, IHttpRequestEngineConfig config, IHTMLParser htmlParser) {\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.client = client;\n\t\tthis.rateLimit = rateLimit;\n\t\tthis.request = request;\n\t\tthis.requestOrigin = requestOrigin;\n\t\tthis.context = context;\n\t\tthis.config = config;\n\t\tthis.htmlParser = htmlParser;\n\t}\n\n\tpublic void setFuture(Future<IHttpResponse> future) {\n\t\tthis.future = future;\n\t}\n\t\n\t@Override\n\tpublic IHttpRequestEngine getRequestEngine() {\n\t\treturn requestEngine;\n\t}\n\n\t@Override\n\tpublic void abort() {\n\t\trequest.abort();\n\t}\n\n\t@Override\n\tpublic HttpUriRequest getRequest() {\n\t\treturn request;\n\t}\n\n\t@Override\n\tpublic IHttpResponse get(boolean readEntity) throws RequestEngineException {\n\t\ttry {\n\t\t\tIHttpResponse response = future.get();\n\t\t\tif(readEntity) {\n\t\t\t\tresponse.lockResponseEntity();\n\t\t\t}\n\t\t\treturn response;\n\t\t} catch (InterruptedException e) {\n\t\t\tlogger.info(\"Request \"+ request.getURI() +\" was interrupted before completion\");\n\t\t} catch (ExecutionException e) {\n\t\t\tthrow translateException(request, e.getCause());\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean isComplete() {\n\t\treturn future.isDone();\n\t}\n\n\t@Override\n\tpublic synchronized Date getTimeCompleted() {\n\t\treturn timeCompleted;\n\t}\n\t\n\t@Override\n\tpublic IHttpResponse call() throws Exception {\n\t\tif(config.getForceIdentityEncoding())\n\t\t\trequest.setHeader(HTTP.CONTENT_ENCODING, HTTP.IDENTITY_CODING);\n\n\t\tif(rateLimit != null)\n\t\t\trateLimit.maybeDelayRequest();\n\n\t\trequestEngine.addRequestInProgress(this);\n\t\tlong elapsed;\n\t\tfinal Date start = new Date();\n\t\tfinal HttpResponse httpResponse;\n\t\ttry {\n\t\t\thttpResponse = client.execute(request, context);\n\t\t} finally {\n\t\t\telapsed = getElapsedTimeFromContext(context);\n\t\t\tif(elapsed == -1) {\n\t\t\t\telapsed = new Date().getTime() - start.getTime();\n\t\t\t}\n\t\t\tsynchronized(this) {\n\t\t\t\ttimeCompleted = new Date();\n\t\t\t}\n\t\t\trequestEngine.removeRequestInProgress(this);\n\t\t}\n\n\t\tfinal HttpEntity entity = httpResponse.getEntity();\n\t\tif(entity != null) {\n\t\t\tif(config.getMaximumResponseKilobytes() > 0 && entity.getContentLength() > (config.getMaximumResponseKilobytes() * 1024)) {\n\t\t\t\tlogger.warning(\"Aborting request \"+ request.getURI().toString() +\" because response length \"+ entity.getContentLength() + \" exceeds maximum length of \"+ config.getMaximumResponseKilobytes() +\" kb.\");\n\t\t\t\trequest.abort();\n\t\t\t\thttpResponse.setEntity(createEmptyEntity());\n\t\t\t}\n\n\t\t\tfinal HttpEntity newEntity = processEntity(httpResponse, entity);\n\t\t\thttpResponse.setEntity(newEntity);\n\t\t}\n\t\tfinal HttpHost host = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);\n\t\tfinal HttpRequest sentRequest = (HttpRequest) context.getAttribute(HttpRequestEngine.VEGA_SENT_REQUEST);\n\t\tfinal List<Cookie> requestCookies = requestEngine.getCookiesForRequest(host, sentRequest);\n\t\tfinal List<IHttpResponseCookie> responseCookies = extractResponseCookies(httpResponse, context);\n\t\tfinal IHttpResponse response = new EngineHttpResponse(\n\t\t\t\trequest.getURI(), host,  \n\t\t\t\t(sentRequest == null) ? (request) : (sentRequest), \n\t\t\t\trequestCookies, responseCookies,\n\t\t\t\trequestOrigin,\n\t\t\t\thttpResponse, \n\t\t\t\telapsed, \n\t\t\t\thtmlParser\n\t\t);\n\n\t\tfor(IHttpResponseProcessor p: config.getResponseProcessors()) {\n\t\t\tp.processResponse(response.getOriginalRequest(), response, context);\n\t\t}\n\t\t\n\t\treturn response;\n\t}\n\t\n\tprivate List<IHttpResponseCookie> extractResponseCookies(HttpResponse response, HttpContext context) {\n\t\tfinal CookieSpec cookieSpec = (CookieSpec) context.getAttribute(ClientContext.COOKIE_SPEC);\n\t\tfinal CookieOrigin cookieOrigin = (CookieOrigin) context.getAttribute(ClientContext.COOKIE_ORIGIN);\n\t\tfinal HeaderIterator it = response.headerIterator(SM.SET_COOKIE);\n\t\tif(cookieOrigin == null || cookieSpec == null || !it.hasNext()) {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t\t\n\t\tfinal List<IHttpResponseCookie> result = new ArrayList<IHttpResponseCookie>();\n\t\twhile(it.hasNext()) {\n\t\t\tfinal Header header = it.nextHeader();\n\t\t\ttry {\n\t\t\t\tfor(Cookie c: cookieSpec.parse(header, cookieOrigin)) {\n\t\t\t\t\tif(c instanceof ClientCookie) {\n\t\t\t\t\t\tresult.add(new HttpResponseCookie(header.getValue(), (ClientCookie) c));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (MalformedCookieException e) {\n\t\t\t\tlogger.warning(\"Malformed Set-Cookie header received: \"+ header.getValue());\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\t\n\n\tprivate long getElapsedTimeFromContext(HttpContext context) {\n\t\tfinal Date start = (Date) context.getAttribute(RequestTimingHttpExecutor.REQUEST_TIME);\n\t\tfinal Date end = (Date) context.getAttribute(RequestTimingHttpExecutor.RESPONSE_TIME);\n\t\tif(start == null || end == null) {\n\t\t\treturn -1;\n\t\t}\n\t\treturn end.getTime() - start.getTime();\n\t}\n\t\n\tprivate HttpEntity processEntity(HttpResponse response, HttpEntity entity) throws IOException {\n\t\tif(entity == null) {\n\t\t\treturn null;\n\t\t}\n\t\tInputStream input = null;\n\t\ttry {\n\t\t\tinput = entity.getContent();\n\t\t} catch(EOFException ex) {\n\t\t\tresponse.setHeader(HTTP.CONTENT_LEN, \"0\");\n\t\t\tinput = null;\n\t\t}\n\n\t\tif(input == null) {\n\t\t\treturn createEmptyEntity();\n\t\t}\n\n\t\tString contentType = (entity.getContentType() == null) ? (null) : (entity.getContentType().getValue());\n\t\tString contentEncoding = (entity.getContentEncoding() == null) ? (null) : (entity.getContentEncoding().getValue());\n\t\tRepeatableStreamingEntity e =  new RepeatableStreamingEntity(input, entity.getContentLength(), false, entity.isChunked(), contentType, contentEncoding);\n\t\tif(config.getMaximumResponseKilobytes() > 0) {\n\t\t\te.setMaximumInputKilobytes(config.getMaximumResponseKilobytes());\n\t\t}\n\t\treturn e;\n\t}\n\n\tprivate HttpEntity createEmptyEntity() {\n\t\treturn new ByteArrayEntity(new byte[0]);\n\t}\n\n\tprivate RequestEngineException translateException(HttpUriRequest request, Throwable ex) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tif(ex instanceof EOFException) {\n\t\t\tsb.append(\"Unexpected EOF received\");\n\t\t} else if(ex instanceof IOException) {\n\t\t\tsb.append(\"Network problem\");\n\t\t} else if(ex instanceof HttpException) {\n\t\t\tsb.append(\"Protocol problem\");\n\t\t} else {\n\t\t\tsb.append(\"Unknown problem\");\n\t\t}\n\t\tsb.append(\" while retrieving URI \");\n\t\tsb.append(request.getURI().toString());\n\t\tif(ex.getMessage() != null) {\n\t\t\tsb.append(\" [\");\n\t\t\tsb.append(ex.getMessage());\n\t\t\tsb.append(\"]\");\n\t\t}\n\t\treturn new RequestEngineException(sb.toString(), ex);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/HttpResponseCookie.java",
    "content": "package com.subgraph.vega.internal.http.requests;\n\nimport java.util.Date;\n\nimport org.apache.http.cookie.ClientCookie;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponseCookie;\n\npublic class HttpResponseCookie implements IHttpResponseCookie {\n\tprivate final String header;\n\tprivate final ClientCookie cookie;\n\t\n\tHttpResponseCookie(String header, ClientCookie cookie) {\n\t\tthis.header = header;\n\t\tthis.cookie = cookie;\n\t}\n\n\t@Override\n\tpublic String getAttribute(String name) {\n\t\treturn cookie.getAttribute(name);\n\t}\n\n\t@Override\n\tpublic boolean containsAttribute(String name) {\n\t\treturn cookie.containsAttribute(name);\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn cookie.getName();\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn cookie.getValue();\n\t}\n\n\t@Override\n\tpublic String getComment() {\n\t\treturn cookie.getComment();\n\t}\n\n\t@Override\n\tpublic String getCommentURL() {\n\t\treturn cookie.getCommentURL();\n\t}\n\n\t@Override\n\tpublic Date getExpiryDate() {\n\t\treturn cookie.getExpiryDate();\n\t}\n\n\t@Override\n\tpublic boolean isPersistent() {\n\t\treturn cookie.isPersistent();\n\t}\n\n\t@Override\n\tpublic String getDomain() {\n\t\treturn cookie.getDomain();\n\t}\n\n\t@Override\n\tpublic String getPath() {\n\t\treturn cookie.getPath();\n\t}\n\n\t@Override\n\tpublic int[] getPorts() {\n\t\treturn cookie.getPorts();\n\t}\n\n\t@Override\n\tpublic boolean isSecure() {\n\t\treturn cookie.isSecure();\n\t}\n\n\t@Override\n\tpublic int getVersion() {\n\t\treturn cookie.getVersion();\n\t}\n\n\t@Override\n\tpublic boolean isExpired(Date date) {\n\t\treturn cookie.isExpired(date);\n\t}\n\n\t@Override\n\tpublic String getHeader() {\n\t\treturn header;\n\t}\n\t\n\t@Override\n\tpublic String toString() {\n\t\treturn cookie.toString();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/PageFingerprint.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.util.Arrays;\n\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\n\npublic class PageFingerprint implements IPageFingerprint {\n\t\n\tpublic static PageFingerprint generateFromCodeAndString(int code, String body) {\n\t\tfinal PageFingerprint fp = new PageFingerprint();\n\t\tfp.setCode(code);\n\t\tif(body == null || body.isEmpty())\n\t\t\treturn fp;\n\t\tboolean inSpace = false;\n\t\tint clen = 0;\n\t\t\n\t\tfor(int i = 0; i < body.length(); i++) {\n\t\t\tchar c = body.charAt(i);\n\t\t\tif(c <= 0x20 || c == '<' || c == '>' || c == '\\'' || c == '\"') {\n\t\t\t\tif(!inSpace) {\n\t\t\t\t\tinSpace = true;\n\t\t\t\t\tfp.addWordLength(clen);\n\t\t\t\t\tclen = 0;\n\t\t\t\t} else {\n\t\t\t\t\tclen++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif(inSpace) {\n\t\t\t\t\tinSpace = false;\n\t\t\t\t\tfp.addWordLength(clen);\n\t\t\t\t\tclen = 0;\n\t\t\t\t} else {\n\t\t\t\t\tclen++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfp.addWordLength(clen);\n\t\treturn fp;\n\t}\n\t\n\tprivate final static int FP_SIZE = 10;\n\tprivate final static int FP_MAX_LEN = 15;\n\tprivate final static int FP_T_REL = 5;\n\tprivate final static int FP_T_ABS = 6;\n\tprivate final static int FP_B_FAIL = 3;\n\t\n\t\n\tprivate final int[] fpData = new int[FP_SIZE];\n\tprivate int fpCode;\n\t\n\tpublic void setCode(int code) {\n\t\tthis.fpCode = code;\n\t}\n\t\n\tpublic int getCode() {\n\t\treturn fpCode;\n\t}\n\t\n\tpublic int[] getData() {\n\t\treturn fpData;\n\t}\n\t\n\tpublic void addWordLength(int length) {\n\t\tif(length <= FP_MAX_LEN) {\n\t\t\tfpData[length % FP_SIZE]++;\n\t\t}\n\t}\n\t\n\tpublic boolean isSame(IPageFingerprint other) {\n\t\tif(other == null || other.getCode() != fpCode)\n\t\t\treturn false;\n\t\tint totalDiff = 0;\n\t\tint totalScale = 0;\n\t\tint bucketFail = 0;\n\t\tfor(int i = 0; i < FP_SIZE; i++) {\n\t\t\tint diff = fpData[i] - other.getData()[i];\n\t\t\tint scale = fpData[i] + other.getData()[i];\n\t\t\tif(!isRelativeMatch(diff, scale) || (Math.abs(diff) > FP_T_ABS)) {\n\t\t\t\tbucketFail++;\n\t\t\t\tif(bucketFail > FP_B_FAIL)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\ttotalDiff += diff;\n\t\t\ttotalScale += scale;\n\t\t}\n\t\treturn isRelativeMatch(totalDiff, totalScale);\n\t}\n\t\n\tprivate boolean isRelativeMatch(int diff, int scale) {\n\t\treturn Math.abs(diff) <= (1 + (scale * FP_T_REL / 100));\n\t}\n\n\tpublic String toString() {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"FP: (code=\");\n\t\tsb.append(fpCode);\n\t\tsb.append(\") [\");\n\t\tfor(int i = 0; i < FP_SIZE; i++) {\n\t\t\tif(i > 0)\n\t\t\t\tsb.append(\", \");\n\t\t\tsb.append(fpData[i]);\n\t\t}\n\t\tsb.append(\"]\");\n\t\treturn sb.toString();\n\t}\n\t\n\t@Override\n\tpublic boolean equals(Object other) {\n\t\tif(this == other) {\n\t\t\treturn true;\n\t\t} else if(other instanceof PageFingerprint) {\n\t\t\tfinal PageFingerprint that = (PageFingerprint) other;\n\t\t\treturn that.fpCode == this.fpCode && Arrays.equals(that.fpData, this.fpData);\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic int hashCode() {\n\t\treturn fpCode * 47 + Arrays.hashCode(fpData);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/RateLimiter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\npublic class RateLimiter {\n\t\n\tprivate final int msInterval;\n\tprivate final Object lock;\n\tprivate long lastTimestamp;\n\t\n\tRateLimiter(int requestsPerMinute) {\n\t\tmsInterval = 60000 / requestsPerMinute;\n\t\tlock = new Object();\n\t\tlastTimestamp = System.currentTimeMillis();\n\t}\n\t\n\tvoid maybeDelayRequest() throws InterruptedException {\n\t\tsynchronized(lock) {\n\t\t\tfinal long elapsed = System.currentTimeMillis() - lastTimestamp;\n\t\t\tif(elapsed < msInterval) {\n\t\t\t\tThread.sleep(msInterval - elapsed);\n\t\t\t}\n\t\t\tlastTimestamp = System.currentTimeMillis();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/RepeatableStreamingEntity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.entity.AbstractHttpEntity;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.util.ByteArrayBuffer;\nimport org.apache.http.util.EntityUtils;\n\n/**\n * An entity wrapper which converts a non-repeatable streaming entity\n * into a repeatable entity by storing the data as it streams in from\n * a connection (or other streaming source).  When all streaming data has\n * been received, the entity behaves like a ByteArrayEntity. \n */\npublic class RepeatableStreamingEntity extends AbstractHttpEntity {\n\tprivate final static int BUFFER_SIZE = 8192;\n\tprivate boolean isStreaming = true;\n\tprivate long length;\n\tprivate long maximumInputKilobytes = 0; // 0 = no maximum length\n\tprivate HttpEntity bufferEntity;\n\tprivate volatile InputStream input;\n\n\t/**\n\t * @param consumeInput Boolean indicating whether to immediately consume all input into buffer. \n\t * @throws IOException \n\t */\n\tRepeatableStreamingEntity(InputStream input, long length, boolean consumeInput, boolean isChunked, String contentType, String contentEncoding) throws IOException {\n\t\tsetChunked(isChunked);\n\t\tsetContentType(contentType);\n\t\tsetContentEncoding(contentEncoding);\n\t\tsetActiveInputStream(input, length);\n\t\tif (consumeInput != false) {\n\t\t\tconsumeAllInput();\n\t\t}\n\t}\n\n\tRepeatableStreamingEntity(HttpEntity originalEntity) throws IOException {\n\t\tcopyEntityProperties(originalEntity);\n\t\tif(originalEntity.isStreaming()) \n\t\t\tsetActiveInputStream(originalEntity.getContent(), originalEntity.getContentLength());\n\t\telse \n\t\t\tsetActiveByteArrayEntity(EntityUtils.toByteArray(originalEntity));\n\t}\n\n\tvoid setMaximumInputKilobytes(int kb) {\n\t\tmaximumInputKilobytes = kb;\n\t}\n\n\tprivate void copyEntityProperties(HttpEntity e) {\n\t\tsetChunked(e.isChunked());\n\t\tif(e.getContentType() != null)\n\t\t\tsetContentType(e.getContentType().getValue());\n\t\tif(e.getContentEncoding() != null)\n\t\t\tsetContentEncoding(e.getContentType().getValue());\n\t\tlength = e.getContentLength();\n\t}\n\n\tprivate void setActiveInputStream(InputStream input, long length) {\n\t\tif(length > Integer.MAX_VALUE)\n\t\t\tthrow new IllegalArgumentException(\"HTTP entity is too large to be buffered in memory: \"+ length);\n\t\tthis.length = length;\n\t\tfinal int sz = (length <  0) ? (BUFFER_SIZE) : ((int) length);\n\t\tthis.input = new CachingInputStream(input, sz);\n\t\tisStreaming = true;\n\t}\n\n\tprivate void setActiveByteArrayEntity(byte[] content) {\n\t\tByteArrayEntity entity = new ByteArrayEntity(content);\n\t\tisStreaming = false;\n\t\tlength = content.length;\n\t\tbufferEntity = entity;\n\t\tinput = null;\n\t}\n\n\tprivate void consumeAllInput() throws IOException {\n\t\tint rv;\n\t\tif (length < 0) {\n\t\t\twhile ((rv = input.read()) != -1);\n\t\t} else {\n\t\t\tint remaining = (int)this.length;\n\t\t\tbyte[] buffer = new byte[BUFFER_SIZE];\n\t\t\twhile (remaining > 0) {\n\t\t\t\tint sz = (remaining < BUFFER_SIZE) ? (remaining) : (BUFFER_SIZE);\n\t\t\t\trv = input.read(buffer, 0, sz);\n\t\t\t\tif(rv == -1)\n\t\t\t\t\tbreak;\n\t\t\t\tremaining -= rv;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic boolean isRepeatable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic long getContentLength() {\n\t\treturn length;\n\t}\n\n\t@Override\n\tpublic InputStream getContent() throws IOException {\n\t\tif(input != null)\n\t\t\treturn input;\n\t\telse\n\t\t\treturn bufferEntity.getContent();\n\t}\n\n\t@Override\n\tpublic void writeTo(OutputStream outstream) throws IOException {\n\t\tif(input == null) {\n\t\t\tbufferEntity.writeTo(outstream);\n\t\t\treturn;\n\t\t}\n\n\t\tbyte[] buffer = new byte[BUFFER_SIZE];\n\t\tint l;\n\t\t\n\t\ttry {\n\t\t\tif(length < 0) {\n\t\t\t\t// consume until EOF\n\t\t\t\twhile((l = input.read(buffer)) != -1) {\n\t\t\t\t\toutstream.write(buffer, 0, l);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// consume no more than length\n\t\t\t\tlong remaining = this.length;\n\n\t\t\t\twhile(remaining > 0) {\n\t\t\t\t\tint sz = (remaining < BUFFER_SIZE) ? ((int) remaining) : (BUFFER_SIZE);\n\t\t\t\t\tl = input.read(buffer, 0, sz);\n\t\t\t\t\tif(l == -1)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\toutstream.write(buffer, 0, l);\n\t\t\t\t\tremaining -= l;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tif(input != null) {\n\t\t\t\tinput.close();\n\t\t\t\tinput = null;\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isStreaming() {\n\t\treturn isStreaming;\n\t}\n\n\t@Override\n\tpublic void consumeContent() throws IOException {\t\n\t\tif(input != null) {\n\t\t\tinput.close();\n\t\t\tinput = null;\n\t\t}\n\t\tif(bufferEntity != null) {\n\t\t\tEntityUtils.consume(bufferEntity);\n\t\t}\n\t}\n\n\tprivate class CachingInputStream extends InputStream {\n\t\tprivate final InputStream wrappedInput;\n\t\tprivate ByteArrayBuffer buffer;\n\t\tprivate boolean eof;\n\n\t\tCachingInputStream(InputStream input, int bufferSize) {\n\t\t\twrappedInput = input;\n\t\t\tbuffer = new ByteArrayBuffer(bufferSize);\n\t\t}\n\n\t\t@Override\n\t\tpublic int read() throws IOException {\n\t\t\tif(eof) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tfinal int b = wrappedInput.read();\n\t\t\tif(b == -1) { \n\t\t\t\tprocessEOF();\n\t\t\t} else {\n\t\t\t\tbuffer.append(b);\n\t\t\t}\n\t\t\tcheckMaximumLength();\n\t\t\treturn b;\n\t\t}\n\t\t\n\t\tpublic int read(byte[] b, int off, int len) throws IOException {\n\t\t\tif(eof) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\t\n\t\t\tfinal int n = wrappedInput.read(b, off, len);\n\t\t\tif(n == -1) {\n\t\t\t\tprocessEOF();\n\t\t\t} else {\n\t\t\t\tbuffer.append(b, off, n);\n\t\t\t}\n\t\t\tcheckMaximumLength();\n\t\t\treturn n;\n\t\t}\n\n\t\tprivate void checkMaximumLength() throws IOException {\n\t\t\tif(maximumInputKilobytes > 0 && buffer.length() > (maximumInputKilobytes * 1024)) {\n\t\t\t\twrappedInput.close();\n\t\t\t\teof = true;\n\t\t\t\tbuffer = null;\n\t\t\t\tsetActiveByteArrayEntity(new byte[0]);\n\t\t\t\tthrow new IOException(\"Maximum length of \"+ maximumInputKilobytes +\" kb exceeded while streaming http entity.\");\n\t\t\t}\n\t\t}\n\n\t\tpublic void close() throws IOException {\n\t\t\twrappedInput.close();\n\t\t\tif(!eof) {\n\t\t\t\tsetActiveByteArrayEntity(buffer.toByteArray());\n\t\t\t}\n\t\t}\n\n\t\tprivate void processEOF() throws IOException {\n\t\t\twrappedInput.close();\n\t\t\teof = true;\n\t\t\tsetActiveByteArrayEntity(buffer.toByteArray());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/RequestCopyHeadersInterceptor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpMessage;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpRequestInterceptor;\nimport org.apache.http.message.BasicHeader;\nimport org.apache.http.message.BasicHttpEntityEnclosingRequest;\nimport org.apache.http.message.BasicHttpRequest;\nimport org.apache.http.protocol.HttpContext;\n\n/**\n * Create a copy of the request which contains the headers which are actually sent.\n */\npublic class RequestCopyHeadersInterceptor implements HttpRequestInterceptor {\n\n\t@Override\n\tpublic void process(HttpRequest request, HttpContext context)\n\t\t\tthrows HttpException, IOException {\n\t\tfinal HttpRequest copy = copyRequest(request);\n\t\tcontext.setAttribute(HttpRequestEngine.VEGA_SENT_REQUEST, copy);\n\t}\n\t\n\tprivate HttpRequest copyRequest(HttpRequest request) {\n\t\tif(request instanceof HttpEntityEnclosingRequest)\n\t\t\treturn copyEntityEnclosingRequest((HttpEntityEnclosingRequest) request);\n\t\telse\n\t\t\treturn copyBasicRequest(request);\n\t}\n\n\tprivate HttpRequest copyEntityEnclosingRequest(HttpEntityEnclosingRequest request) {\n\t\tfinal BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest(request.getRequestLine());\n\t\tr.setEntity(request.getEntity());\n\t\tcopyHeaders(request, r);\n\t\treturn r;\n\t}\n\n\tprivate HttpRequest copyBasicRequest(HttpRequest request) {\n\t\tif(request == null)\n\t\t\treturn null;\n\t\tfinal HttpRequest r = new BasicHttpRequest(request.getRequestLine());\n\t\tcopyHeaders(request, r);\n\t\treturn r;\n\t}\n\n\tprivate static void copyHeaders(HttpMessage from, HttpMessage to) {\n\t\tfor(Header h: from.getAllHeaders())\n\t\t\tto.addHeader(new BasicHeader(h.getName(), h.getValue()));\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/RequestExtractCookiesInterceptor.java",
    "content": "package com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpRequestInterceptor;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.params.ClientPNames;\nimport org.apache.http.client.params.CookiePolicy;\nimport org.apache.http.client.protocol.ClientContext;\nimport org.apache.http.conn.HttpRoutedConnection;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.cookie.CookieOrigin;\nimport org.apache.http.cookie.CookieSpec;\nimport org.apache.http.cookie.CookieSpecRegistry;\nimport org.apache.http.cookie.MalformedCookieException;\nimport org.apache.http.cookie.SM;\nimport org.apache.http.cookie.params.CookieSpecPNames;\nimport org.apache.http.impl.cookie.DateUtils;\nimport org.apache.http.message.BasicHeader;\nimport org.apache.http.params.BasicHttpParams;\nimport org.apache.http.params.DefaultedHttpParams;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.ExecutionContext;\nimport org.apache.http.protocol.HttpContext;\n \n public class RequestExtractCookiesInterceptor implements HttpRequestInterceptor {\n \n\n\t /* Copied from BrowserCompatSpec */\n\t private static final List<String> DATE_PATTERNS = Arrays.asList(\n        DateUtils.PATTERN_RFC1123,\n        DateUtils.PATTERN_RFC1036,\n        DateUtils.PATTERN_ASCTIME,\n        \"EEE, dd-MMM-yyyy HH:mm:ss z\",\n        \"EEE, dd-MMM-yyyy HH-mm-ss z\",\n        \"EEE, dd MMM yy HH:mm:ss z\",\n        \"EEE dd-MMM-yyyy HH:mm:ss z\",\n        \"EEE dd MMM yyyy HH:mm:ss z\",\n        \"EEE dd-MMM-yyyy HH-mm-ss z\",\n        \"EEE dd-MMM-yy HH:mm:ss z\",\n        \"EEE dd MMM yy HH:mm:ss z\",\n        \"EEE,dd-MMM-yy HH:mm:ss z\",\n        \"EEE,dd-MMM-yyyy HH:mm:ss z\",\n        \"EEE, dd-MM-yyyy HH:mm:ss z\",\n        \n        // Added this pattern seen in the wild\n        \"EEE, dd MMM yyyy HH:mm:ss\"\n\t );\n\n\t private final String defaultPolicy;\n\t \n\t public RequestExtractCookiesInterceptor(String defaultPolicy) {\n\t\t this.defaultPolicy = defaultPolicy;\n\t }\n\t\n\t public RequestExtractCookiesInterceptor() {\n\t\t this(CookiePolicy.BROWSER_COMPATIBILITY);\n\t }\n\n\t @Override\n\t public void process(HttpRequest request, HttpContext context)\n\t\t\t throws HttpException, IOException {\n \n\t\t final CookieOrigin trueOrigin = getTrueOrigin(request, context);\n\t\t if(trueOrigin == null) {\n\t\t\t return;\n\t\t }\n\t\t final CookieOrigin cookieOrigin = toCookieOrigin(trueOrigin);\n\t\t \n\t\t final CookieStore cookieStore = (CookieStore) context.getAttribute(ClientContext.COOKIE_STORE);\n\t\t if(cookieStore == null) {\n\t\t\t return;\n\t\t }\n\t\t \n\t\t final CookieSpec cookieSpec = getCookieSpec(request, context);\n\t\t if(cookieSpec == null) {\n\t\t\t return;\n\t\t }\n\t\t \n\t\t for(Header h: request.getHeaders(SM.COOKIE)) {\n\t\t\t addCookiesForHeader(h, cookieSpec, cookieOrigin, cookieStore);\n\t\t }\n\t\t \n\t\t context.setAttribute(ClientContext.COOKIE_SPEC, cookieSpec);\n\t\t context.setAttribute(ClientContext.COOKIE_ORIGIN, trueOrigin);\n\t }\n\t \n\t private void addCookiesForHeader(Header header, CookieSpec spec, CookieOrigin origin, CookieStore store) throws MalformedCookieException {\n\t\t for(Cookie c: processCookieHeader(header, spec, origin)) {\n\t\t\t store.addCookie(c);\n\t\t }\n\t }\n\t\n\t private List<Cookie> processCookieHeader(Header header, CookieSpec spec, CookieOrigin origin) {\n\t\t final List<Cookie> cookies = new ArrayList<Cookie>();\n\t\t for(String cookieValue: header.getValue().split(\";\")) {\n\t\t\t try {\n\t\t\t\t final Header setHeader = new BasicHeader(SM.SET_COOKIE, cookieValue);\n\t\t\t\t final List<Cookie> parsedCookies = spec.parse(setHeader, origin);\n\t\t\t\t cookies.addAll(parsedCookies);\n\t\t\t} catch (MalformedCookieException e) {\n\t\t\t\t// Just ignore it\n\t\t\t}\n\t\t }\n\t\t return cookies;\n\t }\n\t \n\t private CookieSpec getCookieSpec(HttpRequest request, HttpContext context) {\n\t\t final CookieSpecRegistry registry = (CookieSpecRegistry) context.getAttribute(\n\t\t\t\t ClientContext.COOKIESPEC_REGISTRY);\n\t\t if(registry == null) {\n\t\t\t return null;\n\t\t }\n\t\t \n\t\t final HttpParams params = new DefaultedHttpParams(new BasicHttpParams(), request.getParams());\n\t\t params.setParameter(CookieSpecPNames.DATE_PATTERNS, DATE_PATTERNS);\n \t\t final String policy = getCookiePolicy(params);\n \t\t return registry.getCookieSpec(policy, params);\n\t }\n\t \n\t \n\t private String getCookiePolicy(HttpParams params) {\n\t\t final String policy = (String) params.getParameter(ClientPNames.COOKIE_POLICY);\n\t\t if(policy == null) {\n\t\t\t return defaultPolicy;\n\t\t } else {\n\t\t\t return policy;\n\t\t }\n\t }\n \n\t private CookieOrigin getTrueOrigin(HttpRequest request, HttpContext context) throws ProtocolException {\n\t\t final HttpHost targetHost = (HttpHost) context.getAttribute(\n\t\t\t\t ExecutionContext.HTTP_TARGET_HOST);\n\t\t if(targetHost == null) {\n\t\t\t return null;\n\t\t }\n\t\t final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(\n\t\t\t\t ExecutionContext.HTTP_CONNECTION);\n\t\t if(conn == null) {\n\t\t\t return null;\n\t\t }\n\t\t \n\t\t return new CookieOrigin(\n\t\t\t\t targetHost.getHostName(),\n\t\t\t\t getPort(targetHost, conn),\n\t\t\t\t getPathForRequest(request),\n\t\t\t\t conn.isSecure());\n\t }\n\n\t private CookieOrigin toCookieOrigin(CookieOrigin trueOrigin) {\n\t\t return new CookieOrigin(\n\t\t\t\t trueOrigin.getHost(), \n\t\t\t\t trueOrigin.getPort(), \n\t\t\t\t \"/\", // broaden path scope since original cookie path is unknown \n\t\t\t\t false);\n\t }\n\n\t private String getPathForRequest(HttpRequest request) {\n\t\tif(request instanceof HttpUriRequest) {\n\t\t\tfinal URI requestURI = ((HttpUriRequest) request).getURI();\n\t\t\treturn requestURI.getPath();\n\t\t} else {\n\t\t\treturn request.getRequestLine().getUri();\n\t\t}\n\t }\n\n\t private int getPort(HttpHost host, HttpRoutedConnection connection) {\n\t\t if(host.getPort() >= 0) {\n\t\t\t return host.getPort();\n\t\t } else if (connection.getRoute().getHopCount() == 1) {\n\t\t\t return connection.getRemotePort();\n\t\t } else {\n\t\t\t return getPortForScheme(host.getSchemeName());\n\t\t }\n\t}\n\n\tprivate int getPortForScheme(String scheme) {\n\t\tif(scheme.equalsIgnoreCase(\"http\")) {\n\t\t\treturn 80;\n\t\t} else if(scheme.equalsIgnoreCase(\"https\")) {\n\t\t\treturn 443;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/RequestTimingHttpExecutor.java",
    "content": "package com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\nimport java.util.Date;\n\nimport org.apache.http.HttpClientConnection;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpStatus;\nimport org.apache.http.HttpVersion;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.params.CoreProtocolPNames;\nimport org.apache.http.protocol.ExecutionContext;\nimport org.apache.http.protocol.HttpContext;\nimport org.apache.http.protocol.HttpRequestExecutor;\n\npublic class RequestTimingHttpExecutor extends HttpRequestExecutor {\n\tpublic final static String REQUEST_TIME = \"vega.request_time\";\n\tpublic final static String RESPONSE_TIME = \"vega.response_time\";\n\tprotected HttpResponse doSendRequest(\n\t\t\tfinal HttpRequest request,\n\t\t\tfinal HttpClientConnection conn,\n\t\t\tfinal HttpContext context) throws IOException, HttpException {\n\n\t\tif (request == null) {\n            throw new IllegalArgumentException(\"HTTP request may not be null\");\n        }\n        if (conn == null) {\n            throw new IllegalArgumentException(\"HTTP connection may not be null\");\n        }\n        if (context == null) {\n            throw new IllegalArgumentException(\"HTTP context may not be null\");\n        }\n\n        HttpResponse response = null;\n\n        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);\n        context.setAttribute(ExecutionContext.HTTP_REQ_SENT, Boolean.FALSE);\n\n        conn.sendRequestHeader(request);\n        context.setAttribute(REQUEST_TIME, new Date());\n        if (request instanceof HttpEntityEnclosingRequest) {\n            // Check for expect-continue handshake. We have to flush the\n            // headers and wait for an 100-continue response to handle it.\n            // If we get a different response, we must not send the entity.\n            boolean sendentity = true;\n            final ProtocolVersion ver =\n                request.getRequestLine().getProtocolVersion();\n            if (((HttpEntityEnclosingRequest) request).expectContinue() &&\n                !ver.lessEquals(HttpVersion.HTTP_1_0)) {\n\n                conn.flush();\n                // As suggested by RFC 2616 section 8.2.3, we don't wait for a\n                // 100-continue response forever. On timeout, send the entity.\n                int tms = request.getParams().getIntParameter(\n                        CoreProtocolPNames.WAIT_FOR_CONTINUE, 2000);\n\n                if (conn.isResponseAvailable(tms)) {\n                 response = conn.receiveResponseHeader();\n                 context.setAttribute(RESPONSE_TIME, new Date());\n                    if (canResponseHaveBody(request, response)) {\n                        conn.receiveResponseEntity(response);\n                    }\n                    int status = response.getStatusLine().getStatusCode();\n                    if (status < 200) {\n                        if (status != HttpStatus.SC_CONTINUE) {\n                            throw new ProtocolException(\n                                    \"Unexpected response: \" + response.getStatusLine());\n                        }\n                        // discard 100-continue\n                        response = null;\n                    } else {\n                        sendentity = false;\n                    }\n                }\n            }\n            if (sendentity) {\n                conn.sendRequestEntity((HttpEntityEnclosingRequest) request);\n            }\n        }\n        conn.flush();\n        context.setAttribute(ExecutionContext.HTTP_REQ_SENT, Boolean.TRUE);\n        return response;\n\n\t}\n\t\n\tprotected HttpResponse doReceiveResponse(\n\t\t\tfinal HttpRequest request,\n\t\t\tfinal HttpClientConnection conn,\n\t\t\tfinal HttpContext context) throws IOException, HttpException {\n\t\t     if (request == null) {\n            throw new IllegalArgumentException(\"HTTP request may not be null\");\n        }\n        if (conn == null) {\n            throw new IllegalArgumentException(\"HTTP connection may not be null\");\n        }\n        if (context == null) {\n            throw new IllegalArgumentException(\"HTTP context may not be null\");\n        }\n\n        HttpResponse response = null;\n        int statuscode = 0;\n\n        while (response == null || statuscode < HttpStatus.SC_OK) {\n\n            response = conn.receiveResponseHeader();\n            context.setAttribute(RESPONSE_TIME, new Date());\n            if (canResponseHaveBody(request, response)) {\n                conn.receiveResponseEntity(response);\n            }\n            statuscode = response.getStatusLine().getStatusCode();\n\n        } // while intermediate response\n\n        return response;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/SSLSocketFactoryPlus.java",
    "content": "package com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\nimport java.security.KeyManagementException;\nimport java.security.KeyStoreException;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.UnrecoverableKeyException;\n\nimport javax.net.ssl.SSLSocket;\n\nimport org.apache.http.conn.ssl.SSLSocketFactory;\nimport org.apache.http.conn.ssl.TrustStrategy;\nimport org.apache.http.conn.ssl.X509HostnameVerifier;\n\npublic class SSLSocketFactoryPlus extends SSLSocketFactory {\n\t\n    public SSLSocketFactoryPlus(TrustStrategy trustStrategy,\n\t\t\tX509HostnameVerifier hostnameVerifier)\n\t\t\tthrows NoSuchAlgorithmException, KeyManagementException,\n\t\t\tKeyStoreException, UnrecoverableKeyException {\n\t\tsuper(trustStrategy, hostnameVerifier);\n\t\t// TODO Auto-generated constructor stub\n\t}\n\n\tprotected void prepareSocket(final SSLSocket socket) throws IOException {\n\t    double ver = javaVersionAsFloat();\n\n\t    if (ver < 1.8) {\n\t    \t\n\t    \tString[] suites = new String[] {\"TLS_RSA_WITH_AES_128_CBC_SHA\", \n\t    \t\t\t\t\t\t\t\t\t\"SSL_RSA_WITH_RC4_128_SHA\", \n\t    \t\t\t\t\t\t\t\t\t\"TLS_EMPTY_RENEGOTIATION_INFO_SCSV\"};\n\t    \t\n\t    \tsocket.setEnabledCipherSuites(suites);\n\t    }\n    }\n\t\n\tprivate double javaVersionAsFloat() {\n\t\t \n\t\tint count = 0;\n\t\tint position = 0;\n\t\tdouble ver = 0;\n\t\tString versionProperty = System.getProperty(\"java.version\");\n\n\t    for (; position < versionProperty.length() && count < 2; position++) {\n\t        if (versionProperty.charAt(position) == '.') {\n\t            count++;\n\t        }\n\t    }\n\t    position--;\n\n\t    ver = Double.parseDouble(versionProperty.substring(0, position));\n\t    \n\t    return ver;\n\t    \n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/VegaResponseProcessCookies.java",
    "content": "package com.subgraph.vega.internal.http.requests;\n\nimport java.io.IOException;\nimport java.util.List;\n\nimport org.apache.http.Header;\nimport org.apache.http.HeaderIterator;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpResponseInterceptor;\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.client.protocol.ClientContext;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.cookie.CookieOrigin;\nimport org.apache.http.cookie.CookieSpec;\nimport org.apache.http.cookie.MalformedCookieException;\nimport org.apache.http.cookie.SM;\nimport org.apache.http.protocol.HttpContext;\n\npublic class VegaResponseProcessCookies implements HttpResponseInterceptor {\n\n\tpublic void process(final HttpResponse response, final HttpContext context)\n\t\t\tthrows HttpException, IOException {\n\t\tif (response == null) {\n\t\t\tthrow new IllegalArgumentException(\"HTTP request may not be null\");\n\t\t}\n\t\tif (context == null) {\n\t\t\tthrow new IllegalArgumentException(\"HTTP context may not be null\");\n\t\t}\n\n\t\t// Obtain actual CookieSpec instance\n\t\tCookieSpec cookieSpec = (CookieSpec) context\n\t\t\t\t.getAttribute(ClientContext.COOKIE_SPEC);\n\t\tif (cookieSpec == null) {\n\t\t\treturn;\n\t\t}\n\t\t// Obtain cookie store\n\t\tCookieStore cookieStore = (CookieStore) context\n\t\t\t\t.getAttribute(ClientContext.COOKIE_STORE);\n\t\tif (cookieStore == null) {\n\t\t\treturn;\n\t\t}\n\t\t// Obtain actual CookieOrigin instance\n\t\tCookieOrigin cookieOrigin = (CookieOrigin) context\n\t\t\t\t.getAttribute(ClientContext.COOKIE_ORIGIN);\n\t\tif (cookieOrigin == null) {\n\t\t\treturn;\n\t\t}\n\t\tHeaderIterator it = response.headerIterator(SM.SET_COOKIE);\n\t\tprocessCookies(it, cookieSpec, cookieOrigin, cookieStore);\n\n\t\t// see if the cookie spec supports cookie versioning.\n\t\tif (cookieSpec.getVersion() > 0) {\n\t\t\t// process set-cookie2 headers.\n\t\t\t// Cookie2 will replace equivalent Cookie instances\n\t\t\tit = response.headerIterator(SM.SET_COOKIE2);\n\t\t\tprocessCookies(it, cookieSpec, cookieOrigin, cookieStore);\n\t\t}\n\t}\n\n\tprivate void processCookies(final HeaderIterator iterator,\n\t\t\tfinal CookieSpec cookieSpec, final CookieOrigin cookieOrigin,\n\t\t\tfinal CookieStore cookieStore) {\n\t\twhile (iterator.hasNext()) {\n\t\t\tHeader header = iterator.nextHeader();\n\t\t\ttry {\n\t\t\t\tList<Cookie> cookies = cookieSpec.parse(header, cookieOrigin);\n\t\t\t\tfor (Cookie cookie : cookies) {\n\t\t\t\t\tcookieStore.addCookie(cookie);\n\t\t\t\t}\n\t\t\t} catch (MalformedCookieException ex) {\n\t\t\t}\n\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/client/VegaDecompressingHttpClient.java",
    "content": "package com.subgraph.vega.internal.http.requests.client;\n\nimport java.io.IOException;\nimport java.net.URI;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpRequestInterceptor;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpResponseInterceptor;\nimport org.apache.http.client.ClientProtocolException;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.ResponseHandler;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.protocol.RequestAcceptEncoding;\nimport org.apache.http.client.protocol.ResponseContentEncoding;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.conn.ClientConnectionManager;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.BasicHttpContext;\nimport org.apache.http.protocol.HttpContext;\nimport org.apache.http.util.EntityUtils;\n\n/**\n * A copy of DecompressingHttpClient changed to use the Vega request wrapping classes\n */\npublic class VegaDecompressingHttpClient implements HttpClient {\n\n    private HttpClient backend;\n    private HttpRequestInterceptor acceptEncodingInterceptor;\n    private HttpResponseInterceptor contentEncodingInterceptor;\n    \n    /**\n     * Constructs a decorator to ask for and handle compressed\n     * entities on the fly.\n     * @param backend the {@link HttpClient} to use for actually\n     *   issuing requests\n     */\n    public VegaDecompressingHttpClient(HttpClient backend) {\n        this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());\n    }\n    \n    VegaDecompressingHttpClient(HttpClient backend, \n            HttpRequestInterceptor requestInterceptor, \n            HttpResponseInterceptor responseInterceptor) {\n        this.backend = backend;\n        this.acceptEncodingInterceptor = requestInterceptor;\n        this.contentEncodingInterceptor = responseInterceptor;\n    }\n\n    public HttpParams getParams() {\n        return backend.getParams();\n    }\n\n    public ClientConnectionManager getConnectionManager() {\n        return backend.getConnectionManager();\n    }\n\n    public HttpResponse execute(HttpUriRequest request) throws IOException,\n            ClientProtocolException {\n        return execute(getHttpHost(request), request, (HttpContext)null);\n    }\n\n    HttpHost getHttpHost(HttpUriRequest request) {\n        URI uri = request.getURI();\n        return URIUtils.extractHost(uri);\n    }\n\n    public HttpResponse execute(HttpUriRequest request, HttpContext context)\n            throws IOException, ClientProtocolException {\n        return execute(getHttpHost(request), request, context);\n    }\n\n    public HttpResponse execute(HttpHost target, HttpRequest request)\n            throws IOException, ClientProtocolException {\n        return execute(target, request, (HttpContext)null);\n    }\n\n    public HttpResponse execute(HttpHost target, HttpRequest request,\n            HttpContext context) throws IOException, ClientProtocolException {\n        try {\n            if (context == null) context = new BasicHttpContext();\n            HttpRequest wrapped;\n            if (request instanceof HttpEntityEnclosingRequest) {\n                wrapped = new VegaEntityEnclosingRequestWrapper((HttpEntityEnclosingRequest) request);\n            } else {\n                wrapped = new VegaRequestWrapper(request);\n            }\n            acceptEncodingInterceptor.process(wrapped, context);\n            HttpResponse response = backend.execute(target, wrapped, context);\n            contentEncodingInterceptor.process(response, context);\n            if (Boolean.TRUE.equals(context.getAttribute(ResponseContentEncoding.UNCOMPRESSED))) {\n                response.removeHeaders(\"Content-Length\");\n                response.removeHeaders(\"Content-Encoding\");\n                response.removeHeaders(\"Content-MD5\");\n            }\n            return response;\n        } catch (HttpException e) {\n            throw new ClientProtocolException(e);\n        }\n    }\n\n    public <T> T execute(HttpUriRequest request,\n            ResponseHandler<? extends T> responseHandler) throws IOException,\n            ClientProtocolException {\n        return execute(getHttpHost(request), request, responseHandler);\n    }\n\n    public <T> T execute(HttpUriRequest request,\n            ResponseHandler<? extends T> responseHandler, HttpContext context)\n            throws IOException, ClientProtocolException {\n        return execute(getHttpHost(request), request, responseHandler, context);\n    }\n\n    public <T> T execute(HttpHost target, HttpRequest request,\n            ResponseHandler<? extends T> responseHandler) throws IOException,\n            ClientProtocolException {\n        return execute(target, request, responseHandler, null);\n    }\n\n    public <T> T execute(HttpHost target, HttpRequest request,\n            ResponseHandler<? extends T> responseHandler, HttpContext context)\n            throws IOException, ClientProtocolException {\n        HttpResponse response = execute(target, request, context);\n        try {\n            return responseHandler.handleResponse(response);\n        } finally {\n            HttpEntity entity = response.getEntity();\n            if (entity != null) EntityUtils.consume(entity);\n        }\n    }\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/client/VegaEntityEnclosingRequestWrapper.java",
    "content": "package com.subgraph.vega.internal.http.requests.client;\n\nimport java.io.IOException;\n\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.AbortableHttpRequest;\nimport org.apache.http.conn.ClientConnectionRequest;\nimport org.apache.http.conn.ConnectionReleaseTrigger;\nimport org.apache.http.impl.client.EntityEnclosingRequestWrapper;\n\npublic class VegaEntityEnclosingRequestWrapper extends EntityEnclosingRequestWrapper implements AbortableHttpRequest {\n \n\tpublic VegaEntityEnclosingRequestWrapper(HttpEntityEnclosingRequest request)\n\t\t\tthrows ProtocolException {\n\t\tsuper(request);\n\t}\n\n\t@Override\n\tpublic RequestLine getRequestLine() {\n\t\treturn getOriginal().getRequestLine();\n\t}\n\n\tprivate AbortableHttpRequest getAbortableRequest() {\n\t\tif(getOriginal() instanceof AbortableHttpRequest) {\n\t\t\treturn (AbortableHttpRequest) getOriginal();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void setConnectionRequest(ClientConnectionRequest connRequest)\n\t\t\tthrows IOException {\n\t\tfinal AbortableHttpRequest ab = getAbortableRequest();\n\t\tif(ab != null) {\n\t\t\tab.setConnectionRequest(connRequest);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger)\n\t\t\tthrows IOException {\n\t\tfinal AbortableHttpRequest ab = getAbortableRequest();\n\t\tif(ab != null) {\n\t\t\tab.setReleaseTrigger(releaseTrigger);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void abort() {\n\t\tfinal AbortableHttpRequest ab = getAbortableRequest();\n\t\tif(ab != null) {\n\t\t\tab.abort();\n\t\t} else {\n\t\t\tsuper.abort();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/client/VegaHttpClient.java",
    "content": "package com.subgraph.vega.internal.http.requests.client;\n\nimport org.apache.commons.logging.Log;\nimport org.apache.commons.logging.LogFactory;\nimport org.apache.http.ConnectionReuseStrategy;\nimport org.apache.http.client.AuthenticationStrategy;\nimport org.apache.http.client.HttpRequestRetryHandler;\nimport org.apache.http.client.RedirectStrategy;\nimport org.apache.http.client.RequestDirector;\nimport org.apache.http.client.UserTokenHandler;\nimport org.apache.http.conn.ClientConnectionManager;\nimport org.apache.http.conn.ConnectionKeepAliveStrategy;\nimport org.apache.http.conn.routing.HttpRoutePlanner;\nimport org.apache.http.impl.client.DefaultHttpClient;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HttpProcessor;\nimport org.apache.http.protocol.HttpRequestExecutor;\n\nimport com.subgraph.vega.internal.http.requests.RequestTimingHttpExecutor;\n\npublic class VegaHttpClient extends DefaultHttpClient {\n\tprivate final Log log = LogFactory.getLog(getClass());\n\n\tpublic VegaHttpClient(ClientConnectionManager ccm, HttpParams params) {\n\t\tsuper(ccm, params);\n\t}\n\n\t@Override\n\tprotected HttpRequestExecutor createRequestExecutor() {\n\t\treturn new RequestTimingHttpExecutor();\n\t}\n\n\t@Override\n\tprotected RequestDirector createClientRequestDirector(\n\t\t\tfinal HttpRequestExecutor requestExec,\n\t\t\tfinal ClientConnectionManager conman,\n\t\t\tfinal ConnectionReuseStrategy reustrat,\n\t\t\tfinal ConnectionKeepAliveStrategy kastrat,\n\t\t\tfinal HttpRoutePlanner rouplan, final HttpProcessor httpProcessor,\n\t\t\tfinal HttpRequestRetryHandler retryHandler,\n\t\t\tfinal RedirectStrategy redirectStrategy,\n\t\t\tfinal AuthenticationStrategy targetAuthStrategy,\n\t\t\tfinal AuthenticationStrategy proxyAuthStrategy,\n\t\t\tfinal UserTokenHandler userTokenHandler, final HttpParams params) {\n\n\t\treturn new VegaRequestDirector(log, requestExec, conman, reustrat,\n\t\t\t\tkastrat, rouplan, httpProcessor, retryHandler,\n\t\t\t\tredirectStrategy, targetAuthStrategy, proxyAuthStrategy,\n\t\t\t\tuserTokenHandler, params) {\n\n\t\t};\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/client/VegaRequestDirector.java",
    "content": "package com.subgraph.vega.internal.http.requests.client;\n\nimport org.apache.commons.logging.Log;\nimport org.apache.http.ConnectionReuseStrategy;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.client.AuthenticationStrategy;\nimport org.apache.http.client.HttpRequestRetryHandler;\nimport org.apache.http.client.RedirectStrategy;\nimport org.apache.http.client.UserTokenHandler;\nimport org.apache.http.conn.ClientConnectionManager;\nimport org.apache.http.conn.ConnectionKeepAliveStrategy;\nimport org.apache.http.conn.routing.HttpRoutePlanner;\nimport org.apache.http.impl.client.DefaultRequestDirector;\nimport org.apache.http.impl.client.RequestWrapper;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HttpProcessor;\nimport org.apache.http.protocol.HttpRequestExecutor;\n\npublic class VegaRequestDirector extends DefaultRequestDirector {\n\n\tpublic VegaRequestDirector(final Log log,\n\t\t\tfinal HttpRequestExecutor requestExec,\n\t\t\tfinal ClientConnectionManager conman,\n\t\t\tfinal ConnectionReuseStrategy reustrat,\n\t\t\tfinal ConnectionKeepAliveStrategy kastrat,\n\t\t\tfinal HttpRoutePlanner rouplan, final HttpProcessor httpProcessor,\n\t\t\tfinal HttpRequestRetryHandler retryHandler,\n\t\t\tfinal RedirectStrategy redirectStrategy,\n\t\t\tfinal AuthenticationStrategy targetAuthStrategy,\n\t\t\tfinal AuthenticationStrategy proxyAuthStrategy,\n\t\t\tfinal UserTokenHandler userTokenHandler, final HttpParams params) {\n\t\tsuper(log, requestExec, conman, reustrat, kastrat, rouplan,\n\t\t\t\thttpProcessor, retryHandler, redirectStrategy,\n\t\t\t\ttargetAuthStrategy, proxyAuthStrategy, userTokenHandler, params);\n\t}\n\n\t// httpclient patched to change this method private --> protected\n\t@Override\n\tprotected RequestWrapper wrapRequest(final HttpRequest request)\n\t\t\tthrows ProtocolException {\n\t\tif (request instanceof HttpEntityEnclosingRequest) {\n\t\t\treturn new VegaEntityEnclosingRequestWrapper(\n\t\t\t\t\t(HttpEntityEnclosingRequest) request);\n\t\t} else {\n\t\t\treturn new VegaRequestWrapper(request);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/client/VegaRequestWrapper.java",
    "content": "package com.subgraph.vega.internal.http.requests.client;\n\nimport java.io.IOException;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.ProtocolException;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.AbortableHttpRequest;\nimport org.apache.http.conn.ClientConnectionRequest;\nimport org.apache.http.conn.ConnectionReleaseTrigger;\nimport org.apache.http.impl.client.RequestWrapper;\n\npublic class VegaRequestWrapper extends RequestWrapper implements AbortableHttpRequest {\n\n\tpublic VegaRequestWrapper(HttpRequest request) throws ProtocolException {\n\t\tsuper(request);\n\t}\n\t\n\t@Override\n\tpublic RequestLine getRequestLine() {\n\t\treturn getOriginal().getRequestLine();\n\t}\n\n\t\n\tprivate AbortableHttpRequest getAbortableRequest() {\n\t\tif(getOriginal() instanceof AbortableHttpRequest) {\n\t\t\treturn (AbortableHttpRequest) getOriginal();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void setConnectionRequest(ClientConnectionRequest connRequest)\n\t\t\tthrows IOException {\n\t\tfinal AbortableHttpRequest ab = getAbortableRequest();\n\t\tif(ab != null) {\n\t\t\tab.setConnectionRequest(connRequest);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger)\n\t\t\tthrows IOException {\n\t\tfinal AbortableHttpRequest ab = getAbortableRequest();\n\t\tif(ab != null) {\n\t\t\tab.setReleaseTrigger(releaseTrigger);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void abort() {\n\t\tfinal AbortableHttpRequest ab = getAbortableRequest();\n\t\tif(ab != null) {\n\t\t\tab.abort();\n\t\t} else {\n\t\t\tsuper.abort();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/IHttpClientConfigurer.java",
    "content": "package com.subgraph.vega.internal.http.requests.config;\n\nimport org.apache.http.impl.client.DefaultHttpClient;\nimport org.apache.http.params.HttpParams;\n\npublic interface IHttpClientConfigurer {\n\tvoid configureHttpClient(DefaultHttpClient client);\n\tHttpParams createHttpParams();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/IRequestEncodingStrategy.java",
    "content": "package com.subgraph.vega.internal.http.requests.config;\n\nimport org.apache.http.RequestLine;\n\npublic interface IRequestEncodingStrategy {\n\tRequestLine encodeRequestLine(RequestLine requestLine);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/RequestEngineConfig.java",
    "content": "package com.subgraph.vega.internal.http.requests.config;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.internal.http.requests.config.proxy.ProxyHttpClientConfigurer;\nimport com.subgraph.vega.internal.http.requests.config.proxy.ProxyRequestEncodingStrategy;\nimport com.subgraph.vega.internal.http.requests.config.scanner.ScannerHttpClientConfigurer;\nimport com.subgraph.vega.internal.http.requests.config.scanner.ScannerRequestEncodingStrategy;\n\npublic class RequestEngineConfig {\n\t\n\tpublic static IRequestEncodingStrategy getRequestEncodingStrategy(IHttpRequestEngine.EngineConfigType type) {\n\t\tswitch(type) {\n\t\tcase CONFIG_SCANNER:\n\t\t\treturn new ScannerRequestEncodingStrategy();\n\t\tcase CONFIG_PROXY:\n\t\t\treturn new ProxyRequestEncodingStrategy();\n\t\t}\n\t\tthrow new IllegalStateException();\n\t}\n\n\tpublic static IHttpClientConfigurer getHttpClientConfigurer(IHttpRequestEngine.EngineConfigType type) {\n\t\tswitch(type) {\n\t\tcase CONFIG_SCANNER:\n\t\t\treturn new ScannerHttpClientConfigurer();\n\t\tcase CONFIG_PROXY:\n\t\t\treturn new ProxyHttpClientConfigurer();\n\t\t}\n\t\tthrow new IllegalStateException();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/proxy/ProxyHttpClientConfigurer.java",
    "content": "package com.subgraph.vega.internal.http.requests.config.proxy;\n\nimport org.apache.http.HttpVersion;\nimport org.apache.http.client.params.ClientPNames;\nimport org.apache.http.impl.client.DefaultHttpClient;\nimport org.apache.http.params.BasicHttpParams;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.params.HttpProtocolParams;\n\nimport com.subgraph.vega.internal.http.requests.RequestCopyHeadersInterceptor;\nimport com.subgraph.vega.internal.http.requests.RequestExtractCookiesInterceptor;\nimport com.subgraph.vega.internal.http.requests.VegaResponseProcessCookies;\nimport com.subgraph.vega.internal.http.requests.config.IHttpClientConfigurer;\n\n\n\npublic class ProxyHttpClientConfigurer implements IHttpClientConfigurer {\n\n\t@Override\n\tpublic void configureHttpClient(DefaultHttpClient client) {\n\t\tclient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);\n\t\tconfigureRequestInterceptors(client);\n\t\tconfigureResponseInterceptors(client);\n\t}\n\t\n\tprivate void configureRequestInterceptors(DefaultHttpClient client) {\n\t\tclient.clearRequestInterceptors();\n\t\tclient.addRequestInterceptor(new RequestCopyHeadersInterceptor());\n\t\tclient.addRequestInterceptor(new RequestExtractCookiesInterceptor());\n\t}\n\t\n\tprivate void configureResponseInterceptors(DefaultHttpClient client) {\n\t\tclient.clearResponseInterceptors();\n\t\tclient.addResponseInterceptor(new VegaResponseProcessCookies());\n\t}\n\n\t@Override\n\tpublic HttpParams createHttpParams() {\n\t\tfinal HttpParams params = new BasicHttpParams();\n\t\tHttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);\n\t\treturn params;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/proxy/ProxyRequestEncodingStrategy.java",
    "content": "package com.subgraph.vega.internal.http.requests.config.proxy;\n\nimport org.apache.http.RequestLine;\n\nimport com.subgraph.vega.internal.http.requests.config.IRequestEncodingStrategy;\n\npublic class ProxyRequestEncodingStrategy implements IRequestEncodingStrategy {\n\n\t@Override\n\tpublic RequestLine encodeRequestLine(RequestLine requestLine) {\n\t\treturn requestLine;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/scanner/ScannerHttpClientConfigurer.java",
    "content": "package com.subgraph.vega.internal.http.requests.config.scanner;\n\nimport org.apache.http.HttpVersion;\nimport org.apache.http.client.params.ClientPNames;\nimport org.apache.http.client.protocol.ResponseProcessCookies;\nimport org.apache.http.impl.client.DefaultHttpClient;\nimport org.apache.http.params.BasicHttpParams;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.params.HttpProtocolParams;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.internal.http.requests.RequestCopyHeadersInterceptor;\nimport com.subgraph.vega.internal.http.requests.VegaResponseProcessCookies;\nimport com.subgraph.vega.internal.http.requests.config.IHttpClientConfigurer;\n\npublic class ScannerHttpClientConfigurer implements IHttpClientConfigurer {\n\n\t@Override\n\tpublic void configureHttpClient(DefaultHttpClient client) {\n\t\tclient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);\n\t\tclient.addRequestInterceptor(new RequestCopyHeadersInterceptor());\n\t\tclient.removeResponseInterceptorByClass(ResponseProcessCookies.class);\n\t\tclient.addResponseInterceptor(new VegaResponseProcessCookies());\n\t}\n\n\t@Override\n\tpublic HttpParams createHttpParams() {\n\t\tfinal HttpParams params = new BasicHttpParams();\n\t\tHttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);\n\t\tHttpProtocolParams.setUserAgent(params, IHttpRequestEngineFactory.DEFAULT_USER_AGENT);\n\t\treturn params;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/config/scanner/ScannerRequestEncodingStrategy.java",
    "content": "package com.subgraph.vega.internal.http.requests.config.scanner;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URLEncoder;\nimport java.util.logging.Logger;\n\nimport org.apache.http.RequestLine;\nimport org.apache.http.message.BasicRequestLine;\n\nimport com.subgraph.vega.internal.http.requests.config.IRequestEncodingStrategy;\n\npublic class ScannerRequestEncodingStrategy implements IRequestEncodingStrategy {\n\tprivate final String PATH_ENC_CHARS = \"#&=+;,!$?%\";\n\tprivate final String QUERY_ENC_CHARS = \"#+;,!$?%\";\n\tprivate final static Logger logger = Logger.getLogger(\"scanner\"); \n\n\t@Override\n\tpublic RequestLine encodeRequestLine(RequestLine requestLine) {\n\t\tfinal String path = lineToPath(requestLine.getUri());\n\t\tfinal String query = lineToQuery(requestLine.getUri());\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tsb.append(encodePath(path));\n\t\tif(query != null) {\n\t\t\tsb.append('?');\n\t\t\tsb.append(encodeQuery(query));\n\t\t\t\n\t\t\t\n\t\t}\n\t\treturn new BasicRequestLine(requestLine.getMethod(), sb.toString(), requestLine.getProtocolVersion());\n\t}\n\t\n\tprivate String encodeQuery(String query) {\n\t\t// TODO: Quick fix to support URI-encoding UTF-8 characters, probably wrong level of abstraction, should maybe be re-factored as its own EncodingStrategy with a check earlier in the call chain\n\t\tif (containsUnicode(query)){\n\t\t\ttry {\n\t\t\t\treturn URLEncoder.encode(query, \"UTF-8\");\n\t\t\t} catch (UnsupportedEncodingException e) {\n\t\t\t\tlogger.warning(\"UnsupportedEncodingException on query: \" + query);\n\t\t\t}\n\t\t}\n\t\treturn encodeString(query, QUERY_ENC_CHARS);\n\t}\n\n\tprivate String encodePath(String path) {\n\t\treturn encodeString(path, PATH_ENC_CHARS);\n\t}\n\n\tprivate String encodeString(String s, String encChars) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor(int i = 0; i < s.length(); i++) {\n\t\t\tencodeCharIntoBuffer(s.charAt(i), encChars, sb);\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\t\n\tprivate void encodeCharIntoBuffer(char c, String encChars, StringBuilder sb) {\n\t\tif(c <= 0x20 || c >= 0x80 || encChars.indexOf(c) != -1) {\n\t\t\tappendEscape(sb, c);\n\t\t} else {\n\t\t\tsb.append(c);\n\t\t}\n\t}\n\t\n\t  private final static char[] hexDigits = {\n        '0', '1', '2', '3', '4', '5', '6', '7',\n        '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'\n    };\n\n    private static void appendEscape(StringBuilder sb, char c) {\n        sb.append('%');\n        sb.append(hexDigits[(c >> 4) & 0x0f]);\n        sb.append(hexDigits[(c >> 0) & 0x0f]);\n    }\n\n\t\n\tprivate static String lineToPath(String line) {\n\t\tfinal int idx = line.indexOf('?');\n\t\tif(idx == -1) {\n\t\t\treturn line;\n\t\t}\n\t\treturn line.substring(0, idx);\n\t}\n\t\n\tprivate static String lineToQuery(String line) {\n\t\tfinal int idx = line.indexOf('?');\n\t\tif(idx == -1) {\n\t\t\treturn null;\n\t\t}\n\t\treturn line.substring(idx + 1);\n\t}\n\t\n\tprivate static boolean containsUnicode(String line) {\n\t\tfor(int i = 0; i < line.length(); i++) {\n\t\t\tif (line.charAt(i) > 255) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/connection/SocksModeClientConnectionOperator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests.connection;\n\nimport java.io.IOException;\nimport java.lang.reflect.Field;\nimport java.net.ConnectException;\nimport java.net.InetAddress;\nimport java.net.InetSocketAddress;\nimport java.net.Socket;\nimport java.security.cert.CertificateException;\nimport java.security.cert.X509Certificate;\n\nimport javax.net.ssl.SSLException;\nimport javax.net.ssl.SSLSession;\nimport javax.net.ssl.SSLSocket;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.conn.HttpHostConnectException;\nimport org.apache.http.conn.OperatedClientConnection;\nimport org.apache.http.conn.scheme.PlainSocketFactory;\nimport org.apache.http.conn.scheme.Scheme;\nimport org.apache.http.conn.scheme.SchemeRegistry;\nimport org.apache.http.conn.scheme.SchemeSocketFactory;\nimport org.apache.http.conn.ssl.SSLSocketFactory;\nimport org.apache.http.conn.ssl.TrustStrategy;\nimport org.apache.http.conn.ssl.X509HostnameVerifier;\nimport org.apache.http.impl.conn.DefaultClientConnectionOperator;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HttpContext;\n\n\n\n\npublic class SocksModeClientConnectionOperator extends DefaultClientConnectionOperator {\n\n\tprivate final boolean isSocksMode;\n\t\n\tpublic SocksModeClientConnectionOperator(SchemeRegistry sr) {\n\t\tsuper(sr);\n\t\tisSocksMode = System.getProperty(\"socksEnabled\") != null;\n\t}\n\n\t@Override\n\tpublic void openConnection(OperatedClientConnection conn, HttpHost target, InetAddress local, HttpContext context, HttpParams params) throws IOException {\n\t\tif(!isSocksMode) {\n\t\t\tsuper.openConnection(conn, target, local, context, params);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal Scheme scheme = schemeRegistry.getScheme(target.getSchemeName());\n\t\t\t\t\n\t\tfinal SchemeSocketFactory sf = scheme.getSchemeSocketFactory();\n\t\t\n\t\tfinal int port = scheme.resolvePort(target.getPort());\n\t\t\n\t\tSocket sock = sf.createSocket(params);\n\t\t\t\t\n\t\tconn.opening(sock, target);\n\t\t\n\t\tInetSocketAddress remoteAddress = InetSocketAddress.createUnresolved(target.getHostName(), port);\n\t\t\n\t\t/* We need to use reflection to set the private host field to the target hostname, \n\t\t * otherwise SSLSocketImpl blows up due to, it seems, https://bugs.openjdk.java.net/browse/JDK-8022081.\n\t\t */\n\t\t\n\t\tif (sf.isSecure(sock) == true) {\n\t\t\tClass<?> c = sock.getClass();\n\t\t\ttry {\n\t\t\t\tField f = c.getDeclaredField(\"host\");\n\t\t\t\tf.setAccessible(true);\n\t\t\t\tf.set(sock, target.getHostName());\n\t\t\t} catch (NoSuchFieldException e1) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te1.printStackTrace();\n\t\t\t} catch (SecurityException e1) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te1.printStackTrace();\n\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (IllegalAccessException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t\t\t\t\t\t\n\t\tInetSocketAddress localAddress = null;\n\t\tif(local != null) {\n\t\t\tlocalAddress = new InetSocketAddress(local, 0);\n\t\t}\n\t\ttry {\n\t\t\tSocket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);\n\t\t\t\n\t\t\tif(sock != connsock) {\n\t\t\t\tsock = connsock;\n\t\t\t\tconn.opening(sock, target);\n\t\t\t}\n\t\t\tprepareSocket(sock, context, params);\n\t\t\tconn.openCompleted(sf.isSecure(sock), params);\n\t\t\treturn;\n\t\t} catch (ConnectException ex) {\n\t\t\tthrow new HttpHostConnectException(target, ex);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.http.requests/src/com/subgraph/vega/internal/http/requests/connection/SocksSupportingThreadSafeClientConnectionManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.http.requests.connection;\n\nimport org.apache.http.conn.ClientConnectionOperator;\nimport org.apache.http.conn.scheme.SchemeRegistry;\nimport org.apache.http.impl.conn.PoolingClientConnectionManager;\n\npublic class SocksSupportingThreadSafeClientConnectionManager extends\n\t\tPoolingClientConnectionManager {\n\n\tpublic SocksSupportingThreadSafeClientConnectionManager(SchemeRegistry sr) {\n\t\tsuper(sr);\n\t}\n\t\n\t@Override \n\tprotected ClientConnectionOperator createConnectionOperator(final SchemeRegistry sr) { \n\t\treturn new SocksModeClientConnectionOperator(sr);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry exported=\"true\" kind=\"lib\" path=\"lib/db4o-8.0.249.16098-all-java5.jar\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.model</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/.settings/org.eclipse.pde.core.prefs",
    "content": "#Tue Aug 24 16:44:22 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Model\nBundle-SymbolicName: com.subgraph.vega.model\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.google.common.base,\n com.subgraph.vega.api.annotations,\n com.subgraph.vega.api.console,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.html,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.conditions,\n com.subgraph.vega.api.model.conditions.match,\n com.subgraph.vega.api.model.identity,\n com.subgraph.vega.api.model.macros,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.scope,\n com.subgraph.vega.api.model.tags,\n com.subgraph.vega.api.model.variables,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.api.model.web.forms,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.util,\n com.subgraph.vega.api.vuge,\n com.subgraph.vega.api.xml,\n com.subgraph.vega.http.requests.builder,\n com.subgraph.vega.http.requests.custom,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.auth;version=\"4.1.1\",\n org.apache.http.auth.params;version=\"4.1.1\",\n org.apache.http.client;version=\"4.1.1\",\n org.apache.http.client.methods;version=\"4.1.1\",\n org.apache.http.client.params;version=\"4.1.1\",\n org.apache.http.client.protocol;version=\"4.1.1\",\n org.apache.http.client.utils,\n org.apache.http.entity;version=\"4.0.0\",\n org.apache.http.impl.client;version=\"4.1.1\",\n org.apache.http.message;version=\"4.0.0\",\n org.apache.http.util;version=\"4.0.0\",\n org.w3c.dom.html2\nService-Component: OSGI-INF/model.xml\nBundle-ClassPath: .,\n lib/db4o-8.0.249.16098-all-java5.jar\nRequire-Bundle: org.apache.http.core;bundle-version=\"4.2.3\"\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/OSGI-INF/model.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.model\">\n   <implementation class=\"com.subgraph.vega.internal.model.Model\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.model.IModel\"/>\n   </service>\n   <reference bind=\"setConsole\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.console.IConsole\" name=\"IConsole\" policy=\"static\" unbind=\"unsetConsole\"/>\n   <reference bind=\"setHTMLParser\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.html.IHTMLParser\" name=\"IHTMLParser\" policy=\"static\" unbind=\"unsetHTMLParser\"/>\n   <reference bind=\"setXmlRepository\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.xml.IXmlRepository\" name=\"IXmlRepository\" policy=\"static\" unbind=\"unsetXmlRepository\"/>\n   <reference bind=\"setPathFinder\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.paths.IPathFinder\" name=\"IPathFinder\" policy=\"static\" unbind=\"unsetPathFinder\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               lib/db4o-8.0.249.16098-all-java5.jar,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/DatabaseConfigurationFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport com.db4o.Db4oEmbedded;\nimport com.db4o.ObjectContainer;\nimport com.db4o.config.EmbeddedConfiguration;\nimport com.db4o.config.QueryEvaluationMode;\nimport com.db4o.diagnostic.DiagnosticToConsole;\nimport com.db4o.reflect.jdk.JdkReflector;\nimport com.db4o.ta.TransparentPersistenceSupport;\nimport com.subgraph.vega.internal.model.alerts.ScanAlert;\nimport com.subgraph.vega.internal.model.requests.RequestLogRecord;\nimport com.subgraph.vega.internal.model.tags.Tag;\n\npublic class DatabaseConfigurationFactory {\n\tfinal private static boolean LAZY_EVALUATION = true;\n\tfinal private static boolean DIAGNOSTICS_ENABLED = false;\n\tfinal private static boolean DEBUG_OUTPUT_ENABLED = false;\n\tfinal private static int DEBUG_OUTPUT_LEVEL = 4;\n\n\tpublic EmbeddedConfiguration createDefaultConfiguration() {\n\t\tEmbeddedConfiguration configuration = Db4oEmbedded.newConfiguration();\n\t\tconfiguration.common().reflectWith(new JdkReflector(this.getClass().getClassLoader()));\n\t\tconfiguration.common().add(new TransparentPersistenceSupport());\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"requestId\").indexed(true);\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"requestOrigin\").indexed(true);\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"hostname\").indexed(true);\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"requestMethod\").indexed(true);\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"responseCode\").indexed(true);\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"responseLength\").indexed(true);\n\t\tconfiguration.common().objectClass(RequestLogRecord.class).objectField(\"tagList\").indexed(true);\n\t\tconfiguration.common().objectClass(ScanAlert.class).objectField(\"key\").indexed(true);\n\t\tconfiguration.common().objectClass(ScanAlert.class).objectField(\"resource\").indexed(true);\n\t\tconfiguration.common().objectClass(ScanAlert.class).objectField(\"requestId\").indexed(true);\n\t\tconfiguration.common().objectClass(Tag.class).objectField(\"name\").indexed(true);\n\n\t\tconfiguration.common().weakReferences(true);\n\t\t\n\t\tif(DIAGNOSTICS_ENABLED) {\n\t\t\tconfiguration.common().diagnostic().addListener(new DiagnosticToConsole());\n\t\t}\n\t\tif(DEBUG_OUTPUT_ENABLED) {\n\t\t\tconfiguration.common().messageLevel(DEBUG_OUTPUT_LEVEL);\n\t\t}\n\n\t\tif(LAZY_EVALUATION) {\n\t\t\tconfiguration.common().queries().evaluationMode(QueryEvaluationMode.LAZY);\n\t\t}\n\t\treturn configuration;\n\n\t}\n\n\n\tpublic ObjectContainer openContainer(String path) {\n\t\tEmbeddedConfiguration config = createDefaultConfiguration();\n\t\treturn Db4oEmbedded.openFile(config, path);\n\t}\n\n\tpublic ObjectContainer openContainer(EmbeddedConfiguration config, String path) {\n\t\treturn Db4oEmbedded.openFile(config, path);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/Model.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.events.NamedEventListenerManager;\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.IWorkspaceEntry;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.api.xml.IXmlRepository;\n\npublic class Model implements IModel {\n\tprivate final Logger logger = Logger.getLogger(\"model\");\n\tprivate final EventListenerManager workspaceEventManager = new EventListenerManager();\n\tprivate final NamedEventListenerManager conditionSetChangeEventManager = new NamedEventListenerManager();\n\tprivate IWorkspace currentWorkspace;\n\t\n\tprivate IConsole console;\n\tprivate IHTMLParser htmlParser;\n\tprivate IXmlRepository xmlRepository;\n\tprivate IPathFinder pathFinder;\n\t\n\t\n\tprivate WorkspaceEntries workspaceEntries;\n\t\n\tpublic void activate() {\n\t\tworkspaceEntries = new WorkspaceEntries(pathFinder);\n\t}\n\t\n\tprotected void setConsole(IConsole console) {\n\t\tthis.console = console;\t\n\t}\n\n\tprotected void unsetConsole(IConsole console) {\n\t\tthis.console = null;\n\t}\n\t\n\tprotected void setHTMLParser(IHTMLParser parser) {\n\t\tthis.htmlParser = parser;\n\t}\n\t\n\tprotected void unsetHTMLParser(IHTMLParser parser) {\n\t\tthis.htmlParser = null;\n\t}\n\t\n\tprotected void setXmlRepository(IXmlRepository xmlRepository) {\n\t\tthis.xmlRepository = xmlRepository;\n\t}\n\t\n\tprotected void unsetXmlRepository(IXmlRepository xmlRepository) {\n\t\tthis.xmlRepository = null;\n\t}\n\t\n\tprotected void setPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = pathFinder;\n\t}\n\t\n\tprotected void unsetPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = null;\n\t}\n\n\t@Override\n\tpublic IWorkspace addWorkspaceListener(IEventHandler handler) {\n\t\tworkspaceEventManager.addListener(handler);\n\t\treturn currentWorkspace;\n\t}\n\n\t@Override\n\tpublic void removeWorkspaceListener(IEventHandler handler) {\n\t\tworkspaceEventManager.removeListener(handler);\n\t}\n\n\t@Override\n\tpublic List<IWorkspaceEntry> getWorkspaceEntries() {\n\t\treturn workspaceEntries.getWorkspaceEntries();\n\t}\n\n\t@Override\n\tpublic boolean openDefaultWorkspace() {\n\t\tfinal IWorkspaceEntry entry = workspaceEntries.getDefaultWorkspaceEntry();\n\t\tif(entry == null)\n\t\t\treturn false;\n\t\telse\n\t\t\treturn openWorkspaceEntry(entry);\n\t}\n\n\t@Override\n\tpublic boolean openWorkspaceByIndex(int index) {\n\t\tthrow new UnsupportedOperationException(\"Not implemented yet\");\n\t}\n\t\n\tprivate boolean openWorkspaceEntry(IWorkspaceEntry entry) {\n\t\tIWorkspace workspace = new Workspace(this, entry, conditionSetChangeEventManager, workspaceEventManager, console, htmlParser, xmlRepository);\n\t\tif(!workspace.open()) {\n\t\t\tlogger.warning(\"Failed to open workspace at path \"+ entry.getPath());\n\t\t\treturn false;\n\t\t}\n\t\tcurrentWorkspace = workspace;\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic void resetCurrentWorkspace() {\n\t\tif(currentWorkspace != null)\n\t\t\tcurrentWorkspace.reset();\t\t\n\t}\n\n\t@Override\n\tpublic IWorkspace getCurrentWorkspace() {\n\t\treturn currentWorkspace;\n\t}\n\n\t@Override\n\tpublic IHttpConditionSet addConditionSetTracker(String name, IEventHandler handler) {\n\t\tconditionSetChangeEventManager.addListener(name, handler);\n\t\tif(currentWorkspace != null) {\n\t\t\treturn currentWorkspace.getHttpConditionMananger().getConditionSet(name);\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void removeConditionSetTracker(String name, IEventHandler handler) {\n\t\tconditionSetChangeEventManager.removeListener(name, handler);\t\t\n\t}\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/ModelProperties.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Map;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableHashMap;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.IModelProperties;\n\npublic class ModelProperties implements IModelProperties, Activatable {\n\t\n\tprivate final Map<String, Object> propertyMap;\n\tprivate transient Activator activator;\n\t\n\tpublic ModelProperties() {\n\t\tpropertyMap = new ActivatableHashMap<String, Object>();\n\t}\n\t\n\tpublic void setProperty(String name, Object value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(propertyMap) {\n\t\t\tpropertyMap.put(name, value);\n\t\t}\t\t\n\t}\n\t\n\tpublic void setStringProperty(String name, String value) {\n\t\tsetProperty(name, value);\t\t\n\t}\n\t\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tsetProperty(name, value);\t\t\n\t}\n\t\n\tpublic Object getProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(propertyMap) {\n\t\t\treturn propertyMap.get(name);\n\t\t}\n\t}\n\t\n\tpublic String getStringProperty(String name) {\n\t\tfinal Object value = getProperty(name);\n\t\tif(value == null)\n\t\t\treturn null;\n\t\tif(value instanceof String)\n\t\t\treturn (String) value;\n\t\tthrow new IllegalArgumentException(\"Property '\"+ name +\"' exists but it is not a String\");\n\t}\n\t\n\tpublic Integer getIntegerProperty(String name) {\n\t\tfinal Object value = getProperty(name);\n\t\tif(value == null)\n\t\t\treturn null;\n\t\tif(value instanceof Integer)\n\t\t\treturn (Integer) value;\n\t\tthrow new IllegalArgumentException(\"Property '\"+ name +\"' exists but it is not an Integer\");\n\t}\n\t\n\tpublic List<String> propertyKeys() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(propertyMap) {\n\t\t\treturn new ArrayList<String>(propertyMap.keySet());\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator)\n\t\t\treturn;\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/ModelVersion.java",
    "content": "package com.subgraph.vega.internal.model;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.IModelVersion;\n\npublic class ModelVersion implements IModelVersion, Activatable {\n\tprivate transient Activator activator;\n\tprivate final int verMajor;\n\tprivate final int verMinor;\n\n\tpublic ModelVersion(int verMajor, int verMinor) {\n\t\tthis.verMajor = verMajor;\n\t\tthis.verMinor = verMinor;\n\t}\n\n\t@Override\n\tpublic int getVerMajor() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn verMajor;\n\t}\n\n\t@Override\n\tpublic int getVerMinor() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn verMinor;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/Workspace.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport java.io.File;\nimport java.util.List;\nimport java.util.Timer;\nimport java.util.TimerTask;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.ext.DatabaseFileLockedException;\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.NamedEventListenerManager;\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IModelProperties;\nimport com.subgraph.vega.api.model.IModelVersion;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.IWorkspaceEntry;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\nimport com.subgraph.vega.api.model.tags.ITagModel;\nimport com.subgraph.vega.api.model.variables.IVariableModel;\nimport com.subgraph.vega.api.model.web.IWebModel;\nimport com.subgraph.vega.api.vuge.IConstants;\nimport com.subgraph.vega.api.xml.IXmlRepository;\nimport com.subgraph.vega.internal.model.alerts.ScanAlertRepository;\nimport com.subgraph.vega.internal.model.conditions.HttpConditionManager;\nimport com.subgraph.vega.internal.model.identity.IdentityModel;\nimport com.subgraph.vega.internal.model.macros.HttpMacroModel;\nimport com.subgraph.vega.internal.model.requests.RequestLog;\nimport com.subgraph.vega.internal.model.scope.TargetScopeManager;\nimport com.subgraph.vega.internal.model.tags.TagModel;\nimport com.subgraph.vega.internal.model.variables.VariableModel;\nimport com.subgraph.vega.internal.model.web.WebModel;\n\npublic class Workspace implements IWorkspace {\n\tprivate static final int BACKGROUND_COMMIT_INTERVAL = 10000;\n\tprivate final IModel model;\n\tprivate final IWorkspaceEntry workspaceEntry;\n\tprivate final NamedEventListenerManager conditionChangeManager;\n\tprivate final EventListenerManager eventManager;\n\tprivate final DatabaseConfigurationFactory configurationFactory;\n\tprivate final IConsole console;\n\tprivate final IHTMLParser htmlParser;\n\tprivate final IXmlRepository xmlRepository;\n\tprivate final WorkspaceLockStatus lockStatus;\n\n\tprivate IModelVersion modelVersion;\n\tprivate ITagModel tagModel;\n\tprivate IWebModel webModel;\n\tprivate IVariableModel variableModel;\n\tprivate IHttpMacroModel httpMacroModel;\n\tprivate IIdentityModel identityModel;\n\tprivate IRequestLog requestLog;\n\tprivate IScanAlertRepository scanAlerts;\n\tprivate ITargetScopeManager targetScopeManager;\n\tprivate HttpConditionManager conditionManager;\n\n\tprivate ObjectContainer database;\n\tprivate boolean opened;\n\n\tprivate final Timer backgroundCommitTimer;\n\tprivate TimerTask backgroundCommitTask;\n\n\tprivate WorkspaceStatus workspaceStatus;\n\n\tWorkspace(IModel model, IWorkspaceEntry entry, NamedEventListenerManager conditionChangeManager, EventListenerManager eventManager, \n\t\t\tIConsole console, IHTMLParser htmlParser, IXmlRepository xmlRepository) {\n\t\tthis.model = model;\n\t\tthis.configurationFactory = new DatabaseConfigurationFactory();\n\t\tthis.workspaceEntry = entry;\n\t\tthis.conditionChangeManager = conditionChangeManager;\n\t\tthis.eventManager = eventManager;\n\t\tthis.console = console;\n\t\tthis.htmlParser = htmlParser;\n\t\tthis.xmlRepository = xmlRepository;\n\t\tthis.lockStatus = new WorkspaceLockStatus(eventManager);\n\t\tthis.backgroundCommitTimer = new Timer();\n\t}\n\n\t@Override\n\tpublic IModel getModel() {\n\t\treturn model;\n\t}\n\t\n\t@Override\n\tpublic boolean open() {\n\t\tif(opened)\n\t\t\tthrow new IllegalStateException(\"open() called on workspace which has already been opened.\");\n\n\t\tdatabase = openDatabase(getDatabaseFile());\n\t\tif(database == null)\n\t\t\treturn false;\n\t\topened = true;\n\t\teventManager.fireEvent(new WorkspaceOpenEvent(this));\n\t\tbackgroundCommitTask = createBackgroundCommitTask(database);\n\t\tbackgroundCommitTimer.scheduleAtFixedRate(backgroundCommitTask, 0, BACKGROUND_COMMIT_INTERVAL);\n\t\treturn true;\n\t}\n\n\tprivate File getDatabaseFile() {\n\t\treturn new File(workspaceEntry.getPath(), \"model.db\");\n\t}\n\n\tprivate ObjectContainer openDatabase(final File databaseFile) {\n\t\ttry {\n\t\t\tfinal String databasePath = databaseFile.getAbsolutePath();\n\t\t\tfinal boolean exists = databaseFile.exists(); // possible race condition  \n\t\t\tfinal ObjectContainer db = configurationFactory.openContainer(databasePath);\n\t\t\tloadModelVersion(db, !exists);\n\t\t\ttagModel = new TagModel(db);\n\t\t\twebModel = new WebModel(db);\n\t\t\tvariableModel = new VariableModel(db);\n\t\t\thttpMacroModel = new HttpMacroModel(db);\n\t\t\tidentityModel = new IdentityModel(db);\n\t\t\trequestLog = new RequestLog(db);\n\t\t\tscanAlerts = new ScanAlertRepository(db, xmlRepository);\n\t\t\tconditionManager = new HttpConditionManager(db, conditionChangeManager);\n\t\t\ttargetScopeManager = new TargetScopeManager(db);\n\t\t\treturn db;\n\t\t} catch (DatabaseFileLockedException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic IModelVersion getModelVersion() {\n\t\tif (!opened) {\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\t}\n\t\treturn modelVersion;\n\t}\n\n\t@Override\n\tpublic ITagModel getTagModel() {\n\t\tif (!opened) {\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\t}\n\t\treturn tagModel;\n\t}\n\n\t@Override\n\tpublic IVariableModel getVariableModel() {\n\t\tif (!opened) {\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\t}\n\t\treturn variableModel;\n\t}\n\n\t@Override\n\tpublic IHttpMacroModel getHttpMacroModel() {\n\t\tif (!opened) {\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\t}\n\t\treturn httpMacroModel;\n\t}\n\n\t@Override\n\tpublic IIdentityModel getIdentityModel() {\n\t\tif (!opened) {\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\t}\n\t\treturn identityModel;\n\t}\n\n\t@Override\n\tpublic IWebModel getWebModel() {\n\t\tif(!opened)\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\treturn webModel;\n\t}\n\n\t@Override\n\tpublic IRequestLog getRequestLog() {\n\t\tif(!opened)\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\treturn requestLog;\n\t}\n\n\t@Override\n\tpublic IScanAlertRepository getScanAlertRepository() {\n\t\tif(!opened)\n\t\t\tthrow new IllegalStateException(\"Must open workspace first\");\n\t\treturn scanAlerts;\n\t}\n\n\t@Override\n\tpublic IHttpConditionManager getHttpConditionMananger() {\n\t\treturn conditionManager;\n\t}\n\n\t@Override\n\tpublic void close() {\n\t\tif(!opened)\n\t\t\treturn;\n\t\tif(lockStatus.isLocked())\n\t\t\tthrow new IllegalStateException(\"Cannot close locked workspace.\");\n\t\tbackgroundCommitTask.cancel();\n\t\tconditionManager.notifyClosed();\n\t\tdatabase.close();\n\t\topened = false;\n\t\teventManager.fireEvent(new WorkspaceCloseEvent(this));\n\t}\n\n\t@Override\n\tpublic void setProperty(String name, Object value) {\n\t\tgetProperties().setProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setStringProperty(String name, String value) {\n\t\tgetProperties().setStringProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tgetProperties().setIntegerProperty(name, value);\n\t}\n\n\t@Override\n\tpublic Object getProperty(String name) {\n\t\treturn getProperties().getProperty(name);\n\t}\n\n\t@Override\n\tpublic String getStringProperty(String name) {\n\t\treturn getProperties().getStringProperty(name);\n\t}\n\n\t@Override\n\tpublic Integer getIntegerProperty(String name) {\n\t\treturn getProperties().getIntegerProperty(name);\n\t}\n\n\t@Override\n\tpublic List<String> propertyKeys() {\n\t\treturn getProperties().propertyKeys();\n\t}\n\n\tprivate IModelProperties getProperties() {\n\t\tif(workspaceStatus != null)\n\t\t\treturn workspaceStatus.getProperties();\n\t\tsynchronized(this) {\n\t\t\tList<WorkspaceStatus> result = database.query(WorkspaceStatus.class);\n\t\t\tif(result.size() == 0) {\n\t\t\t\tworkspaceStatus = new WorkspaceStatus();\n\t\t\t\tdatabase.store(workspaceStatus);\n\t\t\t\treturn workspaceStatus.getProperties();\n\t\t\t} else if(result.size() == 1) {\n\t\t\t\tworkspaceStatus =  result.get(0);\n\t\t\t\treturn workspaceStatus.getProperties();\n\t\t\t} else {\n\t\t\t\tthrow new IllegalStateException(\"Database corrupted, multiple WorkspaceStatus instances\");\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic IHTMLParser getHTMLParser() {\n\t\treturn htmlParser;\n\t}\n\n\t@Override\n\tpublic ITargetScopeManager getTargetScopeManager() {\n\t\treturn targetScopeManager;\n\t}\n\n\t@Override\n\tpublic void consoleWrite(String output) {\n\t\tconsole.write(output);\n\t}\n\t\n\t@Override\n\tpublic void consoleDebug(String output) {\n\t\tconsole.debug(output);\n\t}\n\t\n\t\n\t@Override\n\tpublic void consoleError(String output) {\n\t\tconsole.error(output);\n\t}\n\n\t@Override\n\tpublic void lock() {\n\t\tlockStatus.lock();\n\t}\n\n\t@Override\n\tpublic void unlock() {\n\t\tlockStatus.unlock();\n\t}\n\n\t@Override\n\tpublic void reset() {\n\t\tif(lockStatus.isLocked())\n\t\t\tthrow new IllegalStateException(\"Cannot reset locked workspace\");\n\n\t\tbackgroundCommitTask.cancel();\n\t\tsynchronized(this) {\n\t\t\tconditionManager.notifyClosed();\n\t\t\tdatabase.close();\n\t\t\tfinal File databaseFile = getDatabaseFile();\n\t\t\tif(!databaseFile.delete()) {\n\t\t\t\t// XXX\n\t\t\t}\n\t\t\tdatabase = openDatabase(databaseFile);\n\t\t\tif(database != null) {\n\t\t\t\tworkspaceStatus = null;\n\t\t\t\teventManager.fireEvent(new WorkspaceResetEvent(this));\n\t\t\t\tbackgroundCommitTask = createBackgroundCommitTask(database);\n\t\t\t\tbackgroundCommitTimer.scheduleAtFixedRate(backgroundCommitTask, 0, BACKGROUND_COMMIT_INTERVAL);\n\t\t\t} else {\n\t\t\t\teventManager.fireEvent(new WorkspaceCloseEvent(this));\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate TimerTask createBackgroundCommitTask(final ObjectContainer db) {\n\t\treturn new TimerTask() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(!db.ext().isClosed()) {\n\t\t\t\t\tdb.commit();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void loadModelVersion(ObjectContainer database, boolean newFile) {\n\t\tif (newFile == false) {\n\t\t\tfinal List<IModelVersion> results = database.query(IModelVersion.class);\n\t\t\tif (results.size() != 0) {\n\t\t\t\tmodelVersion = results.get(0);\n\t\t\t} else {\n\t\t\t\t// reverse compatibility: Vega 1.0 beta and earlier did not have model version\n\t\t\t\tmodelVersion = new ModelVersion(1, 0);\n\t\t\t\tdatabase.store(modelVersion);\n\t\t\t}\n\t\t} else {\n\t\t\tmodelVersion = new ModelVersion(IConstants.VERSION_MAJOR, IConstants.VERSION_MINOR);\n\t\t\tdatabase.store(modelVersion);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/WorkspaceEntries.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.OutputStreamWriter;\nimport java.io.Writer;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.model.IWorkspaceEntry;\nimport com.subgraph.vega.api.paths.IPathFinder;\n\npublic class WorkspaceEntries {\n\tprivate final static int MAX_WORKSPACE_INDEX = 1000;\n\tprivate final static int DEFAULT_WORKSPACE_INDEX = 0;\n\tprivate final Logger logger = Logger.getLogger(\"model\");\n\tprivate final File workspaceDirectory;\n\tprivate final IWorkspaceEntry[] entryArray = new IWorkspaceEntry[MAX_WORKSPACE_INDEX + 1];\n\t\n\tWorkspaceEntries(IPathFinder pathFinder) {\n\t\tthis.workspaceDirectory = pathFinder.getWorkspaceDirectory();\n\t\tloadWorkspaceEntries();\n\t}\n\t\n\tprivate void loadWorkspaceEntries() {\n\t\tif(!workspaceDirectory.exists()) {\n\t\t\tif(!workspaceDirectory.mkdirs()) {\n\t\t\t\tlogger.warning(\"Failed to create workspace directory: \"+ workspaceDirectory);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(!workspaceDirectory.isDirectory()) {\n\t\t\tlogger.warning(\"Workspace directory name exists but is not a directory: \"+ workspaceDirectory);\n\t\t\treturn;\n\t\t}\n\t\tfor(File ws: workspaceDirectory.listFiles()) {\n\t\t\tfinal WorkspaceEntry entry = WorkspaceEntry.createFromPath(ws);\n\t\t\tif(entry != null) {\n\t\t\t\tentryArray[entry.getIndex()] = entry;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(entryArray[DEFAULT_WORKSPACE_INDEX] == null) \n\t\t\tentryArray[DEFAULT_WORKSPACE_INDEX] = createDefaultWorkspace();\n\t\t\t\t\t\n\t}\n\n\tprivate WorkspaceEntry createDefaultWorkspace() {\n\t\treturn createWorkspace(DEFAULT_WORKSPACE_INDEX, \"default\");\n\t}\n\t\n\tprivate WorkspaceEntry createWorkspace(int index, String name) {\n\t\tfinal File path = indexToWorkspacePath(index);\n\t\tfinal File nameFile = new File(path, \".name\");\n\t\tif(path.exists())\n\t\t\tthrow new IllegalStateException(\"Workspace directory already exists \"+ path);\n\t\tif(!path.mkdirs()) {\n\t\t\tlogger.warning(\"Failed to make directory while creating workspace: \"+ path);\n\t\t\treturn null;\n\t\t}\n\t\tfinal Writer writer = openNameFileWriter(nameFile);\n\t\tif(writer == null)\n\t\t\treturn null;\n\t\ttry {\n\t\t\twriter.write(name +\"\\n\");\n\t\t\treturn new WorkspaceEntry(name, index, false, path);\n\t\t} catch (IOException e) {\n\t\t\tlogger.warning(\"I/O error writing to name file while creating workspace \"+ nameFile);\n\t\t\treturn null;\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\twriter.close();\n\t\t\t} catch (IOException e) {}\n\t\t}\n\t}\n\t\n\tprivate Writer openNameFileWriter(File nameFile) {\n\t\ttry {\n\t\t\tfinal FileOutputStream out = new FileOutputStream(nameFile);\n\t\t\treturn new OutputStreamWriter(out);\n\t\t} catch (FileNotFoundException e) {\n\t\t\tlogger.warning(\"Failed to open name file for writing :\"+ nameFile);\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate File indexToWorkspacePath(int index) {\n\t\tif(index < 0 || index > MAX_WORKSPACE_INDEX)\n\t\t\tthrow new IllegalArgumentException(\"Workspace index out of range (0 - \"+ MAX_WORKSPACE_INDEX +\") : \"+ index);\n\t\tfinal String indexStr = String.format(\"%02d\", index);\n\t\treturn new File(workspaceDirectory, indexStr);\n\t}\n\t\n\tList<IWorkspaceEntry> getWorkspaceEntries() {\n\t\tfinal List<IWorkspaceEntry> entryList = new ArrayList<IWorkspaceEntry>();\n\t\tfor(int i = 0; i <= MAX_WORKSPACE_INDEX; i++)\n\t\t\tif(entryArray[i] != null)\n\t\t\t\tentryList.add(entryArray[i]);\n\t\treturn entryList;\n\t}\n\t\n\tIWorkspaceEntry getDefaultWorkspaceEntry() {\n\t\tIWorkspaceEntry firstEntry = null;\n\t\t\n\t\tfor(int i = 0; i <= MAX_WORKSPACE_INDEX; i++) {\n\t\t\tIWorkspaceEntry entry = entryArray[i];\n\t\t\tif(entry != null) {\n\t\t\t\tif(entry.isAutostart())\n\t\t\t\t\treturn entry;\n\t\t\t\telse if(firstEntry == null)\n\t\t\t\t\tfirstEntry = entry;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(firstEntry == null) \n\t\t\tthrow new IllegalStateException(\"No default workspace entry found\");\n\t\t\n\t\treturn firstEntry;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/WorkspaceEntry.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.model.IWorkspaceEntry;\n\npublic class WorkspaceEntry implements IWorkspaceEntry {\n\tprivate static final Logger logger = Logger.getLogger(\"model\");\n\t\n\tstatic WorkspaceEntry createFromPath(File path) {\n\t\tif(!Character.isDigit(path.getName().charAt(0))) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal int index = pathToIndex(path);\n\t\tif(index == -1)\n\t\t\treturn null;\n\t\tfinal String name = pathToWorkspaceName(path);\n\t\tif(name == null)\n\t\t\treturn null;\n\t\tfinal boolean autostart = pathToAutostartFlag(path);\n\n\t\treturn new WorkspaceEntry(name, index, autostart, path);\n\t}\n\t\n\tstatic int pathToIndex(File path) {\n\t\tString indexName = path.getName();\n\t\ttry {\n\t\t\tfinal int n = Integer.parseInt(indexName);\n\t\t\tif(n < 0 || n > 1000) {\n\t\t\t\tlogger.warning(\"Could not read workspace because path is incorrectly formatted \"+ path);\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\telse\n\t\t\t\treturn n;\n\t\t} catch (NumberFormatException e) {\n\t\t\tlogger.warning(\"Could not read workspace because path is incorrectly formatted \"+ path);\n\t\t\treturn -1;\n\t\t}\n\t}\n\t\n\tstatic String pathToWorkspaceName(File path) {\n\t\tfinal File nameFile = new File(path, \".name\");\n\t\tfinal BufferedReader reader = openNameFileReader(nameFile);\n\t\tif(reader == null)\n\t\t\treturn null;\n\t\t\n\t\ttry {\n\t\t\tfinal String name = reader.readLine();\n\t\t\tif(name == null || name.isEmpty()) {\n\t\t\t\tlogger.warning(\"Could not read workpace because name file is empty \"+ nameFile);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn name;\n\t\t\t\n\t\t}  catch (IOException e) {\n\t\t\tlogger.warning(\"Could not read workspace, I/O error reading name file \"+ nameFile);\t\t\n\t\t\treturn null;\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\treader.close();\n\t\t\t} catch (IOException e) { }\n\t\t}\n\t\t\n\t}\n\t\n\tstatic boolean pathToAutostartFlag(File path) {\n\t\tfinal File autostartFile = new File(path, \".autostart\");\n\t\treturn autostartFile.exists();\n\t}\n\t\n\tstatic BufferedReader openNameFileReader(File nameFile) {\n\t\ttry {\n\t\t\tfinal FileInputStream in = new FileInputStream(nameFile);\n\t\t\treturn new BufferedReader(new InputStreamReader(in));\n\t\t} catch (FileNotFoundException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate final String name;\n\tprivate final int index;\n\tprivate final boolean autostart;\n\tprivate final File path;\n\t\n\tWorkspaceEntry(String name, int index, boolean autostart, File path) {\n\t\tthis.name = name;\n\t\tthis.index = index;\n\t\tthis.autostart = autostart;\n\t\tthis.path = path;\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic int getIndex() {\n\t\treturn index;\n\t}\n\n\t@Override\n\tpublic File getPath() {\n\t\treturn path;\n\t}\n\n\n\t@Override\n\tpublic boolean isAutostart() {\n\t\treturn autostart;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/WorkspaceLockStatus.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.WorkspaceLockStatusEvent;\n\npublic class WorkspaceLockStatus {\n\tprivate final EventListenerManager eventManager;\n\tprivate int lockCount = 0;\n\t\n\tWorkspaceLockStatus(EventListenerManager eventManager) {\n\t\tthis.eventManager = eventManager;\n\t}\n\t\n\tsynchronized void lock() {\n\t\tif(lockCount == 0)\n\t\t\teventManager.fireEvent(new WorkspaceLockStatusEvent(true));\n\t\tlockCount += 1;\n\t}\n\t\n\tsynchronized void unlock() {\n\t\tif(lockCount == 0)\n\t\t\tthrow new IllegalStateException(\"Cannot call unlock() on unlocked workspace.\");\n\t\tif(lockCount == 1)\n\t\t\teventManager.fireEvent(new WorkspaceLockStatusEvent(false));\n\t\tlockCount -= 1;\n\t}\n\t\n\tsynchronized boolean isLocked() {\n\t\treturn lockCount != 0;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/WorkspaceStatus.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model;\n\npublic class WorkspaceStatus {\n\tprivate final ModelProperties properties;\n\t\n\tWorkspaceStatus() {\n\t\tproperties = new ModelProperties();\n\t}\n\t\n\tModelProperties getProperties() {\n\t\treturn properties;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/alerts/ScanAlert.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.alerts;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableArrayList;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertHighlight;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.internal.model.ModelProperties;\n\npublic class ScanAlert implements IScanAlert, Activatable {\n\t\n\tprivate final String name;\n\tprivate final Severity severity;\n\tprivate final String title;\n\tprivate final String key;\n\tprivate final IScanInstance scanInstance;\n\tprivate final long requestId;\n\tprivate final List<IScanAlertHighlight> alertHighlights;\n\tprivate String templateName = \"main\";\n\tprivate String resource;\n\tprivate final ModelProperties properties;\n\t\n\tprivate transient Activator activator;\n\tprivate String discretionaryHostname;\n\t\n\tScanAlert(String key, String name, String title, Severity severity, IScanInstance scanInstance, long requestId) {\n\t\tthis.key = key;\n\t\tthis.name = name;\n\t\tthis.title = title;\n\t\tthis.severity = severity;\n\t\tthis.properties = new ModelProperties();\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.requestId = requestId;\n\t\tthis.alertHighlights = new ActivatableArrayList<IScanAlertHighlight>();\n\t}\n\t\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\t\n\t@Override\n\tpublic Severity getSeverity() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn severity;\n\t}\n\n\t@Override\n\tpublic String getTitle() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn title;\n\t}\n\t\n\t@Override\n\tpublic String getDiscretionaryHostname() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn this.discretionaryHostname;\n\t}\n\n\t@Override\n\tpublic void setDiscretionaryHostname(String hostname) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tdiscretionaryHostname = hostname;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\t@Override\n\tpublic void setResource(String resourceString) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.resource = resourceString;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setTemplateName(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\ttemplateName = name;\t\t\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setProperty(String name, Object value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(name.equals(\"resource\") && value instanceof String) {\n\t\t\tresource = (String) value;\n\t\t\tactivate(ActivationPurpose.WRITE);\n\t\t}\n\t\tproperties.setProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setStringProperty(String name, String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tproperties.setStringProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tproperties.setIntegerProperty(name, value);\n\t}\n\n\t@Override\n\tpublic Object getProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getProperty(name);\n\t}\n\n\t@Override\n\tpublic String getStringProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getStringProperty(name);\n\t}\n\n\t@Override\n\tpublic Integer getIntegerProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getIntegerProperty(name);\n\t}\n\n\t@Override\n\tpublic List<String> propertyKeys() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.propertyKeys();\n\t}\n\n\t@Override\n\tpublic String getTemplateName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn templateName;\n\t}\n\t\n\t@Override\n\tpublic String getResource() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn resource;\n\t}\n\n\t@Override\n\tpublic String getKey() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn key;\n\t}\n\n\t@Override\n\tpublic boolean hasAssociatedRequest() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn requestId != -1;\n\t}\n\n\t@Override\n\tpublic IScanInstance getScanInstance() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanInstance;\n\t}\n\t\n\t@Override\n\tpublic long getScanId() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanInstance.getScanId();\n\t}\n\n\t@Override\n\tpublic long getRequestId() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn requestId;\n\t}\n\t\n\t@Override\n\tpublic void addStringMatchHighlight(String matchStr) {\n\t\tactivate(ActivationPurpose.READ);\n\t\talertHighlights.add(new ScanAlertHighlight(matchStr, false, false));\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void addRegexHighlight(String regex) {\n\t\tactivate(ActivationPurpose.READ);\n\t\talertHighlights.add(new ScanAlertHighlight(regex, true, true));\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void addRegexCaseInsensitiveHighlight(String regex) {\n\t\tactivate(ActivationPurpose.READ);\n\t\talertHighlights.add(new ScanAlertHighlight(regex, true, false));\n\t\tactivate(ActivationPurpose.WRITE);\n\t\n\t}\n\t@Override\n\tpublic Collection<IScanAlertHighlight> getHighlights() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn Collections.unmodifiableCollection(new ArrayList<IScanAlertHighlight>(alertHighlights));\n\t}\n\n\t@Override\n\tpublic boolean equals(Object obj) {\n\t\tif (this == obj)\n\t\t\treturn true;\n\t\tif (obj == null)\n\t\t\treturn false;\n\t\tif (getClass() != obj.getClass())\n\t\t\treturn false;\n\t\tScanAlert other = (ScanAlert) obj;\n\t\tif (key == null) {\n\t\t\tif (other.key != null)\n\t\t\t\treturn false;\n\t\t} else if (!key.equals(other.key))\n\t\t\treturn false;\n\t\tif (name == null) {\n\t\t\tif (other.name != null)\n\t\t\t\treturn false;\n\t\t} else if (!name.equals(other.name))\n\t\t\treturn false;\n\t\tif (requestId != other.requestId)\n\t\t\treturn false;\n\t\tif (scanInstance == null) {\n\t\t\tif (other.scanInstance != null)\n\t\t\t\treturn false;\n\t\t} else if (!scanInstance.equals(other.scanInstance))\n\t\t\treturn false;\n\t\tif (severity != other.severity)\n\t\t\treturn false;\n\t\tif (title == null) {\n\t\t\tif (other.title != null)\n\t\t\t\treturn false;\n\t\t} else if (!title.equals(other.title))\n\t\t\treturn false;\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic int hashCode() {\n\t\tfinal int prime = 31;\n\t\tint result = 1;\n\t\tresult = prime * result + ((key == null) ? 0 : key.hashCode());\n\t\tresult = prime * result + ((name == null) ? 0 : name.hashCode());\n\t\tresult = prime * result + (int) (requestId ^ (requestId >>> 32));\n\t\tresult = prime * result\n\t\t\t\t+ ((scanInstance == null) ? 0 : scanInstance.hashCode());\n\t\tresult = prime * result\n\t\t\t\t+ ((severity == null) ? 0 : severity.hashCode());\n\t\tresult = prime * result + ((title == null) ? 0 : title.hashCode());\n\t\treturn result;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n\n\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/alerts/ScanAlertFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.alerts;\n\nimport java.util.logging.Logger;\n\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert.Severity;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.xml.IXmlRepository;\n\npublic class ScanAlertFactory {\n\tprivate final Logger logger = Logger.getLogger(\"alerts\");\n\tprivate final IXmlRepository xmlRepository;\n\t\n\tScanAlertFactory(IXmlRepository xmlRepository) {\n\t\tthis.xmlRepository = xmlRepository;\n\t}\n\t\n\tScanAlert createAlert(String key, String name, IScanInstance scanInstance, long requestId) {\n\t\tDocument doc = xmlRepository.getDocument(\"alerts/\"+ name +\".xml\");\n\t\tif(doc == null)\n\t\t\tdoc = xmlRepository.getDocument(\"alerts/default.xml\");\n\t\tif(doc == null) {\n\t\t\tlogger.warning(\"Could not find XML alert description named \"+ name);\n\t\t\treturn null;\n\t\t}\n\t\tfinal Element alert = getAlertElement(doc, name);\n\t\tif(alert == null)\n\t\t\treturn null;\n\t\tfinal Severity severity = parseSeverity(alert);\n\t\tfinal String title = parseTitle(alert);\n\t\treturn new ScanAlert(key, name, title, severity, scanInstance, requestId);\n\t}\n\t\n\n\tprivate Severity parseSeverity(Element alertElement) {\n\t\tNodeList nodeList = alertElement.getElementsByTagName(\"severity\");\n\t\tif(nodeList.getLength() == 0 || nodeList.item(0).getNodeType() != Node.ELEMENT_NODE)\n\t\t\treturn Severity.UNKNOWN;\n\t\treturn processSeverityElement((Element) nodeList.item(0));\n\t}\n\t\n\tprivate Severity processSeverityElement(Element e) {\n\t\tfinal String sev = getTextForElement(e);\n\t\tif(sev == null)\n\t\t\treturn Severity.UNKNOWN;\n\t\tif(sev.equalsIgnoreCase(\"high\"))\n\t\t\treturn Severity.HIGH;\n\t\telse if(sev.equalsIgnoreCase(\"medium\"))\n\t\t\treturn Severity.MEDIUM;\n\t\telse if(sev.equalsIgnoreCase(\"low\"))\n\t\t\treturn Severity.LOW;\n\t\telse if(sev.equalsIgnoreCase(\"info\"))\n\t\t\treturn Severity.INFO;\n\t\telse\n\t\t\treturn Severity.UNKNOWN;\n\t}\n\n\tprivate String parseTitle(Element alertElement) {\n\t\tfinal NodeList nodeList = alertElement.getElementsByTagName(\"title\");\n\t\tif(nodeList.getLength() == 0 || nodeList.item(0).getNodeType() != Node.ELEMENT_NODE)\n\t\t\treturn null;\n\t\tfinal Element titleElement = (Element) nodeList.item(0);\n\t\treturn getTextForElement(titleElement);\n\t}\n\t\n\tprivate String getTextForElement(Element e) {\n\t\tfinal NodeList nodes = e.getChildNodes();\n\t\tfor(int i = 0; i < nodes.getLength(); i++) {\n\t\t\tNode n = nodes.item(i);\n\t\t\tif(n.getNodeType() == Node.TEXT_NODE) \n\t\t\t\treturn n.getNodeValue();\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate Element getAlertElement(Document xmlRoot, String name) {\n\t\tfinal NodeList alertNodes = xmlRoot.getElementsByTagName(\"alert\");\n\t\tfinal int n = alertNodes.getLength();\n\t\tif(n == 0) {\n\t\t\tlogger.warning(\"No alert node found in XML for description \"+ name);\n\t\t\treturn null;\n\t\t}\n\t\tif(n > 1) {\n\t\t\tlogger.warning(\"Multiple alert entries found in XML for description \"+ name +\", ignoring extras\");\n\t\t}\n\t\tif(alertNodes.item(0).getNodeType() != Node.ELEMENT_NODE)\n\t\t\treturn null;\n\t\treturn (Element) alertNodes.item(0);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/alerts/ScanAlertHighlight.java",
    "content": "package com.subgraph.vega.internal.model.alerts;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlertHighlight;\n\npublic class ScanAlertHighlight implements IScanAlertHighlight {\n\n\tprivate final String matchString;\n\tprivate final boolean isRegex;\n\tprivate boolean isCaseSensitive;\n\t\n\tScanAlertHighlight(String matchString, boolean isRegex, boolean isCaseSensitive) {\n\t\tthis.matchString = matchString;\n\t\tthis.isRegex = isRegex;\n\t\tthis.isCaseSensitive = isCaseSensitive;\n\t}\n\n\t@Override\n\tpublic boolean isRegularExpression() {\n\t\treturn isRegex;\n\t}\n\n\t@Override\n\tpublic boolean isCaseSensitive() {\n\t\treturn isCaseSensitive;\n\t}\n\t\n\t@Override\n\tpublic String getMatchString() {\n\t\treturn matchString;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/alerts/ScanAlertRepository.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.alerts;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.Random;\nimport java.util.logging.Logger;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.events.Event4;\nimport com.db4o.events.EventListener4;\nimport com.db4o.events.EventRegistry;\nimport com.db4o.events.EventRegistryFactory;\nimport com.db4o.events.ObjectInfoEventArgs;\nimport com.db4o.query.Predicate;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.alerts.ActiveScanInstanceEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.NewScanInstanceEvent;\nimport com.subgraph.vega.api.model.alerts.RemoveScanAlertsEvent;\nimport com.subgraph.vega.api.model.alerts.RemoveScanInstanceEvent;\nimport com.subgraph.vega.api.xml.IXmlRepository;\n\npublic class ScanAlertRepository implements IScanAlertRepository {\n\tprivate final static Logger logger = Logger.getLogger(\"alerts\");\n\tprivate final ObjectContainer database;\n\tprivate final Object scanInstanceLock = new Object();\n\tprivate final ScanAlertFactory alertFactory;\n\tprivate final EventListenerManager scanInstanceEventManager;\n\tprivate final List<IScanInstance> activeScanInstanceList;\n\t\n\tpublic ScanAlertRepository(ObjectContainer db, IXmlRepository xmlRepository) {\n\t\tthis.database = db;\n\t\tthis.alertFactory = new ScanAlertFactory(xmlRepository);\n\t\tthis.scanInstanceEventManager = new EventListenerManager();\n\t\tfinal EventRegistry registry = EventRegistryFactory.forObjectContainer(database);\n\t\tregistry.activated().addListener(new EventListener4<ObjectInfoEventArgs>() {\n\t\t\t@Override\n\t\t\tpublic void onEvent(Event4<ObjectInfoEventArgs> e, ObjectInfoEventArgs args) {\n\t\t\t\tfinal Object ob = args.object();\n\t\t\t\tif(ob instanceof ScanInstance) {\n\t\t\t\t\tfinal ScanInstance scan = (ScanInstance) ob;\n\t\t\t\t\tscan.setTransientState(database, ScanAlertRepository.this, alertFactory);\n\t\t\t\t\tfinal int status = scan.getScanStatus();\n\t\t\t\t\tif(status != IScanInstance.SCAN_CONFIG && status != IScanInstance.SCAN_COMPLETED && status != IScanInstance.SCAN_CANCELLED) {\n\t\t\t\t\t\tscan.updateScanStatus(IScanInstance.SCAN_CANCELLED);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tgetProxyScanInstance();\n\t\tactiveScanInstanceList = new ArrayList<IScanInstance>();\n\t}\n\n\tvoid fireRemoveEventsEvent(IScanInstance instance, Collection<IScanAlert> removedAlerts) {\n\t\tscanInstanceEventManager.fireEvent(new RemoveScanAlertsEvent(instance, removedAlerts));\n\t}\n\t\n\t@Override\n\tpublic List<IScanInstance> addActiveScanInstanceListener(IEventHandler listener) {\n\t\tscanInstanceEventManager.addListener(listener);\n\t\treturn getAllActiveScanInstances();\n\t}\n\n\t@Override\n\tpublic void removeActiveScanInstanceListener(IEventHandler listener) {\n\t\tscanInstanceEventManager.removeListener(listener);\n\t}\n\n\t@Override\n\tpublic synchronized void addActiveScanInstance(IScanInstance scanInstance) {\n\t\tactiveScanInstanceList.add(scanInstance);\n\t\tscanInstanceEventManager.fireEvent(new ActiveScanInstanceEvent(scanInstance));\n\t}\n\n\t@Override\n\tpublic synchronized void removeActiveScanInstance(IScanInstance scanInstance) {\n\t\tactiveScanInstanceList.remove(scanInstance);\n\t}\n\n\t@Override\n\tpublic synchronized List<IScanInstance> getAllActiveScanInstances() {\n\t\treturn new ArrayList<IScanInstance>(activeScanInstanceList);\n\t}\n\n\t@Override\n\tpublic List<IScanInstance> getAllScanInstances() {\n\t\treturn database.query(IScanInstance.class);\n\t}\n\n\t@Override\n\tpublic synchronized IScanInstance createNewScanInstance() {\n\t\tsynchronized(scanInstanceLock) {\n\t\t\tfinal long scanId = allocateNewScanId();\n\t\t\tfinal IScanInstance scan = createScanInstanceForScanId(scanId);\n\t\t\tscanInstanceEventManager.fireEvent(new NewScanInstanceEvent(scan));\n\t\t\treturn scan;\n\t\t}\n\t}\n\n\tprivate IScanInstance createScanInstanceForScanId(long scanId) {\n\t\tfinal ScanInstance scan = new ScanInstance(scanId);\n\t\tscan.setTransientState(database, this, alertFactory);\n\t\tdatabase.store(scan);\n\t\treturn scan;\n\t}\n\n\t@Override\n\tpublic synchronized IScanInstance getScanInstanceByScanId(final long scanId) {\n\t\tfinal List<IScanInstance> results = database.query(new Predicate<IScanInstance>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IScanInstance scan) {\n\t\t\t\treturn scan.getScanId() == scanId;\n\t\t\t}\t\t\t\n\t\t});\n\t\tif(results.size() == 0) {\n\t\t\treturn null;\n\t\t} else if (results.size() > 1) {\n\t\t\tlogger.warning(\"Multiple scan instances for scanId = \"+ scanId);\n\t\t} \n\t\treturn results.get(0);\n\t}\n\n\t@Override\n\tpublic synchronized IScanInstance getProxyScanInstance() {\n\t\tfinal IScanInstance scan = getScanInstanceByScanId(PROXY_ALERT_ORIGIN_SCAN_ID);\n\t\tif(scan != null) {\n\t\t\treturn scan;\n\t\t}\n\t\treturn createScanInstanceForScanId(PROXY_ALERT_ORIGIN_SCAN_ID);\n\t}\n\t\n\tprivate long allocateNewScanId() {\n\t\tint count = 0;\n\t\tfinal Random r = new Random();\n\t\twhile(true) {\n\t\t\tlong scanId = r.nextInt(999999) + 1;\n\t\t\tif(getScanInstanceByScanId(scanId) == null) {\n\t\t\t\treturn scanId;\n\t\t\t}\n\t\t\tcount += 1;\n\t\t\tif(count > 10) {\n\t\t\t\tthrow new IllegalStateException(\"Unable to generate unique random scan id\");\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic Collection<IScanAlert> getAlertsByRequestId(final long requestId) {\n\t\treturn database.query(new Predicate<IScanAlert>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IScanAlert alert) {\n\t\t\t\treturn (alert.getRequestId() == requestId);\n\t\t\t}\n\t\t});\n\t}\n\n\t@Override\n\tpublic synchronized void removeScanInstance(IScanInstance scanInstance) {\n\t\tif(scanInstance.getScanId() == PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\tthrow new IllegalArgumentException(\"Cannot remove scan instance for proxy alerts\");\n\t\t}\n\t\tif(scanInstance.isActive()) {\n\t\t\tthrow new IllegalArgumentException(\"Cannot remove active scan instance\");\n\t\t}\n\t\tscanInstanceEventManager.fireEvent(new RemoveScanInstanceEvent(scanInstance));\n\t\tif(activeScanInstanceList.contains(scanInstance)) {\n\t\t\tactiveScanInstanceList.remove(scanInstance);\n\t\t}\n\t\tscanInstance.deleteScanInstance();\n\t\tdatabase.delete(scanInstance);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/alerts/ScanInstance.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.alerts;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Date;\nimport java.util.List;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.ScanExceptionEvent;\nimport com.subgraph.vega.api.model.alerts.ScanPauseStateChangedEvent;\nimport com.subgraph.vega.api.model.alerts.ScanStatusChangeEvent;\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.internal.model.ModelProperties;\n\npublic class ScanInstance implements IScanInstance, Activatable {\n\tprivate final long scanId;\n\tprivate final ModelProperties properties;\n\n\tprivate volatile Date startTime;\n\tprivate volatile Date stopTime;\n\tprivate volatile int scanStatus;\n\t\n\tprivate transient volatile IScan scan;\n\tprivate transient volatile int activeScanCompletedCount;\n\tprivate transient volatile int activeScanTotalCount;\n\tprivate transient volatile String currentPath;\n\tprivate transient volatile boolean isPaused;\n\t\n\tprivate transient ScanAlertRepository repository;\n\tprivate transient ScanInstanceAlerts scanAlerts;\n\tprivate transient EventListenerManager eventManager;\n\n\tprivate transient Activator activator;\n\n\tpublic ScanInstance(long scanId) {\n\t\tthis.scanId = scanId;\n\t\tthis.scanStatus = SCAN_CONFIG;\n\t\tthis.properties = new ModelProperties();\n\t}\n\n\tpublic void setTransientState(ObjectContainer database, ScanAlertRepository repository, ScanAlertFactory alertFactory) {\n\t\tthis.eventManager = new EventListenerManager();\n\t\tthis.repository = repository;\n\t\tthis.scanAlerts = new ScanInstanceAlerts(database, this, eventManager, alertFactory);\n\t}\n\n\t@Override\n\tpublic long getScanId() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanId;\n\t}\n\n\t@Override\n\tpublic IScan getScan() {\n\t\treturn scan;\n\t}\n\n\t@Override\n\tpublic Date getStartTime() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn startTime;\n\t}\n\n\t@Override\n\tpublic Date getStopTime() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn stopTime;\n\t}\n\n\t@Override\n\tpublic IScanAlert createAlert(String type) {\n\t\treturn createAlert(type, null, -1);\n\t}\n\n\t@Override\n\tpublic IScanAlert createAlert(String type, String key) {\n\t\treturn createAlert(type, key, -1);\n\t}\n\n\t@Override\n\tpublic IScanAlert createAlert(String type, String key, long requestId) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanAlerts.createAlert(type, key, requestId);\n\t}\n\n\t@Override\n\tpublic void addAlert(IScanAlert alert) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tscanAlerts.addAlert(alert);\n\t}\n\n\t@Override\n\tpublic void removeAlert(IScanAlert alert) {\n\t\tremoveAlerts(Arrays.asList(alert));\n\t}\n\n\t@Override\n\tpublic void removeAlerts(Collection<IScanAlert> alerts) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tscanAlerts.removeAlerts(alerts);\n\t\trepository.fireRemoveEventsEvent(this, alerts);\n\t}\n\n\t@Override\n\tpublic boolean hasAlertKey(String key) {\n\t\treturn (getAlertByKey(key) != null);\n\t}\n\n\t@Override\n\tpublic IScanAlert getAlertByKey(String key) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanAlerts.getAlertByKey(key); \n\t}\n\n\t@Override\n\tpublic List<IScanAlert> getAllAlerts() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanAlerts.getAllAlerts();\n\t}\n\n\t@Override\n\tpublic void addScanEventListenerAndPopulate(IEventHandler listener) {\n\t\tscanAlerts.addScanEventListenerAndPopulate(listener);\n\t\tlistener.handleEvent(new ScanStatusChangeEvent(this, currentPath, scanStatus, activeScanCompletedCount, activeScanTotalCount));\n\t}\n\n\t@Override\n\tpublic void removeScanEventListener(IEventHandler listener) {\n\t\teventManager.removeListener(listener);\n\t}\n\n\t@Override\n\tpublic int getScanStatus() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanStatus;\n\t}\n\n\t@Override\n\tpublic boolean isActive() {\n\t\tint scanStatus = getScanStatus();\n\t\treturn (scanStatus == SCAN_PROBING || scanStatus == SCAN_STARTING || scanStatus == SCAN_AUDITING);\n\n\t}\n\t\n\t@Override\n\tpublic boolean isComplete() {\n\t\tint scanStatus = getScanStatus();\n\t\treturn (scanStatus == SCAN_CANCELLED || scanStatus == SCAN_COMPLETED);\n\t}\n\n\t@Override\n\tpublic String getScanCurrentPath() {\n\t\treturn currentPath;\n\t}\n\n\t@Override\n\tpublic int getScanCompletedCount() {\n\t\treturn activeScanCompletedCount;\n\t}\n\n\t@Override\n\tpublic int getScanTotalCount() {\n\t\treturn activeScanTotalCount;\n\t}\n\n\t@Override\n\tpublic void setScan(IScan scan) {\n\t\tthis.scan = scan;\n\t}\n\n\t@Override\n\tpublic void updateScanProgress(String currentPath, int completedCount, int totalCount) {\n\t\tif(currentPath != null) {\n\t\t\tthis.currentPath = currentPath;\n\t\t}\n\t\tactiveScanCompletedCount = completedCount;\n\t\tactiveScanTotalCount = totalCount;\n\t\teventManager.fireEvent(new ScanStatusChangeEvent(this, this.currentPath, scanStatus, activeScanCompletedCount, activeScanTotalCount));\n\t}\n\n\t@Override\n\tpublic void updateScanProgress(int completedCount, int totalCount) {\n\t\tactiveScanCompletedCount = completedCount;\n\t\tactiveScanTotalCount = totalCount;\n\t\teventManager.fireEvent(new ScanStatusChangeEvent(this, currentPath, scanStatus, completedCount, totalCount));\n\t}\n\n\t@Override\n\tpublic synchronized void updateScanStatus(int status) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif ((status == SCAN_PROBING || status == SCAN_STARTING) && (startTime == null)) {\n\t\t\tstartTime = new Date();\n\t\t} else if ( (status == SCAN_COMPLETED || status == SCAN_CANCELLED)  && (stopTime == null) ) {\n\t\t\tstopTime = new Date();\n\t\t}\n\t\n\t\tif(status == SCAN_CANCELLED && isPaused) {\n\t\t\tisPaused = false;\n\t\t}\n\t\n\t\tthis.scanStatus = status;\n\t\teventManager.fireEvent(new ScanStatusChangeEvent(this, currentPath, status, activeScanCompletedCount, activeScanTotalCount));\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void notifyScanException(HttpUriRequest request, Throwable exception) {\n\t\teventManager.fireEvent(new ScanExceptionEvent(request, exception));\n\t}\n\n\t@Override\n\tpublic void notifyScanPauseState(boolean isPaused) {\n\t\tthis.isPaused = isPaused;\n\t\teventManager.fireEvent(new ScanPauseStateChangedEvent(isPaused));\n\t}\n\t\n\t@Override \n\tpublic boolean isScanPaused() {\n\t\treturn isPaused;\n\t}\n\n\t@Override\n\tpublic void deleteScanInstance() {\n\t\teventManager.clearListeners();\n\t\tscanAlerts.removeAllAlerts();\n\t}\n\n\t@Override\n\tpublic void setProperty(String name, Object value) {\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tproperties.setProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setStringProperty(String name, String value) {\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tproperties.setStringProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tproperties.setIntegerProperty(name, value);\n\t}\n\n\t@Override\n\tpublic Object getProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getProperty(name);\n\t}\n\n\t@Override\n\tpublic String getStringProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getStringProperty(name);\n\t}\n\n\t@Override\n\tpublic Integer getIntegerProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getIntegerProperty(name);\n\t}\n\n\t@Override\n\tpublic List<String> propertyKeys() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.propertyKeys();\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/alerts/ScanInstanceAlerts.java",
    "content": "package com.subgraph.vega.internal.model.alerts;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.query.Predicate;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.NewScanAlertEvent;\n\npublic class ScanInstanceAlerts {\n\tprivate final static Logger logger = Logger.getLogger(\"alerts\");\n\n\tprivate final ObjectContainer database;\n\tprivate final IScanInstance scanInstance;\n\tprivate final EventListenerManager eventManager;\n\tprivate final ScanAlertFactory alertFactory;\n\n\t\n\tScanInstanceAlerts(ObjectContainer database, IScanInstance scanInstance, EventListenerManager eventManager, ScanAlertFactory alertFactory) {\n\t\tthis.database = database;\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.eventManager = eventManager;\n\t\tthis.alertFactory = alertFactory;\n\t}\n\n\tpublic IScanAlert createAlert(String type, String key, long requestId) {\n\t\treturn alertFactory.createAlert(key, type, scanInstance, requestId);\n\t}\n\n\tpublic void addAlert(IScanAlert alert) {\n\t\tsynchronized(this) {\n\t\t\tif(rejectDuplicateAlert(alert)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdatabase.store(alert);\n\t\t}\n\t\teventManager.fireEvent(new NewScanAlertEvent(alert));\n\t}\n\t\n\t\n\tpublic void removeAlerts(Collection<IScanAlert> alerts) {\n\t\tsynchronized(this) {\n\t\t\tfor(IScanAlert alert: alerts) {\n\t\t\t\tdatabase.delete(alert);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate boolean rejectDuplicateAlert(IScanAlert alert) {\n\t\tif(alert.getResource() == null) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor(ScanAlert sa: getAlertListForResource(alert.getResource())) {\n\t\t\tif(sa.equals(alert)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(alert.getKey() == null) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn hasAlertKey(alert.getKey());\n\t\t}\n\t}\n\n\tprivate List<ScanAlert> getAlertListForResource(final String resource) {\n\t\treturn database.query(new Predicate<ScanAlert>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(ScanAlert alert) {\n\t\t\t\treturn resource.equals(alert.getResource()) && alert.getScanId() == scanInstance.getScanId();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tpublic boolean hasAlertKey(String key) {\n\t\treturn (getAlertByKey(key) != null);\n\t}\n\n\t\n\tpublic IScanAlert getAlertByKey(String key) {\n\t\tif(key == null) {\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tfinal List<ScanAlert> results = getAlertListForKey(key);\n\t\tif(results.size() == 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif(results.size() > 1) {\n\t\t\tlogger.warning(\"Multiple alert model entries for key: \"+ key);\n\t\t}\n\t\treturn results.get(0);\n\t}\n\n\tprivate List<ScanAlert> getAlertListForKey(final String key) {\n\t\t\treturn database.query(new Predicate<ScanAlert>() {\n\t\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t\t@Override\n\t\t\t\tpublic boolean match(ScanAlert alert) {\n\t\t\t\t\treturn key.equals(alert.getKey()) && alert.getScanId() == scanInstance.getScanId();\n\t\t\t\t}\t\t\t\n\t\t\t});\n\t}\n\n\tpublic List<IScanAlert> getAllAlerts() {\n\t\treturn database.query(new Predicate<IScanAlert>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IScanAlert alert) {\n\t\t\t\treturn alert.getScanId() == scanInstance.getScanId();\n\t\t\t}\t\t\t\n\t\t});\n\t}\n\n\tpublic void removeAllAlerts() {\n\t\tfinal List<IScanAlert> all = new ArrayList<IScanAlert>(getAllAlerts());\n\t\tremoveAlerts(all);\n\t}\n\n\tpublic void addScanEventListenerAndPopulate(IEventHandler listener) {\n\t\tList<IScanAlert> allAlerts = null;\n\t\tsynchronized(this) {\n\t\t\tallAlerts = getAllAlerts();\n\t\t\teventManager.addListener(listener);\n\t\t}\n\t\t\n\t\tfor(IScanAlert alert: allAlerts) {\n\t\t\tlistener.handleEvent(new NewScanAlertEvent(alert));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/AbstractCondition.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionIntegerMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionRangeMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionStringMatchAction;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.internal.model.conditions.match.IHttpConditionMatchActionEx;\n\npublic abstract class AbstractCondition implements IHttpCondition, Activatable {\n\t\t\n\tprotected IHttpConditionMatchActionEx matchAction;\n\tprivate boolean isEnabled;\n\tprivate boolean isSufficient;\n\t\t\n\tprotected AbstractCondition(IHttpConditionMatchAction matchAction) {\n\t\tthis.matchAction = (IHttpConditionMatchActionEx) matchAction;\n\t\tthis.isEnabled = true;\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction getMatchAction() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchAction;\n\t}\n\t\n\t@Override\n\tpublic void setMatchAction(IHttpConditionMatchAction matchAction) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchAction instanceof IHttpConditionMatchActionEx) {\n\t\t\tthis.matchAction = (IHttpConditionMatchActionEx) matchAction;\n\t\t\tactivate(ActivationPurpose.WRITE);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic boolean matches(IRequestLogRecord record) {\n\t\treturn matches(record.getRequest(), record.getResponse());\n\t}\n\n\t@Override\n\tpublic boolean isEnabled() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn isEnabled;\n\t}\n\n\t@Override\n\tpublic void setEnabled(boolean state) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tisEnabled = state;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\tpublic IHttpCondition createCopy() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn getType().createConditionInstance(matchAction.createCopy());\n\t}\n\n\tprotected boolean matchesString(String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchAction instanceof IHttpConditionStringMatchAction) {\n\t\t\treturn ((IHttpConditionStringMatchAction) matchAction).matchesValue(value);\n\t\t}\n\t\tthrow new IllegalStateException(\"Expecting an IHttpConditionStringMatchingAction, got\"+ matchAction);\n\t}\n\t\n\tprotected boolean matchesInteger(int value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchAction instanceof IHttpConditionIntegerMatchAction) {\n\t\t\treturn ((IHttpConditionIntegerMatchAction) matchAction).matchesValue(value);\n\t\t} else if(matchAction instanceof IHttpConditionRangeMatchAction) {\n\t\t\treturn ((IHttpConditionRangeMatchAction) matchAction).matchesValue(value);\n\t\t} \n\t\tthrow new IllegalStateException(\"Expecting an IHttpConditonIntegerMatchAction or IHttpConditionRangeMatchAction, got\"+ matchAction);\n\t}\n\t\n\tprotected Constraint constrainQuery(Query query) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchAction.constrainQuery(query);\n\t}\n\n\tpublic String getValueString() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchAction.toString();\n\t}\n\t\n\t@Override\n\tpublic boolean isInternal() {\n\t\treturn false;\n\t}\n\t\n\t@Override\n\tpublic boolean isSufficient() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn isSufficient;\n\t}\n\t\n\t@Override\n\tpublic void setSufficient(boolean value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tisSufficient = value;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\tpublic abstract Constraint filterRequestLogQuery(Query query);\n\t\t\n\tprivate transient Activator activator;\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionHeader.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpMessage;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.StringMatchActionSet;\n\npublic class ConditionHeader extends AbstractCondition {\n\tstatic private transient IHttpConditionType requestConditionType;\n\tstatic private transient IHttpConditionType responseConditionType;\n\t\n\tstatic IHttpConditionType getRequestConditionType() {\n\t\tsynchronized (ConditionHeader.class) {\n\t\t\tif(requestConditionType == null) \n\t\t\t\tcreateTypes();\n\t\t\treturn requestConditionType;\n\t\t}\n\t}\n\t\n\tstatic IHttpConditionType getResponseConditionType() {\n\t\tsynchronized(ConditionHeader.class) {\n\t\t\tif(responseConditionType == null)\n\t\t\t\tcreateTypes();\n\t\t\treturn responseConditionType;\n\t\t}\n\t}\n\n\tprivate static void createTypes() {\n\t\trequestConditionType = createType(\"request header\", true);\n\t\tresponseConditionType = createType(\"response header\", false);\n\t}\n\t\n\tprivate static IHttpConditionType createType(String label, final boolean flag) {\n\t\treturn new ConditionType(label, new StringMatchActionSet()) {\t\t\t\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionHeader(flag, matchAction);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate final boolean matchRequestHeader;\n\t\n\tConditionHeader(boolean matchRequestHeader, IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t\tthis.matchRequestHeader = matchRequestHeader;\n\t}\n\t\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchRequestHeader)\n\t\t\treturn matchesString(headersToString(request));\n\t\telse\n\t\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(!matchRequestHeader)\n\t\t\treturn matchesString(headersToString(response));\n\t\telse\n\t\t\treturn false;\n\t}\n\n\t\n\tprivate String headersToString(HttpMessage message) {\n\t\tif(message == null)\n\t\t\treturn \"\";\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor(Header h: message.getAllHeaders()) {\n\t\t\tsb.append(h.getName());\n\t\t\tsb.append(\": \");\n\t\t\tsb.append(h.getValue());\n\t\t\tsb.append(\"\\r\\n\");\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchRequestHeader)\n\t\t\treturn matchesString(headersToString(request));\n\t\telse\n\t\t\treturn matchesString(headersToString(response));\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchRequestHeader)\n\t\t\treturn getRequestConditionType();\n\t\telse\n\t\t\treturn getResponseConditionType();\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(matchRequestHeader) \n\t\t\treturn constrainQuery(query.descend(\"requestHeaders\"));\n\t\telse\n\t\t\treturn constrainQuery(query.descend(\"responseHeaders\"));\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionHostname.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.StringMatchActionSet;\n\npublic class ConditionHostname extends AbstractCondition {\n\tstatic private transient IHttpConditionType conditionType;\n\t\n\tstatic IHttpConditionType getConditionType() {\n\t\tsynchronized(ConditionHostname.class) {\n\t\t\tif(conditionType == null)\n\t\t\t\tconditionType = createType();\n\t\t\treturn conditionType;\n\t\t}\n\t}\n\n\tprivate static IHttpConditionType createType() {\n\t\treturn new ConditionType(\"hostname\",  new StringMatchActionSet()) {\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionHostname(matchAction);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate ConditionHostname(IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t}\n\t\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\tfinal String hostname = getRequestHostname(request);\n\t\tif(hostname == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn matchesString(hostname);\n\t}\n\t\n\t\n\tprivate String getRequestHostname(HttpRequest request) {\n\t\tHeader hostHeader = request.getFirstHeader(\"Host\");\n\t\tif(hostHeader == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn hostHeader.getValue();\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\treturn matches(request);\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\treturn getConditionType();\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\treturn constrainQuery(query.descend(\"hostname\"));\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionPath.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.StringMatchActionSet;\n\npublic class ConditionPath extends AbstractCondition {\n\n\tstatic private transient IHttpConditionType conditionType;\n\t\n\tstatic IHttpConditionType getConditionType() {\n\t\tsynchronized(ConditionPath.class) {\n\t\t\tif(conditionType == null)\n\t\t\t\tconditionType = createType();\n\t\t\treturn conditionType;\n\t\t}\n\t}\n\t\n\tprivate static IHttpConditionType createType() {\n\t\treturn new ConditionType(\"request path\", new StringMatchActionSet()) {\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionPath(matchAction);\n\t\t\t}\t\t\t\n\t\t};\n\t}\n\n\tprivate ConditionPath(IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\treturn getConditionType();\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\treturn matchesString(request.getRequestLine().getUri());\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\treturn matches(request);\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\treturn constrainQuery(query.descend(\"requestPath\"));\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionRequestId.java",
    "content": "package com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.internal.model.conditions.match.IntegerMatchActionSet;\n\npublic class ConditionRequestId extends AbstractCondition {\n\n\tprivate transient static IHttpConditionType conditionType;\n\t\n\tstatic IHttpConditionType getConditionType() {\n\t\tsynchronized (ConditionRequestId.class) {\n\t\t\tif(conditionType == null) {\n\t\t\t\tconditionType = createType();\n\t\t\t}\n\t\t\treturn conditionType;\n\t\t}\n\t}\n\t\n\tprivate static IHttpConditionType createType() {\n\t\treturn new ConditionType(\"request id\", new IntegerMatchActionSet(), true) {\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(\n\t\t\t\t\tIHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionRequestId(matchAction);\n\t\t\t}\n\t\t};\n\t}\n\tprivate ConditionRequestId(IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\treturn getConditionType();\n\t}\n\t\n\t@Override\n\tpublic boolean matches(IRequestLogRecord record) {\n\t\treturn matchesInteger((int) record.getRequestId());\n\t}\n\t\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean isInternal() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\treturn constrainQuery(query.descend(\"requestId\"));\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionRequestMethod.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.StringMatchActionSet;\n\npublic class ConditionRequestMethod extends AbstractCondition {\n\n\tstatic private transient IHttpConditionType conditionType;\n\t\n\tstatic IHttpConditionType getConditionType() {\n\t\tsynchronized(ConditionRequestMethod.class) {\n\t\t\tif(conditionType == null)\n\t\t\t\tconditionType = createType();\n\t\t\treturn conditionType;\n\t\t}\n\t}\n\t\n\tprivate static IHttpConditionType createType() {\n\t\treturn new ConditionType(\"request method\", new StringMatchActionSet()) {\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionRequestMethod(matchAction);\n\t\t\t}\n\t\t};\n\t}\n\n\tprotected ConditionRequestMethod(IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\tif(request == null)\n\t\t\treturn false;\n\t\tfinal String method = request.getRequestLine().getMethod();\n\t\treturn matchesString(method);\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\treturn matches(request);\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\treturn getConditionType();\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\treturn constrainQuery(query.descend(\"requestMethod\"));\n\t}\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionResponseLength.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.IntegerMatchActionSet;\n\npublic class ConditionResponseLength extends AbstractCondition {\n\t\n\n\tprivate static transient IHttpConditionType conditionType;\n\t\n\tstatic IHttpConditionType getConditionType() {\n\t\tsynchronized (ConditionResponseLength.class) {\n\t\t\tif(conditionType == null)\n\t\t\t\tconditionType = createType();\n\t\t\treturn conditionType;\n\t\t}\n\t}\n\n\tprivate static IHttpConditionType createType() {\n\t\treturn new ConditionType(\"response length\", new IntegerMatchActionSet()) {\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionResponseLength(matchAction);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate ConditionResponseLength(IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\tfinal int length = (int) getLengthFromResponse(response);\n\t\treturn matchesInteger(length);\n\t}\n\n\tprivate long getLengthFromResponse(HttpResponse response) {\n\t\tfinal Header lengthHeader = response.getFirstHeader(\"Content-Length\");\n\t\tif(lengthHeader != null) {\n\t\t\ttry {\n\t\t\t\treturn Long.parseLong(lengthHeader.getValue());\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(response.getEntity() == null)\n\t\t\treturn 0;\n\t\treturn response.getEntity().getContentLength();\n\t}\n\t\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\treturn matches(response);\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\treturn getConditionType();\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\treturn constrainQuery(query.descend(\"responseLength\"));\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionResponseStatusCode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.IntegerMatchActionSet;\n\npublic class ConditionResponseStatusCode extends AbstractCondition {\n\t\n\n\tstatic private transient IHttpConditionType conditionType;\n\t\n\tstatic IHttpConditionType getConditionType() {\n\t\tsynchronized(ConditionResponseStatusCode.class) {\n\t\t\tif(conditionType == null)\n\t\t\t\tconditionType = createType();\n\t\t\treturn conditionType;\n\t\t}\n\t}\n\n\tprivate static IHttpConditionType createType() {\n\t\treturn new ConditionType(\"response status code\", new IntegerMatchActionSet()) {\t\t\t\n\t\t\t@Override\n\t\t\tpublic IHttpCondition createConditionInstance(IHttpConditionMatchAction matchAction) {\n\t\t\t\treturn new ConditionResponseStatusCode(matchAction);\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate ConditionResponseStatusCode(IHttpConditionMatchAction matchAction) {\n\t\tsuper(matchAction);\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpResponse response) {\n\t\tif(response == null)\n\t\t\treturn false;\n\t\treturn matchesInteger(response.getStatusLine().getStatusCode());\n\t}\n\n\t@Override\n\tpublic boolean matches(HttpRequest request, HttpResponse response) {\n\t\treturn matches(response);\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getType() {\n\t\treturn getConditionType();\n\t}\n\n\t@Override\n\tpublic Constraint filterRequestLogQuery(Query query) {\n\t\treturn constrainQuery(query.descend(\"responseCode\"));\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/ConditionType.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.internal.model.conditions.match.IMatchActionSet;\n\npublic abstract class ConditionType implements IHttpConditionType {\n\n\tprivate final String name;\n\tprivate final boolean isInternal;\n\tprivate final IMatchActionSet matchActionSet;\n\t\n\tConditionType(String name, IMatchActionSet matchActionSet) {\n\t\tthis(name, matchActionSet, false);\n\t}\n\n\tConditionType(String name, IMatchActionSet matchActionSet, boolean isInternal) {\n\t\tthis.name = name;\n\t\tthis.isInternal = isInternal;\n\t\tthis.matchActionSet = matchActionSet;\n\t}\n\t\n\t@Override\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\t@Override\n\tpublic boolean isInternal() {\n\t\treturn isInternal;\n\t}\n\t\n\t@Override\n\tpublic List<IHttpConditionMatchAction> getMatchActions() {\n\t\treturn matchActionSet.createMatchActions();\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction getMatchActionByName(String name) {\n\t\tfor(IHttpConditionMatchAction action: getMatchActions()) {\n\t\t\tif(action.getLabel().equals(name)) {\n\t\t\t\treturn action;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic boolean equals(Object other) {\n\t\tif(this == other)\n\t\t\treturn true;\n\t\tif(other instanceof ConditionType) {\n\t\t\tConditionType that = (ConditionType) other;\n\t\t\treturn this.name.equals(that.name);\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tpublic int hashCode() {\n\t\treturn name.hashCode();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/HttpConditionManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.events.CancellableObjectEventArgs;\nimport com.db4o.events.Event4;\nimport com.db4o.events.EventListener4;\nimport com.db4o.events.EventRegistry;\nimport com.db4o.events.EventRegistryFactory;\nimport com.subgraph.vega.api.events.NamedEventListenerManager;\nimport com.subgraph.vega.api.model.conditions.ConditionSetChanged;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\n\npublic class HttpConditionManager implements IHttpConditionManager {\n\n\tprivate final ObjectContainer database;\n\tprivate final List<IHttpConditionType> conditionTypes;\n\tprivate final NamedEventListenerManager conditionSetChangedManager;\n\n\tpublic HttpConditionManager(ObjectContainer database, NamedEventListenerManager conditionSetChangedManager) {\n\t\tthis.database = database;\n\t\tthis.conditionTypes = createConditionTypes();\n\t\tthis.conditionSetChangedManager = conditionSetChangedManager;\n\t\tfinal EventRegistry registry = EventRegistryFactory.forObjectContainer(database);\n\t\tregistry.activating().addListener(new EventListener4<CancellableObjectEventArgs>() {\n\t\t\t@Override\n\t\t\tpublic void onEvent(Event4<CancellableObjectEventArgs> e, CancellableObjectEventArgs args) {\n\t\t\t\tfinal Object ob = args.object();\n\t\t\t\tif(ob instanceof HttpConditionSet) \n\t\t\t\t\t((HttpConditionSet)ob).setConditionManager(HttpConditionManager.this);\t\t\t\t\t\n\t\t\t\telse if(ob instanceof HttpConditionSetMap) \n\t\t\t\t\t((HttpConditionSetMap)ob).setConditionManager(HttpConditionManager.this);\n\t\t\t}\n\t\t});\n\t\tnotifyAllChanged();\n\t}\n\n\tprivate List<IHttpConditionType> createConditionTypes() {\n\t\tfinal List<IHttpConditionType> types = new ArrayList<IHttpConditionType>();\n\t\ttypes.add(ConditionHostname.getConditionType());\n\t\ttypes.add(ConditionRequestMethod.getConditionType());\n\t\ttypes.add(ConditionHeader.getRequestConditionType());\n\t\ttypes.add(ConditionPath.getConditionType());\n\t\ttypes.add(ConditionHeader.getResponseConditionType());\n\t\ttypes.add(ConditionResponseLength.getConditionType());\n\t\ttypes.add(ConditionResponseStatusCode.getConditionType());\n\t\ttypes.add(ConditionRequestId.getConditionType());\n\t\treturn types;\n\t}\n\t\n\tpublic void notifyClosed() {\n\t\tsynchronized(conditionSetChangedManager) {\n\t\t\tconditionSetChangedManager.fireAllKeys(new ConditionSetChanged(null));\n\t\t}\n\t}\n\t\n\tprivate void notifyAllChanged() {\n\t\tsynchronized(conditionSetChangedManager) {\n\t\t\tfor(String conditionSetName: conditionSetChangedManager.getAllKeys()) {\n\t\t\t\tIHttpConditionSet conditionSet = getConditionSet(conditionSetName);\n\t\t\t\tconditionSetChangedManager.fireEvent(conditionSetName, new ConditionSetChanged(conditionSet));\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid notifyConditionSetChanged(IHttpConditionSet conditionSet) {\n\t\tconditionSetChangedManager.fireEvent(conditionSet.getName(), new ConditionSetChanged(conditionSet));\n\t}\n\n\t@Override\n\tpublic IHttpConditionSet getConditionSet(String name) {\n\t\treturn getConditionSetMap().getConditionSet(name);\n\t}\n\t\n\t@Override\n\tpublic IHttpConditionSet getConditionSetCopy(String name) {\n\t\treturn getConditionSetMap().getConditionSetCopy(name);\n\t}\n\n\t@Override\n\tpublic void saveConditionSet(String name, IHttpConditionSet conditionSet) {\n\t\tsynchronized(conditionSetChangedManager) {\n\t\t\tgetConditionSetMap().saveConditionSet(name, conditionSet);\n\t\t\tconditionSetChangedManager.fireEvent(name, new ConditionSetChanged(conditionSet));\n\t\t}\n\t}\n\n\tprivate HttpConditionSetMap getConditionSetMap() {\n\t\tsynchronized(this) {\n\t\t\tfinal List<HttpConditionSetMap> result = database.query(HttpConditionSetMap.class);\n\t\t\tif(result.size() == 1)\n\t\t\t\treturn result.get(0);\n\t\t\telse if(result.size() > 1)\n\t\t\t\tthrow new IllegalStateException(\"Duplicate HttpConditionSetMap records in database\");\n\t\t\tHttpConditionSetMap map = new HttpConditionSetMap(this);\n\t\t\tdatabase.store(map);\n\t\t\treturn map;\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IHttpConditionType> getConditionTypes() {\n\t\treturn getConditionTypes(false);\n\t}\n\t\n\t@Override\n\tpublic List<IHttpConditionType> getConditionTypes(boolean includeInternal) {\n\t\tif(includeInternal) {\n\t\t\treturn Collections.unmodifiableList(new ArrayList<IHttpConditionType>(conditionTypes));\n\t\t}\n\t\tfinal List<IHttpConditionType> result = new ArrayList<IHttpConditionType>();\n\t\tfor(IHttpConditionType type: conditionTypes) {\n\t\t\tif(!type.isInternal()) {\n\t\t\t\tresult.add(type);\n\t\t\t}\n\t\t}\n\t\treturn Collections.unmodifiableList(result);\n\t\t\n\t}\n\n\t@Override\n\tpublic IHttpConditionType getConditionTypeByName(String name) {\n\t\tfor(IHttpConditionType type: getConditionTypes(true)) {\n\t\t\tif(type.getName().equals(name)) {\n\t\t\t\treturn type;\n\t\t\t}\n\t\t}\n\t\treturn null;\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/HttpConditionSet.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.ObjectSet;\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableArrayList;\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic class HttpConditionSet implements IHttpConditionSet, Activatable {\n\n\tprivate final String name;\n\tprivate final List<IHttpCondition> conditionList = new ActivatableArrayList<IHttpCondition>();\n\tprivate boolean matchOnEmptySet;\n\tprivate transient Object lock;\n\tprivate transient HttpConditionManager conditionManager;\n\tprivate transient List<IHttpCondition> temporaryConditions;\n\tprivate transient List<IHttpCondition> allConditions;\n\t\n\tHttpConditionSet(String name, HttpConditionManager conditionManager) {\n\t\tthis(name, conditionManager, null);\n\t}\n\t\n\tHttpConditionSet(String name, HttpConditionManager conditionManager, IHttpConditionSet copyMe) {\n\t\tthis.name = name;\n\t\tthis.conditionManager = conditionManager;\n\t\tthis.temporaryConditions = new ArrayList<IHttpCondition>();\n\t\tthis.lock = new Object();\n\t\tif(copyMe != null) {\n\t\t\tfor(IHttpCondition c: copyMe.getAllConditions(true)) { \n\t\t\t\tconditionList.add(c.createCopy());\n\t\t\t}\n\t\t\tfor(IHttpCondition c: copyMe.getAllTemporaryConditions(true)) {\n\t\t\t\ttemporaryConditions.add(c.createCopy());\n\t\t\t}\n\t\t\tthis.allConditions = new ArrayList<IHttpCondition>();\n\t\t\tupdateAllConditions();\n\t\t}\n\t}\n\n\tprivate void updateAllConditions() {\n\t\tsynchronized (lock) {\n\t\t\tif (allConditions == null) {\n\t\t\t\tallConditions = new ArrayList<IHttpCondition>();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tallConditions.clear();\n\t\t\t}\n\t\t\tallConditions.addAll(conditionList);\n\t\t\tallConditions.addAll(temporaryConditions);\n\t\t}\n\t}\n\t\n\tprivate List<IHttpCondition> getAllConditionsList() {\n\t\tif(allConditions == null) {\n\t\t\tallConditions = new ArrayList<IHttpCondition>();\n\t\t\tupdateAllConditions();\n\t\t}\n\t\treturn allConditions;\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic boolean matchesAll(IRequestLogRecord record) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchesAllConditions(record);\n\t}\n\n\t@Override\n\tpublic boolean matchesAll(HttpRequest request, HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchesAllConditions(request, response);\n\t}\n\n\t@Override\n\tpublic boolean matchesAny(IRequestLogRecord record) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchesAnyCondition(record);\n\t}\n\n\t@Override\n\tpublic boolean matchesAny(HttpRequest request, HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn matchesAnyCondition(request, response);\n\t}\n\t\n\tprivate boolean matchesAllConditions(IRequestLogRecord record) {\n\t\tsynchronized(lock) {\n\t\t\tif(getAllConditionsList().size() == 0) {\n\t\t\t\treturn matchOnEmptySet;\n\t\t\t}\n\t\t\tfor(IHttpCondition c: getAllConditionsList()) {\n\t\t\t\tif(c.isEnabled() && !c.matches(record)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\tprivate boolean matchesAllConditions(HttpRequest request, HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(lock) {\n\t\t\tif (getAllConditionsList().size() == 0) {\n\t\t\t\treturn matchOnEmptySet;\n\t\t\t}\n\t\t\tfor(IHttpCondition c: getAllConditionsList()) {\n\t\t\t\tif(c.isEnabled() && !c.matches(request, response))\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\tprivate boolean matchesAnyCondition(IRequestLogRecord record) {\n\t\tsynchronized (lock) {\n\t\t\tif(getAllConditionsList().size() == 0) {\n\t\t\t\treturn matchOnEmptySet;\n\t\t\t}\n\t\t\tfor(IHttpCondition c: getAllConditionsList()) {\n\t\t\t\tif(c.isEnabled() && c.matches(record)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate boolean matchesAnyCondition(HttpRequest request, HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(lock) {\n\t\t\tif (getAllConditionsList().size() == 0) {\n\t\t\t\treturn matchOnEmptySet;\n\t\t\t}\n\t\t\tfor(IHttpCondition c: getAllConditionsList()) {\n\t\t\t\tif(c.isEnabled() && c.matches(request, response)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\t\n\t}\n\n\t@Override\n\tpublic void notifyChanged() {\n\t\tconditionManager.notifyConditionSetChanged(this);\n\t}\n\n\t@Override\n\tpublic boolean hasActiveConditions(boolean includeInternal) {\n\t\treturn !(getAllTemporaryConditions(includeInternal).isEmpty() && getAllConditions(includeInternal).isEmpty());\n\t}\n\n\t@Override\n\tpublic void appendCondition(IHttpCondition condition, boolean notify) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tconditionList.add(condition);\n\t\tupdateAllConditions();\n\t\tif(notify) {\n\t\t\tconditionManager.notifyConditionSetChanged(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void removeCondition(IHttpCondition condition, boolean notify) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tconditionList.remove(condition);\n\t\tupdateAllConditions();\n\t\tif(notify) {\n\t\t\tconditionManager.notifyConditionSetChanged(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void clearConditions(boolean notify) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tconditionList.clear();\n\t\tupdateAllConditions();\n\t\tif(notify) {\n\t\t\tconditionManager.notifyConditionSetChanged(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IHttpCondition> getAllConditions() {\n\t\treturn getAllConditions(false);\n\t}\n\t\n\t@Override\n\tpublic List<IHttpCondition> getAllConditions(boolean includeInternal) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(!includeInternal) {\n\t\t\treturn Collections.unmodifiableList(new ArrayList<IHttpCondition>(conditionList));\n\t\t}\n\t\tfinal List<IHttpCondition> result = new ArrayList<IHttpCondition>();\n\t\tfor(IHttpCondition condition: conditionList) {\n\t\t\tif(!condition.isInternal()) {\n\t\t\t\tresult.add(condition);\n\t\t\t}\n\t\t}\n\t\treturn Collections.unmodifiableList(result);\n\t}\n\n\t@Override\n\tpublic void appendTemporaryCondition(IHttpCondition condition, boolean notify) {\n\t\ttemporaryConditions.add(condition);\n\t\tupdateAllConditions();\n\t\tif(notify) {\n\t\t\tconditionManager.notifyConditionSetChanged(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void removeTemporaryCondition(IHttpCondition condition, boolean notify) {\n\t\ttemporaryConditions.remove(condition);\n\t\tupdateAllConditions();\n\t\tif(notify) {\n\t\t\tconditionManager.notifyConditionSetChanged(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void clearTemporaryConditions(boolean notify) {\n\t\ttemporaryConditions.clear();\n\t\tupdateAllConditions();\n\t\tif(notify) {\n\t\t\tconditionManager.notifyConditionSetChanged(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IHttpCondition> getAllTemporaryConditions(boolean includeInternal) {\n\t\tif(!includeInternal) {\n\t\t\treturn Collections.unmodifiableList(new ArrayList<IHttpCondition>(temporaryConditions));\n\t\t}\n\t\tfinal List<IHttpCondition> result = new ArrayList<IHttpCondition>();\n\t\tfor(IHttpCondition condition: temporaryConditions) {\n\t\t\tif(!condition.isInternal()) {\n\t\t\t\tresult.add(condition);\n\t\t\t}\n\t\t}\n\t\treturn Collections.unmodifiableList(result);\n\t}\n\n\t@Override\n\tpublic IHttpConditionManager getConditionManager() {\n\t\treturn conditionManager;\n\t}\n\n\tvoid setConditionManager(HttpConditionManager conditionManager) {\n\t\tthis.conditionManager = conditionManager;\n\t\tthis.temporaryConditions = new ArrayList<IHttpCondition>();\n\t\tthis.lock = new Object();\n\t}\n\t\n\tpublic List<IRequestLogRecord> filterRequestLog(ObjectContainer db) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(!hasRecords(db)) {\n\t\t\treturn Collections.emptyList();\n\t\t} else {\n\t\t\treturn executeFilterQuery(db);\n\t\t}\n\t}\n\n\tpublic ObjectSet<IRequestLogRecord> executeFilterQuery(ObjectContainer db) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal Query query = db.query();\n\t\tquery.constrain(IRequestLogRecord.class);\n\t\t\n\t\tConstraint orChain = null;\n\t\tConstraint andChain = null;\n\t\t\n\t\tfor(IHttpCondition c: getAllConditionsList()) {\n\t\t\tConstraint result = ((AbstractCondition)c).filterRequestLogQuery(query);\n\t\t\tif(c.isSufficient()) {\n\t\t\t\torChain = processConstraintChain(result, orChain, false);\n\t\t\t} else {\n\t\t\t\tandChain = processConstraintChain(result, andChain, true);\n\t\t\t}\n\t\t}\n\t\tif(orChain != null && andChain != null) {\n\t\t\torChain.or(andChain);\n\t\t}\n\t\n\t\t// If there are only 'sufficient' conditions, then don't filter at all\n\t\tif(andChain == null) {\n\t\t\tfinal Query q = db.query();\n\t\t\tq.constrain(IRequestLogRecord.class);\n\t\t\treturn q.execute();\n\t\t}\n\t\n\t\treturn query.execute();\n\t}\n\n\tprivate Constraint processConstraintChain(Constraint newConstraint, Constraint chain, boolean useAnd) {\n\t\tif(newConstraint == null) {\n\t\t\treturn chain;\n\t\t} else if(chain == null) {\n\t\t\treturn newConstraint;\n\t\t} else if(useAnd) {\n\t\t\treturn chain.and(newConstraint);\n\t\t} else {\n\t\t\treturn chain.or(newConstraint);\n\t\t}\n\t}\n\n\tprivate boolean hasRecords(ObjectContainer db) {\n\t\tfinal Query query = db.query();\n\t\tquery.constrain(IRequestLogRecord.class);\n\t\treturn query.execute().hasNext();\n\t}\n\n\t@Override\n\tpublic void setMatchOnEmptySet(boolean flag) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tmatchOnEmptySet = flag;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\tprivate transient Activator activator;\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/HttpConditionSetMap.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions;\n\nimport java.util.Map;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableHashMap;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\n\npublic class HttpConditionSetMap implements Activatable {\n\n\tprivate final Map<String, IHttpConditionSet> conditionSetMap = new ActivatableHashMap<String, IHttpConditionSet>();\n\t\n\tprivate transient Activator activator;\n\tprivate transient HttpConditionManager conditionManager;\n\t\n\tpublic HttpConditionSetMap(HttpConditionManager conditionManager) {\n\t\tthis.conditionManager = conditionManager;\n\t}\n\t\n\tvoid setConditionManager(HttpConditionManager conditionManager) {\n\t\tthis.conditionManager = conditionManager;\n\t}\n\n\tIHttpConditionSet getConditionSet(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(conditionSetMap) {\n\t\t\tif(!conditionSetMap.containsKey(name))\n\t\t\t\tconditionSetMap.put(name, new HttpConditionSet(name, conditionManager));\n\t\t\treturn conditionSetMap.get(name);\n\t\t}\n\t}\n\t\n\tIHttpConditionSet getConditionSetCopy(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(conditionSetMap) {\n\t\t\treturn new HttpConditionSet(name, conditionManager, conditionSetMap.get(name));\n\t\t}\n\t}\n\n\tvoid saveConditionSet(String name, IHttpConditionSet conditionSet) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized (conditionSet) {\n\t\t\tconditionSetMap.put(name, conditionSet);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/ContainsAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class ContainsAction extends StringMatchAction {\n\n\tprivate ContainsAction(String value) {\n\t\tsuper(value);\n\t}\n\n\tpublic ContainsAction() {\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"contains\";\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(stringValue).contains();\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new ContainsAction(stringValue);\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\treturn matchesContains(value);\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_STRING;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/DoesNotContainAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class DoesNotContainAction extends StringMatchAction {\n\t\n\tprivate DoesNotContainAction(String value) {\n\t\tsuper(value);\n\t}\n\n\tpublic DoesNotContainAction() {\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"does not contain\";\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new DoesNotContainAction(stringValue);\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(stringValue).contains().not();\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\treturn !matchesContains(value);\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_STRING;\n\t}\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/DoesNotEndWithAction.java",
    "content": "package com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class DoesNotEndWithAction extends StringMatchAction {\n\n\tpublic DoesNotEndWithAction() {\n\t\t\n\t}\n\n\tprivate DoesNotEndWithAction(String value) {\n\t\tsuper(value);\n\t}\n\t\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(stringValue).endsWith(true).not();\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new DoesNotEndWithAction(stringValue);\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"does not end with\";\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_STRING;\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\tif(value == null) {\n\t\t\treturn true;\n\t\t}\n\t\treturn !value.endsWith(stringValue);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/DoesNotMatchRegexAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.regex.Pattern;\n\nimport com.db4o.query.Evaluation;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class DoesNotMatchRegexAction extends RegexMatchAction {\n\t\n\tprivate DoesNotMatchRegexAction(String value) {\n\t\tsuper(value);\n\t}\n\n\tDoesNotMatchRegexAction() {}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"does not match regex\";\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\treturn !matchesRegex(value);\n\t}\n\n\t\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new DoesNotMatchRegexAction(getPatternString());\n\t}\n\n\t@Override\n\tprotected Evaluation createQueryEvaluation(Pattern pattern) {\n\t\treturn new RegexQueryEvaluation(pattern, true);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/DoesNotStartWithAction.java",
    "content": "package com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class DoesNotStartWithAction extends StringMatchAction {\n\t\n\tpublic DoesNotStartWithAction() {\n\t}\n\t\n\tprivate DoesNotStartWithAction(String value) {\n\t\tsuper(value);\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(stringValue).startsWith(true).not();\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new DoesNotStartWithAction(stringValue);\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"does not start with\";\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_STRING;\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\tif(value == null) {\n\t\t\treturn true;\n\t\t}\n\t\treturn !value.startsWith(stringValue);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/EndsWithAction.java",
    "content": "package com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class EndsWithAction extends StringMatchAction {\n\n\tpublic EndsWithAction() {\n\t}\n\n\tprivate EndsWithAction(String value) {\n\t\tsuper(value);\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(stringValue).endsWith(true);\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new EndsWithAction(stringValue);\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"ends with\";\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_STRING;\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\tif(value == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn value.endsWith(stringValue);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/EqualsAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class EqualsAction extends IntegerMatchAction {\n\t\t\n\tEqualsAction() {\n\t\tthis(0);\n\t}\n\t\n\tprivate EqualsAction(int value) {\n\t\tsuper(value);\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"equals\";\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new EqualsAction(integerValue);\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(integerValue).equal();\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(int value) {\n\t\treturn value == integerValue;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IHttpConditionMatchActionEx.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic interface IHttpConditionMatchActionEx extends IHttpConditionMatchAction {\n\tConstraint constrainQuery(Query query);\n\tIHttpConditionMatchAction createCopy();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IMatchActionSet.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic interface IMatchActionSet {\n\tList<IHttpConditionMatchAction> createMatchActions();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IntegerMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionIntegerMatchAction;\n\npublic abstract class IntegerMatchAction implements IHttpConditionIntegerMatchAction, IHttpConditionMatchActionEx {\n\t\n\tprotected int integerValue;\n\t\n\tIntegerMatchAction() { \n\t}\n\t\n\tprotected IntegerMatchAction(int value) {\n\t\tintegerValue = value;\n\t}\n\t\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_INTEGER;\n\t}\n\t\n\t@Override\n\tpublic void setInteger(int value) {\n\t\tintegerValue = value;\n\t}\n\n\t@Override\n\tpublic String getArgumentAsString() {\n\t\treturn Integer.toString(integerValue);\n\t}\n\t\n\t@Override\n\tpublic boolean setArgumentFromString(String value) {\n\t\tfinal Integer n = stringToInteger(value);\n\t\tif(n == null)\n\t\t\treturn false;\n\t\tintegerValue = n;\n\t\treturn true;\n\t}\n\t\n\t@Override\n\tpublic boolean isValidArgumentString(String value) {\n\t\treturn stringToInteger(value) != null;\n\t}\n\t\n\tprivate Integer stringToInteger(String s) {\n\t\ttry {\n\t\t\tint n = Integer.parseInt(s.trim());\n\t\t\treturn (n < 0) ? (null) : (n);\t\t\t\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IntegerMatchActionSet.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class IntegerMatchActionSet implements IMatchActionSet {\n\t@Override\n\tpublic List<IHttpConditionMatchAction> createMatchActions() {\n\t\tfinal List<IHttpConditionMatchAction> actions = new ArrayList<IHttpConditionMatchAction>();\n\t\tactions.add(new EqualsAction());\n\t\tactions.add(new IsGreaterThanAction());\n\t\tactions.add(new IsLessThanAction());\n\t\tactions.add(new IsInsideRangeAction());\n\t\treturn actions;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IsGreaterThanAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class IsGreaterThanAction extends IntegerMatchAction {\n\t\n\tIsGreaterThanAction() {\n\t}\n\t\n\tprivate IsGreaterThanAction(int value) {\n\t\tsuper(value);\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"is greater than\";\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(integerValue).greater();\t\t\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new IsGreaterThanAction(integerValue);\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(int value) {\n\t\treturn value > integerValue;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IsInsideRangeAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionRangeMatchAction;\n\npublic class IsInsideRangeAction implements IHttpConditionRangeMatchAction, IHttpConditionMatchActionEx {\n\n\tprivate int rangeLowValue;\n\tprivate int rangeHighValue;\n\n\tIsInsideRangeAction() {}\n\t\n\tprivate static class Range {\n\t\tfinal int low;\n\t\tfinal int high;\n\t\tRange(int low, int high) {\n\t\t\tthis.low = low;\n\t\t\tthis.high = high;\n\t\t}\n\t}\n\t\n\tprivate IsInsideRangeAction(int low, int high) {\n\t\tthis.rangeLowValue = low;\n\t\tthis.rangeHighValue = high;\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"is inside range\";\n\t}\n\t@Override\n\tpublic void setRange(int rangeLow, int rangeHigh) {\n\t\tthis.rangeLowValue = rangeLow;\n\t\tthis.rangeHighValue = rangeHigh;\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(int value) {\n\t\treturn value >= rangeLowValue && value < rangeHighValue;\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(rangeLowValue).greater().or(query.constrain(rangeLowValue).equal()).and(query.constrain(rangeHighValue).smaller());\n\t}\n\t\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new IsInsideRangeAction(rangeLowValue, rangeHighValue);\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_RANGE;\n\t}\n\n\t@Override\n\tpublic String getArgumentAsString() {\n\t\treturn rangeLowValue + \" - \"+ rangeHighValue;\n\t}\n\n\t@Override\n\tpublic boolean setArgumentFromString(String value) {\n\t\tfinal Range range = stringToRange(value);\n\t\tif(range == null)\n\t\t\treturn false;\n\t\trangeLowValue = range.low;\n\t\trangeHighValue = range.high;\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isValidArgumentString(String value) {\n\t\treturn stringToRange(value) != null;\n\t}\n\t\n\tprivate Range stringToRange(String s) {\n\t\tString[] parts = s.split(\"-\");\n\t\tif(parts.length != 2)\n\t\t\treturn null;\n\t\tInteger low = stringToInteger(parts[0]);\n\t\tInteger high = stringToInteger(parts[1]);\n\t\tif(low == null || high == null || low > high)\n\t\t\treturn null;\n\t\t\n\t\treturn new Range(low, high);\n\t\t\n\t}\n\t\n\tprivate Integer stringToInteger(String s) {\n\t\ttry {\n\t\t\tint n = Integer.parseInt(s.trim());\n\t\t\treturn (n < 0) ? (null) : (n); \n\t\t} catch (NumberFormatException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/IsLessThanAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class IsLessThanAction extends IntegerMatchAction {\n\t\n\tIsLessThanAction() {\n\t}\n\t\n\tprivate IsLessThanAction(int value) {\n\t\tsuper(value);\n\t}\n\t\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"is less than\";\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(int value) {\n\t\treturn value < integerValue;\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(integerValue).smaller();\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new IsLessThanAction(integerValue);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/MatchesRegexAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.regex.Pattern;\n\nimport com.db4o.query.Evaluation;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class MatchesRegexAction extends RegexMatchAction {\n\t\n\tprivate MatchesRegexAction(String value) {\n\t\tsuper(value);\n\t}\n\n\tMatchesRegexAction() {\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"matches regex\";\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new MatchesRegexAction(getPatternString());\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\treturn matchesRegex(value);\n\t}\n\n\t@Override\n\tprotected Evaluation createQueryEvaluation(Pattern pattern) {\n\t\treturn new RegexQueryEvaluation(pattern, false);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/RegexMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.regex.Pattern;\nimport java.util.regex.PatternSyntaxException;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Evaluation;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionStringMatchAction;\n\npublic abstract class RegexMatchAction implements IHttpConditionStringMatchAction, IHttpConditionMatchActionEx {\n\n\tprivate String patternString;\n\t\n\tprivate transient Pattern pattern;\n\tprivate transient boolean patternCompileFailed;\n\tprivate transient Evaluation regexConstraint;\n\t\n\tprotected RegexMatchAction() {\t\t\n\t}\n\n\tprotected RegexMatchAction(String value) {\n\t\tpatternString = value;\n\t}\n\n\tprotected String getPatternString() {\n\t\treturn patternString;\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_REGEX;\n\t}\n\n\t@Override\n\tpublic String getArgumentAsString() {\n\t\treturn patternString;\n\t}\n\n\t@Override\n\tpublic boolean setArgumentFromString(String value) {\n\t\tif(!isValidArgumentString(value))\n\t\t\treturn false;\n\t\n\t\tsetString(value);\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isValidArgumentString(String value) {\n\t\treturn createRegexPattern(value) != null;\n\t}\n\n\tprotected boolean matchesRegex(String value) {\n\t\tfinal Pattern regex = getRegexPattern();\n\t\tif(regex == null || value == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn regex.matcher(value).find();\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\tfinal Pattern p = getRegexPattern();\n\t\tif(p == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn query.constrain(getRegexConstraint(p));\n\t}\n\t\n\tprotected abstract Evaluation createQueryEvaluation(Pattern pattern);\n\t\n\tprivate Evaluation getRegexConstraint(Pattern pattern) {\n\t\tsynchronized(this) {\n\t\t\tif(regexConstraint == null) {\n\t\t\t\tregexConstraint = createQueryEvaluation(pattern);\n\t\t\t}\n\t\t\treturn regexConstraint;\n\t\t}\n\t}\n\t\n\tprivate Pattern getRegexPattern() {\n\t\tif(patternCompileFailed)\n\t\t\treturn null;\n\n\t\tsynchronized(this) {\n\t\t\tif(pattern == null) {\n\t\t\t\tif((pattern = createRegexPattern(patternString)) == null)\n\t\t\t\t\tpatternCompileFailed = true;\n\t\t\t}\n\t\t\treturn pattern;\n\t\t}\n\t}\n\t\n\tprivate Pattern createRegexPattern(String str) {\n\t\ttry {\n\t\t\treturn Pattern.compile(str);\n\t\t} catch (PatternSyntaxException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setString(String value) {\n\t\tthis.patternString = value;\n\t\tthis.pattern = null;\n\t\tthis.patternCompileFailed = false;\n\t\tthis.regexConstraint = null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/RegexQueryEvaluation.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.regex.Pattern;\n\nimport com.db4o.query.Candidate;\nimport com.db4o.query.Evaluation;\n\npublic class RegexQueryEvaluation implements Evaluation {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate final Pattern pattern;\n\tprivate final boolean invertMatch;\n\t\n\tpublic RegexQueryEvaluation(Pattern pattern, boolean invertMatch) {\n\t\tthis.pattern = pattern;\n\t\tthis.invertMatch = invertMatch;\n\t}\n\n\t@Override\n\tpublic void evaluate(Candidate candidate) {\n\t\tfinal String value = (String) candidate.getObject();\n\t\tfinal boolean result = pattern.matcher(value).find();\n\t\tcandidate.include(result ^ invertMatch);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/StartsWithAction.java",
    "content": "package com.subgraph.vega.internal.model.conditions.match;\n\nimport com.db4o.query.Constraint;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class StartsWithAction extends StringMatchAction {\n\n\tpublic StartsWithAction() {\n\t}\n\n\tprivate StartsWithAction(String value) {\n\t\tsuper(value);\n\t}\n\n\t@Override\n\tpublic Constraint constrainQuery(Query query) {\n\t\treturn query.constrain(stringValue).startsWith(true);\n\t}\n\n\t@Override\n\tpublic IHttpConditionMatchAction createCopy() {\n\t\treturn new StartsWithAction(stringValue);\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"starts with\";\n\t}\n\n\t@Override\n\tpublic MatchActionArgumentType getArgumentType() {\n\t\treturn MatchActionArgumentType.ARGUMENT_STRING;\n\t}\n\n\t@Override\n\tpublic boolean matchesValue(String value) {\n\t\tif(value == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn value.startsWith(stringValue);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/StringMatchAction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionStringMatchAction;\n\npublic abstract class StringMatchAction implements IHttpConditionMatchActionEx, IHttpConditionStringMatchAction {\n\tprotected String stringValue;\n\t\n\tprotected StringMatchAction() {}\n\t\n\tprotected StringMatchAction(String value) {\n\t\tthis.stringValue = value;\n\t}\n\n\t@Override\n\tpublic String getArgumentAsString() {\n\t\treturn stringValue;\n\t}\n\t\n\t@Override\n\tpublic boolean setArgumentFromString(String value) {\n\t\tstringValue = value;\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isValidArgumentString(String value) {\n\t\treturn true;\n\t}\n\n\tprotected boolean matchesContains(String value) {\n\t\tif(value == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn value.contains(stringValue);\n\t}\n\t\n\t@Override\n\tpublic void setString(String value) {\n\t\tthis.stringValue = value;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/conditions/match/StringMatchActionSet.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.conditions.match;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class StringMatchActionSet implements IMatchActionSet {\n\n\t@Override\n\tpublic List<IHttpConditionMatchAction> createMatchActions() {\n\t\tfinal List<IHttpConditionMatchAction> actions = new ArrayList<IHttpConditionMatchAction>();\n\t\tactions.add(new ContainsAction());\n\t\tactions.add(new DoesNotContainAction());\n\t\tactions.add(new MatchesRegexAction());\n\t\tactions.add(new DoesNotMatchRegexAction());\n\t\tactions.add(new StartsWithAction());\n\t\tactions.add(new DoesNotStartWithAction());\n\t\tactions.add(new EndsWithAction());\n\t\tactions.add(new DoesNotEndWithAction());\n\t\treturn actions;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/identity/AbstractAuthMethod.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.identity;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\n\npublic abstract class AbstractAuthMethod implements IAuthMethod, Activatable {\n\tprivate transient Activator activator;\n\tprivate AuthMethodType type;\n\n\tprotected AbstractAuthMethod(AuthMethodType type) {\n\t\tthis.type = type;\n\t}\n\t\n\t@Override\n\tpublic AuthMethodType getType() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn type;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/identity/AuthMethodHttpMacro.java",
    "content": "package com.subgraph.vega.internal.model.identity;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\n\npublic class AuthMethodHttpMacro extends AbstractAuthMethod implements IAuthMethodHttpMacro {\n\tprivate IHttpMacro macro;\n\n\tprotected AuthMethodHttpMacro() {\n\t\tsuper(IAuthMethod.AuthMethodType.AUTH_METHOD_HTTP_MACRO);\n\t}\n\n\t@Override\n\tpublic void setMacro(IHttpMacro macro) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.macro = macro;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic IHttpMacro getMacro() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn macro;\n\t}\n\n\t@Override\n\tpublic void setAuth(IHttpRequestEngine requestEngine) {\n\t\t// authentication is handled externally for now\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/identity/AuthMethodNtlm.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.identity;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.auth.AuthScope;\nimport org.apache.http.auth.NTCredentials;\nimport org.apache.http.auth.params.AuthPNames;\nimport org.apache.http.client.CredentialsProvider;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.params.AuthPolicy;\nimport org.apache.http.client.protocol.ClientContext;\nimport org.apache.http.impl.client.BasicCredentialsProvider;\nimport org.apache.http.protocol.HttpContext;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodNtlm;\n\npublic class AuthMethodNtlm extends AbstractAuthMethod implements IAuthMethodNtlm {\n\tprivate String username;\n\tprivate String password;\n\tprivate String workstation;\n\tprivate String domain;\n\t\n\tprotected AuthMethodNtlm() {\n\t\tsuper(IAuthMethod.AuthMethodType.AUTH_METHOD_NTLM);\n\t}\n\n\t@Override\n\tpublic void setUsername(String username) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.username = username;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getUsername() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn username;\n\t}\n\n\t@Override\n\tpublic void setPassword(String password) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.password = password;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getPassword() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn password;\n\t}\n\n\t@Override\n\tpublic void setWorkstation(String workstation) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.workstation = workstation;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getWorkstation() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn workstation;\n\t}\n\n\t@Override\n\tpublic void setDomain(String domain) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.domain = domain;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getDomain() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn domain;\n\t}\n\n\t@Override\n\tpublic void setAuth(IHttpRequestEngine requestEngine) {\n\t\tactivate(ActivationPurpose.READ);\n\n\t\tHttpClient httpClient = requestEngine.getHttpClient();\n\t\tList<String> authPref = new ArrayList<String>(1);\n\t\tauthPref.add(AuthPolicy.NTLM);\n\t\thttpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPref);\n\n\t\tHttpContext httpContext = requestEngine.getHttpContext();\n\t\tNTCredentials creds = new NTCredentials(username, password, workstation, domain);\n\t\tCredentialsProvider credsProvider = new BasicCredentialsProvider();\n\t\tcredsProvider.setCredentials(AuthScope.ANY, creds);\n\t\thttpContext.setAttribute(ClientContext.CREDS_PROVIDER, credsProvider);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/identity/AuthMethodRfc2617.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.identity;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.auth.AuthScope;\nimport org.apache.http.auth.UsernamePasswordCredentials;\nimport org.apache.http.auth.params.AuthPNames;\nimport org.apache.http.client.CredentialsProvider;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.params.AuthPolicy;\nimport org.apache.http.client.protocol.ClientContext;\nimport org.apache.http.impl.client.BasicCredentialsProvider;\nimport org.apache.http.protocol.HttpContext;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodRfc2617;\n\npublic class AuthMethodRfc2617 extends AbstractAuthMethod implements IAuthMethodRfc2617 {\n\tprivate AuthScheme authScheme;\n\tprivate String username;\n\tprivate String password;\n\tprivate String charset;\n\t\n\tprotected AuthMethodRfc2617() {\n\t\tsuper(IAuthMethod.AuthMethodType.AUTH_METHOD_RFC2617);\n\t\tauthScheme = IAuthMethodRfc2617.AuthScheme.AUTH_SCHEME_DIGEST;\n\t}\n\n\t@Override\n\tpublic void setAuthScheme(AuthScheme authScheme) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.authScheme = authScheme;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic AuthScheme getAuthScheme() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn authScheme;\n\t}\n\n\t@Override\n\tpublic void setUsername(String username) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.username = username;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getUsername() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn username;\n\t}\n\n\t@Override\n\tpublic void setPassword(String password) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.password = password;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getPassword() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn password;\n\t}\n\n\t@Override\n\tpublic void setCharset(String charset) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.charset = charset;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getCharset() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn charset;\t\n\t}\n\n\t@Override\n\tpublic void setAuth(IHttpRequestEngine requestEngine) {\n\t\tactivate(ActivationPurpose.READ);\n\n\t\tHttpClient httpClient = requestEngine.getHttpClient();\n\t\tList<String> authPref = new ArrayList<String>(1);\n\t\tswitch (authScheme) {\n\t\tcase AUTH_SCHEME_BASIC:\n\t\t\tauthPref.add(AuthPolicy.BASIC);\n\t\t\tbreak;\n\t\tcase AUTH_SCHEME_DIGEST:\n\t\t\tauthPref.add(AuthPolicy.DIGEST);\n\t\t\tbreak;\n\t\t}\n\t\thttpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPref);\n\n\t\tHttpContext httpContext = requestEngine.getHttpContext();\n\t\tUsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);\n\t\tCredentialsProvider credsProvider = new BasicCredentialsProvider();\n\t\tcredsProvider.setCredentials(AuthScope.ANY, creds);\n\t\thttpContext.setAttribute(ClientContext.CREDS_PROVIDER, credsProvider);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/identity/Identity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.identity;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableArrayList;\nimport com.db4o.collections.ActivatableHashMap;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IIdentity;\n\npublic class Identity implements IIdentity, Activatable {\n\tprivate transient Activator activator;\n\tprivate String name;\n\tprivate IAuthMethod authMethod;\n\tprivate ActivatableHashMap<String, String> userDict;\n\tprivate ActivatableArrayList<String> pathExclusionList;\n\n\tpublic Identity() {\n\t\tpathExclusionList = new ActivatableArrayList<String>();\n\t\tuserDict = new ActivatableHashMap<String, String>(); \n\t}\n\n\t@Override\n\tpublic void setName(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.name = name;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic void setAuthMethod(IAuthMethod authMethod) {\n\t\tactivate(ActivationPurpose.READ);\n\t\t// XXX remove the old one from the database?\n\t\tthis.authMethod = authMethod;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic IAuthMethod getAuthMethod() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn authMethod;\n\t}\n\n\t@Override\n\tpublic void addPathExclusion(String expression) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tpathExclusionList.add(expression);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic Collection<String> getPathExclusions() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn new ArrayList<String>(pathExclusionList);\n\t}\n\n\t@Override\n\tpublic void rmPathExclusion(String expression) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tpathExclusionList.remove(expression);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String setDictValue(String key, String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn userDict.put(key, value);\n\t}\n\n\t@Override\n\tpublic String getDictValue(String key) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn userDict.get(key);\n\t}\n\n\t@Override\n\tpublic Map<String, String> getDict() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn new HashMap<String, String>(userDict);\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/identity/IdentityModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.identity;\n\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.query.Predicate;\n\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.identity.IAuthMethodHttpMacro;\nimport com.subgraph.vega.api.model.identity.IAuthMethodNtlm;\nimport com.subgraph.vega.api.model.identity.IAuthMethodRfc2617;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.api.model.identity.NewIdentityEvent;\n\npublic class IdentityModel implements IIdentityModel {\n\tprivate final ObjectContainer database;\n\tprivate final EventListenerManager changeEventManager;\n\n\tpublic IdentityModel(ObjectContainer database) {\n\t\tthis.database = database;\n\t\tthis.changeEventManager = new EventListenerManager();\n\t}\n\n\t@Override\n\tpublic Collection<IIdentity> getAllIdentities() {\n\t\treturn database.query(IIdentity.class);\n\t}\n\n\t@Override\n\tpublic IIdentity createIdentity() {\n\t\treturn new Identity();\n\t}\n\n\t@Override\n\tpublic IAuthMethodRfc2617 createAuthMethodRfc2617() {\n\t\treturn new AuthMethodRfc2617();\n\t}\n\n\t@Override\n\tpublic IAuthMethodNtlm createAuthMethodNtlm() {\n\t\treturn new AuthMethodNtlm();\n\t}\n\n\t@Override\n\tpublic IAuthMethodHttpMacro createAuthMethodHttpMacro() {\n\t\treturn new AuthMethodHttpMacro();\n\t}\n\n\t@Override\n\tpublic void store(IIdentity identity) {\n\t\tdatabase.store(identity);\n\t\tchangeEventManager.fireEvent(new NewIdentityEvent(identity));\n\t}\n\n\t@Override\n\tpublic boolean isIdentityStored(IIdentity identity) {\n\t\treturn database.ext().isStored(identity);\n\t}\n\n\t@Override\n\tpublic IIdentity getIdentityByName(final String name) {\n\t\tfinal List<IIdentity> results = database.query(new Predicate<IIdentity>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IIdentity identity) {\n\t\t\t\treturn name.equals(identity.getName());\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn results.get(0);\n\t}\n\n\t@Override\n\tpublic void addChangeListener(IEventHandler listener) {\n\t\tchangeEventManager.addListener(listener);\n\t}\n\n\t@Override\n\tpublic void removeChangeListener(IEventHandler listener) {\n\t\tchangeEventManager.removeListener(listener);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/macros/HttpMacro.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.macros;\n\nimport java.io.IOException;\nimport java.net.URISyntaxException;\nimport java.util.ArrayList;\nimport java.util.Collection;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableArrayList;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItem;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic class HttpMacro implements IHttpMacro, Activatable {\n\tprivate transient Activator activator;\n\tprivate String name;\n\tprivate ActivatableArrayList<IHttpMacroItem> macroItemList;\n\n\tpublic HttpMacro() {\n\t\tmacroItemList = new ActivatableArrayList<IHttpMacroItem>();\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.name = name;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic IHttpMacroItem createMacroItem(IRequestLogRecord record) throws URISyntaxException, IOException {\n\t\tactivate(ActivationPurpose.READ);\n\t\tHttpMacroItem macroItem = new HttpMacroItem(record);\n\t\tmacroItemList.add(macroItem);\n\t\treturn macroItem;\n\t}\n\n\t@Override\n\tpublic void removeMacroItem(IHttpMacroItem item) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tmacroItemList.remove(item);\n\t}\n\n\t@Override\n\tpublic Collection<IHttpMacroItem> getMacroItems() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn new ArrayList<IHttpMacroItem>(macroItemList);\n\t}\n\n\t@Override\n\tpublic int macroItemsSize() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn macroItemList.size();\n\t}\n\n\t@Override\n\tpublic int indexOfMacroItem(IHttpMacroItem item) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn macroItemList.indexOf(item);\n\t}\n\n\t@Override\n\tpublic void swapMacroItems(int idx1, int idx2) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif (idx1 < macroItemList.size() && idx2 < macroItemList.size() && idx1 != idx2) {\n\t\t\tfinal IHttpMacroItem tmp = macroItemList.set(idx1, macroItemList.get(idx2));\n\t\t\tmacroItemList.set(idx2, tmp);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/macros/HttpMacroItem.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.macros;\n\nimport java.io.IOException;\nimport java.io.UnsupportedEncodingException;\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URLEncodedUtils;\nimport org.apache.http.entity.StringEntity;\nimport org.apache.http.message.BasicNameValuePair;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.protocol.HTTP;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableArrayList;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpMacroContext;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItem;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam.ValueSetIn;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.http.requests.builder.HttpRequestBuilder;\n\npublic class HttpMacroItem implements IHttpMacroItem, Activatable {\n\t// Headers to remove when copying headers while generating a request.\n\tprivate final static String[] HEADERS_RM = {\n\t\tHTTP.CONN_DIRECTIVE, // \"Connection\"\n\t\tHTTP.CONN_KEEP_ALIVE, // \"Keep-Alive\"\n\t\t\"Proxy-Authenticate\",\n\t\t\"Proxy-Authorization\",\n\t\t\"TE\",\n\t\t\"Trailers\",\n\t\tHTTP.TRANSFER_ENCODING, // \"Transfer-Encoding\"\n\t\t\"Upgrade\",\n\t\t\"Proxy-Connection\",\n\t\tHTTP.CONTENT_LEN,\n\t\tHTTP.CONTENT_TYPE,\n\t\t\"Cookie\",\n\t};\n\n\tprivate transient Activator activator;\n\tprivate IRequestLogRecord requestLogRecord;\n\tprivate HttpParams requestParams;\n\tprivate String requestMethod;\n\tprivate ProtocolVersion requestProtocolVersion;\n\tprivate String requestScheme;\n\tprivate String requestHost;\n\tprivate int requestPort;\n\tprivate String requestPath; /** Raw path of request */\n\tprivate final ArrayList<Header> requestHeaderList = new ArrayList<Header>();\n\tprivate boolean useCookies;\n\tprivate boolean keepCookies;\n\tprivate ActivatableArrayList<IHttpMacroItemParam> paramList;\n\n\tpublic HttpMacroItem(IRequestLogRecord requestLogRecord) throws URISyntaxException, IOException {\n\t\tthis.requestLogRecord = requestLogRecord;\n\t\tuseCookies = true;\n\t\tkeepCookies = true;\n\t\tfinal HttpRequest request = requestLogRecord.getRequest(); \n\t\tprocessRequest(request, requestLogRecord.getHttpHost());\n\t\tparamList = new ActivatableArrayList<IHttpMacroItemParam>();\n\t\tprocessParams(request);\n\t}\n\n\t@Override\n\tpublic IRequestLogRecord getRequestLogRecord() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn requestLogRecord;\n\t}\n\n\t@Override\n\tpublic void setUseCookies(boolean useCookies) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.useCookies = useCookies;\n\t\tactivate(ActivationPurpose.WRITE);\n\n\t}\n\n\t@Override\n\tpublic boolean getUseCookies() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn useCookies;\n\t}\n\n\t@Override\n\tpublic void setKeepCookies(boolean keepCookies) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.keepCookies = keepCookies;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic boolean getKeepCookies() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn keepCookies;\n\t}\n\n\t@Override\n\tpublic IHttpMacroItemParam createParam(String name, String value, ValueSetIn setIn) {\n\t\tHttpMacroItemParam param = new HttpMacroItemParam(name, value, setIn);\n\t\tparamList.add(param);\n\t\treturn param;\n\t}\n\n\t@Override\n\tpublic void removeParam(IHttpMacroItemParam param) {\n\t\tparamList.remove(param);\n\t}\n\n\t@Override\n\tpublic int paramsSize() {\n\t\treturn paramList.size();\n\t}\n\n\t@Override\n\tpublic int indexOfParam(IHttpMacroItemParam param) {\n\t\treturn paramList.indexOf(param);\n\t}\n\n\t@Override\n\tpublic void swapParams(int idx1, int idx2) {\n\t\tif (idx1 < paramList.size() && idx2 < paramList.size() && idx1 != idx2) {\n\t\t\tfinal IHttpMacroItemParam tmp = paramList.set(idx1, paramList.get(idx2));\n\t\t\tparamList.set(idx2, tmp);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Collection<IHttpMacroItemParam> getParams() {\n\t\treturn new ArrayList<IHttpMacroItemParam>(paramList);\n\t}\n\n\t@Override\n\tpublic IHttpMacroItemParam[] getParam(String name) {\n\t\tfinal ArrayList<IHttpMacroItemParam> tmp = new ArrayList<IHttpMacroItemParam>();\n\t\tfor (IHttpMacroItemParam param: paramList) {\n\t\t\tif (param.getName().equals(name)) {\n\t\t\t\ttmp.add(param);\n\t\t\t}\n\t\t}\n\t\treturn tmp.toArray(new IHttpMacroItemParam[0]);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createRequest(IHttpMacroContext context) throws UnsupportedEncodingException, URISyntaxException {\n\t\tfinal HttpRequestBuilder builder = new HttpRequestBuilder();\n\t\tsetRequestBuilder(builder, context);\n\t\treturn builder.buildRequest(false);\n\t}\n\n\t@Override\n\tpublic void setRequestBuilder(IHttpRequestBuilder requestBuilder, IHttpMacroContext context) throws UnsupportedEncodingException, URISyntaxException {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsetRequestParams(requestBuilder);\n\t\tsetRequestLine(requestBuilder, context);\n\t\tsetRequestHeaders(requestBuilder);\n\t\tsetRequestBody(requestBuilder, context);\n\t}\n\n\t@Override\n\tpublic void updateFromRequestBuilder(IHttpRequestBuilder requestBuilder) throws URISyntaxException {\n\t\tactivate(ActivationPurpose.READ);\n\t\trequestParams = requestBuilder.getParams().copy();\n\t\trequestMethod = requestBuilder.getMethod();\n\t\trequestScheme = requestBuilder.getScheme();\n\t\trequestHost = requestBuilder.getHost();\n\t\trequestPort = requestBuilder.getHostPort();\n\t\tfinal URI uri = new URI(requestBuilder.getPath());\n\t\trequestPath = uri.getRawPath();\n\t\trequestProtocolVersion = requestBuilder.getProtocolVersion();\n\t\trequestHeaderList.clear();\n\t\tfor (IHttpHeaderBuilder header: requestBuilder.getHeaders()) {\n\t\t\trequestHeaderList.add(header.buildHeader());\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\n\t\t// REVISIT: we need to process the request body and URI for parameters \n\t}\n\n\tprivate void setRequestParams(IHttpRequestBuilder requestBuilder) {\n\t\trequestBuilder.setParams(requestParams.copy());\n\t}\n\n\tprivate void setRequestLine(IHttpRequestBuilder requestBuilder, IHttpMacroContext context) throws URISyntaxException {\n\t\trequestBuilder.setMethod(requestMethod);\n\t\tsetRequestUri(requestBuilder, context);\n\t\trequestBuilder.setProtocolVersion(requestProtocolVersion);\n\t}\n\t\n\tprivate void setRequestUri(IHttpRequestBuilder requestBuilder, IHttpMacroContext context) throws URISyntaxException {\n\t\trequestBuilder.setScheme(requestScheme);\n\t\trequestBuilder.setHost(requestHost);\n\t\trequestBuilder.setHostPort(requestPort);\n\t\tfinal String query = createUriQuery(context);\n\t\tString path = requestPath;\n\t\tif (query.length() != 0) {\n\t\t\tpath += \"?\" + query;\n\t\t}\n\t\trequestBuilder.setPath(path);\n\t}\n\t\n\tprivate void setRequestHeaders(IHttpRequestBuilder requestBuilder) {\n\t\trequestBuilder.setHeaders(requestHeaderList.toArray(new Header[0]));\n\t}\n\t\n\tprivate void setRequestBody(IHttpRequestBuilder requestBuilder, IHttpMacroContext context) throws UnsupportedEncodingException {\n\t\tArrayList<NameValuePair> bodyParamList = new ArrayList<NameValuePair>();\n\t\tfor (IHttpMacroItemParam param: paramList) {\n\t\t\tif (param.getSetIn() == IHttpMacroItemParam.ValueSetIn.VALUE_SET_IN_BODY) {\n\t\t\t\tbodyParamList.add(new BasicNameValuePair(param.getName(), param.getValue()));\n\t\t\t}\n\t\t}\n\n\t\tif (bodyParamList.size() != 0) {\n\t\t\tfinal StringEntity entity = new StringEntity(URLEncodedUtils.format(bodyParamList, \"UTF-8\"), \"UTF-8\");\n\t\t\tentity.setContentType(\"application/x-www-form-urlencoded\");\n\t\t\trequestBuilder.setEntity(entity);\n\t\t\trequestBuilder.setMethod(\"POST\");\n\t\t}\n\t}\n\n\tprivate String createUriQuery(IHttpMacroContext context) {\n\t\tStringBuilder buf = new StringBuilder();\n\t\tfor (IHttpMacroItemParam param: paramList) {\n\t\t\tif (param.getSetIn() == IHttpMacroItemParam.ValueSetIn.VALUE_SET_IN_URI) {\n\t\t\t\tif (buf.length() != 0) {\n\t\t\t\t\tbuf.append('&');\n\t\t\t\t}\n\t\t\t\tbuf.append(param.getName());\n\t\t\t\tbuf.append('=');\n\t\t\t\tbuf.append(param.getValue());\n\t\t\t}\n\t\t}\n\t\treturn buf.toString();\n\t}\n\t\t\n\tprivate void processRequest(HttpRequest request, HttpHost host) throws URISyntaxException {\n\t\trequestParams = request.getParams().copy();\n\t\tfinal RequestLine requestLine = request.getRequestLine();\t\t\n\t\trequestMethod = requestLine.getMethod();\n\t\trequestScheme = host.getSchemeName();\n\t\trequestHost = host.getHostName();\n\t\trequestPort = host.getPort();\n\t\tfinal URI uri = new URI(request.getRequestLine().getUri());\n\t\trequestPath = uri.getRawPath();\n\t\trequestProtocolVersion = requestLine.getProtocolVersion();\n\t\trequestHeaderList.clear();\n\t\tCollections.addAll(requestHeaderList, copyHeaders(request.getAllHeaders()));\n\t}\n\t\n\tprivate void processParams(HttpRequest request) throws URISyntaxException, IOException {\n\t\tprocessParamsUri(request);\n\t\tprocessParamsBody(request);\n\t}\n\t\n\tprivate void processParamsUri(HttpRequest request) throws URISyntaxException {\n\t\tURI uri = new URI(request.getRequestLine().getUri());\n\t\tList<NameValuePair> requestParamList = URLEncodedUtils.parse(uri, \"UTF-8\");\n\t\tfor (NameValuePair pair: requestParamList) {\n\t\t\tparamList.add(new HttpMacroItemParam(pair.getName(), pair.getValue(), IHttpMacroItemParam.ValueSetIn.VALUE_SET_IN_URI));\n\t\t}\n\t}\n\n\tprivate void processParamsBody(HttpRequest request) throws IOException {\n\t\tif (request instanceof HttpEntityEnclosingRequest) {\n\t\t\tList<NameValuePair> entityParamList = null;\n\t\t\tentityParamList = URLEncodedUtils.parse(((HttpEntityEnclosingRequest) request).getEntity());\n\t\t\tfor (NameValuePair pair: entityParamList) {\n\t\t\t\tparamList.add(new HttpMacroItemParam(pair.getName(), pair.getValue(), IHttpMacroItemParam.ValueSetIn.VALUE_SET_IN_BODY));\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate Header[] copyHeaders(Header[] headers) {\n\t\tArrayList<Header> headerList = new ArrayList<Header>();\n\t\tfor (Header header: headers) {\n\t\t\tint idx;\n\t\t\tfor (idx = 0; idx < HEADERS_RM.length; idx++) {\n\t\t\t\tif (HEADERS_RM[idx].equals(header.getName())) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (idx == HEADERS_RM.length) {\n\t\t\t\theaderList.add(header);\n\t\t\t}\n\t\t}\n\t\treturn headerList.toArray(new Header[0]);\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/macros/HttpMacroItemParam.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.macros;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam;\n\npublic class HttpMacroItemParam implements IHttpMacroItemParam, Activatable {\n\tprivate transient Activator activator;\n\tprivate String name;\n\tprivate ValueSource source;\n\tprivate ValueSetIn setIn;\n\tprivate String value;\n\t\n\tpublic HttpMacroItemParam(String name, ValueSetIn setIn) {\n\t\tthis.name = name;\n\t\tthis.setIn = setIn;\n\t}\n\n\tpublic HttpMacroItemParam(String name, String value, ValueSetIn setIn) {\n\t\tthis.name = name;\n\t\tthis.source = IHttpMacroItemParam.ValueSource.SOURCE_LITERAL;\n\t\tthis.value = value;\n\t\tthis.setIn = setIn;\n\t}\n\t\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic void setValueSource(ValueSource source) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.source = source;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic ValueSource getValueSource() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn source;\n\t}\n\n\t@Override\n\tpublic void setSetIn(ValueSetIn setIn) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.setIn = setIn;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic ValueSetIn getSetIn() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn setIn;\n\t}\n\n\t@Override\n\tpublic void setValue(String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.value = value;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn value;\n\t}\n\t\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/macros/HttpMacroModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.macros;\n\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.query.Predicate;\n\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\nimport com.subgraph.vega.api.model.macros.NewMacroEvent;\n\npublic class HttpMacroModel implements IHttpMacroModel {\n\tprivate ObjectContainer database;\n\tprivate final EventListenerManager changeEventManager;\n\n\tpublic HttpMacroModel(ObjectContainer database) {\n\t\tthis.database = database;\n\t\tthis.changeEventManager = new EventListenerManager();\n\t}\n\n\t@Override\n\tpublic Collection<IHttpMacro> getAllMacros() {\n\t\treturn database.query(IHttpMacro.class);\n\t}\n\n\t@Override\n\tpublic IHttpMacro createMacro() {\n\t\treturn new HttpMacro();\n\t}\n\n\t@Override\n\tpublic void store(IHttpMacro macro) {\n\t\tdatabase.store(macro);\n\t\tchangeEventManager.fireEvent(new NewMacroEvent(macro));\n\t}\n\n\t@Override\n\tpublic boolean isMacroStored(IHttpMacro macro) {\n\t\treturn database.ext().isStored(macro);\n\t}\n\n\t@Override\n\tpublic IHttpMacro getMacroByName(final String name) {\n\t\tfinal List<IHttpMacro> results = database.query(new Predicate<IHttpMacro>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IHttpMacro macro) {\n\t\t\t\treturn name.equals(macro.getName());\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn results.get(0);\n\t}\n\n\t@Override\n\tpublic void addChangeListener(IEventHandler listener) {\n\t\tchangeEventManager.addListener(listener);\n\t}\n\n\t@Override\n\tpublic void removeChangeListener(IEventHandler listener) {\n\t\tchangeEventManager.removeListener(listener);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/HttpMessageCloner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport java.io.IOException;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpMessage;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.message.BasicHeader;\nimport org.apache.http.message.BasicHttpRequest;\nimport org.apache.http.util.EntityUtils;\n\nimport com.db4o.ObjectContainer;\n\npublic class HttpMessageCloner {\n\n\tprivate final ObjectContainer database;\n\n\tHttpMessageCloner(ObjectContainer database) {\n\t\tthis.database = database;\n\t}\n\n\tHttpRequest copyRequest(HttpRequest request) {\n\t\tif(request instanceof HttpEntityEnclosingRequest) {\n\t\t\treturn copyEntityEnclosingRequest((HttpEntityEnclosingRequest) request);\n\t\t} else {\n\t\t\treturn copyBasicRequest(request);\n\t\t}\n\t}\n\n\tHttpResponse copyResponse(HttpResponse response) {\n\t\tfinal HttpEntity e = copyEntity(response.getEntity());\n\t\tfinal RequestLogResponse r = new RequestLogResponse(database, response.getStatusLine(), entityToDatabaseId(e));\n\t\tcopyHeaders(response, r);\n\t\treturn r;\n\t}\n\n\tprivate HttpRequest copyEntityEnclosingRequest(HttpEntityEnclosingRequest request) {\n\t\tfinal HttpEntity e = copyEntity(request.getEntity());\n\t\tfinal RequestLogEntityEnclosingRequest r = new RequestLogEntityEnclosingRequest(database, request.getRequestLine(), entityToDatabaseId(e));\n\t\tcopyHeaders(request, r);\n\t\treturn r;\n\t}\n\n\tprivate HttpRequest copyBasicRequest(HttpRequest request) {\n\t\tif(request == null) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal HttpRequest r = new BasicHttpRequest(request.getRequestLine());\n\t\tcopyHeaders(request, r);\n\t\treturn r;\n\t}\n\n\tprivate static void copyHeaders(HttpMessage from, HttpMessage to) {\n\t\tfor(Header h: from.getAllHeaders()) {\n\t\t\tto.addHeader(new BasicHeader(h.getName(), h.getValue()));\n\t\t}\n\t}\n\n\tprivate long entityToDatabaseId(HttpEntity entity) {\n\t\tif(entity == null) {\n\t\t\treturn 0;\n\t\t}\n\t\tdatabase.ext().store(entity);\n\t\treturn database.ext().getID(entity);\n\t}\n\n\tprivate HttpEntity copyEntity(HttpEntity entity) {\n\t\ttry {\n\t\t\tif(entity == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tfinal byte[] content = EntityUtils.toByteArray(entity);\n\t\t\treturn new RequestLogEntity(content, entity.getContentType(), entity.getContentEncoding());\n\t\t} catch (IOException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/HttpRequestBuilderStorable.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2012 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.params.HttpParams;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.http.requests.builder.HttpHeaderBuilder;\nimport com.subgraph.vega.http.requests.builder.HttpRequestBuilder;\n\n/**\n * Decorator for IHttpRequestBuilder to maintain data in the database using transparent activation.\n */\npublic class HttpRequestBuilderStorable extends HttpRequestBuilder implements IHttpRequestBuilder, Activatable {\n\tprotected transient Activator activator;\n\n\t@Override\n\tpublic void clear() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.clear();\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setParams(HttpParams params) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setParams(params);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic HttpParams getParams() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getParams();\n\t}\n\n\t@Override\n\tpublic void setProtocolVersion(ProtocolVersion protocolVersion) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setProtocolVersion(protocolVersion);\n\t\tactivate(ActivationPurpose.WRITE);\t\t\n\t}\n\n\t@Override\n\tpublic ProtocolVersion getProtocolVersion() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getProtocolVersion();\n\t}\n\n\t@Override\n\tpublic void setHeaders(Header[] headers) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setHeaders(headers);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic HttpHeaderBuilder addHeader(String name, String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal HttpHeaderBuilder builder = super.addHeader(name, value);\n\t\tactivate(ActivationPurpose.WRITE);\n\t\treturn builder;\n\t}\n\n\t@Override\n\tpublic HttpHeaderBuilder setHeader(String name, String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal HttpHeaderBuilder builder = super.setHeader(name, value);\n\t\tactivate(ActivationPurpose.WRITE);\n\t\treturn builder;\n\t}\n\n\t@Override\n\tpublic void removeHeader(IHttpHeaderBuilder header) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.removeHeader(header);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void removeHeaders(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.removeHeaders(name);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void clearHeaders() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.clearHeaders();\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void swapHeader(int idx1, int idx2) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.swapHeader(idx1, idx2);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic int getHeaderIdxOf(IHttpHeaderBuilder next) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getHeaderIdxOf(next);\n\t}\n\n\t@Override\n\tpublic int getHeaderCnt() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getHeaderCnt();\n\t}\n\n\t@Override\n\tpublic IHttpHeaderBuilder getHeader(int idx) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getHeader(idx);\n\t}\n\n\t@Override\n\tpublic IHttpHeaderBuilder[] getHeaders() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getHeaders();\n\t}\n\n\t@Override\n\tpublic void setEntity(HttpEntity entity) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setEntity(entity);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic HttpEntity getEntity() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void setFromRequest(IRequestLogRecord record) throws URISyntaxException {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setFromRequest(record);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setFromRequest(HttpRequest request) throws URISyntaxException {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setFromRequest(request);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setFromRequestLine(RequestLine requestLine) throws URISyntaxException {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setFromRequestLine(requestLine);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setFromUri(URI uri) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setFromUri(uri);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setFromHttpHost(HttpHost host) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setFromHttpHost(host);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void setScheme(String scheme) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setScheme(scheme);\t\t\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getScheme() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getScheme();\n\t}\n\n\t@Override\n\tpublic void setHost(String host) {\n\t\tactivate(ActivationPurpose.READ);\n\t\t\n\t}\n\n\t@Override\n\tpublic String getHost() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getHost();\n\t}\n\n\t@Override\n\tpublic void setHostPort(int port) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setHostPort(port);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic int getHostPort() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getHostPort();\n\t}\n\n\t@Override\n\tpublic void setMethod(String method) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setMethod(method);\n\t}\n\n\t@Override\n\tpublic String getMethod() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getMethod();\n\t}\n\n\t@Override\n\tpublic void setPath(String path) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsuper.setPath(path);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getPath() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getPath();\n\t}\n\n\t@Override\n\tpublic String getRequestLine() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.getRequestLine();\n\t}\n\n\t@Override\n\tpublic HttpUriRequest buildRequest(boolean setHeadersEntity) throws URISyntaxException {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn super.buildRequest(setHeadersEntity);\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/LazyEntityLoader.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.entity.ByteArrayEntity;\n\nimport com.db4o.ObjectContainer;\n\npublic class LazyEntityLoader {\n\t\n\tprivate final long entityId;\n\tprivate final ObjectContainer database;\n\t\n\tLazyEntityLoader(long entityId, ObjectContainer database) {\n\t\tthis.entityId = entityId;\n\t\tthis.database = database;\n\t}\n\t\n\tHttpEntity getEntity() {\n\t\tif(entityId == 0) {\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tfinal RequestLogEntity e = database.ext().getByID(entityId);\n\t\tif(e == null) {\n\t\t\treturn null;\n\t\t}\n\t\tdatabase.ext().activate(e);\n\t\tfinal HttpEntity copy = createEntityCopy(e);\n\t\tdatabase.ext().deactivate(e, 1);\n\t\tdatabase.ext().purge(e);\n\t\treturn copy;\n\t}\n\t\n\tprivate HttpEntity createEntityCopy(RequestLogEntity entity) {\n\t\tfinal ByteArrayEntity copy = new ByteArrayEntity(entity.getContentArray());\n\t\tcopy.setContentType(entity.getContentType());\n\t\tcopy.setContentEncoding(copy.getContentEncoding());\n\t\treturn copy;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport java.net.InetAddress;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.ObjectSet;\nimport com.db4o.events.Event4;\nimport com.db4o.events.EventListener4;\nimport com.db4o.events.EventRegistry;\nimport com.db4o.events.EventRegistryFactory;\nimport com.db4o.events.ObjectInfoEventArgs;\nimport com.db4o.query.Predicate;\nimport com.db4o.query.Query;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.requests.IRequestLogNewRecordListener;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.api.model.requests.IRequestOriginProxy;\nimport com.subgraph.vega.api.model.requests.IRequestOriginScanner;\nimport com.subgraph.vega.internal.model.conditions.HttpConditionSet;\n\npublic class RequestLog implements IRequestLog {\n\tprivate final ObjectContainer database;\n\tprivate final RequestLogId requestLogId;\n\tprivate final HttpMessageCloner cloner;\n\tprivate final List<RequestLogNewRecordListener> newRecordListeners = new ArrayList<RequestLogNewRecordListener>();\n\tprivate final Object lock = new Object();\n\n\tpublic RequestLog(final ObjectContainer database) {\n\t\tthis.database = database;\n\t\tthis.requestLogId = getRequestLogId(database);\n\t\tthis.cloner = new HttpMessageCloner(database);\n\t\tfinal EventRegistry registry = EventRegistryFactory.forObjectContainer(database);\n\t\t\n\t\tregistry.activated().addListener(new EventListener4<ObjectInfoEventArgs> () {\n\n\t\t\t@Override\n\t\t\tpublic void onEvent(Event4<ObjectInfoEventArgs> arg0,  ObjectInfoEventArgs args) {\n\t\t\t\tfinal Object ob = args.object();\n\t\t\t\tif(ob instanceof RequestLogResponse) {\n\t\t\t\t\tfinal RequestLogResponse r = (RequestLogResponse) ob;\n\t\t\t\t\tr.setDatabase(database);\n\t\t\t\t} else if(ob instanceof RequestLogEntityEnclosingRequest) {\n\t\t\t\t\tfinal RequestLogEntityEnclosingRequest r = (RequestLogEntityEnclosingRequest) ob;\n\t\t\t\t\tr.setDatabase(database);\n\t\t\t\t} \n\t\t\t}\n\t\t});\n\t}\n\n\tprivate RequestLogId getRequestLogId(ObjectContainer database) {\n\t\tList<RequestLogId> result = database.query(RequestLogId.class);\n\t\tif(result.size() == 0) {\n\t\t\tRequestLogId rli = new RequestLogId();\n\t\t\tdatabase.store(rli);\n\t\t\treturn rli;\n\t\t} else if(result.size() == 1) {\n\t\t\treturn result.get(0);\n\t\t} else {\n\t\t\tthrow new IllegalStateException(\"Database corrupted, found multiple RequestLogId instances\");\n\t\t}\n\t}\n\n\t@Override\n\tpublic long allocateRequestId() {\n\t\tfinal long id = requestLogId.allocateId();\n\t\tdatabase.store(requestLogId);\n\t\treturn id;\n\t}\n\n\t@Override\n\tpublic long getNextRequestId() {\n\t\treturn requestLogId.getCurrentId();\n\t}\n\t\n\t@Override\n\tpublic long addRequestResponse(IHttpResponse response) {\n\t\tif (response.getRequestId() != -1) {\n\t\t\treturn response.getRequestId();\n\t\t}\n\t\tfinal long id = allocateRequestId();\n\t\tfinal HttpRequest newRequest = cloner.copyRequest(response.getOriginalRequest());\n\t\tfinal HttpResponse newResponse = cloner.copyResponse(response.getRawResponse());\n\t\tdatabase.store(newRequest);\n\t\tdatabase.store(newResponse);\n\t\tfinal RequestLogRecord record = new RequestLogRecord(id, newRequest, response.getRequestOrigin(), newResponse, response.getHost(), response.getRequestMilliseconds(), response.getTags());\n\t\tsynchronized(lock){\n\t\t\tdatabase.store(record);\n\t\t\tfilterNewRecord(record);\n\t\t}\n\t\tresponse.setRequestId(id);\n\t\treturn id;\n\t}\n\t\n\tprivate void filterNewRecord(IRequestLogRecord record) {\n\t\tfor(RequestLogNewRecordListener listener: newRecordListeners) {\n\t\t\tlistener.filterRecord(record);\n\t\t}\n\t}\n\n\t@Override\n\tpublic RequestLogRecord lookupRecord(final long requestId) {\n\t\tsynchronized(this) {\n\t\t\tList<RequestLogRecord> result = database.query(new Predicate<RequestLogRecord>() {\n\t\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t\t@Override\n\t\t\t\tpublic boolean match(RequestLogRecord record) {\n\t\t\t\t\treturn record.requestId == requestId;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif(result.size() == 0)\n\t\t\t\treturn null;\n\t\t\telse if(result.size() == 1)\n\t\t\t\treturn result.get(0);\n\t\t\telse\n\t\t\t\tthrow new IllegalStateException(\"Database corrupted, found multiple RequestLogRecords for id == \"+ requestId);\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IRequestLogRecord> getAllRecords() {\n\t\tif(!hasRecords()) {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t\tfinal Query query = database.query();\n\t\tquery.constrain(IRequestLogRecord.class);\n\t\treturn query.execute();\n\t}\n\t\n\tprivate boolean hasRecords() {\n\t\tfinal Query query = database.query();\n\t\tquery.constrain(IRequestLogRecord.class);\n\t\treturn query.execute().hasNext();\n\t}\n\n\tpublic List<IRequestLogRecord> getRecordsByConditionSet(IHttpConditionSet conditionFilter) {\n\t\tif(conditionFilter instanceof HttpConditionSet) {\n\t\t\treturn ((HttpConditionSet)conditionFilter).filterRequestLog(database);\n\t\t} else {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t}\n\n\t@Override\n\tpublic Iterator<IRequestLogRecord> getRecordIteratorByConditionSet(IHttpConditionSet conditionFilter) {\n\t\tif(conditionFilter instanceof HttpConditionSet) {\n\t\t\tfinal ObjectSet<IRequestLogRecord> result = ((HttpConditionSet)conditionFilter).executeFilterQuery(database);\n\t\t\treturn createIteratorForResult(result);\n\t\t} else {\n\t\t\tfinal List<IRequestLogRecord> emptyList = Collections.emptyList();\n\t\t\treturn emptyList.iterator();\n\t\t}\n\t}\n\n\tprivate Iterator<IRequestLogRecord> createIteratorForResult(final ObjectSet<IRequestLogRecord> result) {\n\t\treturn new Iterator<IRequestLogRecord>() {\n\n\t\t\t@Override\n\t\t\tpublic boolean hasNext() {\n\t\t\t\treturn result.hasNext();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic IRequestLogRecord next() {\n\t\t\t\treturn result.next();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void remove() {\n\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t}\n\t\t};\n\t}\n\n\t@Override\n\tpublic IRequestOriginProxy getRequestOriginProxy(final InetAddress address, final int port) {\n\t\tfinal List<IRequestOriginProxy> results = database.query(new Predicate<IRequestOriginProxy>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IRequestOriginProxy requestOrigin) {\n\t\t\t\treturn address.equals(requestOrigin.getInetAddress()) && port == requestOrigin.getPort();\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\tIRequestOriginProxy requestOrigin = new RequestOriginProxy(address, port);\n\t\t\tdatabase.store(requestOrigin);\n\t\t\treturn requestOrigin;\n\t\t} else {\n\t\t\treturn results.get(0);\n\t\t}\n\t}\n\n\t@Override\n\tpublic IRequestOriginScanner getRequestOriginScanner(final IScanInstance scanInstance) {\n\t\tfinal List<IRequestOriginScanner> results = database.query(new Predicate<IRequestOriginScanner>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IRequestOriginScanner requestOrigin) {\n\t\t\t\treturn scanInstance.getScanId() == requestOrigin.getScanInstance().getScanId();\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\tIRequestOriginScanner requestOrigin = new RequestOriginScanner(scanInstance);\n\t\t\tdatabase.store(requestOrigin);\n\t\t\treturn requestOrigin;\n\t\t} else {\n\t\t\treturn results.get(0);\n\t\t}\n\t}\n\n\t@Override\n\tpublic IRequestOrigin getRequestOriginRequestEditor() {\n\t\tfinal List<IRequestOrigin> results = database.query(new Predicate<IRequestOrigin>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IRequestOrigin requestOrigin) {\n\t\t\t\treturn requestOrigin.getOrigin() == IRequestOrigin.Origin.ORIGIN_REQUEST_EDITOR;\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\tIRequestOrigin requestOrigin = new RequestOrigin(IRequestOrigin.Origin.ORIGIN_REQUEST_EDITOR);\n\t\t\tdatabase.store(requestOrigin);\n\t\t\treturn requestOrigin;\n\t\t} else {\n\t\t\treturn results.get(0);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void addNewRecordListener(IRequestLogNewRecordListener callback) {\n\t\taddNewRecordListener(callback, null);\n\t}\n\n\t@Override\n\tpublic void addNewRecordListener(IRequestLogNewRecordListener callback,\n\t\t\tIHttpConditionSet filterCondition) {\n\t\tsynchronized (lock) {\n\t\t\tnewRecordListeners.add(new RequestLogNewRecordListener(callback, filterCondition));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void removeNewRecordListener(IRequestLogNewRecordListener callback) {\n\t\tsynchronized (lock) {\n\t\t\tfinal Iterator<RequestLogNewRecordListener> it = newRecordListeners.iterator();\n\t\t\twhile(it.hasNext()) {\n\t\t\t\tRequestLogNewRecordListener listener = it.next();\n\t\t\t\tif(listener.getListener() == callback) {\n\t\t\t\t\tit.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLogEntity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.message.BasicHeader;\n\npublic class RequestLogEntity implements HttpEntity {\n\n\tprivate byte[] content;\n\tprivate Header contentType;\n\tprivate Header contentEncoding;\n\t\t\n\tRequestLogEntity(byte[] content, Header contentType, Header contentEncoding) {\n\t\tthis.content = content;\n\t\tthis.contentType = copyHeader(contentType);\n\t\tthis.contentEncoding = copyHeader(contentEncoding);\n\t}\n\n\tpublic byte[] getContentArray() {\n\t\treturn content;\n\t}\n\n\tprivate Header copyHeader(Header h) {\n\t\tif(h == null) {\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn new BasicHeader(h.getName(), h.getValue());\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isRepeatable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isChunked() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic long getContentLength() {\n\t\treturn content.length;\n\t}\n\n\t@Override\n\tpublic Header getContentType() {\n\t\treturn contentType;\n\t}\n\n\t@Override\n\tpublic Header getContentEncoding() {\n\t\treturn contentEncoding;\n\t}\n\n\t@Override\n\tpublic InputStream getContent() throws IOException, IllegalStateException {\n\t\treturn new ByteArrayInputStream(content);\n\t}\n\n\t@Override\n\tpublic void writeTo(OutputStream outstream) throws IOException {\n\t\tif(outstream == null) {\n\t\t\tthrow new IllegalArgumentException(\"Output stream may not be null\");\n\t\t}\n\t\toutstream.write(content);\n\t\toutstream.flush();\n\t}\n\n\t@Override\n\tpublic boolean isStreaming() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic void consumeContent() throws IOException {\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLogEntityEnclosingRequest.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.RequestLine;\nimport org.apache.http.message.BasicHttpEntityEnclosingRequest;\n\nimport com.db4o.ObjectContainer;\n\npublic class RequestLogEntityEnclosingRequest extends BasicHttpEntityEnclosingRequest {\n\n\tprivate final long entityId;\n\n\tprivate transient LazyEntityLoader loader;\n\n\tpublic RequestLogEntityEnclosingRequest(ObjectContainer database, RequestLine requestline, long entityId) {\n\t\tsuper(requestline);\n\t\tthis.entityId = entityId;\n\t\tsetDatabase(database);\n\t}\n\n\tvoid setDatabase(ObjectContainer database) {\n\t\tthis.loader = new LazyEntityLoader(entityId, database);\n\t}\n\n\t@Override\n\tpublic HttpEntity getEntity() {\n\t\treturn loader.getEntity();\n\t}\n\n\t@Override\n\tpublic void setEntity(final HttpEntity entity) {\n\t\tthrow new UnsupportedOperationException();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLogId.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\npublic class RequestLogId {\n\tprivate long currentId = 0;\n\t\n\tsynchronized long allocateId() {\n\t\tfinal long ret = currentId;\n\t\tcurrentId++;\n\t\treturn ret;\n\t}\n\t\n\tsynchronized long getCurrentId() {\n\t\treturn currentId;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLogNewRecordListener.java",
    "content": "package com.subgraph.vega.internal.model.requests;\n\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.requests.IRequestLogNewRecordListener;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.model.requests.RequestLogNewRecordEvent;\n\npublic class RequestLogNewRecordListener {\n\tprivate final IRequestLogNewRecordListener listenerCallback;\n\tprivate final IHttpConditionSet filterCondition;\n\t\n\tpublic RequestLogNewRecordListener(IRequestLogNewRecordListener callback, IHttpConditionSet filter) {\n\t\tthis.listenerCallback = callback;\n\t\tthis.filterCondition = filter;\n\t}\n\t\n\tvoid filterRecord(IRequestLogRecord record) {\n\t\tif(matchesRecord(record)) {\n\t\t\tlistenerCallback.onNewRecord(new RequestLogNewRecordEvent(record));\n\t\t}\n\t}\n\t\n\tIRequestLogNewRecordListener getListener() {\n\t\treturn listenerCallback;\n\t}\n\n\tprivate boolean matchesRecord(IRequestLogRecord record) {\n\t\tif(filterCondition != null) {\n\t\t\treturn filterCondition.matchesAll(record);\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLogRecord.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Date;\nimport java.util.List;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableArrayList;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.api.model.tags.ITag;\n\npublic class RequestLogRecord implements IRequestLogRecord, Activatable {\n\tfinal long requestId;\n\tprivate final HttpRequest request;\n\tprivate IRequestOrigin requestOrigin;\n\tprivate final HttpHost host;\n\tprivate String hostname;\n\tprivate String requestMethod;\n\tprivate String requestPath;\n\tprivate String requestHeaders;\n\tprivate int responseCode;\n\tprivate int responseLength;\n\tprivate String responseHeaders;\n\tprivate HttpResponse response;\n\tprivate final long timestamp;\n\tprivate long requestTimeMs;\n\tprivate ActivatableArrayList<ITag> tagList;\n\tprivate transient Activator activator;\n\n\tRequestLogRecord(long requestId, HttpRequest request, IRequestOrigin requestOrigin, HttpResponse response, HttpHost host, long requestTimeMs, List<ITag> tagList) {\n\t\tthis.requestId = requestId;\n\t\tthis.request = request;\n\t\tthis.requestOrigin = requestOrigin;\n\t\tthis.response = response;\n\t\tthis.host = host;\n\t\tthis.timestamp = new Date().getTime();\n\t\tthis.requestTimeMs = requestTimeMs;\n\t\tthis.tagList = new ActivatableArrayList<ITag>(tagList);\n\t\tsetCachedRequestFields(request, host);\n\t\tsetCachedResponseFields(response);\n\t}\n\n\tRequestLogRecord(long requestId, HttpRequest request, IRequestOrigin requestOrigin, HttpHost host, long requestTimeMs, List<ITag> tagList) {\n\t\tthis(requestId, request, requestOrigin, null, host, requestTimeMs, tagList);\n\t}\n\n\tprivate void setCachedRequestFields(HttpRequest request, HttpHost host) {\n\t\tif(request == null) {\n\t\t\thostname = null;\n\t\t\trequestMethod = null;\n\t\t\trequestHeaders = null;\n\t\t\trequestPath = null;\n\t\t} else {\n\t\t\thostname = host.getHostName();\n\t\t\trequestMethod = request.getRequestLine().getMethod();\n\t\t\trequestHeaders = headersToString(request.getAllHeaders());\n\t\t\trequestPath = request.getRequestLine().getUri();\n\t\t}\n\t}\n\t\n\tprivate void setCachedResponseFields(HttpResponse response) {\n\t\tif(response == null) {\n\t\t\tresponseCode = 0;\n\t\t\tresponseLength = 0;\n\t\t\tresponseHeaders = null;\n\t\t} else {\n\t\t\tresponseCode = response.getStatusLine().getStatusCode();\n\t\t\tresponseLength = (int) getLengthFromResponse(response);\n\t\t\tresponseHeaders = headersToString(response.getAllHeaders());\n\t\t}\n\t}\n\t\n\tprivate String headersToString(Header[] headers) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor(Header h: headers) {\n\t\t\tsb.append(h.getName());\n\t\t\tsb.append(\": \");\n\t\t\tsb.append(h.getValue());\n\t\t\tsb.append(\"\\n\");\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate long getLengthFromResponse(HttpResponse response) {\n\t\tfinal Header lengthHeader = response.getFirstHeader(\"Content-Length\");\n\t\tif(lengthHeader != null) {\n\t\t\ttry {\n\t\t\t\treturn Long.parseLong(lengthHeader.getValue());\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(response.getEntity() == null)\n\t\t\treturn 0;\n\t\treturn response.getEntity().getContentLength();\n\t}\n\t\n\tvoid setResponse(HttpResponse response) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.response = response;\n\t\tsetCachedResponseFields(response);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\tString getHostname() {\n\t\treturn hostname;\n\t}\n\n\tString getRequestMethod() {\n\t\t\treturn requestMethod;\n\t}\n\t\n\tString getRequestHeaders() {\n\t\t\treturn requestHeaders;\n\t}\n\n\tString getRequestPath() {\n\t\t\treturn requestPath;\n\t}\n\n\tint getResponseCode() {\n\t\treturn responseCode;\n\t}\n\n\tint getResponseLength() {\n\t\treturn responseLength;\n\t}\n\n\tString getResponseHeaders() {\n\t\treturn responseHeaders;\n\t}\n\t\n\t@Override\n\tpublic long getRequestId() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn requestId;\n\t}\n\n\t@Override\n\tpublic long getTimestamp() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn timestamp;\n\t}\n\n\t@Override\n\tpublic IRequestOrigin getRequestOrigin() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn requestOrigin;\n\t}\n\n\t@Override\n\tpublic long getRequestMilliseconds() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn requestTimeMs;\n\t}\n\n\t@Override\n\tpublic HttpRequest getRequest() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn request;\n\t}\n\n\t@Override\n\tpublic HttpResponse getResponse() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(response) {\n\t\t\treturn response;\n\t\t}\n\t}\n\n\t@Override\n\tpublic HttpHost getHttpHost() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn host;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\n\t\tthis.activator = activator;\n\t}\n\n\t@Override\n\tpublic Collection<ITag> getAllTags() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn Collections.unmodifiableList(new ArrayList<ITag>(tagList));\n\t}\n\n\t@Override\n\tpublic ITag getTag(int idx) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn tagList.get(idx);\n\t}\n\n\t@Override\n\tpublic int getTagCount() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn tagList.size();\n\t}\n\n\t@Override\n\tpublic void setTags(Collection<ITag> tags) {\n\t\tactivate(ActivationPurpose.READ);\n\t\ttagList.clear();\n\t\ttagList.addAll(tags);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void addTag(ITag tag) {\n\t\tactivate(ActivationPurpose.READ);\n\t\ttagList.add(tag);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void removeTag(ITag tag) {\n\t\tactivate(ActivationPurpose.READ);\n\t\ttagList.remove(tag);\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestLogResponse.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.StatusLine;\nimport org.apache.http.message.BasicHttpResponse;\n\nimport com.db4o.ObjectContainer;\n\npublic class RequestLogResponse extends BasicHttpResponse {\n\n\tprivate final long entityId;\n\n\tprivate transient LazyEntityLoader loader;\n\n\tpublic RequestLogResponse(ObjectContainer database, StatusLine statusline, long entityId) {\n\t\tsuper(statusline);\n\t\tthis.entityId = entityId;\n\t\tsetDatabase(database);\n\t}\n\t\n\tvoid setDatabase(ObjectContainer database) {\n\t\tthis.loader = new LazyEntityLoader(entityId, database);\n\t}\n\n\t@Override\n\tpublic HttpEntity getEntity() {\n\t\treturn loader.getEntity();\n\t}\n\t\n\t@Override\n\tpublic void setEntity(final HttpEntity entity) {\n\t\tthrow new UnsupportedOperationException();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestOrigin.java",
    "content": "package com.subgraph.vega.internal.model.requests;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\npublic class RequestOrigin implements IRequestOrigin, Activatable {\n\tprivate transient Activator activator;\n\tprivate Origin origin;\n\t\n\tpublic RequestOrigin(Origin origin) {\n\t\tthis.origin = origin;\n\t}\n\n\t@Override\n\tpublic Origin getOrigin() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn origin;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestOriginProxy.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport java.net.InetAddress;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.api.model.requests.IRequestOriginProxy;\n\npublic class RequestOriginProxy extends RequestOrigin implements IRequestOriginProxy {\n\tprivate InetAddress address;\n\tprivate int port;\n\n\tpublic RequestOriginProxy(InetAddress address, int port) {\n\t\tsuper(IRequestOrigin.Origin.ORIGIN_PROXY);\n\t\tthis.address = address;\n\t\tthis.port = port;\n\t}\n\n\t@Override\n\tpublic InetAddress getInetAddress() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn address;\n\t}\n\n\t@Override\n\tpublic int getPort() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn port;\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\tfinal StringBuffer buf = new StringBuffer();\n\t\tbuf.append('[');\n\t\tbuf.append(address.getHostAddress());\n\t\tbuf.append(\"]:\");\n\t\tbuf.append(port);\n\t\treturn buf.toString();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/requests/RequestOriginScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.requests;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.requests.IRequestOriginScanner;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\n\npublic class RequestOriginScanner extends RequestOrigin implements IRequestOriginScanner {\n\tprivate IScanInstance scanInstance;\n\t\n\tpublic RequestOriginScanner(IScanInstance scanInstance) {\n\t\tsuper(IRequestOrigin.Origin.ORIGIN_SCANNNER);\n\t\tthis.scanInstance = scanInstance;\n\t}\n\t\n\t@Override\n\tpublic IScanInstance getScanInstance() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scanInstance;\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn \"Scan ID \" + scanInstance.getScanId();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/scope/TargetScope.java",
    "content": "package com.subgraph.vega.internal.model.scope;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Set;\nimport java.util.regex.Pattern;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.utils.URIUtils;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableHashSet;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.scope.ActiveScopeChangedEvent;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.util.UriTools;\n\npublic class TargetScope implements ITargetScope, Activatable {\n\n\tprivate final long id;\n\tprivate final Set<String> scopeURIs;\n\tprivate final Set<String> exclusionPatterns;\n\tprivate final Set<String> exclusionURIs;\n\tprivate final boolean isDefault;\n\tprivate String name;\n\tprivate boolean isActiveScope;\n\tprivate boolean isReadOnly;\n\tprivate boolean isDetached;\n\n\tprivate transient EventListenerManager scopeChangedListeners;\n\tprivate transient List<Pattern> compiledPatterns;\n\tprivate transient Activator activator;\n\t\n\tTargetScope(long id, boolean isDefault, EventListenerManager scopeChangeListeners) {\n\t\tthis.id = id;\n\t\tthis.name = \"\";\n\t\tthis.isDefault = isDefault;\n\t\tthis.scopeURIs = new ActivatableHashSet<String>();\n\t\tthis.exclusionPatterns = new ActivatableHashSet<String>();\n\t\tthis.exclusionURIs = new ActivatableHashSet<String>();\n\t\tthis.scopeChangedListeners = scopeChangeListeners;\n\t}\n\t\n\t@Override\n\tpublic long getScopeId() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn id;\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\t\t\t\t\n\t\treturn name;\n\t}\n\n\tprivate void checkReadOnly() {\n\t\tif(isReadOnly) {\n\t\t\tthrow new IllegalStateException(\"Attempt to modify TargetScope instance which is marked Read Only\");\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tthis.name = name;\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic synchronized void addScopeURI(URI uri) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized (scopeURIs) {\n\t\t\tscopeURIs.add(uri.toString());\t\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic synchronized void removeScopeURI(URI uri, boolean removeContained) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized (scopeURIs) {\n\t\t\tscopeURIs.remove(uri.toString());\n\t\t\tif(removeContained) {\n\t\t\t\tremoveContainedURIs(uri);\n\t\t\t}\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\t\n\tprivate void removeContainedURIs(URI base) {\n\t\tfinal List<String> current = new ArrayList<String>(scopeURIs);\n\t\tfor(String uriStr: current) {\n\t\t\tif(UriTools.doesBaseUriContain(base, URI.create(uriStr))) {\n\t\t\t\tscopeURIs.remove(uriStr);\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized Collection<URI> getScopeURIs() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal List<URI> ret = new ArrayList<URI>();\n\t\tsynchronized (scopeURIs) {\n\t\t\tfor(String uriStr: scopeURIs) {\n\t\t\t\tret.add(URI.create(uriStr));\n\t\t\t}\n\t\t\treturn Collections.unmodifiableCollection(ret);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void addExclusionPattern(String pattern) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized (exclusionPatterns) {\n\t\t\texclusionPatterns.add(pattern);\n\t\t\tcompiledPatterns = compilePatterns();\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic void addExclusionURI(URI uri) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized (exclusionURIs) {\n\t\t\texclusionURIs.add(uri.toString());\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic void removeExclusionPattern(String pattern) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized(exclusionPatterns) {\n\t\t\texclusionPatterns.remove(pattern);\n\t\t\tcompiledPatterns = compilePatterns();\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic void removeExclusionURI(URI uri) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized (exclusionURIs) {\n\t\t\texclusionURIs.remove(uri.toString());\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic Collection<String> getExclusionPatterns() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(exclusionPatterns) {\n\t\t\treturn Collections.unmodifiableCollection(new ArrayList<String>(exclusionPatterns));\n\t\t}\n\t}\n\n\t@Override\n\tpublic Collection<URI> getExclusionURIs() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal List<URI> ret = new ArrayList<URI>();\n\t\tsynchronized (exclusionURIs) {\n\t\t\tfor(String uriStr: exclusionURIs) {\n\t\t\t\tret.add(URI.create(uriStr));\n\t\t\t}\n\t\t\treturn Collections.unmodifiableCollection(ret);\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isExcluded(URI uri) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal String uriString = uri.toString();\n\t\tfor(Pattern p: getCompiledPatterns()) {\n\t\t\tif(p.matcher(uriString).find()) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tsynchronized (exclusionURIs) {\n\t\t\tfor(String uriStr: exclusionURIs) {\n\t\t\t\tif(UriTools.doesBaseUriContain(URI.create(uriStr), uri)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\t@Override\n\tpublic boolean isExcluded(HttpHost host, String uriPath) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal String uriString = host.toString() + uriPath;\n\t\tfor(Pattern p: getCompiledPatterns()) {\n\t\t\tif(p.matcher(uriString).find()) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tsynchronized (exclusionURIs) {\n\t\t\tfor(String uriStr: exclusionURIs) {\n\t\t\t\tif(matchesBase(URI.create(uriStr), host, uriPath)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean isInsideScope(URI uri) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized (scopeURIs) {\n\t\t\tfor(String uriStr: scopeURIs) {\n\t\t\t\tif(UriTools.doesBaseUriContain(URI.create(uriStr), uri)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t@Override \n\tpublic boolean isInsideScope(HttpHost host, String uriPath) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized (scopeURIs) {\n\t\t\tfor(String uriStr: scopeURIs) {\n\t\t\t\tif(matchesBase(URI.create(uriStr), host, uriPath)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate boolean matchesBase(URI baseURI, HttpHost host, String uriPath) {\n\t\tfinal HttpHost baseHost = URIUtils.extractHost(baseURI);\n\t\tfinal String basePath = getPathPart(baseURI);\n\t\tif(!hostsMatch(baseHost, host)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn uriPath.startsWith(basePath);\n\t}\n\n\t\n\tprivate boolean hostsMatch(HttpHost h1, HttpHost h2) {\n\t\treturn stringsMatch(h1.getHostName(), h2.getHostName()) && \n\t\t\t\tstringsMatch(h1.getSchemeName(), h2.getSchemeName()) &&\n\t\t\t\tportsMatch(h1.getSchemeName(), h1.getPort(), h2.getPort());\n\t}\n\n\tprivate boolean stringsMatch(String s1, String s2) {\n\t\tif(s1 == null && s2 != null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn s1.equalsIgnoreCase(s2);\n\t}\n\t\n\tprivate boolean portsMatch(String scheme, int p1, int p2) {\n\t\tif(p1 == p2) {\n\t\t\treturn true;\n\t\t} else if(\n\t\t\t\t\"http\".equalsIgnoreCase(scheme) && (\n\t\t\t\t\t\t((p1 == -1) && (p2 == 80)) ||\n\t\t\t\t\t\t((p1 == 80) && (p2 == -1)))) {\n\t\t\treturn true;\n\t\t} else if(\n\t\t\t\t\"https\".equalsIgnoreCase(scheme) && (\n\t\t\t\t\t\t((p1 == -1) && (p2 == 443)) ||\n\t\t\t\t\t\t((p1 == 443) && (p2 == -1)))) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tprivate String getPathPart(URI uri) {\n\t\tif(uri.getQuery() == null) {\n\t\t\treturn uri.getPath();\n\t\t} else {\n\t\t\treturn uri.getPath() + '?' + uri.getQuery();\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean filter(URI uri) {\n\t\treturn isInsideScope(uri) && !isExcluded(uri);\n\t}\n\t\n\t@Override\n\tpublic boolean filter(HttpHost host, String uri) {\n\t\treturn isInsideScope(host, uri) && !isExcluded(host, uri);\n\t}\n\n\t@Override\n\tpublic void clear() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tcheckReadOnly();\n\t\tsynchronized (scopeURIs) {\n\t\t\tsynchronized (exclusionPatterns) {\n\t\t\t\tscopeURIs.clear();\n\t\t\t\texclusionPatterns.clear();\n\t\t\t\texclusionURIs.clear();\n\t\t\t}\n\t\t}\n\t\tactivate(ActivationPurpose.WRITE);\n\t\tnotifyIfActiveScope();\n\t}\n\n\t@Override\n\tpublic boolean isEmpty() {\n\t\treturn scopeURIs.isEmpty();\n\t}\n\t\n\t@Override\n\tpublic boolean isActiveScope() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn isActiveScope;\n\t}\n\n\t\n\t@Override\n\tpublic void setReadOnly(boolean value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tisReadOnly = value;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\tpublic void setDetached(boolean value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(value && isActiveScope) {\n\t\t\tthrow new IllegalStateException(\"Cannot detach the active scope.\");\n\t\t}\n\t\tif(value && isDefault) {\n\t\t\tthrow new IllegalStateException(\"Cannot detach the default scope\");\n\t\t}\n\t\t\n\t\tisDetached = value;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic boolean isReadOnly() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn isReadOnly;\n\t}\n\n\t@Override\n\tpublic boolean isDetached() {\n\t\treturn isDetached;\n\t}\n\n\tpublic void setIsActiveScope(boolean flag) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(flag && isDetached) {\n\t\t\tthrow new IllegalStateException(\"Cannot use a detached scope as the active scope\");\n\t\t}\n\t\tisActiveScope = flag;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\t@Override\n\tpublic boolean isDefaultScope() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn isDefault;\n\t}\n\n\tprivate List<Pattern> getCompiledPatterns() {\n\t\tsynchronized (exclusionPatterns) {\n\t\t\tif(compiledPatterns == null) {\n\t\t\t\tcompiledPatterns = compilePatterns();\n\t\t\t}\n\t\t}\n\t\treturn compiledPatterns;\n\t}\n\t\n\tprivate List<Pattern> compilePatterns() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tfinal List<Pattern> patterns = new ArrayList<Pattern>();\n\t\tfor(String regex: exclusionPatterns) {\n\t\t\tpatterns.add(Pattern.compile(regex));\n\t\t}\n\t\treturn patterns;\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn getName();\n\t}\n\t\n\tprivate void notifyIfActiveScope() {\n\t\tif(isActiveScope) {\n\t\t\tscopeChangedListeners.fireEvent(new ActiveScopeChangedEvent(this));\n\t\t}\n\t}\n\n\tvoid setEventListenerManager(EventListenerManager mgr) {\n\t\tthis.scopeChangedListeners = mgr;\n\t}\n\t\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/scope/TargetScopeId.java",
    "content": "package com.subgraph.vega.internal.model.scope;\n\npublic class TargetScopeId {\n\tprivate long currentId = 0;\n\t\n\tsynchronized long allocateId() {\n\t\tfinal long ret = currentId;\n\t\tcurrentId ++;\n\t\treturn ret;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/scope/TargetScopeManager.java",
    "content": "package com.subgraph.vega.internal.model.scope;\n\nimport java.net.URI;\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.events.CancellableObjectEventArgs;\nimport com.db4o.events.Event4;\nimport com.db4o.events.EventListener4;\nimport com.db4o.events.EventRegistry;\nimport com.db4o.events.EventRegistryFactory;\nimport com.db4o.query.Predicate;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.scope.ActiveScopeChangedEvent;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\n\npublic class TargetScopeManager implements ITargetScopeManager {\n\tprivate final ObjectContainer database;\n\tprivate final TargetScopeId scopeId;\n\tprivate final EventListenerManager scopeChangeListeners;\n\tprivate ITargetScope activeScope;\n\tprivate ITargetScope defaultScope;\n\t\n\tpublic TargetScopeManager(ObjectContainer database) {\n\t\tthis.database = database;\n\t\tthis.scopeId = getTargetScopeId(database);\n\t\tscopeChangeListeners = new EventListenerManager();\n\t\tfinal EventRegistry registry = EventRegistryFactory.forObjectContainer(database);\n\t\tregistry.activating().addListener(new EventListener4<CancellableObjectEventArgs>() {\n\n\t\t\t@Override\n\t\t\tpublic void onEvent(Event4<CancellableObjectEventArgs> e,\n\t\t\t\t\tCancellableObjectEventArgs args) {\n\t\t\t\tfinal Object ob = args.object();\n\t\t\t\tif(ob instanceof TargetScope) {\n\t\t\t\t\t((TargetScope)ob).setEventListenerManager(scopeChangeListeners);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tdefaultScope = findDefaultScope();\n\t\tactiveScope = findActiveScope();\n\t}\n\t\n\tprivate TargetScopeId getTargetScopeId(ObjectContainer database) {\n\t\tList<TargetScopeId> result = database.query(TargetScopeId.class);\n\t\tif(result.size() == 0) {\n\t\t\tfinal TargetScopeId tsi = new TargetScopeId();\n\t\t\tdatabase.store(tsi);\n\t\t\treturn tsi;\n\t\t} else if(result.size() == 1) {\n\t\t\treturn result.get(0);\n\t\t} else {\n\t\t\tthrow new IllegalStateException(\"Database corrupted, found multiple TargetScopeId instances\");\n\t\t}\n\t}\n\n\t@Override\n\tpublic ITargetScope createNewScope() {\n\t\treturn createNewScope(\"New Scope\");\n\t}\n\t\n\t@Override\n\tpublic ITargetScope createDuplicatedScope(ITargetScope scope) {\n\t\tfinal ITargetScope newScope = createNewScope(scope.getName());\n\t\tfor(URI u: scope.getScopeURIs()) {\n\t\t\tnewScope.addScopeURI(u);\n\t\t}\n\t\tfor(URI u: scope.getExclusionURIs()) {\n\t\t\tnewScope.addExclusionURI(u);\n\t\t}\n\t\tfor(String s: scope.getExclusionPatterns()) {\n\t\t\tnewScope.addExclusionPattern(s);\n\t\t}\n\t\treturn newScope;\n\t}\n\n\tprivate ITargetScope createNewScope(String name) {\n\t\tfinal long id = scopeId.allocateId();\n\t\tfinal ITargetScope scope = new TargetScope(id, false, scopeChangeListeners);\n\t\tscope.setName(name);\n\t\treturn scope;\n\t}\n\t\n\tprivate ITargetScope createDefaultScope() {\n\t\tfinal long id = scopeId.allocateId();\n\t\tfinal ITargetScope scope = new TargetScope(id, true, scopeChangeListeners);\n\t\t((TargetScope)scope).setIsActiveScope(true);\n\t\tscope.setName(\"Default Scope\");\n\t\tdatabase.store(scope);\n\t\treturn scope;\n\t}\n\t\n\t@Override\n\tpublic void saveScope(ITargetScope scope) {\n\t\tdatabase.store(scope);\n\t}\n\n\t@Override\n\tpublic boolean removeScope(ITargetScope scope) {\n\t\tif(scope == defaultScope) {\n\t\t\treturn false;\n\t\t} else if(scope == activeScope) {\n\t\t\tsetActiveScope(defaultScope);\n\t\t}\n\t\t\n\t\tdatabase.delete(scope);\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic Collection<ITargetScope> getAllScopes() {\n\t\treturn database.query(ITargetScope.class);\n\t}\n\n\t@Override\n\tpublic ITargetScope getActiveScope() {\n\t\treturn activeScope;\n\t}\n\n\t@Override\n\tpublic ITargetScope getDefaultScope() {\n\t\treturn defaultScope;\n\t}\n\t\n\t@Override\n\tpublic void setActiveScope(ITargetScope scope) {\n\t\tif(scope == activeScope || !database.ext().isStored(scope)) {\n\t\t\treturn;\n\t\t}\n\t\tsynchronized (this) {\n\t\t\t((TargetScope)activeScope).setIsActiveScope(false);\n\t\t\t((TargetScope)scope).setIsActiveScope(true);\n\t\t\tactiveScope = scope;\n\t\t\t\n\t\t\tscopeChangeListeners.fireEvent(new ActiveScopeChangedEvent(activeScope));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setScopeDetached(ITargetScope scope) {\n\t\tif(scope.isActiveScope()) {\n\t\t\tsetActiveScope(defaultScope);\n\t\t}\n\t\t((TargetScope)scope).setDetached(true);\n\t}\n\n\t@Override\n\tpublic void setScopeAttached(ITargetScope scope) {\n\t\t((TargetScope)scope).setDetached(false);\n\t}\n\n\t@Override\n\tpublic ITargetScope addActiveScopeChangeListener(IEventHandler listener) {\n\t\tsynchronized (this) {\n\t\t\tscopeChangeListeners.addListener(listener);\n\t\t\treturn activeScope;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void removeActiveScopeChangeListener(IEventHandler listener) {\n\t\tscopeChangeListeners.removeListener(listener);\n\t}\n\n\tprivate ITargetScope findDefaultScope() {\n\t\tfinal List<ITargetScope> results = database.query(new Predicate<ITargetScope>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(ITargetScope scope) {\n\t\t\t\treturn scope.isDefaultScope();\n\t\t\t}\n\t\t});\n\t\tif(results.size() == 0) {\n\t\t\treturn createDefaultScope();\n\t\t}\n\t\treturn results.get(0);\n\t}\n\n\tprivate ITargetScope findActiveScope() {\n\t\tfinal List<ITargetScope> results = database.query(new Predicate<ITargetScope>() {\n\n\t\t\tprivate static final long serialVersionUID = 1L;\n\n\t\t\t@Override\n\t\t\tpublic boolean match(ITargetScope scope) {\n\t\t\t\treturn scope.isActiveScope();\n\t\t\t}\n\t\t});\n\n\t\tif(results.size() == 0) {\n\t\t\tfinal ITargetScope active = findDefaultScope();\n\t\t\t((TargetScope)active).setIsActiveScope(true);\n\t\t\treturn active;\n\t\t}\n\t\treturn results.get(0);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/tags/Tag.java",
    "content": "package com.subgraph.vega.internal.model.tags;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.tags.ITag;\n\npublic class Tag implements ITag, Activatable {\n\tprivate transient Activator activator;\n\tprivate String name;\n\tprivate String description;\n\tprivate int nameColor;\n\tprivate int rowColor;\n\n\tpublic Tag() {\n\t\trowColor = 0xffffff;\n\t}\n\n\tpublic Tag(ITag tag) {\n\t\tname = tag.getName();\n\t\tdescription = tag.getDescription();\n\t\tnameColor = tag.getNameColor();\n\t\trowColor = tag.getRowColor();\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n\t@Override\n\tpublic void setName(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.name = name;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic void setDescription(String description) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.description = description;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getDescription() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn description;\n\t}\n\n\t@Override\n\tpublic void setNameColor(int color) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tnameColor = color;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic int getNameColor() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn nameColor;\n\t}\n\n\t@Override\n\tpublic void setRowColor(int color) {\n\t\tactivate(ActivationPurpose.READ);\n\t\trowColor = color;\t\t\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\t@Override\n\tpublic int getRowColor() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn rowColor;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/tags/TagModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.tags;\n\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.query.Predicate;\nimport com.subgraph.vega.api.model.tags.ITag;\nimport com.subgraph.vega.api.model.tags.ITagModel;\n\npublic class TagModel implements ITagModel {\n\tprivate ObjectContainer database;\n\n\tpublic TagModel(ObjectContainer database) {\n\t\tthis.database = database;\n\t}\n\n\t@Override\n\tpublic Collection<ITag> getAllTags() {\n\t\treturn database.query(ITag.class);\n\t}\n\n\t@Override\n\tpublic ITag createTag() {\n\t\treturn new Tag();\n\t}\n\n\t@Override\n\tpublic ITag createTag(ITag tag) {\n\t\treturn new Tag(tag);\n\t}\n\n\t@Override\n\tpublic void store(ITag tag) {\n\t\tdatabase.store(tag);\n\t}\n\n\t@Override\n\tpublic boolean isTagStored(ITag tag) {\n\t\treturn database.ext().isStored(tag);\n\t}\n\n\t@Override\n\tpublic ITag getTagByName(final String name) {\n\t\tfinal List<ITag> results = database.query(new Predicate<ITag>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(ITag tag) {\n\t\t\t\treturn name.equals(tag.getName());\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn results.get(0);\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/variables/Variable.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.variables;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.variables.IVariable;\n\npublic class Variable implements IVariable, Activatable {\n\tprivate transient Activator activator;\n\tprivate String name;\n\tprivate String description;\n\t\n\t@Override\n\tpublic void setName(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.name = name;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic void setDescription(String description) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.description = description;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic String getDescription() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn description;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif (activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif (this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\tif (activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\tthis.activator = activator;\t\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/variables/VariableModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.variables;\n\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.query.Predicate;\nimport com.subgraph.vega.api.model.variables.IVariable;\nimport com.subgraph.vega.api.model.variables.IVariableModel;\n\npublic class VariableModel implements IVariableModel {\n\tprivate ObjectContainer database;\n\n\tpublic VariableModel(ObjectContainer database) {\n\t\tthis.database = database;\n\t}\n\n\t@Override\n\tpublic Collection<IVariable> getAllIdentities() {\n\t\treturn database.query(IVariable.class);\n\t}\n\n\t@Override\n\tpublic IVariable createVariable() {\n\t\treturn new Variable();\n\t}\n\n\t@Override\n\tpublic void store(IVariable variable) {\n\t\tdatabase.store(variable);\n\t}\n\n\t@Override\n\tpublic boolean isVariableStored(IVariable variable) {\n\t\treturn database.ext().isStored(variable);\n\t}\n\n\t@Override\n\tpublic IVariable getVariableByName(final String name) {\n\t\tfinal List<IVariable> results = database.query(new Predicate<IVariable>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IVariable tag) {\n\t\t\t\treturn name.equals(tag.getName());\n\t\t\t}\n\t\t});\n\t\tif (results.size() == 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn results.get(0);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebEntity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport java.util.List;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.IModelProperties;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.NewWebEntityEvent;\nimport com.subgraph.vega.api.model.web.UpdatedWebEntityEvent;\nimport com.subgraph.vega.internal.model.ModelProperties;\n\npublic abstract class WebEntity implements IWebEntity, Activatable {\n\t\n\tprivate transient Activator activator;\n\tprotected transient EventListenerManager eventManager;\n\tprotected transient ObjectContainer database;\n\t\n\tprivate boolean visitedFlag;\n\tprivate boolean scannedFlag;\n\t\n\tprivate IModelProperties properties = new ModelProperties();\n\t\n\tprotected WebEntity(EventListenerManager eventManager, ObjectContainer database) {\n\t\tthis.eventManager = eventManager;\n\t\tthis.database = database;\n\t}\n\t\n\t@Override\n\tpublic boolean isVisited() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn visitedFlag;\n\t}\n\n\t@Override\n\tpublic void setVisited(boolean notify) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(getParent() != null)\n\t\t\tgetParent().setVisited(notify);\n\t\tif(!visitedFlag) {\n\t\t\tvisitedFlag = true;\n\t\t\tactivate(ActivationPurpose.WRITE);\n\t\t\tif(notify)\n\t\t\t\tnotifyUpdatedEntity(this);\n\t\t}\t\t\n\t}\n\t\n\t@Override\n\tpublic boolean isScanned() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn scannedFlag;\n\t}\n\t\n\t@Override\n\tpublic void setScanned() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tscannedFlag = true;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\t@Override\n\tpublic void setProperty(String name, Object value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tproperties.setProperty(name, value);\t\t\n\t}\n\n\t@Override\n\tpublic void setStringProperty(String name, String value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tproperties.setStringProperty(name, value);\t\t\n\t}\n\n\t@Override\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tproperties.setIntegerProperty(name, value);\t\t\n\t}\n\n\t@Override\n\tpublic Object getProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getProperty(name);\n\t}\n\n\t@Override\n\tpublic String getStringProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getStringProperty(name);\n\t}\n\n\t@Override\n\tpublic Integer getIntegerProperty(String name) {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.getIntegerProperty(name);\n\t}\n\n\t@Override\n\tpublic List<String> propertyKeys() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn properties.propertyKeys();\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\t\n\t}\n\t\n\tvoid setEventManager(EventListenerManager eventManager) {\n\t\tthis.eventManager = eventManager;\n\t}\n\t\n\tvoid setDatabase(ObjectContainer database) {\n\t\tif(this.database == null)\n\t\t\tthis.database = database;\n\t}\n\t\n\tObjectContainer getDatabase() {\n\t\treturn database;\n\t}\n\t\n\tvoid notifyNewEntity(IWebEntity entity) {\n\t\tif(eventManager != null)\n\t\t\teventManager.fireEvent(new NewWebEntityEvent(entity));\n\t}\n\t\n\tvoid notifyUpdatedEntity(IWebEntity entity) {\n\t\tif(eventManager != null)\n\t\t\teventManager.fireEvent(new UpdatedWebEntityEvent(entity));\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebHost.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport static com.google.common.base.Preconditions.checkNotNull;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.HttpHost;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.activation.ActivationPurpose;\nimport com.google.common.base.Objects;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebModelVisitor;\nimport com.subgraph.vega.api.model.web.IWebMountPoint;\n\n\npublic class WebHost extends WebEntity implements IWebHost {\n\t\n\tstatic WebHost createWebHost(EventListenerManager eventManager, ObjectContainer database, HttpHost host) {\n\t\tfinal WebMountPoint rootMountPoint = WebMountPoint.createRootMountPoint(eventManager, database, checkNotNull(host));\n\t\tfinal WebHost webHost =  new WebHost(eventManager, database, host, rootMountPoint);\n\t\trootMountPoint.setWebHost(webHost);\n\t\treturn webHost;\n\t}\n\n\tprivate final HttpHost host;\n\tprivate final WebMountPoint mountPoint;\n\tprivate final WebPath rootPath;\n\t\n\tprivate transient URI cachedUri;\n\t\n\t\n\tprivate WebHost(EventListenerManager eventManager, ObjectContainer database, HttpHost host, WebMountPoint rootMountPoint) {\n\t\tsuper(eventManager, database);\n\t\tif(host.getHostName().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Hostname is empty\");\n\t\t}\n\t\thostToUri(host);\n\t\tthis.host = host;\n\t\tthis.mountPoint = rootMountPoint;\n\t\tthis.rootPath = rootMountPoint.getMountPath();\n\t}\n\t\n\t@Override\n\tpublic HttpHost getHttpHost() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn host;\n\t}\n\n\t@Override\n\tpublic String getScheme() {\n\t\treturn getHttpHost().getSchemeName();\n\t}\n\n\t@Override\n\tpublic String getHostname() {\n\t\treturn getHttpHost().getHostName();\n\t}\n\n\t@Override\n\tpublic int getPort() {\n\t\treturn getHttpHost().getPort();\n\t}\n\n\t@Override\n\tpublic IWebMountPoint getRootMountPoint() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn mountPoint;\n\t}\n\n\t@Override\n\tpublic WebPath getRootPath() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn rootPath;\n\t}\n\n\t@Override\n\tpublic URI getUri() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(this) {\n\t\t\tif(cachedUri == null)\n\t\t\t\tcachedUri = generateUri();\n\t\t\treturn cachedUri;\n\t\t}\n\t}\n\t\n\tprivate static URI hostToUri(HttpHost host) {\n\t\ttry {\n\t\t\treturn new URI(host.getSchemeName(), null, host.getHostName(), host.getPort(), null, null, null);\n\t\t} catch (URISyntaxException e) {\n\t\t\tthrow new IllegalArgumentException(\"Unable to convert host to URI: \"+ host);\n\t\t}\n\t}\n\n\tprivate URI generateUri() {\n\t\treturn hostToUri(host);\n\t}\n\n\t@Override\n\tpublic WebPath addPath(String path) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tWebPath wp = getRootPath();\n\t\tfor(String s: path.split(\"/\")) {\n\t\t\tif(!s.isEmpty()) {\n\t\t\t\twp = wp.addChildPath(s);\n\t\t\t}\n\t\t}\n\t\treturn wp;\t\t\n\t}\n\t\n\t@Override\n\tpublic boolean equals(Object other) {\n\t\t\n\t\tif(this == other)\n\t\t\treturn true;\n\t\telse if(other instanceof WebHost) {\n\t\t\tWebHost that = (WebHost) other;\n\t\t\treturn this.getHttpHost().equals(that.getHttpHost());\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic int hashCode() {\n\t\treturn getHttpHost().hashCode();\n\t}\n\t\n\t@Override\n\tpublic String toString() {\n\t\treturn Objects.toStringHelper(this).add(\"host\", getHttpHost()).toString();\n\t}\n\n\t@Override\n\tpublic IWebEntity getParent() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void accept(IWebModelVisitor visitor) {\n\t\tvisitor.visit(this);\n\t\tgetRootPath().accept(visitor);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.apache.http.Consts;\nimport org.apache.http.HttpHost;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.utils.URLEncodedUtils;\nimport org.w3c.dom.html2.HTMLDocument;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.events.CancellableObjectEventArgs;\nimport com.db4o.events.Event4;\nimport com.db4o.events.EventListener4;\nimport com.db4o.events.EventRegistry;\nimport com.db4o.events.EventRegistryFactory;\nimport com.db4o.query.Predicate;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebModel;\nimport com.subgraph.vega.api.model.web.IWebModelVisitor;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.NewWebEntityEvent;\nimport com.subgraph.vega.api.model.web.forms.IWebForm;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.internal.model.web.forms.FormParser;\n\npublic class WebModel implements IWebModel {\n\tprivate final EventListenerManager eventManager = new EventListenerManager();\n\n\tprivate final ObjectContainer database;\n\tprivate final FormParser formParser;\n\n\tpublic WebModel(ObjectContainer database) {\n\t\tthis.formParser = new FormParser(this);\n\t\tthis.database = database;\n\t\tEventRegistry registry = EventRegistryFactory.forObjectContainer(database);\n\t\tregistry.activating().addListener(new EventListener4<CancellableObjectEventArgs>() {\n\n\t\t\t@Override\n\t\t\tpublic void onEvent(Event4<CancellableObjectEventArgs> e,\n\t\t\t\t\tCancellableObjectEventArgs args) {\n\t\t\t\tfinal Object ob = args.object();\n\t\t\t\tif(ob instanceof WebEntity) {\n\t\t\t\t\tfinal WebEntity entity = (WebEntity) ob;\n\t\t\t\t\tentity.setEventManager(eventManager);\n\t\t\t\t\tentity.setDatabase(WebModel.this.database);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t@Override\n\tsynchronized public Collection<IWebHost> getAllWebHosts() {\n\t\t\treturn database.query(IWebHost.class);\n\t}\n\n\t@Override\n\tpublic Collection<IWebHost> getUnscannedHosts() {\n\t\treturn database.query(new Predicate<IWebHost>() {\n\t\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t\t@Override\n\t\t\t\tpublic boolean match(IWebHost host) {\n\t\t\t\t\treturn host.isScanned() == false;\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\t@Override\n\tpublic Collection<IWebPath> getUnscannedPaths() {\n\t\tfinal List<IWebPath> paths = database.query(new Predicate<IWebPath>() {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic boolean match(IWebPath path) {\n\t\t\t\treturn path.isScanned() == false;\n\t\t\t}\n\t\t});\n\t\treturn paths;\n\t}\n\n\t@Override\n\tpublic Collection<IWebPath> getAllPaths() {\n\t\treturn database.query(IWebPath.class);\n\t}\n\n\t@Override\n\tpublic synchronized IWebPath getWebPathByUri(VegaURI uri) {\n\t\tfinal HttpHost host = uri.getTargetHost();\n\t\tif (host != null) {\n\t\t\tIWebHost wh = getWebHostByHttpHost(host);\n\t\t\tif(wh == null) {\n\t\t\t\twh = createWebHostFromHttpHost(host);\n\t\t\t}\n\t\t\treturn wh.addPath(uri.getPath());\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic IWebPath addGetTarget(VegaURI uri) {\n\t\tfinal IWebPath path = getWebPathByUri(uri);\n\t\tif (path != null) {\n\t\t\tList<NameValuePair> params = URLEncodedUtils.parse(uri.getQuery(), Consts.UTF_8);\n\t\t\tpath.addGetParameterList(params);\n\t\t}\n\t\treturn path;\n\t}\n\n\t@Override\n\tsynchronized public WebHost getWebHostByHttpHost(HttpHost host) {\n\t\tfor(WebHost wh: database.query(WebHost.class)) {\n\t\t\tif(wh.getHttpHost().equals(host))\n\t\t\t\treturn wh;\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tsynchronized public IWebHost createWebHostFromHttpHost(HttpHost host) {\n\t\tfinal WebHost wh = getWebHostByHttpHost(host);\n\t\tif(wh != null)\n\t\t\treturn wh;\n\t\tfinal WebHost newHost = WebHost.createWebHost(eventManager, database, host);\n\t\tnewHost.setDatabase(database);\n\t\tnewHost.getRootPath().setDatabase(database);\n\t\tdatabase.store(newHost);\n\t\tdatabase.store(newHost.getRootMountPoint());\n\t\tdatabase.store(newHost.getRootPath());\n\n\t\tnotifyNewEntity(newHost);\n\t\treturn newHost;\n\t}\n\n\t@Override\n\tpublic void addChangeListenerAndPopulate(IEventHandler listener) {\n\t\tsynchronized(this) {\n\t\t\tfor(IWebHost wh: getAllWebHosts()) {\n\t\t\t\tlistener.handleEvent(new NewWebEntityEvent(wh));\n\t\t\t}\n\t\t\teventManager.addListener(listener);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void removeChangeListener(IEventHandler listener) {\n\t\teventManager.removeListener(listener);\n\t}\n\n\tprivate void notifyNewEntity(IWebEntity entity) {\n\t\teventManager.fireEvent(new NewWebEntityEvent(entity));\n\t}\n\n\t@Override\n\tpublic Collection<IWebForm> parseForms(IWebPath source,\n\t\t\tHTMLDocument document) {\n\t\treturn formParser.parseForms(source, document);\n\t}\n\n\t@Override\n\tpublic void accept(IWebModelVisitor visitor) {\n\t\tfor(IWebHost host: getAllWebHosts()) {\n\t\t\t\thost.accept(visitor);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebMountPoint.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport org.apache.http.HttpHost;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebMountPoint;\n\n\npublic class WebMountPoint implements IWebMountPoint, Activatable {\n\n\tstatic WebMountPoint createRootMountPoint(EventListenerManager eventManager, ObjectContainer database, HttpHost httpHost) {\n\t\tWebPath rootPath = WebPath.createRootPath(eventManager, database);\n\t\tfinal WebMountPoint mountPoint = new WebMountPoint(rootPath);\n\t\trootPath.setMountPoint(mountPoint);\n\t\treturn mountPoint;\n\t}\n\tprivate transient Activator activator;\n\n\tprivate IWebHost host;\n\tprivate final WebPath path;\n\t\n\tWebMountPoint() {\n\t\tthis.path = null;\n\t\tthis.host = null;\n\t}\n\t\n\t\n\tprivate WebMountPoint(WebPath rootPath) {\n\t\tthis.path = rootPath;\n\t\tthis.host = null;\n\t}\n\t\n\tWebMountPoint(IWebHost host, WebPath path) {\n\t\tthis.host = host;\n\t\tthis.path = path;\n\t}\n\n\t@Override\n\tpublic IWebHost getWebHost() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn host;\n\t}\n\n\t@Override\n\tpublic WebPath getMountPath() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn path;\n\t}\n\t\n\tvoid setWebHost(IWebHost host) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.host = host;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebPath.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.utils.URLEncodedUtils;\nimport org.apache.http.message.BasicNameValuePair;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.collections.ActivatableHashMap;\nimport com.google.common.base.Objects;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebModelVisitor;\nimport com.subgraph.vega.api.model.web.IWebMountPoint;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebPathParameters;\nimport com.subgraph.vega.api.model.web.IWebResponse;\n\npublic class WebPath extends WebEntity implements IWebPath {\n\n\tstatic WebPath createRootPath(EventListenerManager eventManager, ObjectContainer database) {\n\t\treturn new WebPath(eventManager, database, null, \"\");\n\t}\n\n\tprivate final WebPath parentPath;\n\tprivate final String pathComponent;\n\tprivate final Map<String, WebPath> childPathMap = new ActivatableHashMap<String, WebPath>();\n\n\tprivate IWebMountPoint mountPoint;\n\tprivate final WebPathParameters getParameters = new WebPathParameters();\n\tprivate final WebPathParameters postParameters = new WebPathParameters();\n\n\tprivate final Map<List<NameValuePair>, IWebResponse> getResponses = new ActivatableHashMap<List<NameValuePair>, IWebResponse>();\n\tprivate final Map<List<NameValuePair>, IWebResponse> postResponses = new ActivatableHashMap<List<NameValuePair>, IWebResponse>();\n\n\tprivate PathType pathType;\n\tprivate String mimeType;\n\t\n\tprivate transient URI cachedUri;\n\tprivate transient String cachedFullPath;\n\n\tprivate WebPath(EventListenerManager eventManager, ObjectContainer database, WebPath parentPath, String pathComponent) {\n\t\tthis(eventManager, database, parentPath, pathComponent, null);\n\t}\n\n\tWebPath(EventListenerManager eventManager, ObjectContainer database, WebPath parentPath, String pathComponent, IWebMountPoint mountPoint) {\n\t\tsuper(eventManager, database);\n\t\tthis.parentPath = parentPath;\n\t\tthis.pathComponent = pathComponent;\n\t\tthis.mountPoint = mountPoint;\n\t\tthis.pathType = PathType.PATH_UNKNOWN;\n\t}\n\n\t@Override\n\tpublic WebPath getParentPath() {\n\t\treturn parentPath;\n\t}\n\n\t@Override\n\tpublic URI getUri() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(this) {\n\t\t\tif(cachedUri == null)\n\t\t\t\tcachedUri = generateURI();\n\t\t\treturn cachedUri;\n\t\t}\n\t}\n\n\tprivate URI generateURI() {\n\t\tfinal URI hostUri = mountPoint.getWebHost().getUri();\n\t\ttry {\n\t\t\treturn new URI(hostUri.getScheme(), hostUri.getAuthority(), getFullPath(), null, null);\n\t\t} catch (URISyntaxException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getFullPath() {\n\t\tif(cachedFullPath == null)\n\t\t\tcachedFullPath = generateFullPath();\n\t\treturn cachedFullPath;\n\t}\n\n\tprivate String generateFullPath() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(parentPath == null)\n\t\t\treturn \"/\";\n\n\t\tfinal String parentFullPath = parentPath.getFullPath();\n\t\tif(parentFullPath.endsWith(\"/\"))\n\t\t\treturn parentFullPath + pathComponent;\n\t\telse\n\t\t\treturn parentFullPath + \"/\" + pathComponent;\n\t}\n\n\t@Override\n\tpublic IWebMountPoint getMountPoint() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn mountPoint;\n\t}\n\n\t@Override\n\tpublic Collection<IWebPath> getChildPaths() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(childPathMap) {\n\t\t\treturn new HashSet<IWebPath>(childPathMap.values());\n\t\t}\n\t}\n\n\tvoid setMountPoint(IWebMountPoint mountPoint) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.mountPoint = mountPoint;\n\t}\n\n\t@Override\n\tpublic boolean equals(Object other) {\n\t\tif(this == other) {\n\t\t\treturn true;\n\t\t} else if(other instanceof WebPath) {\n\t\t\tWebPath that = (WebPath) other;\n\t\t\treturn this.getMountPoint().getWebHost().equals(that.getMountPoint().getWebHost()) &&\n\t\t\t\tthis.getFullPath().equals(that.getFullPath());\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@Override\n\tpublic int hashCode() {\n\t\treturn Objects.hashCode(this.getMountPoint().getWebHost(), this.getFullPath());\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn Objects.toStringHelper(this).add(\"host\", mountPoint.getWebHost()).add(\"path\", getFullPath()).toString();\n\t}\n\n\t@Override\n\tpublic boolean isGetTarget() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn getParameters.hasParameters();\n\t}\n\n\t@Override\n\tpublic boolean isPostTarget() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn postParameters.hasParameters();\n\t}\n\n\t@Override\n\tpublic void addGetParameterList(List<NameValuePair> params) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tgetParameters.addParameterList(params);\n\t}\n\n\t@Override\n\tpublic void addPostParameterList(List<NameValuePair> params) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tpostParameters.addParameterList(params);\n\t}\n\n\t@Override\n\tpublic IWebPathParameters getGetParameters() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn getParameters;\n\t}\n\n\t@Override\n\tpublic IWebPathParameters getPostParameters() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn postParameters;\n\t}\n\n\t@Override\n\tpublic IWebPath getChildPath(String pathComponent) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(childPathMap) {\n\t\t\treturn childPathMap.get(pathComponent);\n\t\t}\n\t}\n\n\t@Override\n\tpublic WebPath addChildPath(String pathComponent) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(childPathMap) {\n\t\t\tif(childPathMap.containsKey(pathComponent))\n\t\t\t\treturn childPathMap.get(pathComponent);\n\n\t\t\tWebPath newPath = new WebPath(eventManager, database, this, pathComponent, getMountPoint());\n\n\t\t\tObjectContainer database = getDatabase();\n\t\t\tdatabase.store(newPath);\n\n\t\t\tnewPath.setDatabase(database);\n\t\t\tchildPathMap.put(pathComponent, newPath);\n\t\t\tnotifyNewEntity(newPath);\n\t\t\treturn newPath;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getPathComponent() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn pathComponent;\n\t}\n\n\t@Override\n\tpublic List<IWebResponse> getGetResponses() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(getResponses) {\n\t\t\treturn Collections.unmodifiableList(new ArrayList<IWebResponse>(getResponses.values()));\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IWebResponse> getPostResponses() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(postResponses) {\n\t\t\treturn Collections.unmodifiableList(new ArrayList<IWebResponse>(postResponses.values()));\n\t\t}\n\t}\n\n\t@Override\n\tpublic IWebEntity getParent() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tif(parentPath != null)\n\t\t\treturn parentPath;\n\t\telse if(mountPoint != null)\n\t\t\treturn mountPoint.getWebHost();\n\t\telse\n\t\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void addPostResponse(List<NameValuePair> parameters, String mimeType) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(postResponses) {\n\t\t\tmaybeAddWebResponse(postResponses, parameters, mimeType);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void addGetResponse(String query, String mimeType) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(getResponses) {\n\t\t\tmaybeAddWebResponse(getResponses, parseParameters(query), mimeType);\n\t\t}\n\t}\n\n\tprivate void maybeAddWebResponse(Map<List<NameValuePair>, IWebResponse> responseMap, List<NameValuePair> parameters, String mimeType) {\n\t\tif(responseMap.containsKey(parameters)) {\n\t\t\tfinal IWebResponse wr = responseMap.get(parameters);\n\t\t\tif(mimeType == null || mimeType.equals(wr.getMimeType()))\n\t\t\t\treturn;\n\t\t}\n\t\t// Possibly overwrite a map entry with a new entry that has same query but different mime type\n\t\tfinal IWebResponse newResponse = createWebResponse(parameters, mimeType);\n\t\tresponseMap.put(parameters, newResponse);\n\t\tnotifyNewEntity(newResponse);\n\t}\n\n\tprivate WebResponse createWebResponse(List<NameValuePair> parameters, String mimeType) {\n\t\tWebResponse response = new WebResponse(eventManager, database, this, parameters, mimeType);\n\t\tObjectContainer database = getDatabase();\n\t\tresponse.setDatabase(database);\n\t\tdatabase.store(response);\n\t\treturn response;\n\t}\n\n\tprivate static List<NameValuePair> parseParameters(String query) {\n\t\tif(query == null || query.isEmpty())\n\t\t\treturn Collections.emptyList();\n\t\tfinal List<NameValuePair> parameterList = new ArrayList<NameValuePair>();\n\t\ttry {\n\t\t\tURLEncodedUtils.parse(parameterList, new Scanner(query), \"UTF-8\");\n\t\t} catch (RuntimeException e) {\n\t\t\tparameterList.clear();\n\t\t\tparameterList.add(new BasicNameValuePair(query, null));\n\t\t}\n\t\treturn parameterList;\n\t}\n\n\t@Override\n\tpublic void setPathType(PathType type) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.pathType = type;\n\t\tcachedFullPath = null;\n\t\tcachedUri = null;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\n\t@Override\n\tpublic PathType getPathType() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn pathType;\n\t}\n\n\t@Override\n\tpublic void setMimeType(String mimeType) {\n\t\tactivate(ActivationPurpose.READ);\n\t\tthis.mimeType = mimeType;\n\t\tactivate(ActivationPurpose.WRITE);\n\t}\n\t\n\t@Override\n\tpublic String getMimeType() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn mimeType;\n\t}\n\n\t@Override\n\tpublic void accept(IWebModelVisitor visitor) {\n\t\tvisitor.visit(this);\n\t\tfor(IWebPath child: getChildPaths()) {\n\t\t\tchild.accept(visitor);\n\t\t}\n\t\tfor(IWebResponse response: getGetResponses()) {\n\t\t\tresponse.accept(visitor);\n\t\t}\n\t\tfor(IWebResponse r: getPostResponses()) {\n\t\t\tr.accept(visitor);\n\t\t}\n\t}\n\n\t@Override\n\tpublic HttpHost getHttpHost() {\n\t\treturn mountPoint.getWebHost().getHttpHost();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebPathParameters.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.apache.http.NameValuePair;\n\nimport com.db4o.activation.ActivationPurpose;\nimport com.db4o.activation.Activator;\nimport com.db4o.collections.ActivatableHashSet;\nimport com.db4o.ta.Activatable;\nimport com.subgraph.vega.api.model.web.IWebPathParameters;\n\npublic class WebPathParameters implements IWebPathParameters, Activatable {\n\t\n\tprivate transient Activator activator;\n\n\tprivate final Set<List<NameValuePair>> parameterLists;\n\t\n\tWebPathParameters() {\n\t\tthis.parameterLists = new ActivatableHashSet<List<NameValuePair>>();\n\t}\n\n\tvoid addParameterList(List<NameValuePair> params) {\n\t\tif(params.isEmpty())\n\t\t\treturn;\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(parameterLists) {\n\t\t\tif(parameterLists.contains(params))\n\t\t\t\treturn;\n\t\t\tparameterLists.add(params);\n\t\t}\n\t}\n\t\n\tpublic Collection<String> getValuesForParameter(String name) {\n\t\tfinal Set<String> valueSet = new HashSet<String>();\n\t\tfor(List<NameValuePair> params: getParameterLists()) {\n\t\t\tfor(NameValuePair pair: params) {\n\t\t\t\tif(pair.getName().equals(name)) {\n\t\t\t\t\tvalueSet.add(pair.getValue());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn valueSet;\t\t\n\t}\n\t\n\t@Override\n\tpublic boolean hasParameters() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(parameterLists) {\n\t\t\treturn !parameterLists.isEmpty();\n\t\t}\n\t}\n\n\t@Override\n\tpublic Collection<List<NameValuePair>> getParameterLists() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(parameterLists) {\n\t\t\treturn new HashSet<List<NameValuePair>>(parameterLists);\n\t\t}\n\t}\n\t@Override\n\tpublic Collection<String> getParameterNames() {\n\t\tfinal Set<String> nameSet = new HashSet<String>();\n\t\tfor(List<NameValuePair> params: getParameterLists()) {\n\t\t\tfor(NameValuePair pair: params) {\n\t\t\t\tnameSet.add(pair.getName());\n\t\t\t}\n\t\t}\n\t\treturn nameSet;\n\t}\n\t\n\t@Override\n\tpublic Collection<List<String>> getParameterNameLists() {\n\t\tfinal Set< List<String> > nameLists = new HashSet<List<String>>();\n\t\tfor(List<NameValuePair> params: getParameterLists()) {\n\t\t\tList<String> nl = new ArrayList<String>();\n\t\t\tfor(NameValuePair pair: params) {\n\t\t\t\tnl.add(pair.getName());\n\t\t\t}\n\t\t\tnameLists.add(nl);\n\t\t}\n\t\treturn nameLists;\n\t}\n\n\t@Override\n\tpublic void activate(ActivationPurpose activationPurpose) {\n\t\tif(activator != null) {\n\t\t\tactivator.activate(activationPurpose);\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic void bind(Activator activator) {\n\t\tif(this.activator == activator) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(activator != null && this.activator != null) {\n\t\t\tthrow new IllegalStateException(\"Object can only be bound to one activator\");\n\t\t}\n\t\t\n\t\tthis.activator = activator;\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/WebResponse.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.NameValuePair;\n\nimport com.db4o.ObjectContainer;\nimport com.db4o.activation.ActivationPurpose;\nimport com.subgraph.vega.api.events.EventListenerManager;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebModelVisitor;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\n\npublic class WebResponse extends WebEntity implements IWebResponse {\n\n\tprivate final IWebPath parentPath;\n\tprivate final List<NameValuePair> parameters;\n\tprivate final String mimeType;\n\t\n\tprivate transient String cachedQueryString;\n\t\n\tWebResponse(EventListenerManager eventManager, ObjectContainer database, IWebPath parentPath, List<NameValuePair> parameters, String mimeType) {\n\t\tsuper(eventManager, database);\n\t\tthis.parentPath = parentPath;\n\t\tthis.mimeType = mimeType;\n\t\tthis.parameters = parameters;\n\t\tsetVisited(true);\n\t}\n\t\n\t\n\t@Override\n\tpublic List<NameValuePair> getRequestParameters() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn Collections.unmodifiableList(parameters);\n\t}\n\n\t@Override\n\tpublic String getMimeType() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn mimeType;\n\t}\n\n\n\t@Override\n\tpublic IWebEntity getParent() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn parentPath;\n\t}\n\n\n\t@Override\n\tpublic String getQueryString() {\n\t\tactivate(ActivationPurpose.READ);\n\t\tsynchronized(this) {\n\t\t\tif(cachedQueryString == null) {\n\t\t\t\tcachedQueryString = createQueryString();\n\t\t\t}\n\t\t\treturn cachedQueryString;\n\t\t}\n\t}\n\t\n\tprivate String createQueryString() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor(NameValuePair pair: parameters) {\n\t\t\tif(sb.length() > 0)\n\t\t\t\tsb.append(\"&\");\n\t\t\tsb.append(pair.getName());\n\t\t\tif(pair.getValue() != null) {\n\t\t\t\tsb.append(\"=\");\n\t\t\t\tsb.append(pair.getValue());\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\n\t@Override\n\tpublic IWebPath getPathEntity() {\n\t\tactivate(ActivationPurpose.READ);\n\t\treturn parentPath;\n\t}\n\n\n\t@Override\n\tpublic void accept(IWebModelVisitor visitor) {\n\t\tvisitor.visit(this);\n\t}\n\n\n\t@Override\n\tpublic HttpHost getHttpHost() {\n\t\treturn parentPath.getHttpHost();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/forms/FormFiller.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web.forms;\n\nimport java.util.Set;\n\nimport com.subgraph.vega.api.model.web.forms.IWebFormField;\n\npublic class FormFiller {\n\t\n\n\tString getDefaultValue(IWebFormField field) {\n\t\tswitch(field.getType()) {\n\t\tcase INPUT_TEXT:\n\t\t\treturn getDefaultTextValue(field);\n\t\tcase INPUT_PASSWORD:\n\t\tcase INPUT_FILE:\n\t\t\treturn \"\";\n\t\tcase INPUT_HIDDEN:\n\t\t\treturn field.getValue();\n\t\tcase INPUT_RADIO:\n\t\tcase SELECT_OPTION:\n\t\tcase INPUT_CHECKBOX:\n\t\t\treturn getDefaultMultipleValue(field);\n\t\tcase TEXTAREA:\n\t\t\treturn \"Put Text here\";\n\t\t}\n\t\treturn \"foo\";\n\t}\n\t\n\tString getDefaultTextValue(IWebFormField field) {\n\t\treturn \"foo\";\n\t}\n\t\n\tString getDefaultPasswordValue(IWebFormField field) {\n\t\treturn \"foo\";\n\t}\n\t\n\tString getDefaultMultipleValue(IWebFormField field) {\n\t\tif(!field.hasMultipleValues())\n\t\t\treturn \"foo\";\n\t\t\n\t\tfinal String checkedValue = firstSetValue(field.getCheckedValues());\n\t\tif(checkedValue != null)\n\t\t\treturn checkedValue;\n\t\tfinal String oneValue = firstSetValue(field.getMultipleValues());\n\t\tif(oneValue != null)\n\t\t\treturn oneValue;\n\t\treturn \"foo\";\n\t}\n\t\n\tprivate String firstSetValue(Set<String> stringSet) {\n\t\tif(stringSet.isEmpty())\n\t\t\treturn null;\n\t\treturn stringSet.toArray(new String[0])[0];\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/forms/FormParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web.forms;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.Text;\nimport org.w3c.dom.html2.HTMLCollection;\nimport org.w3c.dom.html2.HTMLDocument;\nimport org.w3c.dom.html2.HTMLElement;\nimport org.w3c.dom.html2.HTMLFormElement;\nimport org.w3c.dom.html2.HTMLInputElement;\n\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.forms.IWebForm;\nimport com.subgraph.vega.internal.model.web.WebModel;\n\npublic class FormParser {\n\tprivate final static Logger logger = Logger.getLogger(\"forms\");\n\tprivate final WebModel model;\n\t\n\tpublic FormParser(WebModel model) {\n\t\tthis.model = model;\n\t\t\n\t}\n\t\n\tpublic Collection<IWebForm> parseForms(IWebPath source, HTMLDocument document) {\n\t\tfinal List<IWebForm> forms = new ArrayList<IWebForm>();\n\t\tfinal HTMLCollection formsCollection = document.getForms();\n\t\tfor(int i = 0; i < formsCollection.getLength(); i++) {\n\t\t\tNode n = formsCollection.item(i);\n\t\t\tif(n instanceof HTMLFormElement) {\n\t\t\t\tSystem.out.println(\"Processing a form at \"+ source);\n\t\t\t\tWebForm form = processOneFormElement(source, (HTMLFormElement) n);\n\t\t\t\tif(form != null)  {\n\t\t\t\t\tSystem.out.println(\"Adding form with action: \"+ form.getAction());\n\t\t\t\t\tforms.add(form);\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn forms;\n\t}\n\t\n\tprivate WebForm processOneFormElement(IWebPath source, HTMLFormElement formElement) {\n\t\tfinal URI action = getFormAction(source, formElement.getAction());\n\t\tif(action == null)\n\t\t\treturn null;\n\n\t\tfinal WebForm form = new WebForm(action, getFormMethod(formElement.getMethod()), getEncodingType(formElement.getEnctype()));\n\n\t\tfinal HTMLCollection formFields = formElement.getElements();\n\t\tfor(int i = 0; i < formFields.getLength(); i++) {\n\t\t\tNode fieldNode = formFields.item(i);\n\t\t\tif(fieldNode instanceof HTMLInputElement) {\n\t\t\t\tprocessFormInputField(form, (HTMLInputElement) fieldNode);\n\t\t\t} else if (fieldNode instanceof HTMLElement) {\n\t\t\t\tprocessFormHTMLElement(form, (HTMLElement) fieldNode);\n\t\t\t} else {\n\t\t\t\tlogger.warning(\"Form field not an HTMLElement\" + fieldNode);\n\t\t\t}\t\n\t\t}\n\t\t\n\t\tNodeList labelList = formElement.getElementsByTagName(\"label\");\n\t\tfor(int i = 0; i < labelList.getLength(); i++) {\n\t\t\tNode n = labelList.item(i);\n\t\t\tif(n instanceof HTMLElement) \n\t\t\t\tprocessLabelElement(form, (HTMLElement) n);\n\t\t}\n\t\treturn form;\n\t}\n\t\n\tIWebForm.FormMethod getFormMethod(String methodName) {\n\t\tif(methodName == null || !methodName.equalsIgnoreCase(\"post\")) \n\t\t\treturn IWebForm.FormMethod.METHOD_GET;\n\t\telse\n\t\t\treturn IWebForm.FormMethod.METHOD_POST;\n\t}\n\t\n\tIWebForm.EncType getEncodingType(String encodingName) {\n\t\tif(encodingName == null || !encodingName.equalsIgnoreCase(\"multipart/form-data\"))\n\t\t\treturn IWebForm.EncType.FORM_URLENCODED;\n\t\telse \n\t\t\treturn IWebForm.EncType.FORM_DATA;\n\t}\n\t\n\tURI getFormAction(IWebPath source, String action) {\n\t\tif(action == null)\n\t\t\treturn null;\n\t\t\n\t\tif(action.contains(\":\")) {\n\t\t\ttry {\n\t\t\t\tURI u = new URI(action);\n\t\t\t\tif(u.getScheme() == null || !(u.getScheme().equals(\"http\") || u.getScheme().equals(\"https\"))) {\n\t\t\t\t\tlogger.warning(\"Could not parse form action: \"+ action);\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\treturn u;\n\t\t\t} catch (URISyntaxException e) {\n\t\t\t\tlogger.warning(\"Could not parse form action : \"+ action);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\treturn source.getUri().resolve(new URI(action));\n\t\t} catch (URISyntaxException e) {\n\t\t\tlogger.warning(\"Could not parse form action: \"+ action);\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate void processFormInputField(WebForm form, HTMLInputElement input) {\n\t\tfinal String fieldType = input.getType();\n\t\tfinal String fieldName = input.getName();\n\t\tfinal String fieldValue = input.getValue();\n\t\tfinal String fieldId = input.getId();\n\t\t\n\t\t// HTML 4.01 section 17.4\n\t\t// This attribute specifies the type of control to create. The default value for this attribute is \"text\".\n\t\tif(fieldType == null || fieldType.equalsIgnoreCase(\"text\")) {\n\t\t\tform.addTextField(fieldName, fieldValue, fieldId, searchLabelText(input));\n\t\t} else if(fieldType.equalsIgnoreCase(\"password\")) {\n\t\t\tform.addPasswordField(fieldName, fieldValue, fieldId, searchLabelText(input));\n\t\t} else if(fieldType.equalsIgnoreCase(\"hidden\")) {\n\t\t\tform.addHiddenField(fieldName, fieldId, fieldValue);\n\t\t} else if(fieldType.equalsIgnoreCase(\"checkbox\")) {\n\t\t\tform.addCheckboxField(fieldName, fieldValue, fieldId, input.getChecked());\n\t\t} else if(fieldType.equalsIgnoreCase(\"radio\")) {\n\t\t\tform.addCheckboxField(fieldName, fieldValue, fieldId, input.getChecked());\n\t\t} else if(fieldType.equalsIgnoreCase(\"file\")) {\n\t\t\tform.addFileField(fieldName);\n\t\t}\n\t\tString msg = \"<input> name=\"+ input.getName() + \" type = \"+ input.getType() + \" value = \"+ input.getValue();\n\t\tlogger.warning(msg);\n\t}\n\t\n\tprivate String searchLabelText(HTMLElement elem) {\n\t\tNode n = elem;\n\t\twhile(n != null && !(n instanceof HTMLFormElement)) {\n\t\t\tNode previousNode = getPreviousNonCommentNode(n);\n\t\t\tSystem.out.println(\"previousNode: \"+ previousNode);\n\t\t\tif(previousNode != null) {\n\t\t\t\tString text = previousNode.getTextContent();\n\t\t\t\tif(text != null && text.length() != 0)\n\t\t\t\t\treturn text;\n\t\t\t}\n\t\t\tn = n.getParentNode();\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate Node getPreviousNonCommentNode(Node node) {\n\t\tNode previousNode = node.getPreviousSibling();\n\n\t\tSystem.out.println(\"CC previousNode: \"+ previousNode);\n\t\twhile(previousNode != null && (previousNode.getNodeType() == Node.COMMENT_NODE || isWhitespaceTextNode(previousNode))) \n\t\t\tpreviousNode = previousNode.getPreviousSibling();\n\t\t\t\n\t\treturn previousNode;\n\t}\n\t\n\tprivate boolean isWhitespaceTextNode(Node node) {\n\t\tif(!(node instanceof Text))\n\t\t\treturn false;\n\t\tfinal Text text = (Text) node;\n\t\treturn text.isElementContentWhitespace();\n\t}\n\t\n\tprivate void processFormHTMLElement(WebForm form, HTMLElement elem) {\n\t\tfinal String tag = elem.getTagName();\n\t\tif(tag != null && tag.equalsIgnoreCase(\"TEXTAREA\")) {\n\t\t\tform.addTextArea(elem.getAttribute(\"name\"), elem.getAttribute(\"value\"));\n\t\t} else {\n\t\t\tlogger.warning(\"Failed to parse HTMLElement in form: \"+ elem.getTagName());\n\t\t}\n\t}\n\t\n\tprivate void processLabelElement(WebForm form, HTMLElement label) {\n\t\tif(label.getTagName() == null || !label.getTagName().equals(\"LABEL\"))\n\t\t\treturn;\n\t\tString id = label.getAttribute(\"id\");\n\t\tif(id == null)\n\t\t\treturn;\n\t\tString content = label.getTextContent();\n\t\tif(content == null || content.trim().isEmpty())\n\t\t\treturn;\n\t\tform.addLabelToField(id, content);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/forms/WebForm.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web.forms;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.model.web.forms.IWebForm;\nimport com.subgraph.vega.api.model.web.forms.IWebFormField;\nimport com.subgraph.vega.api.model.web.forms.IWebFormField.FieldType;\n\npublic class WebForm implements IWebForm {\n\tprivate final static Logger logger = Logger.getLogger(\"forms\");\n\tprivate final URI action;\n\tprivate final FormMethod method;\n\tprivate final EncType encoding;\n\t\n\tprivate final Map<String, WebFormField> fields;\n\n\tWebForm(URI action, FormMethod method, EncType encoding) {\n\t\tthis.action = action;\n\t\tthis.method = method;\n\t\tthis.encoding = encoding;\n\t\tthis.fields = new HashMap<String, WebFormField>();\n\t}\t\n\n\t@Override\n\tpublic EncType getEncodingType() {\n\t\treturn encoding;\n\t}\n\n\t@Override\n\tpublic FormMethod getMethod() {\n\t\treturn method;\n\t}\t\n\t\n\t@Override\n\tpublic URI getAction() {\n\t\treturn action;\n\t}\n\n\t@Override\n\tpublic Collection<IWebFormField> getFields() {\n\t\treturn new ArrayList<IWebFormField>(fields.values());\n\t}\n\t\n\tvoid addTextField(String name, String value, String id, String label) {\n\t\tSystem.out.println(\"Text field name = \"+ name + \" value = \"+ value + \" label = \"+ label);\n\t\tfinal WebFormField field = new WebFormField(FieldType.INPUT_TEXT, name, value, id);\n\t\tif(label != null && label.length() > 0)\n\t\t\tfield.setLabel(label);\n\t\tfields.put(name, field);\n\t}\n\t\n\tvoid addPasswordField(String name, String value, String id, String label) {\n\t\tSystem.out.println(\"Password field name = \"+ name + \" value = \"+ value + \" label = \"+ label);\n\t\tfinal WebFormField field = new WebFormField(FieldType.INPUT_PASSWORD, name, value, id);\n\t\tif(label != null && label.length() > 0)\n\t\t\tfield.setLabel(label);\n\t\tfields.put(name, field);\n\t}\n\t\n\tvoid addCheckboxField(String name, String value, String id, boolean checked) {\n\t\tif(!fields.containsKey(name)) \n\t\t\tfields.put(name, new WebFormField(FieldType.INPUT_CHECKBOX, name, null, id));\n\t\tfinal WebFormField f = fields.get(name);\n\t\tif(f.getType() != FieldType.INPUT_CHECKBOX) {\n\t\t\tlogger.warning(\"Cannot add checkbox field because field name \"+ name +\" is duplicated\");\n\t\t\treturn;\n\t\t}\n\t\tf.addValue(value, checked);\t\t\n\t}\n\t\n\tvoid addRadioField(String name, String value, String id, boolean checked) {\n\t\tif(!fields.containsKey(name))\n\t\t\tfields.put(name, new WebFormField(FieldType.INPUT_RADIO, name, null, id));\n\t\tfinal WebFormField f = fields.get(name);\n\t\tif(f.getType() != FieldType.INPUT_RADIO) {\n\t\t\tlogger.warning(\"Cannot add radio field because field name \"+ name + \" is duplicated\");\n\t\t\treturn;\n\t\t}\n\t\tf.addValue(value, checked);\t\n\t}\n\t\n\tvoid addHiddenField(String name, String value, String id) {\n\t\tfields.put(name, new WebFormField(FieldType.INPUT_HIDDEN, name, value, id));\n\t}\n\t\n\tvoid addFileField(String name) {\n\t\tfields.put(name, new WebFormField(FieldType.INPUT_FILE, name, null, null));\n\t}\n\t\n\tvoid addSelectOption(String name, String value, boolean multiple) {\n\t\t\n\t}\n\t\n\tvoid addTextArea(String name, String value) {\n\t\tfields.put(name, new WebFormField(FieldType.TEXTAREA, name, value, null));\n\t}\n\t\n\tvoid addLabelToField(String fieldId, String label) {\n\t\tfor(WebFormField field: fields.values()) {\n\t\t\tif(field.getId() != null && field.getId().equalsIgnoreCase(fieldId)) {\n\t\t\t\tfield.setLabel(label);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tlogger.warning(\"Could not find corresponding field element with id = \"+ fieldId + \" for <LABEL> content \"+ label);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.model/src/com/subgraph/vega/internal/model/web/forms/WebFormField.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.model.web.forms;\n\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport com.subgraph.vega.api.model.web.forms.IWebFormField;\n\npublic class WebFormField implements IWebFormField {\n\n\tprivate final FieldType type;\n\tprivate final String name;\n\tprivate final String value;\n\tprivate final String id;\n\tprivate final Set<String> multipleValues;\n\tprivate final Set<String> checkedValues;\n\tprivate String label;\n\t\n\tWebFormField(FieldType type, String name, String value, String id) {\n\t\tthis.type = type;\n\t\tthis.name = name;\n\t\tthis.value = value;\n\t\tthis.id = id;\n\t\tif(type == FieldType.INPUT_CHECKBOX || type == FieldType.INPUT_RADIO || type == FieldType.SELECT_OPTION) {\n\t\t\tthis.multipleValues = new HashSet<String>();\n\t\t\tthis.checkedValues = new HashSet<String> ();\n\t\t}\n\t\telse {\n\t\t\tthis.multipleValues = null;\n\t\t\tthis.checkedValues = null;\n\t\t}\n\t}\n\t\n\tvoid addValue(String value, boolean checked) {\n\t\tif(multipleValues == null) \n\t\t\tthrow new IllegalStateException();\n\t\tmultipleValues.add(value);\n\t\tif(checked)\n\t\t\tcheckedValues.add(value);\n\t}\n\t\n\tvoid setLabel(String label) {\n\t\tthis.label = label;\n\t}\n\t\n\tString getLabel() {\n\t\treturn label;\n\t}\n\n\t@Override\n\tpublic FieldType getType() {\n\t\treturn type;\n\t}\n\t\n\t@Override\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic String getValue() {\n\t\treturn value;\n\t}\n\t\n\tString getId() {\n\t\treturn id;\n\t}\n\n\t@Override\n\tpublic boolean hasMultipleValues() {\n\t\treturn multipleValues != null;\n\t}\n\n\t@Override\n\tpublic Set<String> getMultipleValues() {\n\t\treturn multipleValues;\n\t}\n\n\t@Override\n\tpublic Set<String> getCheckedValues() {\n\t\treturn checkedValues;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.scanner</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/.settings/org.eclipse.pde.core.prefs",
    "content": "#Mon Sep 27 12:53:16 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Scanner\nBundle-SymbolicName: com.subgraph.vega.scanner\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.google.common.base,\n com.subgraph.vega.api.analysis,\n com.subgraph.vega.api.crawler,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.html,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.identity,\n com.subgraph.vega.api.model.macros,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.scope,\n com.subgraph.vega.api.model.variables,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.util,\n com.subgraph.vega.http.requests.custom,\n com.subgraph.vega.sslprobe,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client,\n org.apache.http.client.entity,\n org.apache.http.client.methods,\n org.apache.http.client.utils,\n org.apache.http.message;version=\"4.0.0\",\n org.apache.http.params;version=\"4.1.0\",\n org.apache.http.protocol;version=\"4.0.0\",\n org.apache.http.util;version=\"4.1.0\",\n org.jsoup.nodes,\n org.w3c.dom.html2\nService-Component: OSGI-INF/scanner-factory.xml\nRequire-Bundle: org.apache.http.client;bundle-version=\"4.2.2\",\n com.google.guava\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/OSGI-INF/scanner-factory.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"com.subgraph.vega.scanner\">\n   <implementation class=\"com.subgraph.vega.impl.scanner.Scanner\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.scanner.IScanner\"/>\n   </service>\n   <reference bind=\"setCrawlerFactory\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.crawler.IWebCrawlerFactory\" name=\"IWebCrawlerFactory\" policy=\"static\" unbind=\"unsetCrawlerFactory\"/>\n   <reference bind=\"setRequestEngineFactory\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory\" name=\"IHttpRequestEngineFactory\" policy=\"static\" unbind=\"unsetRequestEngineFactory\"/>\n   <reference bind=\"setModuleRegistry\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry\" name=\"IScannerModuleRegistry\" policy=\"static\" unbind=\"unsetModuleRegistry\"/>\n   <reference bind=\"setModel\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.model.IModel\" name=\"IModel\" policy=\"static\" unbind=\"unsetModel\"/>\n   <reference bind=\"setContentAnalyzerFactory\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.analysis.IContentAnalyzerFactory\" name=\"IContentAnalyzerFactory\" policy=\"static\" unbind=\"unsetContentAnalyzerFactory\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/ProxyScan.java",
    "content": "package com.subgraph.vega.impl.scanner;\n\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.params.HttpProtocolParams;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.requests.IRequestOriginScanner;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.api.scanner.IProxyScan;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.impl.scanner.urls.UriFilter;\nimport com.subgraph.vega.impl.scanner.urls.UriParser;\n\npublic class ProxyScan implements IProxyScan {\n\tprivate final Logger logger = Logger.getLogger(\"scanner\");\n\tprivate final IWorkspace workspace;\n\tprivate final CookieStore cookieStore;\n\tprivate final Scanner scanner;\n\tprivate final IScanInstance scanInstance;\n\tprivate final IScannerConfig config;\n\tprivate  IWebCrawler crawler;\n\tprivate UriParser uriParser;\n\t\n\tprivate List<IBasicModuleScript> basicModules;\n\tprivate Object startLock = new Object();\n\tprivate boolean isStarted = false;\n\t\n\tProxyScan(IWorkspace workspace, CookieStore cookieStore, Scanner scanner) {\n\t\tthis.workspace = workspace;\n\t\tthis.cookieStore = cookieStore;\n\t\tthis.scanner = scanner;\n\t\tthis.scanInstance = workspace.getScanAlertRepository().getScanInstanceByScanId(IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID);\n\t\tthis.config = new ScannerConfig();\n\t\treloadModules();\n\t\tlogger.setLevel(Level.ALL);\n\t}\n\n\t@Override\n\tpublic IScannerConfig getConfig() {\n\t\treturn config;\n\t}\n\n\t@Override\n\tpublic void scanGetTarget(VegaURI target, List<NameValuePair> parameters) {\n\t\tsynchronized (startLock) {\n\t\t\tif(!isStarted) {\n\t\t\t\tstart();\n\t\t\t}\n\t\t}\n\t\tfinal IPathState ps = uriParser.processUri(stripQuery(target));\n\t\tps.maybeAddParameters(parameters);\n\t}\n\n\t@Override\n\tpublic void scanPostTarget(VegaURI target, List<NameValuePair> parameters) {\n\t\tsynchronized (startLock) {\n\t\t\tif(!isStarted) {\n\t\t\t\tstart();\n\t\t\t}\n\t\t}\n\t\tfinal IPathState ps = uriParser.processUri(stripQuery(target));\n\t\tps.maybeAddPostParameters(parameters);\n\t}\n\t\n\tprivate VegaURI stripQuery(VegaURI uri) {\n\t\tif(uri.getQuery() != null) {\n\t\t\treturn new VegaURI(uri.getTargetHost(), uri.getPath(), null);\n\t\t} else {\n\t\t\treturn uri;\n\t\t}\n\t}\n\t\t\n\t@Override\n\tpublic void stop() {\n\t\tsynchronized (startLock) {\n\t\t\tif(!isStarted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tcrawler.stop();\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\tthrow new RuntimeException(\"Attempt to stop proxy scan crawler was interrupted\", e);\n\t\t\t}\n\t\t\tcrawler = null;\n\t\t\turiParser = null;\n\t\t\tisStarted = false;\n\t\t}\n\t}\n\t\n\t// Called holding startLock\n\tprivate void start() {\n\t\tif(isStarted) {\n\t\t\treturn;\n\t\t}\n\t\tcrawler = createWebCrawler();\n\t\turiParser = createUriParser(crawler);\n\t\tcrawler.start();\n\t\tisStarted = true;\n\t\treloadModules();\n\t}\n\t\n\tprivate UriParser createUriParser(IWebCrawler crawler) {\n\t\tfinal IContentAnalyzer contentAnalyzer = scanner.getContentAnalyzerFactory().createContentAnalyzer(scanInstance);\n\t\treturn new UriParser(config,\n\t\t\t\tbasicModules,\n\t\t\t\tworkspace,\n\t\t\t\tcrawler,\n\t\t\t\tnew UriFilter(config),\n\t\t\t\tcontentAnalyzer,\n\t\t\t\tscanInstance,\n\t\t\t\ttrue);\n\t}\n\t\n\tprivate IWebCrawler createWebCrawler() {\n\t\tfinal IWebCrawler webCrawler = scanner.getWebCrawlerFactory().create(createRequestEngine(config));\n\t\twebCrawler.setStopOnEmptyQueue(false);\n\t\treturn webCrawler;\n\t}\n\n\tprivate IHttpRequestEngine createRequestEngine(IScannerConfig config) {\n\t\tfinal IHttpRequestEngineFactory factory = scanner.getHttpRequestEngineFactory();\n\t\tfinal IHttpRequestEngineConfig requestEngineConfig = factory.createConfig();\n\t\tif (config.getCookieList() != null && !config.getCookieList().isEmpty()) {\n\t\t\tfor (Cookie c: config.getCookieList()) {\n\t\t\t\tcookieStore.addCookie(c);\n\t\t\t}\n\t\t}\t\t\n\n\t\tif(config.getMaxRequestsPerSecond() > 0) {\n\t\t\trequestEngineConfig.setRequestsPerMinute(config.getMaxRequestsPerSecond() * 60);\n\t\t}\n\t\trequestEngineConfig.setMaxConnections(config.getMaxConnections());\n\t\trequestEngineConfig.setMaxConnectionsPerRoute(config.getMaxConnections());\n\t\trequestEngineConfig.setMaximumResponseKilobytes(config.getMaxResponseKilobytes());\n\t\t\n\t\tfinal IRequestOriginScanner requestOrigin = workspace.getRequestLog().getRequestOriginScanner(scanInstance);\n\t\tfinal IHttpRequestEngine requestEngine = factory.createRequestEngine(IHttpRequestEngine.EngineConfigType.CONFIG_SCANNER, requestEngineConfig, requestOrigin);\n\t\tHttpProtocolParams.setUserAgent(requestEngine.getHttpClient().getParams(), config.getUserAgent());\n\t\trequestEngine.setCookieStore(cookieStore);\n\t\t// REVISIT: consider moving authentication method to request engine config\n\t\tIIdentity identity = config.getScanIdentity();\n\t\tif (identity != null && identity.getAuthMethod() != null) {\n\t\t\tidentity.getAuthMethod().setAuth(requestEngine);\n\t\t}\n\n\t\treturn requestEngine;\n\t}\n\n\t@Override\n\tpublic List<IBasicModuleScript> getInjectionModules() {\n\t\treturn Collections.unmodifiableList(basicModules);\n\t}\n\t\n\t@Override\n\tpublic void reloadModules() {\n\t\tfinal IScannerModuleRegistry moduleRegistry = scanner.getScannerModuleRegistry();\n\t\tif(basicModules == null) {\n\t\t\tbasicModules = moduleRegistry.getBasicModules();\n\t\t} else {\n\t\t\tbasicModules = moduleRegistry.updateBasicModules(basicModules);\n\t\t}\n\t\tif(uriParser != null) {\n\t\t\turiParser.updateInjectionModules(basicModules);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/Scan.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.client.CookieStore;\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.params.HttpProtocolParams;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineConfig;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.requests.IRequestOriginScanner;\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.api.scanner.IScanProbeResult;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\nimport com.subgraph.vega.sslprobe.SSLProbe;\n\npublic class Scan implements IScan {\n\tprivate final Scanner scanner;\n\tprivate final IEventHandler workspaceListener;\n\tprivate final IScannerConfig config;\n\tprivate IScanInstance scanInstance; // guarded by this\n\tprivate IWorkspace workspace; // guarded by this\n\tprivate ScanProbe scanProbe; // guarded by this\n\tprivate SSLProbe sslProbe; \n\tprivate IHttpRequestEngine requestEngine; // guarded by this\n\tprivate ScannerTask scannerTask; // guarded by this\n\tprivate Thread scannerThread; // guarded by this\n\tprivate URI redirectURI = null;\n\tprivate List<IResponseProcessingModule> responseProcessingModules;\n\tprivate List<IBasicModuleScript> basicModules;\n\n\t/**\n\t * Instantiate a scan.\n\t * @param scanner Scanner the scan will be run with.\n\t * @param workspace Workspace to be used for the scan.\n\t * @return Scan.\n\t */\n\tpublic static Scan createScan(Scanner scanner, IWorkspace workspace) {\n\t\tif (workspace == null) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal Scan scan = new Scan(scanner);\n\t\tscan.setWorkspace(workspace);\n\t\tscan.reloadModules();\n\t\treturn scan;\n\t}\n\n\tprivate Scan(Scanner scanner) {\n\t\tthis.scanner = scanner;\n\t\tworkspaceListener = new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceCloseEvent || event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceCloseOrReset();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tconfig = new ScannerConfig();\n\t}\n\n\tprivate void setWorkspace(IWorkspace workspace) {\n\t\tsynchronized(this) {\n\t\t\tworkspace.lock();\n\t\t\tthis.workspace = workspace;\n\t\t\tworkspace.getModel().addWorkspaceListener(workspaceListener);\n\t\t\tscanInstance = workspace.getScanAlertRepository().createNewScanInstance();\n\t\t\tscanInstance.setScan(this);\n\t\t}\n\t}\n\n\tprivate void handleWorkspaceCloseOrReset() {\n\t\tsynchronized(this) {\n\t\t\tscanInstance = null;\n\t\t\tworkspace.getModel().removeWorkspaceListener(workspaceListener);\n\t\t\tworkspace = null;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic IScannerConfig getConfig() {\n\t\treturn config;\n\t}\n\n\t@Override\n\tpublic List<IScannerModule> getModuleList() {\n\t\tsynchronized(this) {\n\t\t\treloadModules();\n\t\t\tfinal List<IScannerModule> moduleList = new ArrayList<IScannerModule>();\n\t\t\tmoduleList.addAll(responseProcessingModules);\n\t\t\tmoduleList.addAll(basicModules);\n\t\t\treturn moduleList;\n\t\t}\n\t}\n\n\t@Override\n\tpublic IScanProbeResult probeTargetUri(URI uri) {\n\t\tsynchronized(this) {\n\t\t\tif (scanInstance == null) {\n\t\t\t\tthrow new IllegalStateException(\"Scan is detached from workspace; scan instance was lost. A new scan must be created\");\n\t\t\t}\n\n\t\t\tsynchronized(scanInstance) {\n\t\t\t\tfinal int scanStatus = scanInstance.getScanStatus();\n\t\t\t\tif (scanStatus != IScanInstance.SCAN_CONFIG) {\n\t\t\t\t\tif (scanStatus != IScanInstance.SCAN_PROBING) {\n\t\t\t\t\t\tthrow new IllegalStateException(\"Unable to run a probe for a scan that is already running or complete\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (scanProbe != null) {\n\t\t\t\t\t\t\tthrow new IllegalStateException(\"Another probe is already in progress\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trequestEngine = createRequestEngine(config);\n\t\t\t\t\tworkspace.getScanAlertRepository().addActiveScanInstance(scanInstance);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tscanInstance.updateScanStatus(IScanInstance.SCAN_PROBING);\n\t\t\t}\n\t\t\t\n\t\t\tscanProbe = new ScanProbe(uri, requestEngine);\n\t\t\t\n\t\t\tif (uri.getScheme().contains(\"https\")) {\n\t\t\t\tint sslPort;\n\t\t\t\tString httpHostString;\n\t\t\t\t\n\t\t\t\tif (uri.getPort() == -1) {\n\t\t\t\t\tsslPort = 443;\n\t\t\t\t\thttpHostString = \"https://\" + uri.getHost();\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tsslPort = uri.getPort();\n\t\t\t\t\thttpHostString = \"https://\" + uri.getHost() + \":\" + sslPort;\n\t\t\t\t}\n\t\t\t\tsslProbe = new SSLProbe(scanInstance, uri.getHost(), sslPort, httpHostString);\n\t\t\t\tsslProbe.run();\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfinal IScanProbeResult probeResult = scanProbe.runProbe();\n\t\tsynchronized(this) {\n\t\t\tscanProbe = null;\n\t\t}\n\t\tredirectURI = probeResult.getRedirectTarget();\n\t\treturn probeResult;\n\t}\n\t\n\t@Override\n\tpublic void startScan() {\n\t\tsynchronized(this) {\n\t\t\tif (scanInstance == null) {\n\t\t\t\tthrow new IllegalStateException(\"Scan is detached from workspace; scan instance was lost. A new scan must be created\");\n\t\t\t}\n\n\t\t\tif (config.getScanTargetScope() == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"Cannot start scan because no target was specified\");\n\t\t\t}\n\n\t\t\tsynchronized(scanInstance) {\n\t\t\t\tfinal int scanStatus = scanInstance.getScanStatus();\n\t\t\t\tif (scanStatus != IScanInstance.SCAN_CONFIG) {\n\t\t\t\t\tif (scanStatus != IScanInstance.SCAN_PROBING) {\n\t\t\t\t\t\tthrow new IllegalStateException(\"Scan is already running or complete\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (scanProbe != null) {\n\t\t\t\t\t\t\tthrow new IllegalStateException(\"A scan probe is in progress\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trequestEngine = createRequestEngine(config);\n\t\t\t\t\tworkspace.getScanAlertRepository().addActiveScanInstance(scanInstance);\n\t\t\t\t}\n\n\t\t\t\tscanInstance.updateScanStatus(IScanInstance.SCAN_STARTING);\n\t\t\t}\n\n\t\t\treloadModules();\n\t\t\tscannerTask = new ScannerTask(this);\n\t\t\tscannerThread = new Thread(scannerTask);\n\t\t\tscannerThread.start();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void stopScan() {\n\t\tsynchronized(this) {\n\t\t\tif(scannerTask != null) {\n\t\t\t\tscannerTask.stop();\n\t\t\t} else {\n\t\t\t\tif(scanProbe != null) {\n\t\t\t\t\tscanProbe.abort();\n\t\t\t\t}\n\n\t\t\t\tif (scanInstance != null) {\n\t\t\t\t\tsynchronized(scanInstance) {\n\t\t\t\t\t\tif (scanInstance.getScanStatus() != IScanInstance.SCAN_CONFIG) {\n\t\t\t\t\t\t\tscanInstance.updateScanStatus(IScanInstance.SCAN_CANCELLED);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdoFinish();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate IHttpRequestEngine createRequestEngine(IScannerConfig config) {\n\t\tfinal IHttpRequestEngineFactory requestEngineFactory = scanner.getHttpRequestEngineFactory();\n\t\tfinal IHttpRequestEngineConfig requestEngineConfig = requestEngineFactory.createConfig();\n\n\t\tif (config.getMaxRequestsPerSecond() > 0) {\n\t\t\trequestEngineConfig.setRequestsPerMinute(config.getMaxRequestsPerSecond() * 60);\n\t\t}\n\t\trequestEngineConfig.setMaxConnections(config.getMaxConnections());\n\t\trequestEngineConfig.setMaxConnectionsPerRoute(config.getMaxConnections());\n\t\trequestEngineConfig.setMaximumResponseKilobytes(config.getMaxResponseKilobytes());\n\t\t\n\t\tfinal IRequestOriginScanner requestOrigin = workspace.getRequestLog().getRequestOriginScanner(scanInstance);\n\t\tIHttpRequestEngine requestEngine = requestEngineFactory.createRequestEngine(IHttpRequestEngine.EngineConfigType.CONFIG_SCANNER, requestEngineConfig, requestOrigin);\n\t\tHttpProtocolParams.setUserAgent(requestEngine.getHttpClient().getParams(), config.getUserAgent());\n\t\t// REVISIT: consider moving authentication method to request engine config\n\t\tIIdentity identity = config.getScanIdentity();\n\t\tif (identity != null && identity.getAuthMethod() != null) {\n\t\t\tidentity.getAuthMethod().setAuth(requestEngine);\n\t\t}\n\t\t\n\t\tif (config.getCookieList() != null && !config.getCookieList().isEmpty()) {\n\t\t\tCookieStore cookieStore = requestEngine.getCookieStore();\n\t\t\tfor (Cookie c: config.getCookieList()) {\n\t\t\t\tcookieStore.addCookie(c);\n\t\t\t}\n\t\t}\t\t\n\n\t\treturn requestEngine;\n\t}\n\n\tprivate void reloadModules() {\n\t\tIScannerModuleRegistry moduleRegistry = scanner.getScannerModuleRegistry();\n\t\tif(responseProcessingModules == null || basicModules == null) {\n\t\t\tresponseProcessingModules = moduleRegistry.getResponseProcessingModules();\n\t\t\tbasicModules = moduleRegistry.getBasicModules();\n\t\t} else {\n\t\t\tresponseProcessingModules = moduleRegistry.updateResponseProcessingModules(responseProcessingModules);\n\t\t\tbasicModules = moduleRegistry.updateBasicModules(basicModules);\n\t\t}\n\t}\n\n\tpublic Scanner getScanner() {\n\t\treturn scanner;\n\t}\n\n\tpublic synchronized IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n\n\tpublic synchronized IWorkspace getWorkspace() {\n\t\treturn workspace;\n\t}\n\n\tpublic synchronized List<IResponseProcessingModule> getResponseModules() {\n\t\treturn responseProcessingModules;\n\t}\n\t\n\tpublic synchronized List<IBasicModuleScript> getBasicModules() {\n\t\treturn basicModules;\n\t}\n\n\tpublic synchronized IHttpRequestEngine getRequestEngine() {\n\t\treturn requestEngine;\n\t}\n\n\tpublic void doFinish() {\n\t\tsynchronized(this) {\n\t\t\tscanInstance.setScan(null);\n\t\t\tworkspace.getScanAlertRepository().removeActiveScanInstance(scanInstance);\n\t\t\tworkspace.unlock();\n\t\t}\n\t}\n\n\tpublic URI getRedirectURI() {\n\t\treturn redirectURI;\n\t}\n\n\t@Override\n\tpublic void pauseScan() {\n\t\tif(scannerTask != null) {\n\t\t\tscannerTask.pauseScan();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void unpauseScan() {\n\t\tif(scannerTask != null) {\n\t\t\tscannerTask.unpauseScan();\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isPausedScan() {\n\t\tif(scannerTask != null) {\n\t\t\treturn scannerTask.isPaused();\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/ScanProbe.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner;\n\nimport java.net.URI;\n\nimport org.apache.http.Header;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.util.EntityUtils;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.RequestEngineException;\nimport com.subgraph.vega.api.scanner.IScanProbeResult;\n\npublic class ScanProbe {\n\tprivate final static int MAX_REDIRECT_COUNT = 5;\n\tprivate final URI targetURI;\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate volatile HttpUriRequest currentRequest;\n\t\n\tScanProbe(URI targetURI, IHttpRequestEngine requestEngine) {\n\t\tthis.targetURI = targetURI;\n\t\tthis.requestEngine = requestEngine;\n\t}\n\t\n\tIScanProbeResult runProbe() {\n\t\tcurrentRequest = requestEngine.createGetRequest(URIUtils.extractHost(targetURI), getPathAndQuery(targetURI));\n\t\ttry {\n\t\t\tIHttpResponse response = requestEngine.sendRequest(currentRequest).get(true);\n\t\t\treturn processFirstProbeResponse(targetURI, response);\n\t\t} catch (RequestEngineException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn ScanProbeResult.createConnectFailedResult(e.getMessage());\n\t\t}\n\t}\n\tprivate String getPathAndQuery(URI uri) {\n\t\tif(uri.getQuery() != null) {\n\t\t\treturn uri.getPath() + '?' + uri.getQuery();\n\t\t} else {\n\t\t\treturn uri.getPath();\n\t\t}\n\t}\n\tprivate IScanProbeResult processFirstProbeResponse(URI targetURI, IHttpResponse response) {\n\t\tif(isResponseRedirect(response)) {\n\t\t\treturn processRedirect(targetURI, response);\n\t\t}\n\t\treturn ScanProbeResult.createOkResult();\n\t}\n\n\tprivate boolean isResponseRedirect(IHttpResponse response) {\n\t\tfinal int code = response.getResponseCode();\n\t\treturn (code == 301 || code == 302 || code == 303 || code == 307);\n\t}\n\n\tprivate IScanProbeResult processRedirect(URI originalTarget, IHttpResponse response) {\n\t\tint redirectCount = 1;\n\t\t\n\t\twhile(redirectCount < MAX_REDIRECT_COUNT) {\n\t\t\tURI location = getLocationURI(response);\n\n\t\t\tif(location == null) {\n\t\t\t\tfinal String msg = \"Target address redirected to a location which could not be understood\";\n\t\t\t\treturn ScanProbeResult.createRedirectFailedResult(msg);\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tcurrentRequest = requestEngine.createGetRequest(URIUtils.extractHost(location), getPathAndQuery(location));\n\t\t\t\tresponse = requestEngine.sendRequest(currentRequest).get(true);\n\t\t\t\tEntityUtils.consumeQuietly(response.getRawResponse().getEntity());\n\t\t\t\tif(!isResponseRedirect(response)) {\n\t\t\t\t\treturn ScanProbeResult.createRedirectResult(location);\n\t\t\t\t}\n\t\t\t} catch (RequestEngineException e) {\n\t\t\t\treturn ScanProbeResult.createRedirectFailedResult(createRedirectExceptionMessage(originalTarget, location, e));\n\t\t\t}\n\t\t\tredirectCount += 1;\n\t\t}\n\t\treturn ScanProbeResult.createConnectFailedResult(\"Could not connect to target because maximum redirection limit reached\");\n\t}\n\n\tprivate String createRedirectExceptionMessage(URI targetURI, URI location, Exception e) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tsb.append(\"Target address \");\n\t\tsb.append(targetURI.toString());\n\t\tsb.append(\" redirected to address \");\n\t\tsb.append(location.toString());\n\t\tsb.append(\" which was not reachable\");\n\t\tsb.append(e.getMessage());\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate URI getLocationURI(IHttpResponse response) {\n\t\tfinal Header locationHeader = response.getRawResponse().getFirstHeader(\"Location\");\n\t\t\n\t\tif(locationHeader == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn response.getRequestUri().resolve(locationHeader.getValue());\n\t}\n\t    \n\t\t\n\tvoid abort() {\n\t\tfinal HttpUriRequest get = currentRequest;\n\t\tif(get != null) {\n\t\t\tget.abort();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/ScanProbeResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner;\n\nimport java.net.URI;\n\nimport com.subgraph.vega.api.scanner.IScanProbeResult;\n\npublic class ScanProbeResult implements IScanProbeResult {\n\n\tstatic ScanProbeResult createOkResult() {\n\t\treturn new ScanProbeResult(ProbeResultType.PROBE_OK, null, null);\n\t}\n\n\tstatic ScanProbeResult createConnectFailedResult(String message) {\n\t\treturn new ScanProbeResult(ProbeResultType.PROBE_CONNECT_FAILED, message, null);\n\t}\n\n\tstatic ScanProbeResult createRedirectFailedResult(String message) {\n\t\treturn new ScanProbeResult(ProbeResultType.PROBE_REDIRECT_FAILED, message, null);\n\t}\n\n\tstatic ScanProbeResult createRedirectResult(URI redirectURI) {\n\t\treturn new ScanProbeResult(ProbeResultType.PROBE_REDIRECT, null, redirectURI);\n\t}\n\n\tprivate final ProbeResultType resultType;\n\tprivate final String failureMessage;\n\tprivate final URI redirectTarget;\n\t\n\tprivate ScanProbeResult(ProbeResultType resultType, String failureMessage, URI redirectTarget) {\n\t\tthis.resultType = resultType;\n\t\tthis.failureMessage = failureMessage;\n\t\tthis.redirectTarget = redirectTarget;\n\t}\n\n\t@Override\n\tpublic ProbeResultType getProbeResultType() {\n\t\treturn resultType;\n\t}\n\n\t@Override\n\tpublic URI getRedirectTarget() {\n\t\treturn redirectTarget;\n\t}\n\n\t@Override\n\tpublic String getFailureMessage() {\n\t\treturn failureMessage;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/Scanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner;\n\nimport org.apache.http.client.CookieStore;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzerFactory;\nimport com.subgraph.vega.api.crawler.IWebCrawlerFactory;\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.scanner.IProxyScan;\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.api.scanner.IScanner;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\n\npublic class Scanner implements IScanner {\n\tprivate IModel model;\n\tprivate IWebCrawlerFactory crawlerFactory;\n\tprivate IHttpRequestEngineFactory requestEngineFactory;\n\tprivate IScannerModuleRegistry moduleRegistry;\n\tprivate IWorkspace currentWorkspace;\n\tprivate IContentAnalyzerFactory contentAnalyzerFactory;\n\n\tprotected void activate() {\n\t\tcurrentWorkspace = model.addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprotected void deactivate() {\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tthis.currentWorkspace = event.getWorkspace();\n\t}\n\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tthis.currentWorkspace = event.getWorkspace();\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tthis.currentWorkspace = null;\n\t}\n\n\t@Override\n\tpublic IScan createScan() {\n\t\treturn Scan.createScan(this, currentWorkspace);\n\t}\n\t\n\t@Override\n\tpublic IProxyScan createProxyScan(IWorkspace workspace, CookieStore cookieStore) {\n\t\treturn new ProxyScan(workspace, cookieStore, this);\n\t}\n\n\t@Override\n\tpublic void runDomTests() {\n\t\tmoduleRegistry.runDomTests();\n\t}\n\t\n\tprotected void setCrawlerFactory(IWebCrawlerFactory crawlerFactory) {\n\t\tthis.crawlerFactory = crawlerFactory;\n\t}\n\t\n\tprotected void unsetCrawlerFactory(IWebCrawlerFactory crawlerFactory) {\n\t\tthis.crawlerFactory = null;\n\t}\n\t\n\tprotected void setRequestEngineFactory(IHttpRequestEngineFactory factory) {\n\t\tthis.requestEngineFactory = factory;\n\t}\n\t\n\tprotected void unsetRequestEngineFactory(IHttpRequestEngineFactory factory) {\n\t\tthis.requestEngineFactory = null;\n\t}\n\t\n\tprotected void setModuleRegistry(IScannerModuleRegistry registry) {\n\t\tthis.moduleRegistry = registry;\n\t}\n\t\n\tprotected void unsetModuleRegistry(IScannerModuleRegistry registry) {\n\t\tthis.moduleRegistry = null;\n\t}\n\t\n\tprotected void setModel(IModel model) {\n\t\tthis.model = model;\n\t}\n\t\n\tprotected void unsetModel(IModel model) {\n\t\tthis.model = null;\n\t}\n\t\n\tprotected void setContentAnalyzerFactory(IContentAnalyzerFactory factory) {\n\t\tthis.contentAnalyzerFactory = factory;\n\t}\n\n\tprotected void unsetContentAnalyzerFactory(IContentAnalyzerFactory factory) {\n\t\tthis.contentAnalyzerFactory = null;\n\t}\n\n\tpublic IWebCrawlerFactory getWebCrawlerFactory() {\n\t\treturn crawlerFactory;\n\t}\n\t\n\tpublic IHttpRequestEngineFactory getHttpRequestEngineFactory() {\n\t\treturn requestEngineFactory;\n\t}\n\n\tpublic IScannerModuleRegistry getScannerModuleRegistry() {\n\t\treturn moduleRegistry;\n\t}\n\t\n\tpublic IModel getModel() {\n\t\treturn model;\n\t}\n\t\n\tpublic IContentAnalyzerFactory getContentAnalyzerFactory() {\n\t\treturn contentAnalyzerFactory;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/ScannerConfig.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.apache.http.cookie.Cookie;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.IFormCredential;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.impl.scanner.forms.FormCredential;\n\npublic class ScannerConfig implements IScannerConfig {\n\n\tprivate final static String[] defaultExcludedParameters = { \"xsrftoken\", \"__eventvalidation\", \"__eventargument\", \"__eventtarget\", \"__viewstateencrypted\", \"__viewstate\", \"anticsrf\", \"csrfmiddlewaretoken\", \"csrftoken\" };\n\tprivate ITargetScope scanTargetScope;\n\tprivate String userAgent = IHttpRequestEngineFactory.DEFAULT_USER_AGENT;\n\tprivate IIdentity scanIdentity;\n\tprivate List<Cookie> cookieList;\n\tprivate List<String> modulesList;\n\tprivate final Set<String> excludedParameterNames = new HashSet<String>();\n\tprivate boolean logAllRequests;\n\tprivate boolean displayDebugOutput;\n\tprivate int maxRequestsPerSecond = DEFAULT_MAX_REQUEST_PER_SECOND;\n\tprivate int maxDescendants = DEFAULT_MAX_DESCENDANTS;\n\tprivate int maxChildren = DEFAULT_MAX_CHILDREN;\n\tprivate int maxDepth = DEFAULT_MAX_DEPTH;\n\tprivate int maxDuplicatePaths = DEFAULT_MAX_DUPLICATE_PATHS;\n\tprivate int maxParameterCount = DEFAULT_MAX_PARAMETER_COUNT;\n\tprivate int maxConnections = DEFAULT_MAX_CONNECTIONS;\n\tprivate int maxResponseKilobytes = DEFAULT_MAX_RESPONSE_KILOBYTES;\n\tprivate final List<IFormCredential> formCredentials = new ArrayList<IFormCredential>();\n\n\t@Override\n\tpublic synchronized void setUserAgent(String userAgent) {\n\t\tthis.userAgent = userAgent;\n\t}\n\n\t@Override\n\tpublic synchronized void setScanIdentity(IIdentity scanIdentity) {\n\t\tthis.scanIdentity = scanIdentity;\n\t}\n\n\t@Override\n\tpublic synchronized void setCookieList(List<Cookie> list) {\n\t\tcookieList = list;\n\t}\n\t\n\t@Override\n\tpublic synchronized void setModulesList(List<String> modules) {\n\t\tmodulesList = modules;\n\t}\n\n\t@Override\n\tpublic synchronized void setExcludedParameterNames(Set<String> names) {\n\t\texcludedParameterNames.clear();\n\t\texcludedParameterNames.addAll(names);\n\t}\n\n\t@Override\n\tpublic Set<String> getDefaultExcludedParameterNames() {\n\t\treturn Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(defaultExcludedParameters)));\n\t}\n\n\t@Override\n\tpublic synchronized Set<String> getExcludedParameterNames() {\n\t\treturn Collections.unmodifiableSet(new HashSet<String>(excludedParameterNames));\n\t}\n\n\t@Override\n\tpublic synchronized String getUserAgent() {\n\t\treturn userAgent;\n\t}\n\n\t@Override\n\tpublic synchronized IIdentity getScanIdentity() {\n\t\treturn scanIdentity;\n\t}\n\n\t@Override\n\tpublic synchronized List<Cookie> getCookieList() {\n\t\treturn cookieList;\n\t}\n\n\t@Override\n\tpublic synchronized List<String> getModulesList() {\n\t\treturn modulesList;\n\t}\n\n\t@Override\n\tpublic synchronized void setLogAllRequests(boolean flag) {\n\t\tlogAllRequests = flag;\n\t}\n\n\t@Override\n\tpublic synchronized boolean getLogAllRequests() {\n\t\treturn logAllRequests;\n\t}\n\n\t@Override\n\tpublic synchronized void setDisplayDebugOutput(boolean flag) {\n\t\tdisplayDebugOutput = flag;\n\t}\n\n\t@Override\n\tpublic synchronized boolean getDisplayDebugOutput() {\n\t\treturn displayDebugOutput;\n\t}\n\n\t@Override\n\tpublic synchronized boolean getDirectoryInjectionChecksFlag() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic synchronized boolean getNonParameterFileInjectionChecksFlag() {\n\t\treturn true;\n\t}\n\n\tpublic synchronized IFormCredential createFormCredential(String username, String password) {\n\t\tfinal IFormCredential credential = new FormCredential(username, password);\n\t\tformCredentials.add(credential);\n\t\treturn credential;\n\t}\n\n\t@Override\n\tpublic synchronized List<IFormCredential> getFormCredentials() {\n\t\treturn formCredentials;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxRequestsPerSecond(int rps) {\n\t\tmaxRequestsPerSecond = rps;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxRequestsPerSecond() {\n\t\treturn maxRequestsPerSecond;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxDescendants() {\n\t\treturn maxDescendants;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxChildren() {\n\t\treturn maxChildren;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxDepth() {\n\t\treturn maxDepth;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxDescendants(int value) {\n\t\tmaxDescendants = value;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxChildren(int value) {\n\t\tmaxChildren = value;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxDepth(int value) {\n\t\tmaxDepth = value;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxDuplicatePaths() {\n\t\treturn maxDuplicatePaths;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxDuplicatePaths(int value) {\n\t\tmaxDuplicatePaths = value;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxParameterCount(int value) {\n\t\tthis.maxParameterCount = value;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxParameterCount() {\n\t\treturn maxParameterCount;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxConnections(int value) {\n\t\tmaxConnections = value;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxConnections() {\n\t\treturn maxConnections;\n\t}\n\n\t@Override\n\tpublic synchronized void setMaxResponseKilobytes(int kb) {\n\t\tmaxResponseKilobytes = kb;\n\t}\n\n\t@Override\n\tpublic synchronized int getMaxResponseKilobytes() {\n\t\treturn maxResponseKilobytes;\n\t}\n\n\t@Override\n\tpublic void setScanTargetScope(ITargetScope scope) {\n\t\tscanTargetScope = scope;\n\t}\n\n\t@Override\n\tpublic ITargetScope getScanTargetScope() {\n\t\treturn scanTargetScope;\n\t}\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/ScannerTask.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner;\n\nimport java.net.URI;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.utils.URIUtils;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpMacroContext;\nimport com.subgraph.vega.api.http.requests.IHttpMacroExecutor;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodHttpMacro;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRunningTime;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.impl.scanner.urls.UriFilter;\nimport com.subgraph.vega.impl.scanner.urls.UriParser;\n\npublic class ScannerTask implements Runnable {\n\tprivate final Logger logger = Logger.getLogger(\"scanner\");\n\tprivate final Scan scan;\n\tprivate final IScanInstance scanInstance;\n\tprivate IContentAnalyzer contentAnalyzer;\n\tprivate final UriParser uriParser;\n\tprivate final UriFilter uriFilter;\n\tprivate final ITargetScope scanTargetScope;\n\tprivate volatile boolean stopRequested;\n\tprivate IWebCrawler currentCrawler;\n\t\n\t\n\tScannerTask(Scan scan) {\n\t\tthis.scan = scan;\n\t\tthis.scanInstance = scan.getScanInstance();\n\t\tcurrentCrawler = scan.getScanner().getWebCrawlerFactory().create(scan.getRequestEngine());\n\t\tcontentAnalyzer = scan.getScanner().getContentAnalyzerFactory().createContentAnalyzer(scanInstance);\n\t\tcontentAnalyzer.setResponseProcessingModules(scan.getResponseModules());\n\t\turiFilter = new UriFilter(scan.getConfig());\n\t\turiParser = new UriParser(scan.getConfig(), scan.getBasicModules(), scan.getWorkspace(), currentCrawler, uriFilter, contentAnalyzer, scanInstance, false);\n\t\tscanTargetScope = scan.getConfig().getScanTargetScope();\n\n\t\tlogger.setLevel(Level.ALL);\n\n//\t\tURI redirectURI = scan.getRedirectURI();\n\n\t\t/* ugly hack */\n\t/*\t\n\t\tif (redirectURI != null) && redirectURI.getHost().equals(baseURI.getHost())) \n\t\t\turiParser.processUri(redirectURI);\n\t\t} else\n\n\t\t\tfor(URI u: scanTargetScope.getScopeURIs()) {\n\t\t\t\turiParser.processUri(u);\n\t\t\t}\n\t*/\n\t}\n\t\n\tvoid stop() {\n\t\tstopRequested = true;\n\t\tif(currentCrawler != null)\n\t\t\ttry {\n\t\t\t\tcurrentCrawler.stop();\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t}\n\t\n\t@Override\n\tpublic void run() {\n\n\n\t\tscanInstance.updateScanStatus(IScanInstance.SCAN_AUDITING);\n\t\tscan.getRequestEngine().getCookieStore().clear();\n\t\t\n\t\tif (handleMacroAuthentication()) {\n\t\t\trunCrawlerPhase();\n\n\t\t\tif(stopRequested) {\n\t\t\t\tscanInstance.updateScanStatus(IScanInstance.SCAN_CANCELLED);\n\t\t\t\tlogger.info(\"Scanner cancelled\");\n\t\t\t} else {\n\t\t\t\tscanInstance.updateScanStatus(IScanInstance.SCAN_COMPLETED);\n\t\t\t\tlogger.info(\"Scanner completed\");\n\t\t\t}\n\t\t}\n\t\tscan.doFinish();\n\t\tprintModuleRuntimeStats();\n\t}\n\t\n\tprivate void printModuleRuntimeStats() {\n\t\tlogger.info(\"Scanning module runtime statistics:\");\n\t\tfor(IScannerModule m: scan.getResponseModules()) {\n\t\t\tIScannerModuleRunningTime profile = m.getRunningTimeProfile();\n\t\t\tif(profile.getInvocationCount() > 0)\n\t\t\t\tlogger.info(profile.toString());\t\t\t\n\t\t}\n\t\tfor(IScannerModule m: scan.getBasicModules()) {\n\t\t\tIScannerModuleRunningTime profile = m.getRunningTimeProfile();\n\t\t\tif(profile.getInvocationCount() > 0)\n\t\t\t\tlogger.info(profile.toString());\t\t\t\n\t\t}\n\t}\n\t\n\t// temporary: in the future this will be managed with session handling rules\n\tprivate boolean handleMacroAuthentication() {\n\t\tIIdentity identity = scan.getConfig().getScanIdentity();\n\t\tif (identity != null) {\n\t\t\tIAuthMethod authMethod = identity.getAuthMethod();\n\t\t\tif (authMethod != null && authMethod.getType() == IAuthMethod.AuthMethodType.AUTH_METHOD_HTTP_MACRO) {\n\t\t\t\tlogger.info(\"Pre-authenticating using an HTTP macro\");\n\t\t\t\tIAuthMethodHttpMacro authMethodMacro = (IAuthMethodHttpMacro)authMethod;\n\t\t\t\tIHttpMacroContext context = scan.getRequestEngine().createMacroContext();\n\t\t\t\tcontext.setDict(identity.getDict());\n\t\t\t\tIHttpMacroExecutor executor = scan.getRequestEngine().createMacroExecutor(authMethodMacro.getMacro(), context);\n\t\t\t\twhile (executor.hasNext()) {\n\t\t\t\t\tIHttpResponse response;\n\t\t\t\t\tint status;\n\t\t\t\t\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresponse = executor.sendNextRequest().get(true);\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tlogger.log(Level.WARNING, e.getMessage());\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\t\t\n\t\t\t\t\tcontentAnalyzer.processResponse(response, true, false);\n\t\t\t\t\tstatus = response.getResponseCode();\n\t\t\t\t\tif (status == 301 || status == 302 || status == 303 || status == 307) {\n\t\t\t\t\t\tHeader locationHeader = response.getRawResponse().getFirstHeader(\"Location\");\n\t\t\t\t\t\tif (locationHeader == null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tfinal VegaURI base = VegaURI.fromHostAndRequest(response.getHost(), response.getOriginalRequest());\n\t\t\t\t\t\t\tfinal VegaURI uri = base.resolve(locationHeader.getValue());\n\t\t\t\t\t\t\tif (uriFilter.filter(uri)) {\t\n\t\t\t\t\t\t\t\turiParser.processUri(uri);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate void runCrawlerPhase() {\n\t\tlogger.info(\"Starting crawling phase\");\n\t\t\t\t\n\t\tfor(URI u: scanTargetScope.getScopeURIs()) {\n\t\t\turiParser.processUri(toVegaURI(u));\n\t\t}\n\t\tcurrentCrawler.start();\n\t\ttry {\n\t\t\tcurrentCrawler.waitFinished();\n\t\t} catch (InterruptedException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\tcurrentCrawler = null;\n\t\tlogger.info(\"Crawler finished\");\n\t}\n\n\tprivate VegaURI toVegaURI(URI u) {\n\t\tfinal HttpHost targetHost = URIUtils.extractHost(u);\n\t\treturn new VegaURI(targetHost, u.getPath(), u.getQuery());\n\t}\n\n\tvoid pauseScan() {\n\t\tfinal IWebCrawler crawler = currentCrawler;\n\t\tif(crawler != null) {\n\t\t\tcrawler.pause();\n\t\t\tscanInstance.notifyScanPauseState(true);\n\t\t}\n\t}\n\n\tvoid unpauseScan() {\n\t\tfinal IWebCrawler crawler = currentCrawler;\n\t\tif(crawler != null) {\n\t\t\tcrawler.unpause();\n\t\t\tscanInstance.notifyScanPauseState(false);\n\t\t}\n\t}\n\t\n\tboolean isPaused() {\n\t\tfinal IWebCrawler crawler = currentCrawler;\n\t\tif(crawler != null) {\n\t\t\treturn crawler.isPaused();\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/forms/FormCredential.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.forms;\n\nimport com.subgraph.vega.api.scanner.IFormCredential;\n\npublic class FormCredential implements IFormCredential {\n\n\tprivate final String username;\n\tprivate final String password;\n\n\tprivate String usernameField;\n\tprivate String passwordField;\n\tprivate String targetName;\n\n\tpublic FormCredential(String username, String password) {\n\t\tthis.username = username;\n\t\tthis.password = password;\n\t}\n\n\t@Override\n\tpublic void setTargetName(String name) {\n\t\tthis.targetName = name;\n\t}\n\n\t@Override\n\tpublic void setUsernameFieldName(String name) {\n\t\tthis.usernameField = name;\n\t}\n\n\t@Override\n\tpublic void setPasswordFieldName(String name) {\n\t\tthis.passwordField = name;\n\t}\n\n\t@Override\n\tpublic String getUsername() {\n\t\treturn username;\n\t}\n\n\t@Override\n\tpublic String getPassword() {\n\t\treturn password;\n\t}\n\n\t@Override\n\tpublic String getTargetName() {\n\t\treturn targetName;\n\t}\n\n\t@Override\n\tpublic String getUsernameFieldName() {\n\t\treturn usernameField;\n\t}\n\n\t@Override\n\tpublic String getPasswordFieldName() {\n\t\treturn passwordField;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/forms/FormHints.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.forms;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.message.BasicNameValuePair;\n\npublic class FormHints {\n\tprivate final static String DEFAULT_VALUE = \"1\";\n\tprivate final List<NameValuePair> hintList = new ArrayList<NameValuePair>();\n\n\tFormHints() {\n\t\tadd(\"phone\", \"2129824052\");\n\t\tadd(\"zip\", \"10003\");\n\t\tadd(\"first\", \"Joey\");\n\t\tadd(\"last\", \"Ramone\");\n\t\tadd(\"name\", \"Joey\");\n\t\tadd(\"mail\", \"vega@example.com\");\n\t\tadd(\"street\", \"315 Bowery\");\n\t\tadd(\"city\", \"New York\");\n\t\tadd(\"state\", \"NY\");\n\t\tadd(\"country\", \"US\");\n\t\tadd(\"language\", \"en\");\n\t\tadd(\"company\", \"subgraph\");\n\t\tadd(\"search\", \"vega\");\n\t\tadd(\"login\", \"vega\");\n\t\tadd(\"user\", \"vega\");\n\t\tadd(\"nick\", \"vega\");\n\t\tadd(\"pass\", \"vega\");\n\t\tadd(\"pwd\", \"vega\");\n\t\tadd(\"year\", \"2012\");\n\t\tadd(\"card\", \"4111111111111111\");\n\t\tadd(\"code\", \"000\");\n\t\tadd(\"cvv\", \"000\");\n\t\tadd(\"expir\", \"1212\");\n\t\tadd(\"ssn\", \"987654320\");\n\t\tadd(\"url\", \"http://example.com/?vega_form_test\");\n\t\tadd(\"site\", \"http://example.com/?vega_form_test\");\n\t\tadd(\"domain\", \"example.com\");\n\t\tadd(\"search\", \"a\");\n\t\tadd(\"comment\", \"vega\");\n\t\tadd(\"desc\", \"vega\");\n\t\tadd(\"title\", \"vega\");\n\t\tadd(\"subject\", \"vega\");\n\t\tadd(\"message\", \"vega\");\n\t}\n\n\tprivate void add(String k, String v) {\n\t\thintList.add(new BasicNameValuePair(k, v));\n\t}\n\n\tpublic String lookupHint(String fieldName) {\n\t\tif(fieldName == null || fieldName.isEmpty())\n\t\t\treturn DEFAULT_VALUE;\n\t\tfinal String name = fieldName.toLowerCase();\n\t\tfor(NameValuePair p: hintList) {\n\t\t\tif(name.contains(p.getName()))\n\t\t\t\treturn p.getValue();\n\t\t}\n\t\treturn DEFAULT_VALUE;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/forms/FormProcessingState.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.forms;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.message.BasicNameValuePair;\n\nimport com.subgraph.vega.api.scanner.IFormCredential;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic class FormProcessingState {\n\tprivate final static Logger logger = Logger.getLogger(\"scanner\");\n\tprivate final static FormHints formHints = new FormHints();\n\n\t//private final List<IFormCredential> credentials;\n\tprivate final VegaURI baseURI;\n\tprivate final String action;\n\tprivate final String method;\n\n\tprivate final List<NameValuePair> parameters = new ArrayList<NameValuePair>();\n\n\tprivate VegaURI cachedTargetURI;\n\tprivate boolean passwordFlag;\n\tprivate boolean fileFieldFlag;\n\n\tFormProcessingState(VegaURI baseURI, String action, String method, List<IFormCredential> credentials) {\n\t\tthis.baseURI = baseURI;\n\t\tthis.action = action;\n\t\tthis.method = method;\n\t\t//this.credentials = credentials;\n\t}\n\n\tboolean isValid() {\n\t\treturn (getTargetURI() != null);\n\t}\n\n\tboolean isPostMethod() {\n\t\treturn (method != null && method.toLowerCase().equals(\"post\"));\n\t}\n\n\tVegaURI getTargetURI() {\n\t\tsynchronized(this) {\n\t\t\tif(cachedTargetURI == null) {\n\t\t\t\tcachedTargetURI = createTargetURI();\n\t\t\t}\n\t\t\treturn cachedTargetURI;\n\t\t}\n\t}\n\n\tprivate VegaURI createTargetURI() {\n\t\tif(baseURI == null)\n\t\t\treturn null;\n\t\tif(action == null || action.trim().equals(\"#\")) {\n\t\t\treturn baseURI;\n\t\t}\n\t\ttry {\n\t\t\tfinal VegaURI target = baseURI.resolve(action);\n\t\t\tfinal String scheme = target.getTargetHost().getSchemeName();\n\t\t\tif(scheme.equalsIgnoreCase(\"http\") || scheme.equalsIgnoreCase(\"https\"))\n\t\t\t\treturn target;\n\t\t\telse\n\t\t\t\treturn null;\n\t\t} catch (IllegalArgumentException e) {\n\t\t\tlogger.log(Level.WARNING, \"Failed to create new URI from base: \"+ baseURI + \" and action=\"+ action, e);\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tvoid add(String name, String value) {\n\t\tparameters.add(new BasicNameValuePair(name, (value == null) ? (\"\") : (value)));\n\t}\n\n\tvoid addGuessedValue(String name) {\n\t\tadd(name, guessFormValue(name));\n\t}\n\n\tvoid setPasswordFieldFlag() {\n\t\tpasswordFlag = true;\n\t}\n\n\tboolean getPasswordFieldFlag() {\n\t\treturn passwordFlag;\n\t}\n\n\tvoid setFileFieldFlag() {\n\t\tfileFieldFlag = true;\n\t}\n\n\tboolean getFileFieldFlag() {\n\t\treturn fileFieldFlag;\n\t}\n\n\t/*\n\tprivate boolean isPossiblePasswordField(String name) {\n\t\tfinal String n = name.toLowerCase();\n\t\treturn (n.contains(\"pass\") || n.contains(\"pwd\"));\n\t}\n\n\tprivate boolean isPossibleLoginField(String name) {\n\t\tfinal String n = name.toLowerCase();\n\t\treturn (n.contains(\"name\") || n.contains(\"user\") || n.contains(\"log\"));\n\t}\n\t*/\n\tprivate String guessFormValue(String name) {\n\t\t/*\n\t\tif(config.getNtlmPassword() != null && isPossiblePasswordField(name))\n\t\t\treturn config.getNtlmPassword();\n\t\tif(config.getNtlmUsername() != null && isPossibleLoginField(name))\n\t\t\treturn config.getNtlmUsername();\n\t\t\t*/\n\t\treturn formHints.lookupHint(name);\n\t}\n\n\tList<NameValuePair> getParameters() {\n\t\treturn parameters;\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\tif(isPostMethod()) {\n\t\t\treturn \"POST \"+ getTargetURI().toString() + parametersAsPostString();\n\t\t} else {\n\t\t\treturn \"GET \" + getTargetURI().toString() + parametersAsQueryString();\n\t\t}\n\t}\n\n\tprivate String parametersAsQueryString() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tsb.append(\"?\");\n\t\tfor(NameValuePair nvp: parameters) {\n\t\t\tif(sb.length() > 1)\n\t\t\t\tsb.append(\"&\");\n\t\t\tsb.append(nvp.getName());\n\t\t\tif(nvp.getValue() != null) {\n\t\t\t\tsb.append(\"=\");\n\t\t\t\tsb.append(nvp.getValue());\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tprivate String parametersAsPostString() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tboolean first = true;\n\t\tsb.append(\" [\");\n\t\tfor(NameValuePair nvp: parameters) {\n\t\t\tif(first)\n\t\t\t\tfirst = false;\n\t\t\telse\n\t\t\t\tsb.append(\", \");\n\t\t\tsb.append(nvp.getName());\n\t\t\tif(nvp.getValue() != null) {\n\t\t\t\tsb.append(\"=\");\n\t\t\t\tsb.append(nvp.getValue());\n\t\t\t}\n\t\t}\n\t\tsb.append(\"]\");\n\t\treturn sb.toString();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/forms/FormProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.forms;\n\nimport java.net.URI;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.html2.HTMLCollection;\nimport org.w3c.dom.html2.HTMLDocument;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.impl.scanner.urls.UriFilter;\nimport com.subgraph.vega.impl.scanner.urls.UriParser;\n\npublic class FormProcessor {\n\n\tprivate final IScannerConfig config;\n\tprivate final UriFilter uriFilter;\n\tprivate final UriParser uriParser;\n\n\tpublic FormProcessor(IScannerConfig config, UriFilter uriFilter, UriParser uriParser) {\n\t\tthis.config = config;\n\t\tthis.uriFilter = uriFilter;\n\t\tthis.uriParser = uriParser;\n\t}\n\n\tpublic void processForms(IInjectionModuleContext ctx, HttpUriRequest request, IHttpResponse response) {\n\t\tfinal IHTMLParseResult html = response.getParsedHTML();\n\t\tif(html == null)\n\t\t\treturn;\n\n\t\tfinal HTMLDocument document = html.getDOMDocument();\n\t\tfinal HTMLCollection forms = document.getForms();\n\n\t\tfor(int i = 0; i < forms.getLength(); i++) {\n\t\t\tNode n = forms.item(i);\n\t\t\tif(n instanceof Element) {\n\t\t\t\tprocessFormElement(ctx, request, (Element) n);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void processFormElement(IInjectionModuleContext ctx, HttpUriRequest request, Element form) {\n\t\tfinal URI reqURI = request.getURI();\n\t\tfinal HttpHost targetHost = URIUtils.extractHost(reqURI);\n\t\tfinal VegaURI baseURI = new VegaURI(targetHost, reqURI.getPath(), reqURI.getQuery());\n\t\tfinal FormProcessingState fps = new FormProcessingState(baseURI, form.getAttribute(\"action\"), form.getAttribute(\"method\"), config.getFormCredentials());\n\t\tif(!fps.isValid())\n\t\t\treturn;\n\n\t\tNodeList es = form.getElementsByTagName(\"*\");\n\t\tfor(int i = 0; i < es.getLength(); i++) {\n\t\t\tNode n = es.item(i);\n\t\t\tif(n instanceof Element)\n\t\t\t\tprocessSingleFormElement(fps, (Element) n);\n\n\t\t}\n\t\tif(fps.getFileFieldFlag()) {\n\t\t\tctx.debug(\"Cannot process form because file input handling not implemented\");\n\t\t\treturn;\n\t\t}\n\t\tctx.debug(\"Processed form: \"+ fps);\n\t\tsubmitNewForm(fps);\n\t}\n\n\tprivate void submitNewForm(FormProcessingState formData) {\n\t\tif(!uriFilter.isAllowed(formData.getTargetURI())) {\n\t\t\treturn;\n\t\t}\n\t\t\t\n\t\tfinal IPathState ps = uriParser.processUri(formData.getTargetURI());\n\t\tif(formData.isPostMethod())\n\t\t\tps.maybeAddPostParameters(formData.getParameters());\n\t\telse\n\t\t\tps.maybeAddParameters(formData.getParameters());\n\t}\n\n\tprivate void processSingleFormElement(FormProcessingState fps, Element element) {\n\t\tif(element.getTagName().toLowerCase().equals(\"input\"))\n\t\t\tprocessInputElement(fps, element);\n\t\telse\n\t\t\tprocessOtherFormElement(fps, element);\n\t}\n\n\tprivate void processInputElement(FormProcessingState fps, Element input) {\n\t\tfinal String name = decodeAttribute(input, \"name\");\n\t\tif(name == null)\n\t\t\treturn;\n\t\tfinal String rawType = input.getAttribute(\"type\");\n\t\tfinal String type = (rawType == null) ? (\"text\") : (rawType.toLowerCase());\n\t\tfinal String value = decodeAttribute(input, \"value\");\n\t\tif(type.equals(\"file\")) {\n\t\t\t// XXX\n\t\t\tfps.setFileFieldFlag();\n\t\t\treturn;\n\t\t} else if(type.equals(\"checkbox\")) {\n\t\t\tfps.add(name, \"on\");\n\t\t} else if(type.equals(\"hidden\") && value != null && !value.isEmpty()) {\n\t\t\tfps.add(name, value);\n\t\t} else if(type.equals(\"reset\")) {\n\t\t\t// do nothing\n\t\t} else if(value != null && !value.isEmpty()) {\n\t\t\tfps.add(name, value);\n\t\t} else {\n\t\t\tfps.addGuessedValue(name);\n\t\t}\n\n\t\tif(type.equals(\"password\"))\n\t\t\tfps.setPasswordFieldFlag();\n\t}\n\n\tprivate void processOtherFormElement(FormProcessingState fps, Element element) {\n\t\tfinal String tag = element.getTagName().toLowerCase();\n\t\tif(tag.equals(\"textarea\") || tag.equals(\"select\") || tag.equals(\"button\")) {\n\t\t\tfinal String name = decodeAttribute(element, \"name\");\n\t\t\tif(name == null)\n\t\t\t\treturn;\n\t\t\tfinal String value = decodeAttribute(element, \"value\");\n\t\t\tif(value == null || value.isEmpty())\n\t\t\t\tfps.addGuessedValue(name);\n\t\t\telse\n\t\t\t\tfps.add(name, value);\n\t\t}\n\t}\n\n\tprivate String decodeAttribute(Element e, String a) {\n\t\tfinal String v = e.getAttribute(a);\n\t\tif(v == null)\n\t\t\treturn null;\n\t\t// XXX do html decode\n\t\treturn v;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/CaseSensitivityCheck.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class CaseSensitivityCheck extends CrawlerModule {\n\t\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response,\n\t\t\tIInjectionModuleContext ctx) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/CrawlerModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic abstract class CrawlerModule implements ICrawlerResponseProcessor {\n\t\n\tpublic abstract void initialize(IPathState ps);\n\tpublic abstract void runModule(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx); \n\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request, IHttpResponse response, Object argument) {\n\t\tif(!(argument instanceof IInjectionModuleContext))\n\t\t\tthrow new IllegalArgumentException(\"Crawler callback argument is not IModuleContext as expected: \"+ argument);\n\t\trunModule(request, response, (IInjectionModuleContext) argument);\n\t}\n\t\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tctx.reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/Dir404Tests.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class Dir404Tests extends CrawlerModule {\n\tprivate static final String PAGE_DOES_NOT_EXIST = \"nosuchpage123\";\n\n\tprivate final DirParentCheck dirParentCheck = new DirParentCheck();\n\tprivate final CaseSensitivityCheck caseSensitivityCheck = new CaseSensitivityCheck();\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\tctx.submitAlteredRequest(this, \"/\"+ PAGE_DOES_NOT_EXIST);\n\t}\n\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx) {\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tfinal boolean isFirstResponse = ctx.getCurrentIndex() == 0;\n\t\tboolean failed = false;\n\n\t\tif(ps.hasFailed404Detection())\n\t\t\tfailed = true;\n\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"during 404 response checks\");\n\t\t\tfailed = true;\n\t\t}\n\n\t\tif(!failed) {\n\t\t\tprocessResponseFingerprint(ctx, request, response, isFirstResponse);\n\t\t\tif(isFirstResponse)\n\t\t\t\tfinishProcessingFirstResponse(ctx, ps);\n\t\t}\n\n\t\tfinishProcessingResponse(ctx, ps);\n\t}\n\n\tprivate void finishProcessingResponse(IInjectionModuleContext ctx, IPathState ps) {\n\t\tctx.incrementResponseCount();\n\t\tif(!ctx.allResponsesReceived())\n\t\t\treturn;\n\t\tif(!ps.has404Fingerprints() || ps.hasFailed404Detection())\n\t\t\thandleFailed404Detection(ctx, ps);\n\t\tdirParentCheck.initialize(ps);\n\t}\n\n\tprivate void finishProcessingFirstResponse(IInjectionModuleContext ctx, IPathState ps) {\n\t\tif(!ps.has404Fingerprints()) {\n\t\t\tctx.debug(\"First 404 probe failed to produce a signature\");\n\t\t} else {\n\t\t\tctx.pivotChecks(ps.createRequest(), ps.getResponse());\n\t\t\tcaseSensitivityCheck.initialize(ps);\n\t\t\tscheduleProbes(ctx);\n\t\t}\n\t}\n\n\tprivate void processResponseFingerprint(IInjectionModuleContext ctx, HttpUriRequest req, IHttpResponse res, boolean isFirstResponse) {\n\t\tfinal IPageFingerprint fp = res.getPageFingerprint();\n\t\tfinal IPathState ps = ctx.getPathState();\n\n\t\tif(isFirstResponse && !ps.isSureDirectory() && !ps.isRootPath() && ps.matchesPathFingerprint(fp)) {\n\t\t\tctx.debug(\"First 404 probe identical to parent page\");\n\t\t\treturn;\n\t\t}\n\n\t\tif(!ps.add404Fingerprint(fp)) {\n\t\t\tctx.debug(\"Failed 404 detection, too many unique 404 signatures received\");\n\t\t\tps.setFailed404Detection();\n\t\t\treturn;\n\t\t}\n\n\t\tfinal IPathState parent404 = ps.get404Parent();\n\t\tif((parent404 != null) && !parent404.has404FingerprintMatching(fp)) {\n\t\t\tctx.debug(\"New 404 signature detected that was not detected on parent\");\n\t\t\tctx.responseChecks(req, res);\n\t\t}\n\t}\n\n\tprivate void scheduleProbes(IInjectionModuleContext ctx) {\n\t\tfor(String ext: ctx.getFileExtensionList())\n\t\t\tctx.submitAlteredRequest(this, PAGE_DOES_NOT_EXIST + \".\"+ ext, 1);\n\t\tctx.submitAlteredRequest(this, \"lpt9\", 1);\n\t\tctx.submitAlteredRequest(this, \"~\"+PAGE_DOES_NOT_EXIST, 1);\n\t\tctx.submitAlteredRequest(this, PAGE_DOES_NOT_EXIST, 1);\n\t}\n\n\tprivate void handleFailed404Detection(IInjectionModuleContext ctx, IPathState ps) {\n\t\tfinal int code = (ps.getResponse() == null) ? (0) : (ps.getResponse().getResponseCode());\n\t\tif(code == 404) {\n\t\t\tps.setPageMissing();\n\t\t} else if(code > 400) {\n\t\t\tlogFailureMessage(ctx, code);\n\t\t} else if(!ps.isRootPath()) {\n\t\t\tps.getPath().setPathType(PathType.PATH_PATHINFO);\n\t\t} else {\n\t\t\tctx.debug(\"No distinctive 404 signatures detected\");\n\t\t}\n\t\tps.clear404Fingerprints();\n\n\t\tif(ps.getParentState() == null || ps.getParentState().getResponse() == null) {\n\t\t\tctx.pivotChecks(ps.createRequest(), ps.getResponse());\n\t\t\treturn;\n\t\t}\n\n\t\tif(!ps.getParentState().matchesPathFingerprint(ps.getPathFingerprint())) {\n\t\t\tIPathState parent404 = ps.get404Parent();\n\t\t\tif(parent404 == null || !parent404.has404FingerprintMatching(ps.getPathFingerprint())) {\n\t\t\t\tctx.pivotChecks(ps.createRequest(), ps.getResponse());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void logFailureMessage(IInjectionModuleContext ctx, int httpCode) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tsb.append(\"Directory resource is not accessible: HTTP response code (\");\n\t\tsb.append(httpCode);\n\t\tsb.append(\")\");\n\t\tif(httpCode == 401)\n\t\t\tsb.append(\" [HTTP Auth required\");\n\t\tif(httpCode >= 500)\n\t\t\tsb.append(\" [Server error]\");\n\t\tctx.debug(sb.toString());\n\t}\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/DirIPSCheck.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IHttpResponse.ResponseStatus;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class DirIPSCheck extends CrawlerModule {\n\tprivate final static String IPS_TEST =\n\t\t\"_test1=c:\\\\windows\\\\system32\\\\cmd.exe\" +\n\t\t\"&_test2=/etc/passwd\" +\n\t\t\"&_test3=|/bin/sh\" +\n\t\t\"&_test4=(SELECT * FROM nonexistent) --\" +\n\t\t\"&_test5=>/no/such/file\" +\n\t\t\"&_test6=<script>alert(1)</script>\" +\n\t\t\"&_test7=javascript:alert(1)\";\n\n\tprivate final static String IPS_SAFE =\n\t\t \"_test1=ccddeeeimmnossstwwxy.:\\\\\\\\\\\\\" +\n\t\t  \"&_test2=acdepsstw//\" +\n\t\t  \"&_test3=bhins//\" +\n\t\t  \"&_test4=CEEFLMORSTeeinnnosttx-*\" +\n\t\t  \"&_test5=cefhilnosu///\" +\n\t\t  \"&_test6=acceiilpprrrssttt1)(\" +\n\t\t  \"&_test7=aaaceijlprrsttv1):(\";\n\n\tprivate final InjectionChecks injection = new InjectionChecks();\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\tctx.submitRequest(createRequest(ps, IPS_TEST), this, 0);\n\t\tctx.submitRequest(createRequest(ps, IPS_SAFE), this, 1);\n\t}\n\n\tprivate HttpUriRequest createRequest(IPathState ps, String query) {\n\t\tfinal IHttpRequestEngine requestEngine = ps.getRequestEngine();\n\t\tfinal HttpHost host = ps.getPath().getHttpHost();\n\t\tfinal String requestLine = ps.getPath().getFullPath() + \"?\" + query;\n\t\treturn requestEngine.createGetRequest(host, requestLine);\n\t}\n\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx) {\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tif(ctx.hasModuleFailed())\n\t\t\treturn;\n\n\t\tif(ctx.getCurrentIndex() == 1 && response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"Fetch failed during IPS tests\");\n\t\t\tctx.setModuleFailed();\n\t\t\tinjection.initialize(ps);\n\t\t}\n\t\tctx.addRequestResponse(request, response);\n\t\tctx.incrementResponseCount();\n\t\tif(!ctx.allResponsesReceived())\n\t\t\treturn;\n\n\t\tIPathState p404 = ps.get404Parent();\n\t\tif(p404 == null || !p404.isIPSDetected()) {\n\t\t\tif(ctx.getSavedResponse(0).getResponseStatus() != IHttpResponse.ResponseStatus.RESPONSE_OK) {\n\t\t\t\tctx.debug(\"Possible IPS filter detected\");\n\t\t\t\tctx.getPathState().setIPSDetected();\n\n\t\t\t} else if(!ctx.isFingerprintMatch(0, 1)) {\n\t\t\t\tctx.debug(\"Possible IPS filter detected\");\n\t\t\t\tctx.getPathState().setIPSDetected();\n\t\t\t}\n\t\t} else {\n\t\t\tif(ctx.getSavedResponse(0).getResponseStatus() == ResponseStatus.RESPONSE_OK && ctx.isFingerprintMatch(0, 1)) {\n\t\t\t\tctx.debug(\"Previously detected IPS filter is no longer active\");\n\t\t\t}\n\t\t}\n\n\t\tinjection.initialize(ps);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/DirParentCheck.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class DirParentCheck extends CrawlerModule {\n\n\tprivate final DirIPSCheck ipsCheck = new DirIPSCheck();\n\t\n\tpublic void initialize(IPathState ps) {\n\t\tif(!ps.has404Fingerprints() || !hasSuitablePath(ps)) {\n\t\t\tipsCheck.initialize(ps);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\tfinal HttpUriRequest req = createRequest(ps);\n\t\tctx.submitRequest(req, this, 0);\n\t}\n\t\n\tprivate boolean hasSuitablePath(IPathState ps) {\n\t\tfinal IWebPath parentPath = ps.getPath().getParentPath();\n\t\treturn(parentPath != null && parentPath.getParentPath() != null);\n\t}\n\t\n\tprivate HttpUriRequest createRequest(IPathState ps) {\n\t\tfinal IWebPath path = ps.getPath();\n\t\tfinal IWebPath parent = path.getParentPath();\n\t\tString basePath = parent.getParentPath().getFullPath();\n\t\tString newPath = basePath + \"foo/\" + path.getPathComponent();\n\t\treturn ps.getRequestEngine().createGetRequest(path.getHttpHost(), newPath);\n\t}\n\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx) {\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\t\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"Fetch failed during parent directory check\");\n\t\t} else if(ps.matchesPathFingerprint(response.getPageFingerprint())) {\n\t\t\tctx.debug(\"Problem with parent directory behavior\");\n\t\t\tctx.getPathState().setBadParentDirectory();\n\t\t}\n\t\n\t\tipsCheck.initialize(ctx.getPathState());\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/DirectoryProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class DirectoryProcessor implements ICrawlerResponseProcessor {\n\n\tprivate final Dir404Tests dir404Tests;\n\tprivate final SecondaryExtChecks secondaryExt;\n\n\tpublic DirectoryProcessor() {\n\t\tthis.dir404Tests = new Dir404Tests();\n\t\tthis.secondaryExt = new SecondaryExtChecks();\n\t}\n\n\t@Override\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request,\n\t\t\tIHttpResponse response, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tps.getPath().setVisited(true);\n\n\t\tps.setResponse(response);\n\n\t\tif(ps.isRootPath())\n\t\t\tctx.pivotChecks(request, response);\n\n\t\tdir404Tests.initialize(ps);\n\n\t\tif(ps.get404Parent() != null)\n\t\t\tsecondaryExt.initialize(ps);\n\t}\n\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tctx.reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/FileProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class FileProcessor implements ICrawlerResponseProcessor {\n\tprivate final InjectionChecks injectionChecks = new InjectionChecks();\n\tprivate final SecondaryExtChecks secondaryExtChecks = new SecondaryExtChecks();\n\tprivate final ParametricCheckHandler parametricChecks = new ParametricCheckHandler();\n\tprivate final CaseSensitivityCheck caseCheck = new CaseSensitivityCheck();\n\t@Override\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request,\n\t\t\tIHttpResponse response, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\t\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tps.setResponse(response);\n\t\tps.getPath().setVisited(true);\n\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"during initial file fetch\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal IPathState ps404Parent = ps.get404Parent();\n\t\tboolean is404Response = ((ps404Parent == null) && response.getResponseCode() == 404) ||\n\t\t\t((ps404Parent != null) && ps404Parent.has404FingerprintMatching(response.getPageFingerprint()));\n\t\t\n\t\tif(is404Response) {\n\t\t\tps.setPageMissing();\n\t\t} else {\n\t\t\tif(response.getResponseCode() > 400) \n\t\t\t\tctx.debug(\"Page is not accessible.  http code (\"+ response.getResponseCode() + \")\");\n\t\t\t\t\n\t\t\tfinal IPathState pps = ps.getParentState();\n\t\t\tif(pps == null || pps.getResponse() == null || !ps.matchesPathFingerprint(pps.getPathFingerprint())) {\n\t\t\t\tctx.responseChecks(request, response);\n\t\t\t}\n\t\t\tif(ps404Parent != null && !ps.isParametric())\n\t\t\t\tsecondaryExtChecks.initialize(ps);\n\t\t\tif(ps.getPath().getPathType() == PathType.PATH_FILE)\n\t\t\t\tcaseCheck.initialize(ps);\n\t\t\t\t\n\t\t}\n\t\t\n\t\tps.unlockChildren();\n\t\tif(ps.isParametric()) {\n\t\t\tparametricChecks.initialize(ps);\n\t\t} else {\n\t\t\tinjectionChecks.initialize(ps);\n\t\t}\n\t}\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tctx.reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/InjectionChecks.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.impl.scanner.state.PathState;\n\npublic class InjectionChecks {\n\n\tprivate final PutChecks putChecks;\n\tprivate final PageVariabilityCheck pageVariabilityChecks;\n\n\tpublic InjectionChecks() {\n\t\tputChecks = new PutChecks(this);\n\t\tpageVariabilityChecks = new PageVariabilityCheck(this);\n\t}\n\n\tpublic void initialize(IPathState ps) {\n\t\tps.unlockChildren();\n\t\tif(ps.getPath().getPathType() == PathType.PATH_DIRECTORY) {\n\t\t\tputChecks.initialize(ps);\n\t\t} if(ps.isParametric()) {\n\t\t\tlaunchInjectionModules(ps);\n\t\t} else {\n\t\t\trunPageVariabilityCheck(ps);\n\t\t}\n\t}\n\n\tpublic void runPageVariabilityCheck(IPathState ps) {\n\t\tif(ps.doInjectionChecks()) {\n\t\t\tpageVariabilityChecks.initialize(ps);\n\t\t} else {\n\t\t\tps.setDone(); \n\t\t}\n\t}\n\n\tpublic void launchInjectionModules(IPathState ps) {\n\t\tfor(IBasicModuleScript m: ps.getInjectionModules()) {\n\t\t\tif(m.isEnabled() && !(ps.getResponseVaries() && m.isDifferential())) {\n\t\t\t\tm.runScript(ps);\n\t\t\t}\n\t\t}\n\t\t((PathState)ps).setFinishOnNoRequests();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/OgnlHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\n\npublic class OgnlHandler implements ICrawlerResponseProcessor {\n\n\t@Override\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request,\n\t\t\tIHttpResponse response, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\n\t\tif(ctx.hasModuleFailed())\n\t\t\treturn;\n\t\t\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.setModuleFailed();\n\t\t\tctx.error(request, response, \"during OGNL tests\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tctx.addRequestResponse(ctx.getCurrentIndex(), request, response);\n\t\tif(ctx.incrementResponseCount() < 2)\n\t\t\treturn;\n\t\tfinal IPageFingerprint pathFP = ctx.getPathState().getPathFingerprint();\n\t\t\n\t\tif(ctx.isFingerprintMatch(0, pathFP) && ! ctx.isFingerprintMatch(1, pathFP)) {\n\t\t\tSystem.out.println(\"Problem: response to [0]['name']=... identical to name=...\");\t\t\t\n\t\t}\n\t}\n\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tctx.reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/PageVariabilityCheck.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class PageVariabilityCheck extends CrawlerModule {\n\tprivate final static int BH_CHECKS = 15;\n\n\tprivate final InjectionChecks injectionChecks;\n\n\tpublic PageVariabilityCheck(InjectionChecks injectionChecks) {\n\t\tthis.injectionChecks = injectionChecks;\n\t}\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\n\t\tfor(int i = 0; i < BH_CHECKS; i++) {\n\t\t\tctx.submitRequest(ps.createRequest(), this, i);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx) {\n\t\tfinal IPathState ps = ctx.getPathState();\n\n\t\tif(response.isFetchFail())\n\t\t\tctx.error(request, response, \"Failed to fetch response during page variability check\");\n\t\telse\n\t\t\ttestResponse(request, response, ctx);\n\n\t\tctx.incrementResponseCount();\n\t\t\n\t\tif(!ctx.allResponsesReceived())\n\t\t\treturn;\n\n\t\tinjectionChecks.launchInjectionModules(ps);\n\t}\n\n\tprivate void testResponse(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx) {\n\t\tfinal IPageFingerprint fp = response.getPageFingerprint();\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tif(!ps.matchesPathFingerprint(fp)) {\n\t\t\tps.setResponseVaries();\n\t\t\tctx.debug(\"Response varies\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/ParametricCheckHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport java.util.Random;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class ParametricCheckHandler extends CrawlerModule {\n\tprivate final static Random random = new Random();\n\tprivate final ICrawlerResponseProcessor ognlHandler = new OgnlHandler();\n\tprivate final InjectionChecks injectionChecks = new InjectionChecks();\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\t// XXX check URI filter and parameter filter\n\t\tif(!ps.isParametric() || false) {\n\t\t\tctx.debug(\"not parametric??\");\n\t\t\tps.setDone();\n\t\t\treturn;\n\t\t}\n\n\t\tfinal String param = generateBogusParameter();\n\t\tfor(int i = 0; i < 5; i++) {\n\t\t\tctx.submitAlteredRequest(this, param, i);\n\t\t}\n\n\t}\n\t\n\tprivate String generateBogusParameter() {\n\t\tfinal int unique = random.nextInt(9000) + 1000;\n\t\treturn \"asdf\" + unique;\n\t}\n\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response,\n\t\t\tIInjectionModuleContext ctx) {\n\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"during parameter behavior test\");\n\t\t\tmaybeScheduleNext(ctx);\n\t\t\treturn;\n\t\t}\n\n\n\t\tfinal IPageFingerprint pathFP = ctx.getPathState().getPathFingerprint();\n\t\tif(pathFP != null && pathFP.isSame(response.getPageFingerprint())) {\n\t\t\tctx.getPathState().setBogusParameter();\n\t\t\tmaybeScheduleNext(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tif(ctx.getPathState().isBogusParameter()) {\n\t\t\tctx.debug(\"We classified parameter as no effect, but now it's changing\");\n\t\t\tctx.getPathState().setResponseVaries();\n\t\t\t// XXX problem varies\n\t\t\tmaybeScheduleNext(ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tif(!ctx.getPathState().has404Fingerprints()) {\n\t\t\tctx.debug(\"Adding 404 signature from parameter probe\");\n\t\t\tctx.getPathState().add404Fingerprint(response.getPageFingerprint());\n\t\t} else if(!ctx.getPathState().has404FingerprintMatching(response.getPageFingerprint())) {\n\t\t\tctx.debug(\"Signature does not match previous responses\");\n\t\t\t// XXX problem varies\n\t\t\tctx.getPathState().setResponseVaries();\n\t\t}\n\t\tmaybeScheduleNext(ctx);\n\t}\n\n\tprivate void maybeScheduleNext(IInjectionModuleContext ctx) {\n\t\tif(ctx.incrementResponseCount() < 5)\n\t\t\treturn;\n\t\tscheduleNext(ctx.getPathState());\n\t}\n\n\tprivate void scheduleNext(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\tfinal String pname = ps.getFuzzableParameter().getName();\n\t\tif(!ps.isBogusParameter() && !ps.getResponseVaries() && pname != null) {\n\t\t\tctx.submitAlteredParameterNameRequest(ognlHandler, \"[0]['\"+pname+\"']\", 0);\n\t\t\tctx.submitAlteredParameterNameRequest(ognlHandler, \"[0]['vega']\", 1);\n\t\t}\n\t\tinjectionChecks.initialize(ps);\n\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/PutChecks.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport java.net.URI;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpVersion;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpPut;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.apache.http.message.BasicRequestLine;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.http.requests.custom.VegaHttpUriRequest;\n\npublic class PutChecks extends CrawlerModule {\n\n\tprivate final InjectionChecks injectionChecks;\n\n\tPutChecks(InjectionChecks injectionChecks) {\n\t\tthis.injectionChecks = injectionChecks;\n\t}\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\tURI u = ps.getPath().getUri().resolve(\"PUT-putfile\");\n\t\tHttpHost host = URIUtils.extractHost(u);\n\t\tRequestLine line = new BasicRequestLine(HttpPut.METHOD_NAME, u.getPath(), HttpVersion.HTTP_1_1);\n\t\tVegaHttpUriRequest r = new VegaHttpUriRequest(host, line);\n\t\tctx.submitRequest(r, this);\n\t}\n\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response,\n\t\t\tIInjectionModuleContext ctx) {\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"during PUT checks\");\n\t\t} else {\n\t\t\tfinal int rc = response.getResponseCode();\n\t\t\tfinal IPageFingerprint fp = response.getPageFingerprint();\n\t\t\t\n\t\t\tif(rc >= 200 && rc < 300 && !ps.matchesPathFingerprint(fp) && !ps.has404FingerprintMatching(fp)) {\n\t\t\t\tfinal String resource = request.getURI().toString();\n\t\t\t\tfinal String key = \"vinfo-http-put:\" + resource;\n\t\t\t\tctx.publishAlert(\"vinfo-http-put\", key, \"HTTP PUT succeeded\", request, response, \"resource\", resource);\n\t\t\t}\n\t\t}\n\n\t\tinjectionChecks.runPageVariabilityCheck(ctx.getPathState());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/SecondaryExtChecks.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class SecondaryExtChecks extends CrawlerModule {\n\n\t@Override\n\tpublic void initialize(IPathState ps) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\t@Override\n\tpublic void runModule(HttpUriRequest request, IHttpResponse response,\n\t\t\tIInjectionModuleContext ctx) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\t\n\t\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/handlers/UnknownProcessor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.handlers;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class UnknownProcessor implements ICrawlerResponseProcessor {\n\tprivate final ParametricCheckHandler parametricChecks = new ParametricCheckHandler();\n\tprivate final ICrawlerResponseProcessor fetchFileProcessor = new FileProcessor();\n\tprivate final ICrawlerResponseProcessor fetchDirProcessor = new DirectoryProcessor();\n\n\t@Override\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request,\n\t\t\tIHttpResponse response, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tfinal IPathState ps = ctx.getPathState();\n\t\tif(ctx.getCurrentIndex() == 0) {\n\t\t\tprocessInitialResponse(request, response, ctx, ps);\n\t\t} else {\n\t\t\tprocessProbeResponses(request, response, ctx, ps);\n\t\t}\n\t}\n\n\tprivate void processInitialResponse(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx, IPathState ps) {\n\t\tps.setResponse(response);\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"during initial resource fetch\");\n\t\t\treturn;\n\t\t}\n\t\tps.getPath().setVisited(true);\n\t\tfinal IPageFingerprint fp = response.getPageFingerprint();\n\t\tfinal IPathState par = ps.get404Parent();\n\t\tfinal int rcode = response.getResponseCode();\n\t\tif((par == null && rcode == 404) || (ps.hasParent404Fingerprint(fp))) {\n\t\t\tps.setPageMissing();\n\t\t\tps.unlockChildren();\n\t\t\tctx.debug(\"Starting parametric checks on unknown path because page is missing.\");\n\t\t\tparametricChecks.initialize(ps);\n\t\t\treturn;\n\t\t}\n\n\t\tif(par != null && !response.getBodyAsString().isEmpty() && rcode == 200 && fp.isSame(par.getUnknownFingerprint())) {\n\t\t\tctx.debug(\"Unknown path fetch matches parent unknown fp, processing as a file.\");\n\t\t\tps.getPath().setPathType(PathType.PATH_FILE);\n\t\t\tfetchFileProcessor.processResponse(null, request, response, ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tif(par != null && rcode >= 300 && rcode < 400 && fp.isSame(par.getUnknownFingerprint()) && fp.isSame(par.getPathFingerprint())) {\n\t\t\tctx.debug(\"Unknown path fetch matches both parent probes, processing as file.\");\n\t\t\tps.getPath().setPathType(PathType.PATH_FILE);\n\t\t\tfetchFileProcessor.processResponse(null, request, response, ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tctx.debug(\"Sending probes to resolve unknown path.\");\n\t\tsendProbeRequests(ps);\n\t}\n\n\tprivate void sendProbeRequests(IPathState ps) {\n\t\tfinal IInjectionModuleContext ctx = ps.createModuleContext();\n\t\tctx.submitAlteredRequest(this, \"/\", 1);\n\t\tctx.submitAlteredRequest(this, \"/abc123/\", 2);\n\t}\n\n\tprivate void processProbeResponses(HttpUriRequest request, IHttpResponse response, IInjectionModuleContext ctx, IPathState ps) {\n\t\tif(response.isFetchFail()) {\n\t\t\tctx.error(request, response, \"Fetch failed processing unknown path probe responses\");\n\t\t\tcallFetchHandler(ctx, ps);\n\t\t}\n\t\tctx.addRequestResponse(request, response);\n\t\tctx.incrementResponseCount();\n\t\tif(ctx.allResponsesReceived())\n\t\t\tanalyzeResponses(ctx, ps);\n\t}\n\n\tprivate void analyzeResponses(IInjectionModuleContext ctx, IPathState ps) {\n\n\t\t// http://host.com/foo/bar.php/ vs. http://host.com/foo/bar.php/abc123/ vs http://host.com/foo/bar.php\n\t\tif(ctx.isFingerprintMatch(1, 2) && ctx.isFingerprintMatch(2, ps.getPathFingerprint())) {\n\t\t\tctx.debug(\"Probes all match for unknown path, processing as file.\");\n\t\t\tps.getPath().setPathType(PathType.PATH_FILE);\n\t\t\tcallFetchHandler(ctx, ps);\n\t\t\treturn;\n\t\t}\n\n\t\tfinal IHttpResponse res1 = ctx.getSavedResponse(1);\n\t\tif(ctx.isFingerprintMatch(1, ps.getPathFingerprint())) {\n\t\t\tctx.debug(\"Trailing / probe matches initial path fetch, processing as directory.\");\n\t\t\tassumeDirectory(res1, ctx, ps);\n\t\t\treturn;\n\t\t}\n\n\t\t// pivot code, response code\n\t\tfinal int pcode = ps.getResponse().getResponseCode();\n\t\tfinal int rcode = res1.getResponseCode();\n\t\tif(pcode >= 300 && pcode < 400) {\n\t\t\tif(hasLocationHeaderWithRequestUri(ps, ctx.getSavedRequest(1))) {\n\t\t\t\tctx.debug(\"Trailing slash probe matches redirect from initial fetch, processing as directory\");\n\t\t\t\tps.setSureDirectory();\n\t\t\t\tassumeDirectory(res1, ctx, ps);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif(isProbe404(ps, res1)) {\n\t\t\tctx.debug(\"Trailing slash probe looks like a 404, processing as a file\");\n\t\t\tps.getPath().setPathType(PathType.PATH_FILE);\n\t\t} else if(pcode  < 300 && rcode >= 300 && ps.getResponse().getBodyAsString().length() > 0) {\n\t\t\tctx.debug(\"Trailing slash probe returned code 3xx - 5xx and initial fetch was a 200, processing as file\");\n\t\t\tps.getPath().setPathType(PathType.PATH_FILE);\n\t\t} else {\n\t\t\tctx.debug(\"No idea what this is, try processing as file\");\n\t\t}\n\t\tcallFetchHandler(ctx, ps);\n\t}\n\n\tprivate boolean isProbe404(IPathState ps, IHttpResponse response) {\n\t\tfinal IPathState p404 = ps.get404Parent();\n\t\tfinal int rcode = response.getResponseCode();\n\t\tfinal IPageFingerprint rfp = response.getPageFingerprint();\n\t\tif(p404 != null)\n\t\t\treturn p404.has404FingerprintMatching(rfp);\n\t\telse\n\t\t\treturn rcode == 404;\n\t}\n\n\tprivate boolean hasLocationHeaderWithRequestUri(IPathState ps, HttpUriRequest req) {\n\t\tfinal String locationValue = getLocationHeader(ps);\n\t\tif(locationValue == null)\n\t\t\treturn false;\n\t\tfinal String uriString = req.getURI().toString();\n\t\treturn locationValue.equalsIgnoreCase(uriString);\n\n\t}\n\tprivate String getLocationHeader(IPathState ps) {\n\t\tfinal HttpResponse rr = ps.getResponse().getRawResponse();\n\t\tfinal Header lh = rr.getFirstHeader(\"Location\");\n\t\tif(lh == null)\n\t\t\treturn null;\n\t\treturn lh.getValue();\n\t}\n\n\tprivate void assumeDirectory(IHttpResponse response, IInjectionModuleContext ctx, IPathState ps) {\n\t\tps.getPath().setPathType(PathType.PATH_DIRECTORY);\n\t\tps.setUnknownFingerprint(ps.getPathFingerprint());\n\t\tps.setResponse(response);\n\t\tcallFetchHandler(ctx, ps);\n\t}\n\n\tprivate void callFetchHandler(IInjectionModuleContext ctx, IPathState ps) {\n\t\tfinal IWebPath path = ps.getPath();\n\t\tfinal HttpUriRequest req = ps.createRequest();\n\t\tfinal IHttpResponse res = ps.getResponse();\n\t\tif(path.getPathType() == PathType.PATH_DIRECTORY || path.getParentPath() == null)\n\t\t\tfetchDirProcessor.processResponse(null, req, res, ctx);\n\t\telse\n\t\t\tfetchFileProcessor.processResponse(null, req, res, ctx);\n\t}\n\t\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tctx.reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/requests/AbstractParameterRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.requests;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.message.BasicNameValuePair;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.web.IWebPath;\n\npublic abstract class AbstractParameterRequestBuilder extends AbstractRequestBuilder {\n\n\tprotected final List<NameValuePair> parameters;\n\tprotected final int parameterFuzzIndex;\n\t\n\tprotected AbstractParameterRequestBuilder(IHttpRequestEngine requestEngine, IWebPath path, List<NameValuePair> parameters, int index) {\n\t\tsuper(requestEngine, path);\n\t\tif(parameters == null || index < 0 || index >= parameters.size())\n\t\t\tthrow new IllegalArgumentException();\n\t\t\n\t\tthis.parameters = parameters;\n\t\tthis.parameterFuzzIndex = index;\n\t}\n\t\n\t@Override\n\tpublic boolean isFuzzable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic NameValuePair getFuzzableParameter() {\n\t\treturn parameters.get(parameterFuzzIndex);\n\t}\n\t\n\tprotected List<NameValuePair> getAlteredParameters(String fuzzValue, boolean append, boolean fuzzName) {\n\t\tfinal List<NameValuePair> result = new ArrayList<NameValuePair>();\n\t\tfor(int i = 0; i < parameters.size(); i++) {\n\t\t\tNameValuePair p = parameters.get(i);\n\t\t\tif(parameterFuzzIndex == i)\n\t\t\t\tresult.add(fuzzParameter(p, fuzzValue, append, fuzzName));\n\t\t\telse\n\t\t\t\tresult.add(p);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected NameValuePair fuzzParameter(NameValuePair param, String fuzzValue, boolean append, boolean fuzzName) {\n\t\tif(fuzzName) {\n\t\t\treturn new BasicNameValuePair(fuzzValue, param.getValue());\n\t\t} else if(append) {\n\t\t\treturn new BasicNameValuePair(param.getName(), param.getValue() + fuzzValue);\n\t\t} else {\n\t\t\treturn new BasicNameValuePair(param.getName(), fuzzValue);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/requests/AbstractRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.requests;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.web.IWebPath;\n\npublic abstract class AbstractRequestBuilder implements IRequestBuilder {\n\t\n\tprotected final IHttpRequestEngine requestEngine;\n\tprotected final IWebPath webPath;\n\t\t\n\tprotected AbstractRequestBuilder(IHttpRequestEngine requestEngine, IWebPath path) {\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.webPath = path;\n\t}\n\t\n\tprotected HttpUriRequest createRequestForPath(String path) {\n\t\treturn requestEngine.createGetRequest(webPath.getHttpHost(), path);\n\t}\n\t\n\tprotected HttpUriRequest createPathRequest() {\n\t\treturn createRequestForPath(getBasePath());\n\t}\n\t\n\n\tprotected HttpUriRequest createRequestFromQuery(String query) {\n\t\tfinal String requestLine = getBasePath() + \"?\" + query;\n\t\treturn createRequestForPath(requestLine);\n\t}\n\n\tprotected String getBasePath() {\n\t\tswitch(webPath.getPathType()) {\n\t\tcase PATH_DIRECTORY:\n\t\t\treturn maybeAddTrailingSlash(webPath.getFullPath());\n\t\tcase PATH_PATHINFO:\n\t\t\treturn maybeRemoveTrailingSlash(webPath.getFullPath());\n\t\tdefault:\n\t\t\treturn webPath.getFullPath();\n\t\t}\n\t}\n\n\tprivate String maybeAddTrailingSlash(String basePath) {\n\t\tif(basePath.endsWith(\"/\")) {\n\t\t\treturn basePath;\n\t\t}\n\t\treturn basePath + \"/\";\n\t}\n\t\n\tprivate String maybeRemoveTrailingSlash(String basePath) {\n\t\tif(!basePath.endsWith(\"/\")) {\n\t\t\treturn basePath;\n\t\t}\n\t\tString p = basePath;\n\t\twhile(p.length() > 0 && p.endsWith(\"/\")) {\n\t\t\tp = p.substring(0, p.length() - 1);\n\t\t}\n\t\treturn p;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/requests/BasicRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.requests;\n\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.message.BasicNameValuePair;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.web.IWebPath;\n\npublic class BasicRequestBuilder extends AbstractRequestBuilder {\n\n\tpublic BasicRequestBuilder(IHttpRequestEngine requestEngine, IWebPath path) {\n\t\tsuper(requestEngine, path);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createBasicRequest() {\n\t\treturn createPathRequest();\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredRequest(String value, boolean append) {\n\t\tfinal String path = createPathWithSuffix(getBasePath(), value);\n\t\treturn createRequestForPath(path);\n\t}\n\n\tprivate String createPathWithSuffix(String oldPath, String suffix) {\n\t\tif(oldPath.endsWith(\"/\") && suffix.startsWith(\"/\"))\n\t\t\treturn oldPath + suffix.substring(1);\n\t\telse if(oldPath.endsWith(\"/\") || suffix.startsWith(\"/\"))\n\t\t\treturn oldPath + suffix;\n\t\telse\n\t\t\treturn oldPath + \"/\" + suffix;\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredParameterNameRequest(String name) {\n\t\tthrow new UnsupportedOperationException();\n\t}\n\n\t@Override\n\tpublic NameValuePair getFuzzableParameter() {\n\t\treturn new BasicNameValuePair(\"\", \"\");\n\t}\n\n\t@Override\n\tpublic boolean isFuzzable() {\n\t\treturn false;\n\t}\n\t\n\t@Override\n\tpublic String toString() {\n\t\treturn \"GET \"+ getBasePath();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/requests/GetParameterRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.requests;\n\nimport java.util.List;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.web.IWebPath;\n\npublic class GetParameterRequestBuilder extends AbstractParameterRequestBuilder {\n\n\t\n\tpublic GetParameterRequestBuilder(IHttpRequestEngine requestEngine, IWebPath path, List<NameValuePair> parameters, int index) {\n\t\tsuper(requestEngine, path, parameters, index);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createBasicRequest() {\n\t\treturn createRequestFromQuery(formatDefaultParameters());\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredRequest(String value, boolean append) {\n\t\treturn createRequestFromQuery(formatParametersWithFuzz(value, append, false));\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredParameterNameRequest(String name) {\n\t\treturn createRequestFromQuery(formatParametersWithFuzz(name, false, true));\n\t}\n\t\n\t\n\tprivate String formatDefaultParameters() {\n\t\treturn formatParameterList(parameters);\n\t}\n\n\tprivate String formatParametersWithFuzz(String fuzzValue, boolean append, boolean fuzzName) {\n\t\treturn formatParameterList( getAlteredParameters(fuzzValue, append, fuzzName));\n\t}\n\t\n\tprivate String formatParameterList(List<NameValuePair> plist) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor(int i = 0; i < plist.size(); i++) {\n\t\t\tNameValuePair p = plist.get(i);\n\t\t\tif(i != 0)\n\t\t\t\tsb.append(\"&\");\n\t\t\tsb.append(p.getName());\n\t\t\tif(p.getValue() != null) {\n\t\t\t\tsb.append(\"=\");\n\t\t\t\tsb.append(p.getValue());\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\t@Override\n\tpublic String toString() {\n\t\treturn \"GET \"+ getBasePath() + \"?\" + formatDefaultParameters() + \" (idx=\"+ parameterFuzzIndex +\")\";\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/requests/IRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.requests;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.methods.HttpUriRequest;\n\npublic interface IRequestBuilder {\n\tHttpUriRequest createBasicRequest();\n\tHttpUriRequest createAlteredRequest(String value, boolean append);\n\tHttpUriRequest createAlteredParameterNameRequest(String name);\n\tboolean isFuzzable();\n\tNameValuePair getFuzzableParameter();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/requests/PostParameterRequestBuilder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.requests;\n\nimport java.io.UnsupportedEncodingException;\nimport java.util.List;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.entity.UrlEncodedFormEntity;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.model.web.IWebPath;\n\npublic class PostParameterRequestBuilder extends AbstractParameterRequestBuilder {\n\n\tpublic PostParameterRequestBuilder(IHttpRequestEngine requestEngine, IWebPath path, List<NameValuePair> parameters, int index) {\n\t\tsuper(requestEngine, path, parameters, index);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createBasicRequest() {\n\t\treturn createPostRequest(parameters);\n\t}\n\n\tprivate HttpUriRequest createPostRequest(List<NameValuePair> parameters) {\n\t\tfinal HttpUriRequest req =  requestEngine.createPostRequest(webPath.getHttpHost(), getBasePath());\n\t\t((HttpEntityEnclosingRequest)req).setEntity(createParameterEntity(parameters));\n\t\treturn req;\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredRequest(String value, boolean append) {\n\t\treturn createPostRequest(getAlteredParameters(value, append, false));\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredParameterNameRequest(String name) {\n\t\treturn createPostRequest(getAlteredParameters(name, false, true));\n\t}\n\t\n\tprivate HttpEntity createParameterEntity(List<NameValuePair> parameters) {\n\t\ttry {\n\t\t\treturn new UrlEncodedFormEntity(parameters, \"UTF-8\");\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tthrow new RuntimeException(\"Failed to encode form parameters.\", e);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic String toString() {\n\t\treturn \"POST \"+ getBasePath() + \" (\"+ printParameters() + \") (idx = \"+ parameterFuzzIndex + \")\";\n\t}\n\t\n\tprivate String printParameters() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tboolean first = true;\n\t\tfor(NameValuePair p: parameters) {\n\t\t\tif(first)\n\t\t\t\tfirst = false;\n\t\t\telse\n\t\t\t\tsb.append(\", \");\n\t\t\tsb.append(p.getName());\n\t\t\tif(p.getValue() != null) {\n\t\t\t\tsb.append(\"=\");\n\t\t\t\tsb.append(p.getValue());\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/CrawlerCallbackWrapper.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\n\npublic class CrawlerCallbackWrapper implements ICrawlerResponseProcessor {\n\tstatic ICrawlerResponseProcessor createLogging(PathState pathState, IRequestLog requestLog, ICrawlerResponseProcessor callback) {\n\t\treturn new CrawlerCallbackWrapper(pathState, requestLog, callback);\n\t}\n\t\n\tstatic ICrawlerResponseProcessor create(PathState pathState, ICrawlerResponseProcessor callback) {\n\t\treturn new CrawlerCallbackWrapper(pathState, null, callback);\n\t}\n\t\n\tprivate final PathState pathState;\n\tprivate final boolean logRequest;\n\tprivate final IRequestLog requestLog;\n\tprivate final ICrawlerResponseProcessor wrappedCallback;\n\t\n\tprivate CrawlerCallbackWrapper(PathState pathState, IRequestLog requestLog, ICrawlerResponseProcessor callback) {\n\t\tthis.pathState = pathState;\n\t\tthis.logRequest = (requestLog != null);\n\t\tthis.requestLog = requestLog;\n\t\tthis.wrappedCallback = callback;\n\t\t\n\t}\n\n\t@Override\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request, IHttpResponse response, Object argument) {\n\t\tpathState.decrementOutstandingRequests();\n\t\t\n\t\tif(!response.lockResponseEntity()) {\n\t\t\treturn;\n\t\t}\n\t\twrappedCallback.processResponse(crawler, request, response, argument);\n\t\tif(logRequest) {\n\t\t\trequestLog.addRequestResponse(response);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tpathState.decrementOutstandingRequests();\n\t\tpathState.getPathStateManager().reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/ModuleContext.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Logger;\nimport java.util.regex.Pattern;\nimport java.util.regex.PatternSyntaxException;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.google.common.net.InternetDomainName;\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.impl.scanner.requests.IRequestBuilder;\n\npublic class ModuleContext implements IInjectionModuleContext {\n\tprivate final static Logger logger = Logger.getLogger(\"scanner\");\n\tprivate final PathStateManager scanState;\n\tprivate final IRequestBuilder requestBuilder;\n\tprivate final PathState pathState;\n\tprivate final int currentIndex;\n\tprivate final ModuleContextState contextState;\n\tprivate final List<String> stringHighlights;\n\tprivate final List<String> regexHighlights;\n\tprivate final List<String> caseInsensitiveRegexHighlights;\n\n\n\tModuleContext(PathStateManager scanState, IRequestBuilder requestBuilder, PathState pathState, int index) {\n\t\tthis.scanState = scanState;\n\t\tthis.requestBuilder = requestBuilder;\n\t\tthis.pathState = pathState;\n\t\tcurrentIndex = index;\n\t\tcontextState = new ModuleContextState();\n\t\tthis.stringHighlights = new ArrayList<String>();\n\t\tthis.regexHighlights = new ArrayList<String>();\n\t\tthis.caseInsensitiveRegexHighlights = new ArrayList<String>();\n\n\t}\n\n\tModuleContext(PathStateManager scanState, IRequestBuilder requestBuilder, PathState pathState) {\n\t\tthis(scanState, requestBuilder, pathState, -1);\n\t}\n\n\tprivate ModuleContext(ModuleContext ctx, int index) {\n\t\tscanState = ctx.scanState;\n\t\trequestBuilder = ctx.requestBuilder;\n\t\tpathState = ctx.pathState;\n\t\tcontextState = ctx.contextState;\n\t\tcurrentIndex = index;\n\t\tthis.stringHighlights = new ArrayList<String>(ctx.stringHighlights);\n\t\tthis.regexHighlights = new ArrayList<String>(ctx.regexHighlights);\n\t\tthis.caseInsensitiveRegexHighlights = new ArrayList<String>();\n\t}\n\n\t@Override\n\tpublic IPathState getPathState() {\n\t\treturn pathState;\n\t}\n\n\t@Override\n\tpublic int incrementResponseCount() {\n\t\treturn contextState.incrementResponseCount();\n\t}\n\t\n\n\t@Override\n\tpublic boolean allResponsesReceived() {\n\t\treturn contextState.allResponsesReceieved();\n\t}\n\n\t@Override\n\tpublic void addRequestResponse(HttpUriRequest request,\n\t\t\tIHttpResponse response) {\n\t\tif (currentIndex == -1)\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"Cannot add request/response because index has not been specified\");\n\t\tcontextState.addRequestResponse(currentIndex, request, response);\n\t}\n\n\t@Override\n\tpublic void addRequestResponse(int index, HttpUriRequest request,\n\t\t\tIHttpResponse response) {\n\t\tcontextState.addRequestResponse(index, request, response);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest getSavedRequest(int index) {\n\t\treturn contextState.getSavedRequest(index);\n\t}\n\n\t@Override\n\tpublic IHttpResponse getSavedResponse(int index) {\n\t\treturn contextState.getSavedResponse(index);\n\t}\n\n\t/* Added below method because of bug #547 */\n\t\n\t@Override\n\tpublic String getSavedResponseBody(int index) {\n\t\treturn contextState.getSavedResponseBody(index);\n\n\t}\n\t@Override\n\tpublic IPageFingerprint getSavedFingerprint(int index) {\n\t\treturn contextState.getSavedFingerprint(index);\n\t}\n\n\t@Override\n\tpublic boolean isFingerprintMatch(int idx1, int idx2) {\n\t\tfinal IPageFingerprint fp1 = getSavedFingerprint(idx1);\n\t\tfinal IPageFingerprint fp2 = getSavedFingerprint(idx2);\n\t\tif (fp1 == null || fp2 == null)\n\t\t\treturn false;\n\t\treturn fp1.isSame(fp2);\n\t}\n\n\t@Override\n\tpublic boolean isFingerprintMatch(int idx, IPageFingerprint fp) {\n\t\tfinal IPageFingerprint fp2 = getSavedFingerprint(idx);\n\t\tif (fp == null || fp2 == null)\n\t\t\treturn false;\n\t\treturn fp.isSame(fp2);\n\t}\n\n\t@Override\n\tpublic int getCurrentIndex() {\n\t\treturn currentIndex;\n\t}\n\n\t@Override\n\tpublic void submitRequest(HttpUriRequest request,\n\t\t\tICrawlerResponseProcessor callback, int index) {\n\t\tcontextState.incrementSentRequestCount();\n\t\tpathState.incrementOutstandingRequests();\n\t\tscanState.getCrawler().submitTask(request, getWrappedCallback(callback), new ModuleContext(this, index));\n\t}\n\t\n\tprivate ICrawlerResponseProcessor getWrappedCallback(ICrawlerResponseProcessor callback) {\n\t\tif(scanState.requestLoggingEnabled())\n\t\t\treturn CrawlerCallbackWrapper.createLogging(pathState, scanState.getRequestLog(), callback);\n\t\telse\n\t\t\treturn CrawlerCallbackWrapper.create(pathState, callback);\n\t}\n\t\n\t@Override\n\tpublic void submitRequest(HttpUriRequest request,\n\t\t\tICrawlerResponseProcessor callback) {\n\t\tsubmitRequest(request, callback, 0);\n\t}\n\n\t@Override\n\tpublic void submitRequest(ICrawlerResponseProcessor callback, int flag) {\n\t\tfinal HttpUriRequest req = requestBuilder.createBasicRequest();\n\t\tif (req != null)\n\t\t\tsubmitRequest(req, callback, flag);\n\t}\n\n\t@Override\n\tpublic void submitAlteredRequest(ICrawlerResponseProcessor callback,\n\t\t\tString value) {\n\t\tsubmitAlteredRequest(callback, value, false, 0);\n\t}\n\n\t@Override\n\tpublic void submitAlteredRequest(ICrawlerResponseProcessor callback,\n\t\t\tString value, int flag) {\n\t\tsubmitAlteredRequest(callback, value, false, flag);\n\t}\n\n\t@Override\n\tpublic void submitAlteredRequest(ICrawlerResponseProcessor callback,\n\t\t\tString value, boolean append, int flag) {\n\t\tfinal HttpUriRequest req = requestBuilder.createAlteredRequest(value,\n\t\t\t\tappend);\n\t\tif (req != null)\n\t\t\tsubmitRequest(req, callback, flag);\n\t}\n\n\t@Override\n\tpublic void submitAlteredParameterNameRequest(\n\t\t\tICrawlerResponseProcessor callback, String name, int flag) {\n\t\tfinal HttpUriRequest req = requestBuilder\n\t\t\t\t.createAlteredParameterNameRequest(name);\n\t\tif (req != null)\n\t\t\tsubmitRequest(req, callback, flag);\n\t}\n\n\t@Override\n\tpublic void submitMultipleAlteredRequests(\n\t\t\tICrawlerResponseProcessor callback, String[] injectables) {\n\t\tsubmitMultipleAlteredRequests(callback, injectables, false);\n\t}\n\n\t@Override\n\tpublic void submitMultipleAlteredRequests(\n\t\t\tICrawlerResponseProcessor callback, String[] injectables,\n\t\t\tboolean append) {\n\t\tfor (int i = 0; i < injectables.length; i++)\n\t\t\tsubmitAlteredRequest(callback, injectables[i], append, i);\n\t}\n\n\t@Override\n\tpublic void setModuleFailed() {\n\t\tcontextState.setModuleFailed();\n\t}\n\n\t@Override\n\tpublic boolean hasModuleFailed() {\n\t\treturn contextState.hasModuleFailed();\n\t}\n\n\t@Override\n\tpublic void reportRequestException(HttpUriRequest request, Throwable ex) {\n\t\tpathState.decrementOutstandingRequests();\n\t\tscanState.reportRequestException(request, ex);\n\t}\n\n\t@Override\n\tpublic void error(HttpUriRequest request, IHttpResponse response,\n\t\t\tString message) {\n\t\tfinal long requestId = scanState.getRequestLog().addRequestResponse(response);\n\t\tlogger.warning(\"Error running module: \"+ message + \" (request logged with id=\"+ requestId +\")\");\n\t}\n\n\t@Override\n\tpublic void debug(String msg) {\n\t\tscanState.debug(\"[\" + pathState.getPath().getUri() + \"] \" + msg);\n\t}\n\t\n\t@Override\n\tpublic void debug(String msg, Boolean colored) {\n\t\tscanState.debug(\"[\" + pathState.getPath().getUri() + \"] \" + msg, colored);\n\t}\n\t\n\t@Override\n\tpublic void analyzePage(HttpUriRequest request, IHttpResponse response) {\n\t\tscanState.analyzePage(this, request, response);\n\t}\n\n\t@Override\n\tpublic void responseChecks(HttpUriRequest request, IHttpResponse response) {\n\t\tscanState.analyzeContent(this, request, response);\n\t\tscanState.analyzePage(this, request, response);\n\t}\n\n\t@Override\n\tpublic void contentChecks(HttpUriRequest request, IHttpResponse response) {\n\t\tscanState.analyzeContent(this, request, response);\n\t}\n\n\t@Override\n\tpublic void responseChecks(int idx) {\n\t\tfinal HttpUriRequest req = getSavedRequest(idx);\n\t\tfinal IHttpResponse res = getSavedResponse(idx);\n\t\tif (req != null && res != null)\n\t\t\tresponseChecks(req, res);\n\t}\n\n\t@Override\n\tpublic void pivotChecks(HttpUriRequest request, IHttpResponse response) {\n\t\tscanState.analyzePivot(this, request, response);\n\t\tscanState.analyzeContent(this, request, response);\n\t\tscanState.analyzePage(this, request, response);\n\t}\n\t\n\t\n\tpublic void publishAlert(String type, String message, HttpRequest request, IHttpResponse response, Object ...properties) {\n\t\tpublishAlert(type, null, message, request, response, properties);\n\t}\n\n\tpublic void publishAlert(String type, String key, String message, HttpRequest request, IHttpResponse response, Object ...properties) {\n\t\tdebug(\"Publishing Alert: (\"+ type + \") [\"+ request.getRequestLine().getUri() + \"] \");\n\t\tfinal IScanInstance scan = scanState.getScanInstance();\n\t\tfinal IRequestLog requestLog = scanState.getRequestLog();\n\t\tsynchronized(scan) {\n\t\t\tif(key != null && scan.hasAlertKey(key))\n\t\t\t\treturn;\n\t\t\tfinal long requestId = requestLog.addRequestResponse(response);\n\t\t\tfinal IScanAlert alert = scan.createAlert(type, key, requestId);\n\t\t\tfinal String hostname = response.getHost().getHostName();\n\t\t\t\n\t\t\talert.setDiscretionaryHostname(hostname);\n\n\t\t\tfor(int i = 0; (i + 1) < properties.length; i += 2) {\n\t\t\t\tif(properties[i] instanceof String) {\n\t\t\t\t\talert.setProperty((String) properties[i], properties[i + 1]);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.warning(\"Property key passed to publishAlert() is not a string\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pathState.isParametric()) {\n\t\t\t\tif (pathState.getFuzzableParameter() != null) {\n\t\t\t\t\talert.setProperty(\"param\", pathState.getFuzzableParameter().getName());\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\talert.setProperty(\"methods\", request.getRequestLine().getMethod());\n\t\t\t\n\t\t\tif(message != null)\n\t\t\t\talert.setStringProperty(\"message\", message);\n\t\t\t\n\t\t\tfor(String hl: stringHighlights) {\n\t\t\t\talert.addStringMatchHighlight(hl);\n\t\t\t}\n\t\t\tfor(String hl: regexHighlights) {\n\t\t\t\talert.addRegexHighlight(hl);\n\t\t\t}\n\t\t\tfor (String hl: caseInsensitiveRegexHighlights) {\n\t\t\t\talert.addRegexCaseInsensitiveHighlight(hl);\n\t\t\t}\n\n\t\t\tscan.addAlert(alert);\n\t\t}\n\t}\n\t\n\tpublic List<String> getFileExtensionList() {\n\t\treturn scanState.getFileExtensionList();\n\t}\n\n\t@Override\n\tpublic void setProperty(String name, Object value) {\n\t\tscanState.getScanInstance().setProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setStringProperty(String name, String value) {\n\t\tscanState.getScanInstance().setStringProperty(name, value);\t\t\n\t}\n\n\t@Override\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tscanState.getScanInstance().setIntegerProperty(name, value);\t\t\n\t}\n\n\t@Override\n\tpublic Object getProperty(String name) {\n\t\treturn scanState.getScanInstance().getProperty(name);\n\t}\n\n\t@Override\n\tpublic String getStringProperty(String name) {\n\t\treturn scanState.getScanInstance().getStringProperty(name);\n\t}\n\n\t@Override\n\tpublic Integer getIntegerProperty(String name) {\n\t\treturn scanState.getScanInstance().getIntegerProperty(name);\n\t}\n\n\t@Override\n\tpublic List<String> propertyKeys() {\n\t\treturn scanState.getScanInstance().propertyKeys();\n\t}\n\t\n\t@Override\n\tpublic void addStringHighlight(String str) {\n\t\tstringHighlights.add(str);\n\t}\n\n\t@Override\n\tpublic void addRegexHighlight(String regex) {\n\t\ttry {\n\t\t\tPattern.compile(regex);\n\t\t\tregexHighlights.add(regex);\n\t\t} catch (PatternSyntaxException e) {\n\t\t\tlogger.warning(\"Invalid regular expression '\"+ regex +\"' passed to addHighlightRegex(): \"+ e.getDescription());\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void addRegexCaseInsensitiveHighlight(String regex) {\t\t\n\t\ttry {\n\t\t\tPattern.compile(regex);\n\t\t\tcaseInsensitiveRegexHighlights.add(regex);\n\t\t} catch (PatternSyntaxException e) {\n\t\t\tlogger.warning(\"Invalid regular expression '\"+ regex +\"' passed to addHighlightRegex(): \"+ e.getDescription());\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void reset() {\n\t\tstringHighlights.clear();\n\t\tregexHighlights.clear();\n\t}\n\t\n\t@Override\n\tpublic boolean alertExists(String key) {\n\t\tfinal IScanInstance scan = scanState.getScanInstance();\n\n\t\treturn scan.hasAlertKey(key);\n\t}\n\t\n\tpublic InternetDomainName internetDomainName(String domain) {\n\t\treturn InternetDomainName.from(domain);\n\t\t\n\t}\n\t\n\tpublic boolean isValidInternetDomainName(String domain) {\n\t\treturn InternetDomainName.isValid(domain);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/ModuleContextState.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\n\n/*\n * This is a separate class out so that several 'argument' ModuleContext instances\n * can share a common mutable state. \n */\npublic class ModuleContextState {\n\tprivate final static int INITIAL_CAPACITY = 8;\n\n\tprivate HttpUriRequest[] savedRequests;\n\tprivate IHttpResponse[] savedResponses;\n\tprivate int currentCapacity;\n\tprivate int responseCount;\n\tprivate int sentRequestCount;\n\tprivate boolean moduleFailed;\n\n\tpublic synchronized void incrementSentRequestCount() {\n\t\tsentRequestCount += 1;\n\t}\n\t\n\tpublic synchronized int incrementResponseCount() {\n\t\tresponseCount += 1;\n\t\treturn responseCount;\n\t}\n\t\n\tpublic synchronized boolean allResponsesReceieved() {\n\t\treturn responseCount == sentRequestCount;\n\t}\n\n\tprivate void ensureCapacity(int index) {\n\t\tif(currentCapacity == 0) {\n\t\t\tcurrentCapacity = INITIAL_CAPACITY;\n\t\t\tsavedRequests = new HttpUriRequest[INITIAL_CAPACITY];\n\t\t\tsavedResponses = new IHttpResponse[INITIAL_CAPACITY];\n\t\t}\n\t\t\n\t\tif(index >= currentCapacity) {\t\t\n\t\t\tfinal HttpUriRequest[] newRequests = new HttpUriRequest[index + 1];\n\t\t\tfinal IHttpResponse[] newResponses = new IHttpResponse[index + 1];\n\t\t\tSystem.arraycopy(savedRequests, 0, newRequests, 0, currentCapacity);\n\t\t\tSystem.arraycopy(savedResponses, 0, newResponses, 0, currentCapacity);\n\t\t\tsavedRequests = newRequests;\n\t\t\tsavedResponses = newResponses;\n\t\t\tcurrentCapacity = index + 1;\n\t\t}\n\t}\n\n\tpublic synchronized void addRequestResponse(int index, HttpUriRequest request, IHttpResponse response) {\n\t\tensureCapacity(index);\n\t\tsavedRequests[index] = request;\n\t\tsavedResponses[index] = response;\n\t}\n\t\n\tpublic synchronized HttpUriRequest getSavedRequest(int index) {\n\t\tensureCapacity(index);\n\t\treturn savedRequests[index];\n\t}\n\t\n\tpublic synchronized IHttpResponse getSavedResponse(int index) {\n\t\tensureCapacity(index);\n\t\treturn savedResponses[index];\n\t}\n\t\n\t/* Added below method because of bug #547 */\n\n\tpublic synchronized String getSavedResponseBody(int index) {\n\t\tensureCapacity(index);\n\t\tfinal IHttpResponse response = savedResponses[index];\n\t\tif(response != null)\n\t\t\treturn response.getBodyAsString();\n\t\treturn null;\n\t}\n\tpublic synchronized IPageFingerprint getSavedFingerprint(int index) {\n\t\tensureCapacity(index);\n\t\tfinal IHttpResponse response = savedResponses[index];\n\t\tif(response != null)\n\t\t\treturn response.getPageFingerprint();\n\t\treturn null;\n\t}\n\t\n\tpublic synchronized void setModuleFailed() {\n\t\tmoduleFailed = true;\t\t\n\t}\n\n\tpublic synchronized boolean hasModuleFailed() {\n\t\treturn moduleFailed;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/PathState.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.atomic.AtomicInteger;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.cookie.Cookie;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.analysis.IContentAnalyzerResult;\nimport com.subgraph.vega.api.analysis.MimeType;\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.http.requests.custom.VegaHttpUriRequest;\nimport com.subgraph.vega.impl.scanner.requests.BasicRequestBuilder;\nimport com.subgraph.vega.impl.scanner.requests.GetParameterRequestBuilder;\nimport com.subgraph.vega.impl.scanner.requests.IRequestBuilder;\nimport com.subgraph.vega.impl.scanner.requests.PostParameterRequestBuilder;\n\npublic class PathState implements IPathState {\n\n\tpublic static PathState createBasicPathState(ICrawlerResponseProcessor fetchProcessor, PathStateManager stateManager, PathState parentState, IWebPath path) {\n\t\tfinal IHttpRequestEngine requestEngine = stateManager.getCrawler().getRequestEngine();\n\t\tfinal IRequestBuilder rb = new BasicRequestBuilder(requestEngine, path);\n\t\tfinal PathState st = new PathState(fetchProcessor, stateManager, parentState, path, rb);\n\t\tif(parentState != null)\n\t\t\tparentState.addChildState(st, true);\n\t\telse {\n\t\t\tst.setLocked();\n\t\t\tst.performInitialFetch();\n\t\t}\n\t\treturn st;\n\t}\n\n\tpublic static PathState createParameterPathState(ICrawlerResponseProcessor fetchProcessor, PathState parentState, List<NameValuePair> parameters, int fuzzIndex) {\n\t\tif(parentState == null)\n\t\t\tthrow new IllegalArgumentException(\"Parent of parameter path cannot be null\");\n\t\tfinal IHttpRequestEngine requestEngine = parentState.getPathStateManager().getCrawler().getRequestEngine();\n\t\tfinal IRequestBuilder rb = new GetParameterRequestBuilder(requestEngine, parentState.getPath(), parameters, fuzzIndex);\n\t\tfinal PathState st = new PathState(fetchProcessor, parentState.getPathStateManager(), parentState, parentState.getPath(), rb);\n\t\tparentState.addChildState(st, false);\n\t\treturn st;\n\t}\n\n\tpublic static PathState createPostParameterPathState(ICrawlerResponseProcessor fetchProcessor, PathState parentState, List<NameValuePair> parameters, int fuzzIndex) {\n\t\tif(parentState == null)\n\t\t\tthrow new IllegalArgumentException(\"Parent of parameter path cannot be null\");\n\t\tfinal IHttpRequestEngine requestEngine = parentState.getPathStateManager().getCrawler().getRequestEngine();\n\t\tfinal IRequestBuilder rb = new PostParameterRequestBuilder(requestEngine, parentState.getPath(), parameters, fuzzIndex);\n\t\tfinal PathState st = new PathState(fetchProcessor, parentState.getPathStateManager(), parentState, parentState.getPath(), rb);\n\t\tparentState.addChildState(st, false);\n\t\treturn st;\n\t}\n\n\tprivate final PathStateManager pathStateManager;\n\tprivate final IWebPath path;\n\tprivate final PathState parentState;\n\tprivate final List<PathState> childStates = new ArrayList<PathState>();\n\tprivate final IRequestBuilder requestBuilder;\n\tprivate final PathState404 state404;\n\tprivate final ICrawlerResponseProcessor initialFetchProcessor;\n\n\tprivate IHttpResponse response;\n\tprivate IPageFingerprint pathFingerprint;\n\tprivate IPageFingerprint unknownFingerprint;\n\n\tprivate boolean isDone;\n\tprivate boolean hasFailed404;\n\tprivate boolean hasBadParent;\n\tprivate boolean ipsDetected;\n\n\tprivate boolean isSureDirectory;\n\tprivate boolean isPageMissing;\n\tprivate boolean isBogusParameter;\n\tprivate boolean responseVaries;\n\tprivate boolean lockedFlag;\n\tprivate PathStateParameterManager parameterManager;\n\t\n\tprivate final Object childCountLock = new Object();\n\tprivate int descendantCount = 0;\n\tprivate int childCount = 0;\n\t\n\tprivate AtomicInteger outstandingRequests = new AtomicInteger();\n\tprivate AtomicInteger fuzzCounter = new AtomicInteger(0);\n\t\n\tprivate volatile boolean finishOnNoRequests;\n\t\n\tprivate PathState(ICrawlerResponseProcessor fetchProcessor, PathStateManager stateManager, PathState parentState, IWebPath path, IRequestBuilder requestBuilder) {\n\t\tthis.initialFetchProcessor = fetchProcessor;\n\t\tthis.pathStateManager = stateManager;\n\t\tthis.path = path;\n\t\tthis.parentState = parentState;\n\t\tthis.requestBuilder = requestBuilder;\n\t\tthis.state404 = new PathState404(this);\n\t}\n\n\t@Override\n\tpublic PathState getParentState() {\n\t\treturn parentState;\n\t}\n\n\tprivate void addChildState(PathState state, boolean checkDup) {\n\t\tsynchronized(childStates) {\n\t\t\tif(checkDup) {\n\t\t\t\tfor(IPathState cs: childStates) {\n\t\t\t\t\tif(cs.getPath().equals(state.getPath()))\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tchildStates.add(state);\n\t\t\tif(lockedFlag)\n\t\t\t\tstate.setLocked();\n\t\t\telse\n\t\t\t\tstate.performInitialFetch();\n\t\t\t\n\t\t\tsynchronized(childCountLock) {\n\t\t\t\tchildCount += 1;\n\t\t\t\tincrementDescendants();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void incrementDescendants() {\n\t\tsynchronized(childCountLock) {\n\t\t\tdescendantCount += 1;\n\t\t\tif(parentState != null) {\n\t\t\t\tparentState.incrementDescendants();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic int getDescendantCount() {\n\t\treturn descendantCount;\n\t}\n\t\n\tpublic int getChildCount() {\n\t\treturn childCount;\n\t}\n\n\tpublic synchronized int getDepth() {\n\t\tif(parentState == null) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn 1 + parentState.getDepth();\n\t\t}\n\t}\n\n\tpublic PathStateManager getPathStateManager() {\n\t\treturn pathStateManager;\n\t}\n\t@Override\n\tpublic boolean isParametric() {\n\t\treturn requestBuilder.isFuzzable();\n\t}\n\n\t@Override\n\tpublic boolean isDone() {\n\t\treturn isDone;\n\t}\n\n\t@Override\n\tpublic synchronized void setDone() {\n\t\tif (!isDone) {\n\t\t\tisDone = true;\n\t\t\tresponse = null;\n\t\t\tpathStateManager.notifyPathNodeFinish(this);\n\t\t}\n\t}\n\n\tpublic void requeueInitialFetch() {\n\t\tif(lockedFlag) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IInjectionModuleContext ctx = new ModuleContext(pathStateManager, requestBuilder, this, 0);\n\t\tfinal HttpUriRequest req = createRequest();\n\t\tsubmitRequest(req, initialFetchProcessor, ctx);\n\t}\n\n\tprivate void setLocked() {\n\t\tlockedFlag = true;\n\t}\n\n\tprivate void performInitialFetch() {\n\t\tfinal IInjectionModuleContext ctx = new ModuleContext(pathStateManager, requestBuilder, this, 0);\n\t\tfinal HttpUriRequest req = createRequest();\n\n\t\tif(response != null) {\n\t\t\tinitialFetchProcessor.processResponse(pathStateManager.getCrawler(), req, response, ctx);\n\t\t} else {\n\t\t\tsubmitRequest(req, initialFetchProcessor, ctx);\n\t\t}\n\t\tpathStateManager.notifyPathNodeStart(this);\n\t}\n\n\t@Override\n\tpublic void setBogusParameter() {\n\t\tisBogusParameter = true;\n\t}\n\n\t@Override\n\tpublic boolean isBogusParameter() {\n\t\treturn isBogusParameter;\n\t}\n\n\t@Override\n\tpublic IWebPath getPath() {\n\t\treturn path;\n\t}\n\n\t@Override\n\tpublic void setUnknownFingerprint(IPageFingerprint fp) {\n\t\tunknownFingerprint = fp;\n\t}\n\n\t@Override\n\tpublic IPageFingerprint getUnknownFingerprint() {\n\t\treturn unknownFingerprint;\n\t}\n\n\tpublic void submitRequest(ICrawlerResponseProcessor callback) {\n\t\tfinal HttpUriRequest req = requestBuilder.createBasicRequest();\n\t\tfinal IInjectionModuleContext ctx = createModuleContext();\n\t\tsubmitRequest(req, callback, ctx);\n\t}\n\n\tpublic void submitRequest(HttpUriRequest request, ICrawlerResponseProcessor callback) {\n\t\tfinal IInjectionModuleContext ctx = createModuleContext();\n\t\tsubmitRequest(request, callback, ctx);\n\t}\n\n\tpublic void submitRequest(HttpUriRequest request, ICrawlerResponseProcessor callback, IInjectionModuleContext ctx) {\n\t\tincrementOutstandingRequests();\n\t\tpathStateManager.getCrawler().submitTask(request, getWrappedCallback(callback), ctx);\n\t}\n\n\tprivate ICrawlerResponseProcessor getWrappedCallback(ICrawlerResponseProcessor callback) {\n\t\tif(pathStateManager.requestLoggingEnabled())\n\t\t\treturn CrawlerCallbackWrapper.createLogging(this, pathStateManager.getRequestLog(), callback);\n\t\telse\n\t\t\treturn CrawlerCallbackWrapper.create(this, callback);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createRequest() {\n\t\treturn requestBuilder.createBasicRequest();\n\t}\n\n\t@Override\n\tpublic HttpUriRequest createAlteredRequest(String value, boolean append) {\n\t\treturn requestBuilder.createAlteredRequest(value, append);\n\t}\n\n\tpublic boolean hasMaximum404Fingerprints() {\n\t\treturn state404.hasMaximum404Fingerprints();\n\t}\n\n\t@Override\n\tpublic boolean add404Fingerprint(IPageFingerprint fp) {\n\t\treturn state404.add404Fingerprint(fp);\n\t}\n\n\t@Override\n\tpublic boolean isRootPath() {\n\t\treturn path.getParentPath() == null;\n\t}\n\n\t@Override\n\tpublic boolean has404Fingerprints() {\n\t\treturn state404.has404Fingerprints();\n\t}\n\n\t@Override\n\tpublic IPathState get404Parent() {\n\t\treturn state404.get404Parent();\n\t}\n\n\t@Override\n\tpublic boolean has404FingerprintMatching(IPageFingerprint fp) {\n\t\treturn state404.has404FingerprintMatching(fp);\n\t}\n\t@Override\n\tpublic boolean hasParent404Fingerprint(IPageFingerprint fp) {\n\t\treturn state404.hasParent404Fingerprint(fp);\n\t}\n\n\tpublic void dump404Fingerprints() {\n\t\tstate404.dumpFingerprints();\n\t}\n\t@Override\n\tpublic boolean hasParent404FingerprintMatchingThis() {\n\t\treturn state404.hasParent404Fingerprint(pathFingerprint);\n\t}\n\n\t@Override\n\tpublic void setSureDirectory() {\n\t\tisSureDirectory = true;\n\t}\n\n\t@Override\n\tpublic void clear404Fingerprints() {\n\t\tstate404.clear404Fingerprints();\n\t}\n\n\tpublic void setSkip404() {\n\t\tstate404.setSkip404();\n\t}\n\n\tpublic boolean getSkip404() {\n\t\treturn state404.getSkip404();\n\t}\n\n\t@Override\n\tpublic boolean isSureDirectory() {\n\t\treturn isSureDirectory;\n\t}\n\n\t@Override\n\tpublic void setResponse(IHttpResponse response) {\n\t\tthis.response = response;\n\t\tif(response != null) {\n\t\t\tthis.pathFingerprint = response.getPageFingerprint();\n\t\t} else {\n\t\t\tthis.pathFingerprint = null;\n\t\t\treturn;\n\t\t}\n\n\t\tif(response.getResponseCode() == 200) {\n\t\t\taddWebResponseToPath(response);\n\t\t}\n\t}\n\n\tprivate void addWebResponseToPath(IHttpResponse response) {\n\t\tfinal IContentAnalyzer contentAnalyzer = pathStateManager.getContentAnalyzer();\n\t\tfinal IContentAnalyzerResult result = contentAnalyzer.processResponse(response, false, false);\n\t\tfinal URI uri = createRequest().getURI();\n\t\tfinal String mimeType = contentAnalyzerResultToMimeString(result);\n\t\tif(uri.getQuery() == null) {\n\t\t\tif(path.getMimeType() == null && mimeType != null) {\n\t\t\t\tpath.setMimeType(mimeType);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tpath.addGetResponse(uri.getQuery(), mimeType);\n\t}\n\n\tprivate String contentAnalyzerResultToMimeString(IContentAnalyzerResult result) {\n\t\tif(result.getSniffedMimeType() != MimeType.MIME_NONE)\n\t\t\treturn result.getSniffedMimeType().getCanonicalName();\n\t\telse if(result.getDeclaredMimeType() != MimeType.MIME_NONE)\n\t\t\treturn result.getDeclaredMimeType().getCanonicalName();\n\t\telse\n\t\t\treturn null;\n\t}\n\n\t@Override\n\tpublic IHttpResponse getResponse() {\n\t\treturn response;\n\t}\n\n\tpublic boolean isPageMissing() {\n\t\treturn isPageMissing;\n\t}\n\n\t@Override\n\tpublic void setPageMissing() {\n\t\tisPageMissing = true;\n\t}\n\n\t@Override\n\tpublic void setResponseVaries() {\n\t\tresponseVaries = true;\n\t}\n\n\t@Override\n\tpublic boolean getResponseVaries() {\n\t\treturn responseVaries;\n\t}\n\n\tpublic void debug(String msg) {\n\t\tpathStateManager.debug(\"[\"+path.getUri()+\"] \"+ msg);\n\t}\n\n\t@Override\n\tpublic IPageFingerprint getPathFingerprint() {\n\t\treturn pathFingerprint;\n\t}\n\n\t@Override\n\tpublic boolean matchesPathFingerprint(IPageFingerprint fp) {\n\t\tif(pathFingerprint == null) {\n\t\t\tdebug(\"Whoops no path fingerprint for \"+ path.getUri() + \" : \" + this);\n\t\t\treturn false;\n\t\t}\n\t\treturn pathFingerprint.isSame(fp);\n\t}\n\n\t@Override\n\tpublic long getScanId() {\n\t\treturn pathStateManager.getScanId();\n\t}\n\t@Override\n\tpublic int allocateXssId() {\n\t\treturn pathStateManager.allocateXssId();\n\t}\n\t@Override\n\tpublic String createXssTag(int xssId) {\n\t\treturn pathStateManager.createXssTag(xssId);\n\t}\n\t@Override\n\tpublic String createXssTag(String prefix, int xssId) {\n\t\treturn pathStateManager.createXssTag(prefix, xssId);\n\t}\n\t@Override\n\tpublic String createXssPattern(int xssId) {\n\t\treturn pathStateManager.createXssPattern(xssId);\n\t}\n\t@Override\n\tpublic String createXssPattern(String prefix, int xssId) {\n\t\treturn pathStateManager.createXssPattern(prefix, xssId);\n\t}\n\t@Override\n\tpublic void registerXssRequest(HttpUriRequest request, int xssId) {\n\t\tpathStateManager.registerXssRequest(request, xssId);\n\t}\n\n\t@Override\n\tpublic HttpUriRequest getXssRequest(int xssId, int scanId) {\n\t\treturn pathStateManager.getXssRequest(xssId, scanId);\n\t}\n\n\t@Override\n\tpublic NameValuePair getFuzzableParameter() {\n\t\treturn requestBuilder.getFuzzableParameter();\n\t}\n\n\t@Override\n\tpublic void maybeAddParameters(List<NameValuePair> parameters) {\n\t\tfinal PathStateParameterManager pm = getParameterManager();\n\t\tsynchronized(pm) {\n\t\t\tif(parameters.size() > pathStateManager.getMaxParameterCount()) {\n\t\t\t\treturn;\n\t\t\t} else if(pm.hasParameterList(parameters)) {\n\t\t\t\tif(isRescanNeeded()) {\n\t\t\t\t\trescanGetParameters(parameters, pm);\n\t\t\t\t} \n\t\t\t} else if(!pathStateManager.hasExceededLimits(this)) {\n\t\t\t\tpm.addParameterList(parameters);\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic void maybeAddPostParameters(List<NameValuePair> parameters) {\n\t\tfinal PathStateParameterManager pm = getParameterManager();\n\t\tsynchronized(pm) {\n\t\t\tif(parameters.size() > pathStateManager.getMaxParameterCount()) {\n\t\t\t\treturn;\n\t\t\t} else if(!pm.hasPostParameterList(parameters)) {\n\t\t\t\tpm.addPostParameterList(parameters);\n\t\t\t} else if(isRescanNeeded()) {\n\t\t\t\trescanPostParameters(parameters,  pm);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate boolean isRescanNeeded() {\n\t\tif(!pathStateManager.isProxyScan() || response == null) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tfinal IHttpRequestEngine requestEngine = pathStateManager.getCrawler().getRequestEngine();\n\t\tfinal List<Cookie> cookies = requestEngine.getCookiesForRequest(response.getHost(), response.getOriginalRequest());\n\t\treturn !sameCookies(cookies, response.getSentCookies());\n\t}\n\t\n\tprivate boolean sameCookies(List<Cookie> a, List<Cookie> b) {\n\t\tif(a.size() != b.size()) {\n\t\t\treturn false;\n\t\t}\n\t\tfor(Cookie c: a) {\n\t\t\tCookie c2 = findFirstCookieByName(b, c.getName());\n\t\t\tif(c2 == null) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate Cookie findFirstCookieByName(List<Cookie> cookieList, String name) {\n\t\tfor(Cookie c: cookieList) {\n\t\t\tif(c.getName().equalsIgnoreCase(name)) {\n\t\t\t\treturn c;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate void rescanGetParameters(List<NameValuePair> parameters, PathStateParameterManager manager) {\n\t\trescanPathStates(manager.getStatesForParameterList(parameters));\n\t}\n\t\n\tprivate void rescanPostParameters(List<NameValuePair> parameters, PathStateParameterManager manager) {\n\t\trescanPathStates(manager.getStatesForPostParameterList(parameters));\n\t}\n\t\n\tprivate void rescanPathStates(List<PathState> states) {\n\t\tfor(PathState ps: states) {\n\t\t\tps.requeueInitialFetch();\n\t\t}\n\t}\n\n\tprivate synchronized PathStateParameterManager getParameterManager() {\n\t\tif(parameterManager == null) {\n\t\t\tparameterManager = new PathStateParameterManager(this);\n\t\t}\n\t\treturn parameterManager;\n\t}\n\n\t@Override\n\tpublic void unlockChildren() {\n\t\tsynchronized(childStates) {\n\t\t\tif(!lockedFlag)\n\t\t\t\treturn;\n\t\t\tlockedFlag = false;\n\t\t\tfor(PathState c: childStates) {\n\t\t\t\tc.performInitialFetch();\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn \"STATE: [\"+ requestBuilder + \"]\";\n\t}\n\n\t@Override\n\tpublic IInjectionModuleContext createModuleContext() {\n\t\treturn new ModuleContext(pathStateManager, requestBuilder, this);\n\t}\n\n\t@Override\n\tpublic void setFailed404Detection() {\n\t\thasFailed404 = true;\n\t}\n\n\t@Override\n\tpublic boolean hasFailed404Detection() {\n\t\treturn hasFailed404;\n\t}\n\n\t@Override\n\tpublic void setBadParentDirectory() {\n\t\thasBadParent = true;\n\t}\n\n\t@Override\n\tpublic boolean hasBadParentDirectory() {\n\t\treturn hasBadParent;\n\t}\n\n\t@Override\n\tpublic boolean isIPSDetected() {\n\t\treturn ipsDetected;\n\t}\n\n\t@Override\n\tpublic void setIPSDetected() {\n\t\tipsDetected = true;\n\t}\n\n\t@Override\n\tpublic boolean doInjectionChecks() {\n\t\tif(isParametric())\n\t\t\treturn true;\n\t\telse if(path.getPathType() == PathType.PATH_DIRECTORY)\n\t\t\treturn pathStateManager.getDirectoryInjectionChecksFlag();\n\t\telse\n\t\t\treturn pathStateManager.getNonParameterFileInjectionChecksFlag();\n\t}\n\n\t@Override\n\tpublic List<IBasicModuleScript> getInjectionModules() {\n\t\treturn pathStateManager.getInjectionModules();\n\t}\n\n\t@Override\n\tpublic IHttpRequestEngine getRequestEngine() {\n\t\treturn pathStateManager.getCrawler().getRequestEngine();\n\t}\n\t\n\tpublic HttpUriRequest createRawRequest(HttpHost httpHost, String method, String uriString) {\n\t\tVegaHttpUriRequest request = new VegaHttpUriRequest(httpHost, method, uriString);\n\t\treturn getRequestEngine().createRawRequest(httpHost, request.getRequestLine());\n\t\n\t}\n\t\n\tvoid incrementOutstandingRequests() {\n\t\toutstandingRequests.incrementAndGet();\n\t}\n\t\n\tpublic void decrementOutstandingRequests() {\n\t\tif((outstandingRequests.decrementAndGet() <= 0) && (fuzzCounter.get() <= 0)) {\n\t\t\tif(finishOnNoRequests) {\n\t\t\t\tsetDone();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void incrementFuzzCounter() {\n\t\tfuzzCounter.incrementAndGet();\n\t}\n\t\n\tpublic void decrementFuzzCounter() {\n\t\tif((fuzzCounter.decrementAndGet() <= 0) && (outstandingRequests.get() <= 0)) {\n\t\t\tif(finishOnNoRequests) {\n\t\t\t\tsetDone();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic void setFinishOnNoRequests() {\n\t\tfinishOnNoRequests = true;\n\t\tif(outstandingRequests.get() == 0) {\n\t\t\tsetDone();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/PathState404.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class PathState404 {\n\tprivate final static int MAX_404_SIGS = 4;\n\tprivate final IPathState pathState;\n\tprivate final List<IPageFingerprint> page404Fingerprints = new ArrayList<IPageFingerprint>();\n\tprivate boolean skip404;\n\t\n\tPathState404(IPathState ps) {\n\t\tthis.pathState = ps;\n\t}\n\t\n\tvoid setSkip404() {\n\t\tskip404 = true;\n\t}\n\t\n\tboolean getSkip404() {\n\t\treturn skip404;\n\t}\n\t\n\tpublic synchronized boolean hasMaximum404Fingerprints() {\n\t\treturn page404Fingerprints.size() == MAX_404_SIGS;\n\t}\n\t\n\tpublic synchronized boolean add404Fingerprint(IPageFingerprint fp) {\n\t\tif(hasMaximum404Fingerprints()) \n\t\t\treturn false;\n\t\tif(!has404FingerprintMatching(fp))\n\t\t\tpage404Fingerprints.add(fp);\n\t\t// XXX add parent check from dir_404_callback\n\t\treturn true;\n\t}\n\t\n\tpublic synchronized boolean has404Fingerprints() {\n\t\treturn !page404Fingerprints.isEmpty();\n\t}\n\t\n\tpublic IPathState get404Parent() {\n\t\tfinal IPathState parent = pathState.getParentState();\n\t\tif(parent != null && parent.has404Fingerprints())\n\t\t\treturn parent;\n\t\telse\n\t\t\treturn null;\t\n\t}\n\t\n\tpublic synchronized boolean has404FingerprintMatching(IPageFingerprint fp) {\n\t\tif(fp == null)\n\t\t\treturn false;\n\t\t\n\t\tfor(IPageFingerprint f: page404Fingerprints)\n\t\t\tif(f.isSame(fp))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\t\n\tpublic boolean hasParent404Fingerprint(IPageFingerprint fp) {\n\t\tfinal IPathState pps = get404Parent();\n\t\treturn (pps != null && pps.has404FingerprintMatching(fp));\n\t}\n\t\n\tpublic synchronized void clear404Fingerprints() {\n\t\tpage404Fingerprints.clear();\n\t}\n\t\n\tpublic void dumpFingerprints() {\n\t\tfor(IPageFingerprint fp: page404Fingerprints) {\n\t\t\tSystem.out.println(fp);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/PathStateManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport java.net.URI;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.logging.Logger;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.impl.scanner.handlers.DirectoryProcessor;\nimport com.subgraph.vega.impl.scanner.urls.ResponseAnalyzer;\n\npublic class PathStateManager {\n\tprivate final Logger logger = Logger.getLogger(\"scanner\");\n\tprivate final IScannerConfig config;\n\tprivate List<IBasicModuleScript> injectionModules;\n\tprivate final IWorkspace workspace;\n\tprivate final IWebCrawler crawler;\n\tprivate final ResponseAnalyzer responseAnalyzer;\n\tprivate final boolean isProxyScan;\n\tprivate final ICrawlerResponseProcessor directoryFetchCallback = new DirectoryProcessor();\n\tprivate final Wordlists wordlists = new Wordlists();\n\n\tprivate final Map<IWebPath, PathState> modelToScanState = new HashMap<IWebPath, PathState>();\n\n\tprivate int currentXssId = 0;\n\tprivate final Map<Integer, HttpUriRequest> xssRequests = new HashMap<Integer, HttpUriRequest>();\n\n\tprivate final IScanInstance scanInstance;\n\n\tprivate Object progressLock = new Object();\n\tprivate volatile int totalPathCount;\n\tprivate volatile int completedPathCount;\n\n\n\tpublic PathStateManager(IScannerConfig config, List<IBasicModuleScript> injectionModules, IWorkspace workspace, IWebCrawler crawler, ResponseAnalyzer responseAnalyzer, IScanInstance scanInstance, boolean isProxyScan) {\n\t\tthis.config = config;\n\t\tthis.injectionModules = injectionModules;\n\t\tthis.workspace = workspace;\n\t\tthis.crawler = crawler;\n\t\tthis.responseAnalyzer = responseAnalyzer;\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.isProxyScan = isProxyScan;\n\t}\n\n\tpublic void setInjectionModules(List<IBasicModuleScript> injectionModules) {\n\t\tthis.injectionModules = injectionModules;\n\t}\n\n\tpublic List<IBasicModuleScript> getInjectionModules() {\n\t\treturn injectionModules;\n\t}\n\n\tpublic boolean requestLoggingEnabled() {\n\t\treturn config.getLogAllRequests();\n\t}\n\n\tpublic boolean hasSeenPath(IWebPath path) {\n\t\tsynchronized(modelToScanState) {\n\t\t\treturn modelToScanState.containsKey(path);\n\t\t}\n\t}\n\n\tpublic boolean isProxyScan() {\n\t\treturn isProxyScan;\n\t}\n\n\t/* called with modelToScanState lock */\n\tprivate PathState getParentDirectoryState(IWebPath path) {\n\t\tfinal IWebPath parentPath = path.getParentPath();\n\t\tif(parentPath == null)\n\t\t\treturn null;\n\t\tif(!modelToScanState.containsKey(parentPath)) {\n\t\t\tif(parentPath.getPathType() != PathType.PATH_DIRECTORY)\n\t\t\t\tparentPath.setPathType(PathType.PATH_DIRECTORY);\n\t\t\tfinal PathState parentState = createStateForPathNoChecks(parentPath, directoryFetchCallback);\n\t\t\tmodelToScanState.put(parentPath, parentState);\n\t\t\treturn parentState;\n\t\t}\n\t\treturn modelToScanState.get(parentPath);\n\n\n\t}\n\n\tpublic PathState createStateForPath(IWebPath path, ICrawlerResponseProcessor fetchCallback) {\n\t\tfinal PathState parent = getParentDirectoryState(path);\n\t\tif(parent != null) {\n\t\t\tif(hasExceededLimits(parent)) {\n\t\t\t\tlogger.warning(\"Failed to add \"+ path.getUri().toString() + \" due to exceeded limits\");\n\t\t\t\treturn null;\n\t\t\t} else if(exceedsDuplicatePathLimit(path.getPathComponent(), parent)) {\n\t\t\t\tlogger.warning(\"Maximum duplicate path limit of \"+ config.getMaxDuplicatePaths() + \" exceeded adding \"+ path.getUri().toString());\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn createStateForPathNoChecks(path, fetchCallback);\n\t}\n\n\tboolean hasExceededLimits(PathState ps) {\n\t\tif(ps.getDepth() > config.getMaxDepth()) {\n\t\t\tlogger.warning(\"Maximum path depth of \"+ config.getMaxDepth() + \" exceeded at \"+ ps.getPath().getUri().toString());\n\t\t\treturn true;\n\t\t} else if(ps.getChildCount() > config.getMaxChildren()) {\n\t\t\tlogger.warning(\"Maximum child path count of \"+ config.getMaxChildren() + \" exceeded at \"+ ps.getPath().getUri().toString());\n\t\t\treturn true;\n\t\t} else if(ps.getDescendantCount() > config.getMaxDescendants()) {\n\t\t\tlogger.warning(\"Maximum total descendant count of \"+ config.getMaxDescendants() + \" exceeded at \"+ ps.getPath().getUri().toString());\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate boolean exceedsDuplicatePathLimit(String name, PathState parent) {\n\t\tint count = 0;\n\t\tPathState ps = parent;\n\t\twhile(ps != null) {\n\t\t\tif(ps.getPath().getPathComponent().equalsIgnoreCase(name)) {\n\t\t\t\tcount += 1;\n\t\t\t}\n\t\t\tps = ps.getParentState();\n\t\t}\n\t\treturn count > config.getMaxDuplicatePaths();\n\t}\n\n\tprivate PathState createStateForPathNoChecks(IWebPath path, ICrawlerResponseProcessor fetchCallback) {\n\t\tsynchronized(modelToScanState) {\n\t\t\tif(path == null)\n\t\t\t\tthrow new NullPointerException();\n\t\t\tif(modelToScanState.containsKey(path))\n\t\t\t\tthrow new IllegalStateException(\"Path already exists.\"+ path);\n\t\t\tfinal PathState parent = getParentDirectoryState(path);\n\t\t\tfinal PathState st = PathState.createBasicPathState(fetchCallback, this, parent, path);\n\t\t\tmodelToScanState.put(path, st);\n\t\t\treturn st;\n\t\t}\n\t}\n\n\tpublic PathState getStateForPath(IWebPath path) {\n\t\tif(path == null)\n\t\t\treturn null;\n\t\tsynchronized(modelToScanState) {\n\t\t\treturn modelToScanState.get(path);\n\t\t}\n\t}\n\n\tpublic IWebCrawler getCrawler() {\n\t\treturn crawler;\n\t}\n\n\tpublic void analyzePage(IInjectionModuleContext ctx, HttpUriRequest request, IHttpResponse response) {\n\t\tresponseAnalyzer.analyzePage(ctx, request, response);\n\t}\n\n\tpublic void analyzeContent(IInjectionModuleContext ctx, HttpUriRequest request, IHttpResponse response) {\n\t\tresponseAnalyzer.analyzeContent(ctx, request, response);\n\t}\n\n\tpublic void analyzePivot(IInjectionModuleContext ctx, HttpUriRequest request, IHttpResponse response) {\n\t\tresponseAnalyzer.analyzePivot(ctx, request, response);\n\t}\n\n\tpublic String createXssTag(int xssId) {\n\t\treturn createXssTag(\"\", xssId);\n\t}\n\t\n\tpublic String createXssPattern(int xssId) {\n\t\treturn createXssPattern(\"\", xssId);\n\t}\n\n\tpublic int allocateXssId() {\n\t\tsynchronized(xssRequests) {\n\t\t\treturn currentXssId++;\n\t\t}\n\t}\n\tpublic String createXssTag(String prefix, int xssId) {\n\t\tif(scanInstance.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\treturn formatXssTag(prefix, xssId, 0);\n\t\t} else {\n\t\t\treturn formatXssTag(prefix, xssId, scanInstance.getScanId());\n\t\t}\n\t}\n\t\n\tpublic String createXssPattern(String prefix, int xssId) {\n\t\tif(scanInstance.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\treturn formatXssPattern(prefix, xssId, 0);\n\t\t} else {\n\t\t\treturn formatXssPattern(prefix, xssId, scanInstance.getScanId());\n\t\t}\t\t\n\t}\n\n\tprivate String formatXssTag(String prefix, int xssId, long scanId) {\n\t\treturn String.format(\"%s-->\\\">'>'\\\"<vvv%06dv%06d>\", prefix, xssId, scanId);\n\t}\n\n\tprivate String formatXssPattern(String prefix, int xssId, long scanId) {\n\t\treturn String.format(\"%svvv%06dv%06d\", prefix, xssId, scanId);\n\t}\n\t\n\tpublic void registerXssRequest(HttpUriRequest request, int xssId) {\n\t\tsynchronized(xssRequests) {\n\t\t\txssRequests.put(xssId, request);\n\t\t}\n\t}\n\t\n\tpublic long getScanId() {\n\t\treturn scanInstance.getScanId();\n\t}\n\n\tpublic HttpUriRequest getXssRequest(int xssId, int scanId) {\n\t\tsynchronized(xssRequests) {\n\t\t\tif(isValidXssId(xssId, scanId)) {\n\t\t\t\treturn xssRequests.get(xssId);\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate boolean isValidXssId(int xssId, int scanId) {\n\t\tif(scanId == 0 && scanInstance.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID && xssId < currentXssId) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn scanId == scanInstance.getScanId() && xssId < currentXssId;\n\t\t}\n\t}\n\n\tpublic IRequestLog getRequestLog() {\n\t\treturn workspace.getRequestLog();\n\t}\n\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n\n\tpublic boolean isExcludedParameter(String name) {\n\t\treturn config.getExcludedParameterNames().contains(name.toLowerCase());\n\t}\n\t\n\tpublic void debug(String message) {\n\t\tif(config.getDisplayDebugOutput())\n\t\t\tlogger.info(message);\n\t}\n\t\n\tpublic void debug(String message, Boolean colored) {\n\t\tif(config.getDisplayDebugOutput()) {\n\t\t\tif (colored) {\n\t\t\t\tlogger.finer(message);\n\t\t\t} else {\n\t\t\t\tlogger.info(message);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic void reportRequestException(HttpUriRequest request, Throwable ex) {\n\t\tlogger.warning(\"Exception processing request: \"+ request +\" : \"+ ex.getMessage());\n\t\tscanInstance.notifyScanException(request, ex);\n\t}\n\n\tpublic List<String> getFileExtensionList() {\n\t\treturn wordlists.getFileExtensions();\n\t}\n\n\tpublic IContentAnalyzer getContentAnalyzer() {\n\t\treturn responseAnalyzer.getContentAnalyzer();\n\t}\n\n\tpublic boolean getDirectoryInjectionChecksFlag() {\n\t\treturn config.getDirectoryInjectionChecksFlag();\n\t}\n\n\tpublic boolean getNonParameterFileInjectionChecksFlag() {\n\t\treturn config.getNonParameterFileInjectionChecksFlag();\n\t}\n\t\n\tpublic int getMaxParameterCount() {\n\t\treturn config.getMaxParameterCount();\n\t}\n\t\n\tvoid notifyPathNodeStart(PathState ps) {\n\t\tfinal String path = pathNodeToPathString(ps);\n\t\tdebug(\"Starting path \"+ path);\n\t\tsynchronized(progressLock) {\n\t\t\tif(totalPathCount == 0) {\n\t\t\t\tscanInstance.updateScanProgress(path, 0, 1);\n\t\t\t}\n\t\t\ttotalPathCount += 1;\n\t\t}\n\t\tscanInstance.updateScanProgress(completedPathCount, totalPathCount);\n\t}\n\t\n\tvoid notifyPathNodeFinish(PathState ps) {\n\t\tfinal String path = pathNodeToPathString(ps);\n\t\tdebug(\"Finished path \"+ path);\n\t\tsynchronized (progressLock) {\n\t\t\tcompletedPathCount += 1;\n\t\t}\n\t\tscanInstance.updateScanProgress(path, completedPathCount, totalPathCount);\n\t}\n\t\n\tprivate String pathNodeToPathString(PathState ps) {\n\t\tfinal URI uri = ps.getPath().getUri();\n\t\treturn uri.toString();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/PathStateParameterManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\n\nimport org.apache.http.NameValuePair;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebPathParameters;\nimport com.subgraph.vega.impl.scanner.handlers.FileProcessor;\n\npublic class PathStateParameterManager {\n\tprivate final static ICrawlerResponseProcessor fileFetchProcessor = new FileProcessor();\n\tprivate final PathState pathState;\n\t// For each unique set of parameters, we have an indexed list of PathState nodes, one for each parameter\n\tprivate final Map<Set<String>, List<PathState>> parametersToPathStates = new HashMap<Set<String>, List<PathState>>();\n\tprivate final Map<Set<String>, List<PathState>> parametersToPostPathStates = new HashMap<Set<String>, List<PathState>>();\n\n\tPathStateParameterManager(PathState ps) {\n\t\tthis.pathState = ps;\n\t\tfinal IWebPath path = ps.getPath();\n\t\tIWebPathParameters parameters = path.getGetParameters();\n\t\t// XXX hmmm?\n\t\tfor(List<NameValuePair> plist: parameters.getParameterLists()) {\n\t\t\taddParameterList(plist);\n\t\t}\n\t}\n\n\tpublic synchronized List<PathState> addParameterList(List<NameValuePair> plist) {\n\t\tfinal Set<String> names = getNameSetForParameterList(plist);\n\n\t\tif(parametersToPathStates.containsKey(names))\n\t\t\treturn parametersToPathStates.get(names);\n\n\t\tfinal List<PathState> pathStates = new ArrayList<PathState>(plist.size());\n\n\t\tparametersToPathStates.put(names, pathStates);\n\n\t\tfor(int i = 0; i < plist.size(); i++)  {\n\t\t\tif(!isExcludedParameter(plist.get(i))) {\n\t\t\t\taddFuzzablePathState(pathStates, plist, i);\n\t\t\t}\n\t\t}\n\t\treturn pathStates;\n\t}\n\t\n\tprivate boolean isExcludedParameter(NameValuePair parameter) {\n\t\treturn pathState.getPathStateManager().isExcludedParameter(parameter.getName());\n\t}\n\t\t\n\tprivate void addFuzzablePathState(List<PathState> pathStates, List<NameValuePair> parameters, int index) {\n\t\tfinal PathState ps = PathState.createParameterPathState(fileFetchProcessor, pathState, parameters, index);\n\t\tpathStates.add(ps);\n\t}\n\t\n\tprivate Set<String> getNameSetForParameterList(List<NameValuePair> plist) {\n\t\tfinal Set<String> names = new HashSet<String>();\n\t\tfor(NameValuePair nvp: plist) {\n\t\t\tnames.add(nvp.getName());\n\t\t}\n\t\treturn names;\n\t}\n\n\tpublic synchronized boolean hasParameterList(List<NameValuePair> plist) {\n\t\treturn parametersToPathStates.containsKey( getNameSetForParameterList(plist) );\n\t}\n\n\tpublic synchronized List<PathState> getStatesForParameterList(List<NameValuePair> plist) {\n\t\tfinal List<PathState> result = parametersToPathStates.get( getNameSetForParameterList(plist) );\n\t\tif(result == null)\n\t\t\treturn Collections.emptyList();\n\t\telse\n\t\t\treturn result;\n\t}\n\n\tpublic synchronized boolean hasPostParameterList(List<NameValuePair> plist) {\n\t\treturn parametersToPostPathStates.containsKey( getNameSetForParameterList(plist) );\n\t}\n\n\tpublic synchronized List<PathState> getStatesForPostParameterList(List<NameValuePair> plist) {\n\t\tfinal List<PathState> result = parametersToPostPathStates.get( getNameSetForParameterList(plist) );\n\t\tif(result == null)\n\t\t\treturn Collections.emptyList();\n\t\telse\n\t\t\treturn result;\n\t}\n\n\tpublic synchronized List<PathState> addPostParameterList(List<NameValuePair> plist) {\n\t\tfinal Set<String> names = getNameSetForParameterList(plist);\n\t\tif(parametersToPostPathStates.containsKey(names))\n\t\t\treturn parametersToPostPathStates.get(names);\n\n\t\tfinal List<PathState> pathStates = new ArrayList<PathState>();\n\t\tparametersToPostPathStates.put(names, pathStates);\n\n\t\tfor(int i = 0; i < plist.size(); i++) {\n\t\t\tif(!isExcludedParameter(plist.get(i))) {\n\t\t\t\taddFuzzablePostPathState(pathStates, plist, i);\n\t\t\t}\n\t\t}\n\t\treturn pathStates;\n\t}\n\t\n\tprivate void addFuzzablePostPathState(List<PathState> pathStates, List<NameValuePair> parameters, int index) {\n\t\tfinal PathState ps = PathState.createPostParameterPathState(fileFetchProcessor, pathState, parameters, index);\n\t\tpathStates.add(ps);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/state/Wordlists.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.state;\n\nimport java.util.Collections;\nimport java.util.List;\n\npublic class Wordlists {\n\t\n\tpublic List<String> getFileExtensions() {\n\t\treturn Collections.emptyList();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/urls/ResponseAnalyzer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2013 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors:\n * Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.urls;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.utils.URIUtils;\nimport org.jsoup.nodes.Document;\nimport org.w3c.dom.Attr;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.html2.HTMLDocument;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.analysis.IContentAnalyzerResult;\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.util.UriTools;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.impl.scanner.forms.FormProcessor;\n\npublic class ResponseAnalyzer {\n\n\tprivate final IContentAnalyzer contentAnalyzer;\n\tprivate final UriParser uriParser;\n\tprivate final UriFilter uriFilter;\n\tprivate final FormProcessor formProcessor;\n\tprivate final SQLErrorMessageDetector sqlDetector;\n\tprivate final boolean isProxyScan;\n\tprivate final static Logger logger = Logger.getLogger(\"modules\");\n\t\n\n\tpublic ResponseAnalyzer(IScannerConfig config,\n\t\t\tIContentAnalyzer contentAnalyzer, UriParser uriParser,\n\t\t\tUriFilter uriFilter, boolean isProxyScan) {\n\t\tthis.contentAnalyzer = contentAnalyzer;\n\t\tthis.uriParser = uriParser;\n\t\tthis.uriFilter = uriFilter;\n\t\tthis.isProxyScan = isProxyScan;\n\t\tthis.formProcessor = new FormProcessor(config, uriFilter, uriParser);\n\t\tthis.sqlDetector = new SQLErrorMessageDetector(this);\n\t}\n\n\tpublic IContentAnalyzer getContentAnalyzer() {\n\t\treturn contentAnalyzer;\n\t}\n\n\tpublic void analyzePivot(IInjectionModuleContext ctx, HttpUriRequest req,\n\t\t\tIHttpResponse res) {\n\n\t}\n\n\tpublic void analyzePage(IInjectionModuleContext ctx, HttpUriRequest req,\n\t\t\tIHttpResponse res) {\n\n\t\tfinal IContentAnalyzerResult result = contentAnalyzer.processResponse(\n\t\t\t\tres, false, true);\n\t\tif (isProxyScan) {\n\t\t\treturn;\n\t\t}\n\t\tfor (VegaURI u : result.getDiscoveredURIs()) {\n\t\t\tif (uriFilter.filter(u))\n\t\t\t\turiParser.processUri(u);\n\t\t}\n\t\tformProcessor.processForms(ctx, req, res);\n\t}\n\n\tpublic void analyzeContent(IInjectionModuleContext ctx, HttpUriRequest req,\n\t\t\tIHttpResponse res) {\n\t\tanalyzeHtml(ctx, req, res);\n\t\tif (!filterInjectedPath(res.getRequestUri().getPath())) {\n\t\t\tcontentAnalyzer.processResponse(res, false, false);\n\t\t}\n\t\tsqlDetector.detectErrorMessages(ctx, req, res);\n\t}\n\n\tprivate void analyzeHtml(IInjectionModuleContext ctx, HttpUriRequest req,\n\t\t\tIHttpResponse res) {\n\t\tIHTMLParseResult html = res.getParsedHTML();\n\t\tif (html == null)\n\t\t\treturn;\n\t\tHTMLDocument document = html.getDOMDocument();\n\t\tNodeList elements = document.getElementsByTagName(\"*\");\n\t\tfor (int i = 0; i < elements.getLength(); i++) {\n\t\t\tNode node = elements.item(i);\n\t\t\tif (node instanceof Element) {\n\t\t\t\tanalyzeHtmlElement(ctx, req, res, (Element) node);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate boolean filterInjectedPath(String path) {\n\t\treturn path.contains(\"vega://\") || path.contains(\"//vega.invalid\")\n\t\t\t\t|| pathContainsXssTag(path);\n\t}\n\n\tprivate boolean pathContainsXssTag(String path) {\n\t\tfinal int idx = path.indexOf(\"vvv\");\n\t\tif (idx == -1) {\n\t\t\treturn false;\n\t\t}\n\t\treturn extractXssTag(path, idx) != null;\n\t}\n\n\tprivate void analyzeHtmlElement(IInjectionModuleContext ctx,\n\t\t\tHttpUriRequest req, IHttpResponse res, Element elem) {\n\t\tboolean remoteScript = false;\n\t\tNamedNodeMap attributes = elem.getAttributes();\n\t\tfinal String tag = elem.getTagName().toLowerCase();\n\t\tfor (int i = 0; i < attributes.getLength(); i++) {\n\t\t\tNode item = attributes.item(i);\n\t\t\tif (item instanceof Attr) {\n\t\t\t\tString n = ((Attr) item).getName().toLowerCase();\n\t\t\t\tString v = ((Attr) item).getValue().toLowerCase();\n\t\t\t\tif (match(tag, \"script\") && match(n, \"src\"))\n\t\t\t\t\tremoteScript = true;\n\t\t\t\tif ((v != null)\n\t\t\t\t\t\t&& (match(n, \"href\", \"src\", \"action\", \"codebase\") || (match(\n\t\t\t\t\t\t\t\tn, \"value\") && !match(tag, \"input\")))) {\n\t\t\t\t\tif (v.startsWith(\"vega://\"))\n\t\t\t\t\t\talert(ctx, \"vinfo-url-inject\", \"URL injection into <\"\n\t\t\t\t\t\t\t\t+ tag + \"> tag\", req, res, null);\n\n\t\t\t\t\tif (v.startsWith(\"http://vega.invalid/\")\n\t\t\t\t\t\t\t|| v.startsWith(\"//vega.invalid/\")) {\n\t\t\t\t\t\tif (match(tag, \"script\", \"link\")) {\n\t\t\t\t\t\t\tctx.addStringHighlight(((Attr) item).getValue());\n\t\t\t\t\t\t\talert(ctx, \"vinfo-xss-inject\",\n\t\t\t\t\t\t\t\t\t\"URL injection into actively fetched field in tag <\"\n\t\t\t\t\t\t\t\t\t\t\t+ tag + \"> (high risk)\", req, res,\n\t\t\t\t\t\t\t\t\tnull);\n\t\t\t\t\t\t} else if (match(tag, \"a\")) {\n\t\t\t\t\t\t\tctx.addStringHighlight(((Attr) item).getValue());\n\t\t\t\t\t\t\talert(ctx, \"vinfo-url-inject\",\n\t\t\t\t\t\t\t\t\t\"URL injection into anchor tag (low risk)\",\n\t\t\t\t\t\t\t\t\treq, res, null);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tctx.addStringHighlight(((Attr) item).getValue());\n\t\t\t\t\t\t\talert(ctx, \"vinfo-url-inject\",\n\t\t\t\t\t\t\t\t\t\"URL injection into tag <\" + tag + \">\",\n\t\t\t\t\t\t\t\t\treq, res, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ((v != null) && (n.startsWith(\"on\") || n.equals(\"style\"))) {\n\t\t\t\t\tcheckJavascriptXSS(ctx, req, res, v);\n\t\t\t\t}\n\n\t\t\t\tif (match(tag, \"script\", \"frame\", \"iframe\")\n\t\t\t\t\t\t&& match(n, \"src\")\n\t\t\t\t\t\t&& ((v != null) && (v.startsWith(\"javascript:\") || v\n\t\t\t\t\t\t\t\t.startsWith(\"vbscript:\")))) {\n\t\t\t\t\tcheckJavascriptXSS(ctx, req, res, v);\n\t\t\t\t}\n\n\t\t\t\tif (n.contains(\"vvv\"))\n\t\t\t\t\tpossibleXssAlert(ctx, req, res, n, n.indexOf(\"vvv\"),\n\t\t\t\t\t\t\t\"vinfo-xss-inject\",\n\t\t\t\t\t\t\t\"Injected XSS tag into HTML attribute value\");\n\t\t\t}\n\t\t}\n\n\t\tif (tag.startsWith(\"vvv\"))\n\t\t\tpossibleXssAlert(ctx, req, res, tag, 0, \"vinfo-xss-inject\",\n\t\t\t\t\t\"Injected XSS tag into HTML tag name\");\n\n\t\tif (tag.equals(\"style\") || (tag.equals(\"script\") && !remoteScript)) {\n\t\t\tString content = elem.getTextContent();\n\t\t\tif (content != null)\n\t\t\t\tcheckJavascriptXSS(ctx, req, res, content);\n\t\t}\n\t}\n\n\tprivate void possibleXssAlert(IInjectionModuleContext ctx,\n\t\t\tHttpUriRequest req, IHttpResponse res, String text, int offset,\n\t\t\tString type, String message) {\n\t\tfinal int[] xids = extractXssTag(text, offset);\n\t\tfinal String xidstring = extractXssString(text, offset);\n\t\tif (xids == null)\n\t\t\treturn;\n\t\tif (xidstring == null)\n\t\t\treturn;\n\t\tfinal HttpUriRequest xssReq = ctx.getPathState().getXssRequest(xids[0],\n\t\t\t\txids[1]);\n\t\tif (xssReq != null) {\n\t\t\tif (text.length() > 20)\n\t\t\t\tctx.addStringHighlight(text);\n\t\t\telse\n\t\t\t\tctx.addStringHighlight(xidstring);\n\t\t\talert(ctx, type, message, xssReq, res, null);\n\t\t} else {\n\n\t\t\tif (text.length() > 20)\n\t\t\t\tctx.addStringHighlight(text);\n\t\t\telse\n\t\t\t\tctx.addStringHighlight(xidstring);\n\n\t\t\tString path = req.getURI().normalize().getPath();\n\t\t\tString storedXSSContext;\n\n\t\t\tif (offset == 0) {\n\t\t\t\tint tagOffset = res.getBodyAsString().indexOf(text);\n\t\t\t\tif ((tagOffset + 26) < res.getBodyAsString().length())\n\t\t\t\t\tstoredXSSContext = res.getBodyAsString().substring(\n\t\t\t\t\t\t\ttagOffset + 16, tagOffset + 26);\n\t\t\t\telse\n\t\t\t\t\tstoredXSSContext = res.getBodyAsString().substring(\n\t\t\t\t\t\t\ttagOffset, res.getBodyAsString().length() - 1);\n\t\t\t} else if ((offset + 26) < text.length())\n\t\t\t\tstoredXSSContext = text.substring(offset + 16, offset + 26);\n\t\t\telse\n\t\t\t\tstoredXSSContext = text.substring(offset + 16,\n\t\t\t\t\t\ttext.length() - 1);\n\n\t\t\tint i = path.indexOf('?');\n\n\t\t\tif (i != -1) {\n\t\t\t\tpath = path.substring(0, i);\n\t\t\t}\n\n\t\t\talert(ctx, \"vinfo-xss-stored\", message + \" (from previous scan)\",\n\t\t\t\t\treq, res, \"vinfo-xss-stored:\" + path + \":\"\n\t\t\t\t\t\t\t+ storedXSSContext);\n\t\t}\n\t}\n\n\tprivate boolean match(String s, String... options) {\n\t\tif (s == null)\n\t\t\treturn false;\n\t\tfor (int i = 0; i < options.length; i++)\n\t\t\tif (s.equals(options[i]))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\n\tprivate String extractXssString(String text, int offset) {\n\t\t// 3 9\n\t\t// vvv000000v000000\n\t\tif (text.length() < (offset + 16))\n\t\t\treturn null;\n\t\tif (text.charAt(offset + 9) != 'v')\n\t\t\treturn null;\n\t\treturn text.substring(offset, offset + 16);\n\t}\n\n\tprivate int[] extractXssTag(String text, int offset) {\n\t\t// 3 9\n\t\t// vvv000000v000000\n\t\tif (text.length() < (offset + 16))\n\t\t\treturn null;\n\t\tif (text.charAt(offset + 9) != 'v')\n\t\t\treturn null;\n\n\t\tfinal int[] res = new int[2];\n\t\tres[0] = extractXssId(text, offset + 3);\n\t\tres[1] = extractXssId(text, offset + 10);\n\t\tif (res[0] == -1 || res[1] == -1)\n\t\t\treturn null;\n\t\telse\n\t\t\treturn res;\n\n\t}\n\n\tprivate int extractXssId(String text, int offset) {\n\t\tif (text.length() < (offset + 6))\n\t\t\treturn -1;\n\t\tfinal String idStr = text.substring(offset, offset + 6);\n\t\ttry {\n\t\t\treturn Integer.parseInt(idStr);\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tprivate void checkJavascriptXSS(IInjectionModuleContext ctx,\n\t\t\tHttpUriRequest req, IHttpResponse res, String text) {\n\t\tif (text == null)\n\t\t\treturn;\n\t\tint lastWordIdx = 0;\n\t\tint idx = 0;\n\t\tint possibleUrlIdx = 0;\n\t\t\n\t\tboolean inQuote = false;\n\t\tboolean prevSpace = true;\n\t\tboolean possibleUrl = false;\n\t\t\n\t\twhile (idx < text.length()) {\n\t\t\tidx = maybeSkipJavascriptComment(text, idx);\n\t\t\tif (idx >= text.length())\n\t\t\t\treturn;\n\t\t\tchar c = text.charAt(idx);\n\t\t\tif (!inQuote && (c == '\\'' || c == '\"')) {\n\t\t\t\tinQuote = true;\n\t\t\t\t\n\t\t\t\tif (matchStartsWith(text, lastWordIdx, \"innerHTML\", \"open\", \"asyncRequest\",\n\t\t\t\t\t\t\"url\", \"href\", \"write\", \"src\", \"location\", \"action\")) {\n\t\t\t\t\tpossibleUrl = true;\n\t\t\t\t\tpossibleUrlIdx = idx + 1;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (matchStartsWith(text, lastWordIdx, \"innerHTML\", \"open\",\n\t\t\t\t\t\t\"url\", \"href\", \"write\")\n\t\t\t\t\t\t&& matchStartsWith(text, idx + 1, \"//vega.invalid/\",\n\t\t\t\t\t\t\t\t\"http://vega.invalid\", \"vega:\")) {\n\t\t\t\t\talert(ctx, \"vinfo-url-inject\",\n\t\t\t\t\t\t\t\"Injected URL in JS/CSS code\", req, res, null);\n\t\t\t\t}\n\t\t\t} else if (c == '\\'' || c == '\"') {\n\t\t\t\tif (possibleUrl) {\n\t\t\t\t\taddPossibleUrl(req.getURI(),text.substring(possibleUrlIdx, idx));\n\t\t\t\t\tpossibleUrlIdx = 0;\n\t\t\t\t\tpossibleUrl = false;\n\t\t\t\t}\n\t\t\t\tinQuote = false;\n\t\t\t} else if (!inQuote && text.startsWith(\"vvv\", idx)) {\n\t\t\t\tpossibleXssAlert(ctx, req, res, text, idx, \"vinfo-xss-inject\",\n\t\t\t\t\t\t\"Injected syntax into JS/CSS code\");\n\t\t\t} else if (Character.isWhitespace(c) || c == '.') {\n\t\t\t\tprevSpace = true;\n\t\t\t} else if (prevSpace && Character.isLetterOrDigit(c)) {\n\t\t\t\tlastWordIdx = idx;\n\t\t\t\tprevSpace = false;\n\t\t\t}\n\t\t\tidx += 1;\n\t\t}\n\t}\n\n\tprivate void addPossibleUrl(URI uri, String candidateLink) {\n\t\t// TODO Auto-generated method stub\n\t\tString link;\n\n\t\tif (isProxyScan) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif (!candidateLink.startsWith(\"http\")) {\n\t\t\tlink = absUri(uri, candidateLink);\n\t\t}\n\t\telse {\n\t\t\tlink = candidateLink;\n\t\t}\n\t\tURI u = createURI(link);\n\t\tif(u != null && hasValidHttpScheme(u)) {\n\t\t\tfinal HttpHost targetHost = URIUtils.extractHost(u);\n\t\t\tif(validateHost(targetHost)) {\n\t\t\t\tfinal VegaURI vegaURI = new VegaURI(targetHost, u.normalize().getPath(), u.getQuery());\n\t\t\t\t\tif (uriFilter.filter(vegaURI))\n\t\t\t\t\turiParser.processUri(vegaURI);\n\t\t\t}\n\t\t}\t\t\n\t}\n\t\n\tprivate URI createURI(String link) {\n\t\ttry {\n\t\t\tif(link.isEmpty())\n\t\t\t\treturn null;\n\t\t\treturn new URI(link);\n\t\t} catch (URISyntaxException ex) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate boolean validateHost(HttpHost host) {\n\t\tif(host.getHostName() == null || host.getHostName().isEmpty()) {\n\t\t\treturn false;\n\t\t}\n\t\ttry {\n\t\t\tnew URI(host.getSchemeName(), null, host.getHostName(), host.getPort(), null, null, null);\n\t\t\treturn true;\n\t\t} catch (URISyntaxException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate boolean hasValidHttpScheme(URI uri) {\n\t\tfinal String scheme = uri.getScheme();\n\t\treturn (scheme != null && (scheme.equalsIgnoreCase(\"http\") || scheme.equalsIgnoreCase(\"https\")));\n\t}\n\t\n\tprivate String absUri(URI u, String path) {\n\t\tfinal String link;\n\t\t\t\t\n\t\tif (path.startsWith(\"/\")) {\n\t\t\tlink = u.getScheme() + \"://\" + u.getHost() + path;\n\t\t} else {\n\t\t\tint i = 0;\n\t\t\tint lastIndex = 0;\n\t\t\tfor (i = 0; i <= u.normalize().getPath().length()-1; i++) {\n\t\t\t  if (u.normalize().getPath().charAt(i) == '/') {\n\t\t\t\t  lastIndex = i;\n\t\t\t  }\n\t\t\t}\n\t\t\tlink = u.getScheme() + \"://\" + u.getHost() + u.normalize().getPath().substring(0,  lastIndex) + \"/\" + path;\n\t\t} \n\t\treturn link;\n\t}\n\t\n\tprivate boolean matchStartsWith(String str, int offset, String... options) {\n\t\tfor (int i = 0; i < options.length; i++) {\n\t\t\tif (str.startsWith(options[i], offset))\n\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate int maybeSkipJavascriptComment(String text, int idx) {\n\t\tfinal int max = text.length();\n\t\tfinal int savedIdx = idx;\n\t\tif (idx >= max)\n\t\t\treturn idx;\n\t\tfinal char c = text.charAt(idx++);\n\t\t// Skip escaped characters here too\n\t\tif (c == '\\\\')\n\t\t\treturn idx + 1;\n\t\tif (c != '/')\n\t\t\treturn savedIdx;\n\t\tif (idx >= max)\n\t\t\treturn idx;\n\t\tfinal char c1 = text.charAt(idx++);\n\t\tif (c1 == '/') {\n\t\t\twhile (idx < max) {\n\t\t\t\tchar cc = text.charAt(idx);\n\t\t\t\tif (cc == '\\n' || c == '\\r')\n\t\t\t\t\treturn idx;\n\t\t\t\tidx += 1;\n\t\t\t}\n\t\t\treturn max;\n\t\t} else if (c1 == '*') {\n\t\t\tint end = text.indexOf(\"*/\", idx);\n\t\t\tif (end == -1)\n\t\t\t\treturn max;\n\t\t\telse\n\t\t\t\treturn end + 2;\n\t\t}\n\t\treturn savedIdx;\n\n\t}\n\n\tpublic void alert(IInjectionModuleContext ctx, String type, String message,\n\t\t\tHttpUriRequest request, IHttpResponse response, String key) {\n\n\t\tif (key == null) {\n\t\t\tkey = createAlertKey(ctx, type, request);\n\t\t}\n\t\tString resource = request.getURI().normalize().getPath();\n\n\t\tint i = resource.indexOf('?');\n\n\t\tif (i != -1) {\n\t\t\tresource = resource.substring(0, i);\n\t\t}\n\n\t\tctx.publishAlert(type, key, message, request, response, \"resource\",\n\t\t\t\tresource);\n\t}\n\n\tprivate String createAlertKey(IInjectionModuleContext ctx, String type,\n\t\t\tHttpUriRequest request) {\n\t\tif (ctx.getPathState().isParametric()) {\n\t\t\tfinal String uri = UriTools.stripQueryFromUri(request.getURI())\n\t\t\t\t\t.toString();\n\t\t\treturn type + \":\" + uri + \":\"\n\t\t\t\t\t+ ctx.getPathState().getFuzzableParameter().getName();\n\t\t} else {\n\t\t\treturn type + \":\" + request.getURI();\n\t\t}\n\t}\n\n}"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/urls/SQLErrorMessageDetector.java",
    "content": "package com.subgraph.vega.impl.scanner.urls;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.google.common.collect.ImmutableMap;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\n\npublic class SQLErrorMessageDetector {\n\t\n\tprivate static enum databaseErrorTypes {SQLSERVER, ASP, MS, ACCESS, MYSQL, POSTGRES, JAVA, ORACLE, DQL, CF, DB2}\n\t\n\tprivate final static ImmutableMap<databaseErrorTypes, String> DATABASE_ALERTS = ImmutableMap.<databaseErrorTypes, String>builder().put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.SQLSERVER, \"vinfo-sqlserver-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.ASP, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.MS, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.ACCESS, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.MYSQL, \"vinfo-mysql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.POSTGRES, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.JAVA, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.ORACLE, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.DQL, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.CF, \"vinfo-sql-error\").put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdatabaseErrorTypes.DB2, \"vinfo-sql-error\").build();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\n\tprivate final static ImmutableMap<String, databaseErrorTypes> ERROR_STRINGS = ImmutableMap.<String, databaseErrorTypes>builder().put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"Incorrect syntax near\",  databaseErrorTypes.SQLSERVER).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\"Unclosed quotation mark\", databaseErrorTypes.SQLSERVER).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\"Dynamic SQL Error\", databaseErrorTypes.SQLSERVER).put(\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\"SqlClient.SqlException: Syntax error\", databaseErrorTypes.ASP).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"[Microsoft][ODBC SQL Server Driver]\", databaseErrorTypes.MS).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"Microsoft OLE DB Provider for ODBC Drivers</font>\", databaseErrorTypes.MS).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"Microsoft OLE DB Provider for ODBC Drivers</FONT>\", databaseErrorTypes.MS).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"Syntax error in string in query expression\",  databaseErrorTypes.ACCESS).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"<b>Warning</b>:  MySQL: \", databaseErrorTypes.MYSQL).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"You have an error in your SQL syntax\", databaseErrorTypes.MYSQL).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"supplied argument is not a valid MySQL\", databaseErrorTypes.MYSQL).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"PostgreSQL query failed:\", databaseErrorTypes.POSTGRES).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"unterminated quoted string at or near\", databaseErrorTypes.POSTGRES).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"syntax error at or near\", databaseErrorTypes.POSTGRES).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"invalid input syntax for integer:\",\tdatabaseErrorTypes.POSTGRES).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"Query failed: ERROR: syntax error\",\tdatabaseErrorTypes.POSTGRES).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"Unexpected end of command in statement\", databaseErrorTypes.JAVA).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"java.sql.SQLException:\", databaseErrorTypes.JAVA).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"quoted string not properly terminated\",\tdatabaseErrorTypes.ORACLE).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"SQL command not properly ended\", databaseErrorTypes.ORACLE).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"unable to perform query\", databaseErrorTypes.ORACLE).put(\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"[DM_QUERY_E_SYNTAX]\", databaseErrorTypes.DQL).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"[Macromedia][SQLServer JDBC Driver]\", databaseErrorTypes.CF).put(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"[Macromedia][MySQL JDBC Driver]\", databaseErrorTypes.CF).put(\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   \t\t\t\t    \"DB2 SQL Error:\", databaseErrorTypes.DB2).build();\n\t\t\t\n\tprivate final ResponseAnalyzer responseAnalyzer; \n\t\n\tpublic SQLErrorMessageDetector(ResponseAnalyzer responseAnalyzer) {\n\t\tthis.responseAnalyzer = responseAnalyzer;\n\t}\n\t\n\tpublic void detectErrorMessages(IInjectionModuleContext ctx, HttpUriRequest request, IHttpResponse response) {\n\t\tfinal String body = response.getBodyAsString();\n\t\tif(body == null || body.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\t\tfor(String errorString: ERROR_STRINGS.keySet()) {\n\t\t\tif(body.contains(errorString)) {\n\t\t\t\tprocessDetectedErrorMessage(ctx, request, response, errorString, ERROR_STRINGS.get(errorString));\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void processDetectedErrorMessage(IInjectionModuleContext ctx, HttpUriRequest request, IHttpResponse response, String errorString, databaseErrorTypes errorType) {\n\t\tctx.addStringHighlight(errorString);\n\t\tresponseAnalyzer.alert(ctx, DATABASE_ALERTS.get(errorType), \"SQL Error Message Detected\", request, response, null);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/urls/UriFilter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.urls;\n\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.Set;\nimport java.util.regex.Pattern;\n\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.util.VegaURI;\n\npublic class UriFilter {\n\tprivate final IScannerConfig scannerConfig;\n\tprivate final Set<VegaURI> visitedURIs = new HashSet<VegaURI>();\n\tprivate final ArrayList<Pattern> exclusionList = new ArrayList<Pattern>();\n\n\tpublic UriFilter(IScannerConfig scannerConfig) {\n\t\tthis.scannerConfig = scannerConfig;\n\t\t// REVISIT: we should really be merging identity config into scan config when scan starts\n\t\tif (scannerConfig.getScanIdentity() != null) {\n\t\t\tfor (String exclusion: scannerConfig.getScanIdentity().getPathExclusions()) {\n\t\t\t\texclusionList.add(Pattern.compile(exclusion));\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic boolean isExcluded(final VegaURI uri) {\n\t\tfor (Pattern p: exclusionList) {\n\t\t\tif (p.matcher(uri.toString()).find() == true) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tpublic boolean isAllowed(VegaURI uri) {\n\t\tfinal ITargetScope scanTargetScope = scannerConfig.getScanTargetScope();\n\t\treturn scanTargetScope.filter(uri.toURI()) && !isExcluded(uri);\n\t}\n\n\tpublic synchronized boolean filter(VegaURI uri) {\n\t\tif(visitedURIs.contains(uri) || !isAllowed(uri))\n\t\t\treturn false;\n\t\tvisitedURIs.add(uri);\n\t\treturn true;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner/src/com/subgraph/vega/impl/scanner/urls/UriParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.urls;\n\nimport java.util.List;\n\nimport org.apache.http.Consts;\nimport org.apache.http.HttpHost;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.utils.URLEncodedUtils;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebModel;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebPath.PathType;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.util.VegaURI;\nimport com.subgraph.vega.impl.scanner.handlers.DirectoryProcessor;\nimport com.subgraph.vega.impl.scanner.handlers.FileProcessor;\nimport com.subgraph.vega.impl.scanner.handlers.UnknownProcessor;\nimport com.subgraph.vega.impl.scanner.state.PathState;\nimport com.subgraph.vega.impl.scanner.state.PathStateManager;\n\npublic class UriParser {\n\tprivate final IWorkspace workspace;\n\tprivate final ICrawlerResponseProcessor directoryProcessor;\n\tprivate final ICrawlerResponseProcessor fileProcessor;\n\tprivate final ICrawlerResponseProcessor unknownProcessor;\n\tprivate final PathStateManager pathStateManager;\n\n\tpublic UriParser(IScannerConfig config, List<IBasicModuleScript> injectionModules, IWorkspace workspace, IWebCrawler crawler, UriFilter filter, IContentAnalyzer contentAnalyzer, IScanInstance scanInstance, boolean isProxyScan) {\n\t\tthis.workspace = workspace;\n\t\tthis.directoryProcessor = new DirectoryProcessor();\n\t\tthis.fileProcessor = new FileProcessor();\n\t\tthis.unknownProcessor = new UnknownProcessor();\n\t\tthis.pathStateManager = new PathStateManager(config, injectionModules, workspace, crawler, new ResponseAnalyzer(config, contentAnalyzer, this, filter, isProxyScan), scanInstance, isProxyScan);\n\t}\n\n\tpublic void updateInjectionModules(List<IBasicModuleScript> injectionModules) {\n\t\tpathStateManager.setInjectionModules(injectionModules);\n\t}\n\n\tpublic IPathState processUri(VegaURI uri) {\n\t\tfinal IWebHost webHost = getWebHost(uri.getTargetHost());\n\t\tfinal IWebPath rootPath = webHost.getRootPath();\n\t\tIWebPath path = rootPath;\n\t\tfinal boolean hasTrailingSlash = uri.getPath().endsWith(\"/\");\n\n\t\tString[] parts = uri.getPath().split(\"/\");\n\t\tIWebPath childPath = null;\n\t\tfor(int i = 1; i < parts.length; i++) {\n\t\t\tsynchronized(path) {\n\t\t\t\tchildPath = path.getChildPath(parts[i]);\n\t\t\t\tif(childPath == null) {\n\t\t\t\t\tchildPath = path.addChildPath(parts[i]);\n\t\t\t\t}\n\t\t\t\tprocessPath(childPath, uri, (i == (parts.length - 1)), hasTrailingSlash);\n\t\t\t}\n\t\t\tpath = childPath;\n\t\t}\n\t\t\n\t\tif(path == rootPath && uri.getQuery() != null) {\n\t\t\tfinal PathState ps = pathStateManager.getStateForPath(rootPath);\n\t\t\tsynchronized (pathStateManager) {\n\t\t\t\tps.maybeAddParameters(URLEncodedUtils.parse(uri.getQuery(), Consts.UTF_8));\n\t\t\t}\n\t\t}\n\t\treturn pathStateManager.getStateForPath(path);\n\t}\n\n\tprivate IWebHost getWebHost(HttpHost host) {\n\t\tIWebHost webHost = null;\n\t\tsynchronized(workspace) {\n\t\t\tfinal IWebModel webModel = workspace.getWebModel();\n\t\t\twebHost = webModel.getWebHostByHttpHost(host);\n\t\t\tif(webHost == null)\n\t\t\t\twebHost = webModel.createWebHostFromHttpHost(host);\n\t\t}\n\t\tprocessWebHost(webHost);\n\t\treturn webHost;\n\t}\n\n\tprivate void processWebHost(IWebHost webHost) {\n\t\tfinal IWebPath rootPath = webHost.getRootPath();\n\t\tsynchronized(pathStateManager) {\n\t\t\tif(!pathStateManager.hasSeenPath(rootPath)) {\n\t\t\t\tpathStateManager.createStateForPath(rootPath, unknownProcessor);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void processPath(IWebPath webPath, VegaURI uri, boolean isLast, boolean hasTrailingSlash) {\n\t\tif(!isLast || (isLast && hasTrailingSlash)) {\n\t\t\tprocessDirectory(webPath, uri);\n\t\t} else if(uri.getQuery() != null) {\n\t\t\twebPath.setPathType(PathType.PATH_FILE);\n\t\t\tprocessPathWithQuery(webPath, uri);\n\t\t} else {\n\t\t\tprocessUnknown(webPath);\n\t\t}\n\t}\n\n\tprivate void processDirectory(IWebPath webPath, VegaURI uri) {\n\t\tsynchronized(pathStateManager) {\n\t\t\tif(!pathStateManager.hasSeenPath(webPath)) {\n\t\t\t\twebPath.setPathType(PathType.PATH_DIRECTORY);\n\t\t\t\tfinal PathState ps = pathStateManager.createStateForPath(webPath, directoryProcessor);\n\t\t\t\tif(uri.getQuery() != null) {\n\t\t\t\t\tps.maybeAddParameters(URLEncodedUtils.parse(uri.getQuery(), Consts.UTF_8));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(webPath.getPathType() != PathType.PATH_DIRECTORY) {\n\t\t\t\t// XXX What to do in this case?  The PathState node may be executing PATH_UNKNOWN checks already\n\t\t\t\tSystem.out.println(\"Scan state node for path=\"+ webPath + \" already exists but it's not a directory in UriParser.processDirectory()\");\n\t\t\t}\n\t\t}\n\t}\n\n\n\tprivate void processPathWithQuery(IWebPath path, VegaURI uri) {\n\t\tpath.setPathType(PathType.PATH_FILE);\n\t\tList<NameValuePair> plist = URLEncodedUtils.parse(uri.getQuery(), Consts.UTF_8);\n\t\tsynchronized(pathStateManager) {\n\t\t\tfinal PathState ps = getPathStateForFile(path);\n\t\t\tif(ps != null) {\n\t\t\t\tps.maybeAddParameters(plist);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate PathState getPathStateForFile(IWebPath filePath) {\n\t\tsynchronized(pathStateManager) {\n\t\t\tif(pathStateManager.hasSeenPath(filePath))\n\t\t\t\treturn pathStateManager.getStateForPath(filePath);\n\t\t\telse\n\t\t\t\treturn pathStateManager.createStateForPath(filePath, fileProcessor);\n\t\t}\n\t}\n\n\tprivate void processUnknown(IWebPath path) {\n\t\tsynchronized(pathStateManager) {\n\t\t\tif(pathStateManager.hasSeenPath(path))\n\t\t\t\treturn;\n\t\t\tpathStateManager.createStateForPath(path, unknownProcessor);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"lib\" path=\"lib/js.jar\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.scanner.modules</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/.settings/org.eclipse.pde.core.prefs",
    "content": "#Tue Sep 28 15:34:24 EDT 2010\neclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Modules\nBundle-SymbolicName: com.subgraph.vega.scanner.modules\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.google.common.io,\n com.google.common.net,\n com.subgraph.vega.api.annotations,\n com.subgraph.vega.api.console,\n com.subgraph.vega.api.crawler,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.html,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.xml,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client,\n org.apache.http.client.methods,\n org.apache.http.util;version=\"4.0.0\",\n org.jsoup.nodes,\n org.jsoup.select,\n org.osgi.framework;version=\"1.5.0\",\n org.w3c.dom.html2\nService-Component: OSGI-INF/scanner-module-registry.xml, OSGI-INF/xml-repository.xml\nBundle-ClassPath: .,\n lib/js.jar\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/OSGI-INF/scanner-module-registry.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.scanner-modules\">\n   <implementation class=\"com.subgraph.vega.impl.scanner.modules.ScannerModuleRepository\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry\"/>\n   </service>\n   <reference bind=\"setPathFinder\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.paths.IPathFinder\" name=\"IPathFinder\" policy=\"static\" unbind=\"unsetPathFinder\"/>\n   <reference bind=\"setHTMLParser\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.html.IHTMLParser\" name=\"IHTMLParser\" policy=\"static\" unbind=\"unsetHTMLParser\"/>\n   <reference bind=\"setModel\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.model.IModel\" name=\"IModel\" policy=\"static\" unbind=\"unsetModel\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/OSGI-INF/xml-repository.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.xml-repository\">\n   <implementation class=\"com.subgraph.vega.impl.scanner.modules.XmlRepository\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.xml.IXmlRepository\"/>\n   </service>\n   <reference bind=\"setPathFinder\" cardinality=\"1..1\" interface=\"com.subgraph.vega.api.paths.IPathFinder\" name=\"IPathFinder\" policy=\"static\" unbind=\"unsetPathFinder\"/>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               lib/js.jar,\\\n               tests/,\\\n               OSGI-INF/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/ScannerModuleRepository.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules;\n\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.Reader;\nimport java.util.ArrayList;\nimport java.util.LinkedHashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Properties;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.osgi.framework.Bundle;\nimport org.osgi.framework.BundleContext;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\nimport com.subgraph.vega.api.scanner.modules.ModuleScriptType;\nimport com.subgraph.vega.impl.scanner.modules.scripting.BasicModuleScript;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ResponseProcessorScript;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptLoader;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptedModule;\nimport com.subgraph.vega.impl.scanner.modules.scripting.tests.DomTestModule;\nimport com.subgraph.vega.impl.scanner.modules.scripting.tests.TestScriptLoader;\n\npublic class ScannerModuleRepository implements IScannerModuleRegistry {\n\tprivate final Logger logger = Logger.getLogger(\"modules\");\n\tprivate IPathFinder pathFinder;\n\tprivate IHTMLParser htmlParser;\n\tprivate IModel model;\n\tprivate ScriptLoader scriptLoader;\n\tprivate TestScriptLoader testScriptLoader;\n\tprivate Bundle bundle;\n\tprivate IWorkspace currentWorkspace;\n\n\tvoid activate(BundleContext context) {\n\t\tthis.bundle = context.getBundle();\n\t\tscriptLoader = new ScriptLoader(getScriptDirectory());\n\t\tscriptLoader.reloadModules();\n\t\tcurrentWorkspace = model.addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent)\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceCloseEvent)\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tthis.currentWorkspace = event.getWorkspace();\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tthis.currentWorkspace = null;\n\t}\n\n\tprivate File getScriptDirectory() {\n\t\tfinal File configScriptPath = getScriptDirectoryFromConfig(pathFinder.getConfigFilePath());\n\t\tif(configScriptPath != null && configScriptPath.exists() && configScriptPath.isDirectory())\n\t\t\treturn configScriptPath;\n\n\t\treturn new File(pathFinder.getDataDirectory(), \"scripts\" + File.separator + \"scanner\");\n\t}\n\n\tprivate File getScriptDirectoryFromConfig(File configFile) {\n\t\tReader configReader = null;\n\t\ttry {\n\t\t\tif(!(configFile.exists() && configFile.canRead())) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconfigReader = new FileReader(configFile);\n\t\t\tProperties configProperties = new Properties();\n\t\t\tconfigProperties.load(configReader);\n\t\t\tString pathProp = configProperties.getProperty(\"vega.scanner.datapath\");\n\n\t\t\tif(pathProp != null) {\n\t\t\t\treturn new File(pathProp, \"scripts\" + File.separator + \"scanner\");\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"I/O error opening config file \"+ configFile.getAbsolutePath(), e);\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif(configReader != null) {\n\t\t\t\t\tconfigReader.close();\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tlogger.log(Level.WARNING, \"I/O error closing config file \"+ configFile.getAbsolutePath(), e);\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic List<IResponseProcessingModule> getResponseProcessingModules() {\n\t\tfinal List<IResponseProcessingModule> modules = new ArrayList<IResponseProcessingModule>();\n\t\tfor(ScriptedModule m: scriptLoader.getAllModules()) {\n\t\t\tif(m.getModuleType() == ModuleScriptType.RESPONSE_PROCESSOR)\n\t\t\t\tmodules.add(new ResponseProcessorScript(m));\n\t\t}\n\t\treturn modules;\n\t}\n\n\t@Override\n\tpublic List<IBasicModuleScript> getBasicModules() {\n\t\tfinal List<IBasicModuleScript> modules = new ArrayList<IBasicModuleScript>();\n\t\tfor(ScriptedModule m: scriptLoader.getAllModules()) {\n\t\t\tif(m.getModuleType() == ModuleScriptType.BASIC_MODULE)\n\t\t\t\tmodules.add(new BasicModuleScript(m));\n\t\t}\n\t\treturn modules;\n\t}\n\n\tprotected void setPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = pathFinder;\n\t}\n\n\tprotected void unsetPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = null;\n\t}\n\n\tprotected void setHTMLParser(IHTMLParser htmlParser) {\n\t\tthis.htmlParser = htmlParser;\n\t}\n\n\tprotected void unsetHTMLParser(IHTMLParser htmlParser) {\n\t\tthis.htmlParser = null;\n\t}\n\n\tprotected void setModel(IModel model) {\n\t\tthis.model = model;\n\t}\n\n\tprotected void unsetModel(IModel model) {\n\t\tthis.model = null;\n\t}\n\n\t@Override\n\tpublic void runDomTests() {\n\t\tif(testScriptLoader == null) {\n\t\t\ttestScriptLoader = new TestScriptLoader(scriptLoader.getPreludeScope(),bundle);\n\t\t\ttestScriptLoader.load();\n\t\t}\n\n\t\tThread testThread = new Thread(createDomTestRunnable());\n\t\ttestThread.start();\n\t}\n\n\tprivate Runnable createDomTestRunnable() {\n\t\treturn new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tfor(ScriptedModule m: testScriptLoader.getAllModules()) {\n\t\t\t\t\trunDomTestModule(m);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void runDomTestModule(ScriptedModule module) {\n\t\tif(module.getModuleType() != ModuleScriptType.DOM_TEST)\n\t\t\treturn;\n\t\tfinal DomTestModule test = new DomTestModule(module, bundle, htmlParser);\n\t\ttry {\n\t\t\ttest.run(currentWorkspace);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n\t@Override\n\tpublic List<IResponseProcessingModule> updateResponseProcessingModules(List<IResponseProcessingModule> currentModules) {\n\t\tif(!scriptLoader.reloadModules()) {\n\t\t\treturn currentModules;\n\t\t}\n\t\t\n\t\tfinal Map<String, ResponseProcessorScript> pathMap = new LinkedHashMap<String, ResponseProcessorScript>();\n\t\tfinal List<IResponseProcessingModule> newModules = new ArrayList<IResponseProcessingModule>();\n\t\t\n\t\tfor(IResponseProcessingModule m: currentModules) {\n\t\t\tif(m instanceof ResponseProcessorScript) {\n\t\t\t\tResponseProcessorScript rps = (ResponseProcessorScript) m;\n\t\t\t\tpathMap.put(rps.getModule().getScriptFile().getPath(), rps);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(ScriptedModule sm: scriptLoader.getAllModulesByType(ModuleScriptType.RESPONSE_PROCESSOR)) {\n\t\t\tString path = sm.getScriptFile().getPath();\n\t\t\tif(pathMap.containsKey(path)) {\n\t\t\t\tResponseProcessorScript old = pathMap.get(path);\n\t\t\t\tnewModules.add(new ResponseProcessorScript(sm, old.isEnabled(), old.getRunningTimeProfile()));\n\t\t\t} else {\n\t\t\t\tnewModules.add(new ResponseProcessorScript(sm));\n\t\t\t}\n\t\t}\n\t\treturn newModules;\n\t}\n\n\t@Override\n\tpublic List<IBasicModuleScript> updateBasicModules(List<IBasicModuleScript> currentModules) {\n\t\tif(!scriptLoader.reloadModules()) {\n\t\t\treturn currentModules;\n\t\t}\n\t\t\n\t\tfinal Map<String, BasicModuleScript> pathMap = new LinkedHashMap<String, BasicModuleScript>();\n\t\tfinal List<IBasicModuleScript> newModules = new ArrayList<IBasicModuleScript>();\n\t\t\n\t\tfor(IBasicModuleScript m: currentModules) {\n\t\t\tif(m instanceof BasicModuleScript) {\n\t\t\t\tBasicModuleScript bms = (BasicModuleScript) m;\n\t\t\t\tpathMap.put(bms.getModule().getScriptFile().getPath(), bms);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(ScriptedModule sm: scriptLoader.getAllModulesByType(ModuleScriptType.BASIC_MODULE)) {\n\t\t\tString path = sm.getScriptFile().getPath();\n\t\t\tif(pathMap.containsKey(path)) {\n\t\t\t\tBasicModuleScript old = pathMap.get(path);\n\t\t\t\tnewModules.add(new BasicModuleScript(sm, old.isEnabled(), old.getRunningTimeProfile()));\n\t\t\t} else {\n\t\t\t\tnewModules.add(new BasicModuleScript(sm));\n\t\t\t}\n\t\t}\n\t\treturn newModules;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/XmlRepository.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules;\n\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport javax.xml.parsers.DocumentBuilder;\nimport javax.xml.parsers.DocumentBuilderFactory;\nimport javax.xml.parsers.ParserConfigurationException;\n\nimport org.w3c.dom.Document;\nimport org.xml.sax.SAXException;\n\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.api.xml.IXmlRepository;\n\npublic class XmlRepository implements IXmlRepository {\n\tprivate final Logger logger = Logger.getLogger(\"xml-repository\");\n\n\tprivate IPathFinder pathFinder;\n\tprivate File xmlDirectory;\n\tprivate DocumentBuilderFactory documentBuilderFactory;\n\t\n\tprivate Map<String, Document> xmlCache = new HashMap<String, Document>();\n\t\n\tvoid activate() {\n\t\tfinal File dataDirectory = pathFinder.getDataDirectory();\n\t\txmlDirectory = new File(dataDirectory, \"xml\");\n\t\tdocumentBuilderFactory = DocumentBuilderFactory.newInstance();\n\t}\n\t\n\t@Override\n\tpublic synchronized Document getDocument(String path) {\n\t\tif(xmlCache.containsKey(path))\n\t\t\treturn xmlCache.get(path);\n\t\t\n\t\tfinal Document document = loadXML(path);\n\t\tif(document != null) {\n\t\t\txmlCache.put(path, document);\n\t\t}\n\t\treturn document;\n\t}\n\t\n\t\n\tprivate Document loadXML(String path) {\n\t\tif(File.separatorChar != '/')\n\t\t\tpath = path.replace('/', File.separatorChar);\n\t\tfinal File xmlFile = new File(xmlDirectory, path);\n\t\ttry {\n\t\t\tfinal InputStream input = new FileInputStream(xmlFile);\n\t\t\tfinal DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();\n\t\t\treturn builder.parse(input);\n\t\t} catch (FileNotFoundException e) {\n\t\t\tlogger.warning(\"Could not find XML file: \"+ xmlFile);\n\t\t} catch (ParserConfigurationException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error setting up XML parser:\" + e.getMessage(), e);\n\t\t} catch (SAXException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error parsing XML document: \"+ xmlFile + \" : \"+ e.getMessage(), e);\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"I/O error reading XML file: \"+ xmlFile + \" : \"+ e.getMessage(), e);\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprotected void setPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = pathFinder;\n\t}\n\t\n\tprotected void unsetPathFinder(IPathFinder pathFinder) {\n\t\tthis.pathFinder = null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/AbstractScriptModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.mozilla.javascript.WrappedException;\n\nimport com.subgraph.vega.api.scanner.modules.IEnableableModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRunningTime;\nimport com.subgraph.vega.api.scanner.modules.ModuleScriptType;\n\npublic abstract class AbstractScriptModule implements IScannerModule, IEnableableModule {\n\tprivate static final Logger logger = Logger.getLogger(\"script-module\");\n\tprotected static class ExportedObject {\n\t\tprivate final String identifier;\n\t\tprivate final Object object;\n\t\tExportedObject(String identifier, Object object) {\n\t\t\tthis.identifier = identifier;\n\t\t\tthis.object = object;\n\t\t}\n\t}\n\t\n\tprivate final ScriptedModule module;\n\tprivate final ScriptedModuleRunningTime runningTime;\n\t\n\tprivate boolean isEnabled;\n\t\n\tprotected AbstractScriptModule(ScriptedModule module) {\n\t\tthis.module = module;\n\t\tthis.isEnabled = module.isDefaultEnabled();\n\t\tthis.runningTime = new ScriptedModuleRunningTime(module.getModuleName());\n\t}\n\n\tpublic String getModuleName() {\n\t\treturn module.getModuleName();\n\t}\n\t\n\tpublic String getModuleCategoryName() {\n\t\treturn module.getCategoryName();\n\t}\n\n\tpublic ModuleScriptType getModuleType() {\n\t\treturn module.getModuleType();\n\t}\n\t\n\tprotected void runScript(List<ExportedObject> exports, String target) {\n\t\ttry {\n\t\t\tContext cx = Context.enter();\n\t\t\tScriptable instance = module.createInstanceScope(cx);\n\t\t\tprocessExports(exports, instance);\n\t\t\tfinal long startTS = System.currentTimeMillis();\n\t\t\tmodule.runModule(cx, instance);\n\t\t\tfinal long endTS = System.currentTimeMillis();\n\t\t\trunningTime.addTimestamp((int) (endTS - startTS), target);\n\t\t} catch (WrappedException e) {\n\t\t\tlogger.log(Level.WARNING, new RhinoExceptionFormatter(\"Wrapped exception running module script\", e).toString());\n\t\t\te.printStackTrace();\n\t\t} catch (RhinoException e) {\n\t\t\tlogger.warning(new RhinoExceptionFormatter(\"Exception running module script.\", e).toString());\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic IScannerModuleRunningTime getRunningTimeProfile() {\n\t\treturn runningTime;\n\t}\n\t\n\t@Override\n\tpublic void setEnabled(boolean flag) {\n\t\tisEnabled = flag;\n\t}\n\t\n\t@Override\n\tpublic boolean isEnabled() {\n\t\treturn isEnabled;\n\t}\n\t\n\tprotected void export(List<ExportedObject> exports, String name, Object object) {\n\t\t\texports.add(new ExportedObject(name, object));\n\t}\n\t\n\tprivate void processExports(List<ExportedObject> exports, Scriptable instance) {\n\t\tfor(ExportedObject exp: exports) {\n\t\t\tObject wrappedObject = Context.javaToJS(exp.object, instance);\n\t\t\tScriptableObject.putProperty(instance, exp.identifier, wrappedObject);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/BasicModuleScript.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\n\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.WrappedException;\n\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\nimport com.subgraph.vega.api.scanner.modules.IBasicModuleScript;\nimport com.subgraph.vega.api.scanner.modules.IEnableableModule;\n\npublic class BasicModuleScript implements IBasicModuleScript, IEnableableModule {\n\tprivate static final Logger logger = Logger.getLogger(\"script-module\");\n\n\tprivate final ScriptedModule module;\n\tprivate final ScriptedModuleRunningTime runningTime;\n\t\n\tprivate boolean isEnabled;\n\t\n\tpublic BasicModuleScript(ScriptedModule module, boolean isEnabled, ScriptedModuleRunningTime runningTime) {\n\t\tthis.module = module;\n\t\tthis.isEnabled = isEnabled;\n\t\tthis.runningTime = runningTime;\n\t}\n\tpublic BasicModuleScript(ScriptedModule module) {\n\t\tthis.module = module;\n\t\tthis.isEnabled = module.isDefaultEnabled();\n\t\tthis.runningTime = new ScriptedModuleRunningTime(module.getModuleName());\n\t}\n\n\tpublic ScriptedModule getModule() {\n\t\treturn module;\n\t}\n\n\t@Override\n\tpublic void runScript(IPathState pathState) {\n\t\tfinal IInjectionModuleContext ctx = pathState.createModuleContext();\n\t\ttry {\n\t\t\tContext cx = Context.enter();\n\t\t\tScriptable instance = module.createInstanceScope(cx);\n\t\t\tfinal Object[] args = new Object[] { new ModuleContextJS(instance, ctx) };\n\t\t\tfinal long startTS = System.currentTimeMillis();\n\t\t\tmodule.runModule(cx, instance, args);\n\t\t\tfinal long endTS = System.currentTimeMillis();\n\t\t\trunningTime.addTimestamp((int) (endTS - startTS), pathState.toString());\n\t\t} catch (WrappedException e) {\n\t\t\tlogger.log(Level.WARNING, new RhinoExceptionFormatter(\"Wrapped exception running module script: \"+ module.getModuleName(), e).toString());\n\t\t} catch (RhinoException e) {\n\t\t\tlogger.warning(new RhinoExceptionFormatter(\"Exception running module script: \"+ module.getModuleName(), e).toString());\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setEnabled(boolean flag) {\n\t\tisEnabled = flag;\n\t}\n\n\t@Override\n\tpublic boolean isEnabled() {\n\t\treturn isEnabled;\n\t}\n\n\t@Override\n\tpublic String getModuleName() {\n\t\treturn module.getModuleName();\n\t}\n\n\t@Override\n\tpublic String getModuleCategoryName() {\n\t\treturn module.getCategoryName();\n\t}\n\n\t@Override\n\tpublic ScriptedModuleRunningTime getRunningTimeProfile() {\n\t\treturn runningTime;\n\t}\n\t@Override\n\tpublic boolean isDifferential() {\n\t\treturn module.isDifferential();\n\t}\n\t@Override\n\tpublic boolean isTimeSensitive() {\n\t\treturn module.isTimeSensitive();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/CrawlerCallbackWrapper.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Function;\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.WrappedException;\n\nimport com.subgraph.vega.api.crawler.ICrawlerResponseProcessor;\nimport com.subgraph.vega.api.crawler.IWebCrawler;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\n\npublic class CrawlerCallbackWrapper implements ICrawlerResponseProcessor {\n\tprivate static final Logger logger = Logger.getLogger(\"scanner\");\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate Function callbackFunction;\n\t\n\tpublic CrawlerCallbackWrapper(Function callback) {\n\t\tcallbackFunction = callback;\n\t}\n\t\n\t@Override\n\tpublic void processResponse(IWebCrawler crawler, HttpUriRequest request, IHttpResponse response, Object argument) {\n\t\tif(!(argument instanceof IInjectionModuleContext)) {\n\t\t\t\n\t\t}\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tfinal Scriptable scope = callbackFunction.getParentScope();\n\t\ttry {\n\t\t\tfinal Context cx = Context.enter();\n\t\t\tfinal Object[] arguments = { request, createResponse(response, cx, scope), new ModuleContextJS(scope, ctx) };\n\t\t\tcallbackFunction.call(cx, scope, scope, arguments);\n\t\t} catch (WrappedException e) {\n\t\t\tlogger.log(Level.WARNING, new RhinoExceptionFormatter(\"Wrapped exception running module script\", e).toString());\n\t\t\te.printStackTrace();\n\t\t} catch (RhinoException e) {\n\t\t\tlogger.warning(new RhinoExceptionFormatter(\"Exception running module script.\", e).toString());\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\t\t\n\t}\n\t\n\tprivate Scriptable createResponse(IHttpResponse response, Context cx, Scriptable scope) {\n\t\tObject responseOb = Context.javaToJS(response, scope);\n\t\tObject[] args = { responseOb };\n\t\treturn cx.newObject(scope, \"Response\", args);\n\t}\n\n\t@Override\n\tpublic void processException(HttpUriRequest request, Throwable ex, Object argument) {\n\t\tfinal IInjectionModuleContext ctx = (IInjectionModuleContext) argument;\n\t\tctx.reportRequestException(request, ex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ModuleContextJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2013 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Function;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.Wrapper;\n\nimport com.google.common.net.InternetDomainName;\nimport com.google.common.io.BaseEncoding;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IPageFingerprint;\nimport com.subgraph.vega.api.scanner.IInjectionModuleContext;\nimport com.subgraph.vega.api.scanner.IPathState;\n\npublic class ModuleContextJS {\n\n\tprivate final Scriptable scope;\n\tprivate final IInjectionModuleContext context;\n\n\tModuleContextJS(Scriptable scope, IInjectionModuleContext context) {\n\t\tthis.scope = scope;\n\t\tthis.context = context;\n\t}\n\n\tpublic int getCurrentIndex() {\t\n\t\treturn context.getCurrentIndex();\n\t}\n\n\tpublic IPathState getPathState() {\n\t\treturn context.getPathState();\n\t}\n\n\tpublic int incrementResponseCount() {\n\t\treturn context.incrementResponseCount();\n\t}\n\n\tpublic boolean allResponsesReceived() {\n\t\treturn context.allResponsesReceived();\n\t}\n\n\tpublic void setModuleFailed() {\n\t\tcontext.setModuleFailed();\n\t}\n\t\n\tpublic boolean hasModuleFailed() {\n\t\treturn context.hasModuleFailed();\n\t}\n\n\tpublic void addRequestResponse(HttpUriRequest request,\n\t\t\tResponseJS response) {\n\t\tcontext.addRequestResponse(request, response.getResponse());\n\t}\n\n\tpublic void addRequestResponse(int index, HttpUriRequest request,\n\t\t\tResponseJS response) {\n\t\tcontext.addRequestResponse(index, request, response.getResponse());\n\t}\n\n\tpublic HttpUriRequest getSavedRequest(int index) {\n\t\treturn context.getSavedRequest(index);\n\t}\n\n\tpublic Scriptable getSavedResponse(int index) {\n\t\tfinal IHttpResponse r = context.getSavedResponse(index);\n\t\tObject responseOb = Context.javaToJS(r, scope);\n\t\tObject[] args = { responseOb };\n\t\treturn Context.getCurrentContext().newObject(scope, \"Response\", args);\n\t}\n\t\n\tpublic Scriptable getOrigResponse() {\n\t\tfinal IHttpResponse r =  context.getPathState().getResponse();\n\t    Object responseOb = Context.javaToJS(r, scope);\n\t\tObject[] args = { responseOb };\n\t\treturn Context.getCurrentContext().newObject(scope, \"Response\", args);\t\t\n\t}\n\t\n\t/* Added below method because of bug #547 */\n\n\tpublic String getSavedResponseBody(int index) {\n\t\treturn context.getSavedResponseBody(index);\n\n\t}\n\n\tpublic IPageFingerprint getSavedFingerprint(int index) {\n\t\treturn context.getSavedFingerprint(index);\n\t}\n\n\tpublic void error(HttpUriRequest request, ResponseJS response,\n\t\t\tString message) {\n\t\tcontext.error(request, response.getResponse(), message);\n\t}\n\n\tpublic void debug(String msg) {\n\t\tcontext.debug(msg);\n\t}\n\n\tpublic void debug(String msg, Boolean flag) {\n\t\tcontext.debug(msg, flag);\n\t}\n\t\n\tpublic void analyzePage(HttpUriRequest request, ResponseJS response) {\n\t\tcontext.analyzePage(request, response.getResponse());\n\t}\n\n\tpublic boolean isFingerprintMatch(int idx1, int idx2) {\n\t\treturn context.isFingerprintMatch(idx1, idx2);\n\t}\n\n\tpublic boolean isFingerprintMatch(int idx, IPageFingerprint fp) {\n\t\treturn context.isFingerprintMatch(idx, fp);\n\t}\n\n\tpublic void submitRequest(HttpUriRequest request,\n\t\t\tFunction callback, int index) {\n\t\tcontext.submitRequest(request, wrap(callback), index);\n\t}\n\n\tpublic void submitRequest(HttpUriRequest request,\n\t\t\tFunction callback) {\n\t\tcontext.submitRequest(request, wrap(callback));\n\t}\n\n\tpublic void submitRequest(Function callback, int flag) {\n\t\tcontext.submitRequest(wrap(callback), flag);\n\t}\n\n\tpublic void submitAlteredRequest(Function callback,\n\t\t\tString value) {\n\t\tcontext.submitAlteredRequest(wrap(callback), value);\n\t}\n\n\tpublic void submitAlteredRequest(Function callback,\n\t\t\tString value, int flag) {\n\t\tcontext.submitAlteredRequest(wrap(callback), value, flag);\n\t}\n\n\tpublic void submitAlteredRequest(Function callback,\n\t\t\tString value, boolean append, int flag) {\n\t\tcontext.submitAlteredRequest(wrap(callback), value, append, flag);\n\t}\n\t\n\tpublic void submitAlteredParameterNameRequest(\n\t\t\tFunction callback, String name, int flag) {\n\t\tcontext.submitAlteredParameterNameRequest(wrap(callback), name, flag);\n\t}\n\n\tpublic void submitMultipleAlteredRequests(Function callback, String[] injectables) {\n\t\tcontext.submitMultipleAlteredRequests(wrap(callback), injectables);\n\t}\n\n\tpublic void submitMultipleAlteredRequests(Function callback, String[] injectables, boolean append) {\n\t\tcontext.submitMultipleAlteredRequests(wrap(callback), injectables, append);\n\t}\n\t\n\tpublic void responseChecks(HttpUriRequest request, ResponseJS response) {\n\t\tcontext.responseChecks(request, response.getResponse());\n\t}\n\t\n\tpublic void contentChecks(HttpUriRequest request, ResponseJS response) {\n\t\tcontext.contentChecks(request, response.getResponse());\n\t}\n\t\n\tpublic void responseChecks(int idx) {\n\t\tcontext.responseChecks(idx);\n\t}\n\t\n\tpublic void pivotChecks(HttpUriRequest request, ResponseJS response) {\n\t\tcontext.pivotChecks(request, response.getResponse());\n\t}\n\n\tprivate CrawlerCallbackWrapper wrap(Function callback) {\n\t\treturn new CrawlerCallbackWrapper(callback);\n\t}\n\t\n\tpublic void addStringHighlight(String str) {\n\t\tcontext.addStringHighlight(str);\n\t}\n\n\tpublic void addRegexHighlight(String regex) {\n\t\tcontext.addRegexHighlight(regex);\n\t}\n\n\tpublic void addRegexCaseInsensitiveHighlight(String regex) {\n\t\tcontext.addRegexCaseInsensitiveHighlight(regex);\n\t}\n\t\n\tpublic void reset () {\n\t\tcontext.reset();\n\t}\n\n\tpublic void alert(String type, HttpUriRequest request, ResponseJS response) {\n\t\talert(type, request, response, null);\n\t}\n\t\n\tpublic void alert(String type, HttpRequest request, ResponseJS response, Scriptable ob) {\n\t\tList<Object> properties = new ArrayList<Object>();\n\t\tString keyValue = null;\n\t\tString messageValue = null;\n\t\tif(ob == null) {\n\t\t\tpublishAlert(type, null, request, response.getResponse());\n\t\t\treturn;\n\t\t}\n\n\t\tfor(Object k: ob.getIds()) {\n\t\t\tif(k instanceof String) {\n\t\t\t\tString key = (String) k;\n\t\t\t\tString val = lookup(key, ob);\n\t\t\t\tif(val != null) {\n\t\t\t\t\tif(\"key\".equals(key)) {\n\t\t\t\t\t\tkeyValue = val;\n\t\t\t\t\t} else if(\"message\".equals(key)) {\n\t\t\t\t\t\tmessageValue = val;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tproperties.add(key);\n\t\t\t\t\t\tproperties.add(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcontext.publishAlert(type, keyValue, messageValue, request, response.getResponse(), properties.toArray());\t\t\n\t}\n\n\tprivate String lookup(String key, Scriptable ob) {\n\t\tfinal Object value = ob.get(key, ob);\n\t\tif(value instanceof String) {\n\t\t\treturn (String) value;\n\t\t} else if(value instanceof Wrapper) {\n\t\t\tWrapper w = (Wrapper) value;\n\t\t\tif(w.unwrap() instanceof String) {\n\t\t\t\treturn (String) w.unwrap();\n\t\t\t}\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tpublic void publishAlert(String type, String message, HttpRequest request, IHttpResponse response) {\n\t\tcontext.publishAlert(type, message, request, response);\n\t}\n\t\n\tpublic void publishAlert(String type, String key, String message, HttpRequest request, IHttpResponse response) {\n\t\tcontext.publishAlert(type, key, message, request, response);\n\t}\n\n\n\tpublic void setProperty(String name, Object value) {\n\t\tcontext.setProperty(name, value);\n\t}\n\n\tpublic void setStringProperty(String name, String value) {\n\t\tcontext.setStringProperty(name, value);\t\t\n\t}\n\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tcontext.setIntegerProperty(name, value);\t\t\n\t}\n\n\n\tpublic Object getProperty(String name) {\n\t\treturn context.getProperty(name);\n\t}\n\n\n\tpublic String getStringProperty(String name) {\n\t\treturn context.getStringProperty(name);\n\t}\n\n\tpublic Integer getIntegerProperty(String name) {\n\t\treturn context.getIntegerProperty(name);\n\t}\n\n\tpublic Object propertyKeys() {\n\t\t\t\t\n\t\tList<String> keys = context.propertyKeys();\n\t\t\n\t\tfinal Context cx = Context.getCurrentContext();\n\t\tfinal Scriptable array = cx.newArray(scope, keys.size());\n\t\tfor(int i = 0; i < keys.size(); i++) {\n\t\t\tarray.put(i, array, Context.javaToJS(keys.get(i), scope));\n\t\t}\n\t\treturn array;\n\t\t\n\t}\n\t\n\tpublic boolean alertExists(String key) {\n\t\treturn context.alertExists(key);\n\t}\n\t\n\tpublic InternetDomainName internetDomainName(String domain) {\n\t\treturn context.internetDomainName(domain);\n\t}\n\t\n\tpublic boolean isValidInternetDomainName(String domain) {\n\t\treturn context.isValidInternetDomainName(domain);\n\t}\n\t\n\tpublic String base64decode(String encoded) {\n\t\tbyte[] decoded = BaseEncoding.base64().decode(encoded);\n\t\treturn new String(decoded);\n\t}\n\t\n\tpublic String base64encode(String input) {\n\t\tString encoded = BaseEncoding.base64().encode(input.getBytes());\n\t\treturn encoded;\n\t}\n}"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ModuleValidator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Function;\nimport org.mozilla.javascript.Scriptable;\n\nimport com.subgraph.vega.api.scanner.modules.ModuleScriptType;\n\npublic class ModuleValidator {\n\t\n\tprivate final Scriptable moduleScope;\n\tprivate String moduleName;\n\tprivate String categoryName;\n\tprivate ModuleScriptType moduleType;\n\tprivate Function runFunction;\n\tprivate boolean isValidated;\n\tprivate boolean isDisabled;\n\tprivate boolean isDefaultDisabled;\n\tprivate boolean isTimeSensitive;\n\tprivate boolean isDifferential;\n\t\n\tpublic ModuleValidator(Scriptable moduleScope) {\n\t\tthis.moduleScope = moduleScope;\n\t}\n\t\n\tpublic static class ModuleValidationException extends Exception {\n\t\tprivate static final long serialVersionUID = 1L;\n\t\tModuleValidationException(String message) {\n\t\t\tsuper(message);\n\t\t}\n\t}\n\t\n\tpublic void validate() throws ModuleValidationException {\n\t\tif(isValidated)\n\t\t\treturn;\n\t\tfinal Scriptable moduleObject = getModule();\n\t\tmoduleName = getStringFromModuleObject(moduleObject, \"name\");\n\t\tmoduleType = getScriptType(moduleObject);\n\t\tif(hasStringInModuleObject(moduleObject, \"category\"))\n\t\t\tcategoryName = getStringFromModuleObject(moduleObject, \"category\");\n\t\telse\n\t\t\tcategoryName = moduleType.getVerboseName();\n\t\t\n\t\trunFunction = getEntryFunction();\n\t\tisDisabled = getFlagFromModuleObject(moduleObject, \"disabled\");\n\t\tisDefaultDisabled = getFlagFromModuleObject(moduleObject, \"defaultDisabled\");\n\t\tisTimeSensitive = getFlagFromModuleObject(moduleObject, \"timeSensitive\");\n\t\tisDifferential = getFlagFromModuleObject(moduleObject, \"differential\");\n\t\tisValidated = true;\n\t}\n\t\n\tpublic String getName() {\n\t\tif(!isValidated)\n\t\t\tthrow new IllegalStateException(\"Cannot get name because module is not validated\");\n\t\treturn moduleName;\n\t}\n\t\n\tpublic String getCategoryName() {\n\t\tif(!isValidated)\n\t\t\tthrow new IllegalStateException(\"Cannot get category name because module is not validated\");\n\t\treturn categoryName;\n\t}\n\n\tpublic boolean isDisabled() {\n\t\tif(!isValidated)\n\t\t\tthrow new IllegalStateException(\"Cannot get disabled flag because module is not validated\");\n\t\treturn isDisabled;\n\t}\n\t\n\tpublic boolean isDefaultEnabled() {\n\t\tif(!isValidated) \n\t\t\tthrow new IllegalStateException(\"Cannot get default enabled flag because module is not validated\");\n\n\t\treturn !isDefaultDisabled;\n\t}\n\n\tpublic boolean isTimeSensitive() {\n\t\tif(!isValidated) { \n\t\t\tthrow new IllegalStateException(\"Cannot get time sensitive flag because module is not validated\");\n\t\t}\n\t\treturn isTimeSensitive;\n\t}\n\n\tpublic boolean isDifferential() {\n\t\tif(!isValidated) {\n\t\t\tthrow new IllegalStateException(\"Cannot get differential flag because module is not validated\");\n\t\t}\n\t\treturn isDifferential;\n\t}\n\n\tpublic ModuleScriptType getType() {\n\t\tif(!isValidated)\n\t\t\tthrow new IllegalStateException(\"Cannot get type because module is not validated\");\n\t\treturn moduleType;\n\t}\n\t\n\tpublic Function getRunFunction() {\n\t\tif(!isValidated)\n\t\t\tthrow new IllegalStateException(\"Cannot get run function because module is not validated\");\n\t\treturn runFunction;\n\t}\n\t\n\tprivate Scriptable getModule() throws ModuleValidationException {\n\t\tfinal Object ob = moduleScope.get(\"module\", moduleScope);\n\t\tif(ob == Scriptable.NOT_FOUND) \n\t\t\tthrow new ModuleValidationException(\"No 'module' object found.\");\n\t\treturn Context.toObject(ob, moduleScope);\n\t}\n\t\n\tprivate ModuleScriptType getScriptType(Scriptable module) throws ModuleValidationException {\n\t\tif(!hasStringInModuleObject(module, \"type\"))\n\t\t\treturn ModuleScriptType.BASIC_MODULE;\n\t\t\n\t\tfinal String typeName = getStringFromModuleObject(module, \"type\");\n\t\tfinal ModuleScriptType type = ModuleScriptType.lookup(typeName);\n\t\tif(type == null) \n\t\t\tthrow new ModuleValidationException(\"Unrecognized module type: \"+ typeName);\n\t\telse\n\t\t\treturn type;\n\t}\n\t\n\tprivate boolean hasStringInModuleObject(Scriptable module, String name) {\n\t\tfinal Object ob = module.get(name, moduleScope);\n\t\treturn (ob != Scriptable.NOT_FOUND && (ob instanceof String));\n\t\t\t\n\t}\n\tprivate String getStringFromModuleObject(Scriptable module, String name) throws ModuleValidationException {\n\t\tfinal Object ob = module.get(name, moduleScope);\n\t\tif(ob == Scriptable.NOT_FOUND) \n\t\t\tthrow new ModuleValidationException(\"Could not find module property '\"+ name +\"'.\");\n\t\tif(!(ob instanceof String)) \n\t\t\tthrow new ModuleValidationException(\"Module property '\"+ name +\"' is not a string type as expected.\");\n\t\treturn (String) ob;\n\t}\n\t\n\tprivate boolean getFlagFromModuleObject(Scriptable module, String name) {\n\t\tfinal Object ob = module.get(name, moduleScope);\n\t\treturn !(ob == Scriptable.NOT_FOUND);\n\t}\n\t\n\tprivate Function getEntryFunction() throws ModuleValidationException {\n\t\tFunction entry = getGlobalFunction(\"run\");\n\t\tif(entry == null) \n\t\t\tentry = getGlobalFunction(\"initialize\");\n\t\tif(entry == null)\n\t\t\tthrow new ModuleValidationException(\"Could not find global entry function 'run()' or 'initialize()' in module.\");\n\t\treturn entry;\n\t}\n\t\n\tprivate Function getGlobalFunction(String name) throws ModuleValidationException {\n\t\tfinal Object ob = moduleScope.get(name, moduleScope);\n\t\tif(ob == Scriptable.NOT_FOUND)\n\t\t\treturn null;\n\t\tif(!(ob instanceof Function))\n\t\t\tthrow new ModuleValidationException(\"Global identifier '\"+ name +\"' is not a function as expected\");\n\t\treturn (Function) ob;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/PreludeLoader.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.io.File;\nimport java.io.FileFilter;\nimport java.lang.reflect.InvocationTargetException;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\n\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.AnchorJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.AttrJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.CharacterDataJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.CommentJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.DocumentJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.ElementJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.FormJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.HTMLCollectionJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.HTMLDocumentJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.InputJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.LinkJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.NodeJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.NodeListJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.OptionJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.SelectJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.TextJS;\n\npublic class PreludeLoader {\n\tprivate final Logger logger = Logger.getLogger(\"prelude-loader\");\n\tprivate final File preludeDirectory;\n\tprivate final ScriptCompiler preludeCompiler;\n\n\tprivate final FileFilter scriptFilter = new FileFilter() {\n\t\tpublic boolean accept(File pathname) {\n\t\t\treturn pathname.isFile() && pathname.getName().endsWith(\".js\");\n\t\t}\n\t};\n\t\n\tprivate Scriptable preludeScope;\n\t\n\tPreludeLoader(File directory, Scriptable scope) {\n\t\tthis.preludeDirectory = directory;\n\t\tthis.preludeCompiler = new ScriptCompiler(scope);\n\t}\n\t\n\tboolean load() {\n\t\ttry {\n\t\t\tContext cx = Context.enter();\n\t\t\tScriptable scope = preludeCompiler.newScope(cx);\n\t\t\tfor(File ps: preludeDirectory.listFiles(scriptFilter)) {\n\t\t\t\tScriptFile scriptFile = new ScriptFile(ps);\n\t\t\t\tif(!preludeCompiler.compile(scriptFile, cx, scope)) {\n\t\t\t\t\tlogger.warning(\"Failed to load module prelude\");\n\t\t\t\t\tlogger.warning(scriptFile.getCompileFailureMessage());\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tdefineHostObject(scope, NodeJS.class);\n\t\t\tdefineHostObject(scope, DocumentJS.class);\n\t\t\tdefineHostObject(scope, ElementJS.class);\n\t\t\tdefineHostObject(scope, AttrJS.class);\n\t\t\tdefineHostObject(scope, CharacterDataJS.class);\n\t\t\tdefineHostObject(scope, TextJS.class);\n\t\t\tdefineHostObject(scope, AnchorJS.class);\n\t\t\tdefineHostObject(scope, FormJS.class);\n\t\t\tdefineHostObject(scope, CommentJS.class);\n\t\t\tdefineHostObject(scope, HTMLCollectionJS.class);\n\t\t\tdefineHostObject(scope, HTMLDocumentJS.class);\n\t\t\tdefineHostObject(scope, InputJS.class);\n\t\t\tdefineHostObject(scope, LinkJS.class);\n\t\t\tdefineHostObject(scope, OptionJS.class);\n\t\t\tdefineHostObject(scope, SelectJS.class);\n\t\t\tdefineHostObject(scope, NodeListJS.class);\n\t\t\tdefineHostObject(scope, ResponseJS.class);\n\t\t\tpreludeScope = scope;\n\t\t\treturn true;\n\t\t\t\n\t\t} catch (Exception e) {\n\t\t\tlogger.log(Level.WARNING, \"Unexpected exception loading prelude: \"+ e);\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t}\n\t\n\tprivate void defineHostObject(Scriptable scope, Class<? extends ScriptableObject> klass) {\n\t\ttry {\n\t\t\tScriptableObject.defineClass(scope, klass, true, true);\n\t\t} catch (IllegalAccessException e) {\n\t\t\tlogger.warning(\"IllegalAccessException defining class '\"+ klass.getName() + \"' : \"+ e.getMessage());\n\t\t} catch (InstantiationException e) {\n\t\t\tlogger.warning(\"InstantiationException defining class '\"+ klass.getName() + \"' : \"+ e.getMessage());\n\t\t} catch (InvocationTargetException e) {\n\t\t\tlogger.warning(\"InvocationTargetException defining class '\"+ klass.getName() + \"' : \"+ e.getMessage());\n\t\t}\t\t\n\t}\n\t\n\tScriptable getPreludeScope() {\n\t\treturn preludeScope;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ResponseJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.util.List;\n\nimport org.apache.http.Header;\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.w3c.dom.html2.HTMLDocument;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.IHttpResponseCookie;\n\npublic class ResponseJS extends ScriptableObject {\n\n\tprivate static final long serialVersionUID = -1;\n\tprivate IHttpResponse response;\n\tprivate Scriptable cachedDocument;\n\t\n\tpublic ResponseJS() {\n\t\tresponse = null;\n\t\tcachedDocument = null;\n\t}\n\t\n\tpublic ResponseJS(Object response) {\n\t\tthis.response = (IHttpResponse) Context.jsToJava(response, IHttpResponse.class);\n\t}\n\t\n\t\n\tprivate Scriptable createCachedDocument() {\n\t\tfinal IHTMLParseResult htmlResult = response.getParsedHTML();\n\t\tif(htmlResult == null) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal Context cx = Context.getCurrentContext();\n\t\tfinal HTMLDocument domDocument = htmlResult.getDOMDocument();\n\t\tfinal Scriptable scope = ScriptableObject.getTopLevelScope(this);\n\t\tfinal Object docOb = Context.javaToJS(domDocument, scope);\n\t\tfinal Object[] args = { docOb };\n\t\treturn cx.newObject(scope, \"HTMLDocument\", args);\n\t}\n\n\tIHttpResponse getResponse() {\n\t\treturn response;\n\t}\n\n\tpublic int jsGet_code() {\n\t\treturn response.getResponseCode();\n\t}\n\n\tpublic boolean jsFunction_hasHeader(String name) {\n\t\treturn response.getRawResponse().containsHeader(name);\n\t}\n\n\tpublic Object jsFunction_getFirstHeader(String name) {\n\t\tfinal Header hdr = response.getRawResponse().getFirstHeader(name);\n\t\tif(hdr == null) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal Scriptable parent = ScriptableObject.getTopLevelScope(this);\n\t\treturn Context.javaToJS(hdr, parent);\n\t}\n\n\tpublic Object jsFunction_getHeaders(String name) {\n\t\treturn headersToJS(response.getRawResponse().getHeaders(name));\n\t}\n\n\tpublic Object jsGet_allHeaders() {\n\t\treturn headersToJS(response.getRawResponse().getAllHeaders());\n\t}\n\n\tpublic Object jsFunction_getCookies() {\n\t\treturn cookiesToJS(response.getResponseCookies());\n\t}\n\tpublic Object jsGet_cookies() {\n\t\treturn cookiesToJS(response.getResponseCookies());\n\t}\n\n\tprivate Object headersToJS(Header[] headers) {\n\t\tfinal Scriptable scope = ScriptableObject.getTopLevelScope(this);\n\t\tfinal Context cx = Context.getCurrentContext();\n\t\tfinal Scriptable array = cx.newArray(scope, headers.length);\n\t\tfor(int i = 0; i < headers.length; i++) {\n\t\t\tarray.put(i, array, Context.javaToJS(headers[i], scope));\n\t\t}\n\t\treturn array;\n\t}\n\t\n\tprivate Object cookiesToJS(List<IHttpResponseCookie> cookies) {\n\t\tfinal Scriptable scope = ScriptableObject.getTopLevelScope(this);\n\t\tfinal Context cx = Context.getCurrentContext();\n\t\tfinal Scriptable array = cx.newArray(scope, cookies.size());\n\t\tfor(int i = 0; i < cookies.size(); i++) {\n\t\t\tarray.put(i, array, Context.javaToJS(cookies.get(i), scope));\n\t\t}\n\t\treturn array;\n\t}\n\n\tpublic boolean jsGet_fetchFail() {\n\t\treturn response.isFetchFail();\n\t}\n\n\tpublic Scriptable jsGet_document() {\n\t\tif(cachedDocument == null) {\n\t\t\tcachedDocument = createCachedDocument();\n\t\t}\n\t\treturn cachedDocument;\n\t}\n\n\tpublic Object jsGet_originalRequest() {\n\t\treturn export(response.getOriginalRequest());\n\t}\n\n\tpublic Object jsGet_rawResponse() {\n\t\treturn export(response.getRawResponse());\n\t}\n\n\tpublic Object jsGet_host() {\n\t\treturn export(response.getHost());\n\t}\n\n\tpublic String jsGet_bodyAsString() {\n\t\treturn response.getBodyAsString();\n\t}\n\n\tpublic boolean jsGet_mostlyAscii() {\n\t\treturn response.isMostlyAscii();\n\t}\n\n\tpublic Object jsGet_fingerprint() {\n\t\treturn export(response.getPageFingerprint());\n\t}\n\n\tpublic int jsGet_milliseconds() {\n\t\treturn (int) response.getRequestMilliseconds();\n\t}\n\n\tprivate Object export(Object ob) {\n\t\tfinal Scriptable scope = ScriptableObject.getTopLevelScope(this);\n\t\treturn Context.javaToJS(ob, scope);\n\t}\n\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Response\";\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ResponseModuleContext.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2013 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Logger;\nimport java.util.regex.Pattern;\nimport java.util.regex.PatternSyntaxException;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.Wrapper;\n\nimport com.google.common.io.BaseEncoding;\nimport com.google.common.net.InternetDomainName;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.scanner.IModuleContext;\n\npublic class ResponseModuleContext implements IModuleContext {\n\tprivate final static Logger logger = Logger.getLogger(\"modules\");\n\n\tprivate final IWorkspace workspace;\n\tprivate final IScanInstance scanInstance;\n\tprivate final List<String> stringHighlights;\n\tprivate final List<String> regexHighlights;\n\tprivate final List<String> regexCaseInsensitiveHighlights;\n\t\n\tResponseModuleContext(IWorkspace workspace, IScanInstance scanInstance) {\n\t\tthis.workspace = workspace;\n\t\tthis.scanInstance = scanInstance;\n\t\tthis.stringHighlights = new ArrayList<String>();\n\t\tthis.regexHighlights = new ArrayList<String>();\n\t\tthis.regexCaseInsensitiveHighlights = new ArrayList<String>();\n\t}\n\n\t@Override\n\tpublic void reportRequestException(HttpUriRequest request, Throwable ex) {\n\t\tlogger.warning(\"Exception processing request \"+ request +\" : \"+ ex.getMessage());\n\t\tscanInstance.notifyScanException(request, ex);\n\t}\n\n\t@Override\n\tpublic void error(HttpUriRequest request, IHttpResponse response,\n\t\t\tString message) {\n\t\tfinal long requestId = workspace.getRequestLog().addRequestResponse(response);\n\t\tlogger.warning(\"Error running module: \"+ message + \" (request logged with id=\"+ requestId +\")\");\n\t}\n\n\tpublic void error(HttpUriRequest request, ResponseJS response, String message) {\n\t\terror(request, response.getResponse(), message);\n\t}\n\n\t@Override\n\tpublic void debug(String msg) {\n\t\tworkspace.consoleWrite(msg);\n\t}\n\t\n\t@Override\n\tpublic void debug(String msg, Boolean colored) {\n\t\tif (colored) {\n\t\t\tworkspace.consoleDebug(msg);\n\t\t} else {\n\t\t\tworkspace.consoleWrite(msg);\n\t\t}\n\t}\n\t\n\tpublic void alert(String type, HttpUriRequest request, ResponseJS response) {\n\t\talert(type, request, response, null);\n\t}\n\t\n\tpublic void alert(String type, HttpRequest request, ResponseJS response, Scriptable ob) {\n\t\tList<Object> properties = new ArrayList<Object>();\n\t\tString keyValue = null;\n\t\tString messageValue = null;\n\t\tif(ob == null) {\n\t\t\tpublishAlert(type, null, request, response.getResponse());\n\t\t\treturn;\n\t\t}\n\t\t\n\n\t\tfor(Object k: ob.getIds()) {\n\t\t\tif(k instanceof String) {\n\t\t\t\tString key = (String) k;\n\t\t\t\tString val = lookup(key, ob);\n\t\t\t\tif(val != null) {\n\t\t\t\t\tif(\"key\".equals(key)) {\n\t\t\t\t\t\tkeyValue = val;\n\t\t\t\t\t} else if(\"message\".equals(key)) {\n\t\t\t\t\t\tmessageValue = val;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tproperties.add(key);\n\t\t\t\t\t\tproperties.add(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpublishAlert(type, keyValue, messageValue, request, response.getResponse(), properties.toArray());\n\t\t\n\t}\n\t\n\tprivate String lookup(String key, Scriptable ob) {\n\t\tfinal Object value = ob.get(key, ob);\n\t\tif(value instanceof String) {\n\t\t\treturn (String) value;\n\t\t} else if(value instanceof Wrapper) {\n\t\t\tWrapper w = (Wrapper) value;\n\t\t\tif(w.unwrap() instanceof String) {\n\t\t\t\treturn (String) w.unwrap();\n\t\t\t}\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void publishAlert(String type, String message,\n\t\t\tHttpRequest request, IHttpResponse response,\n\t\t\tObject... properties) {\n\t\tpublishAlert(type, null, message, request, response, properties);\n\t}\n\n\t@Override\n\tpublic void publishAlert(String type, String key, String message,\n\t\t\tHttpRequest request, IHttpResponse response,\n\t\t\tObject... properties) {\n\t\tdebug(\"Publishing Alert: (\"+ type +\") [\"+ request.getRequestLine().getUri() +\"] \");\n\t\tfinal IRequestLog requestLog = workspace.getRequestLog();\n\t\n\t\tsynchronized(scanInstance) {\n\t\t\tif(key != null && scanInstance.hasAlertKey(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal long requestId = requestLog.addRequestResponse(response);\n\t\t\tfinal IScanAlert alert = scanInstance.createAlert(type, key, requestId);\n\t\t\tfinal String hostname = response.getHost().getHostName();\n\t\t\talert.setDiscretionaryHostname(hostname);\n\t\t\t\n\t\t\tfor(int i = 0; (i + 1) < properties.length; i += 2) {\n\t\t\t\tif(properties[i] instanceof String) {\n\t\t\t\t\talert.setProperty((String) properties[i], properties[i + 1]);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.warning(\"Property key passed to publishAlert() is not a string\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(message != null) {\n\t\t\t\talert.setStringProperty(\"message\", message);\n\t\t\t}\n\t\t\tfor(String hl: stringHighlights) {\n\t\t\t\talert.addStringMatchHighlight(hl);\n\t\t\t}\n\t\t\tfor(String hl: regexHighlights) {\n\t\t\t\talert.addRegexHighlight(hl);\n\t\t\t}\n\t\t\tfor (String hl: regexCaseInsensitiveHighlights) {\n\t\t\t\talert.addRegexCaseInsensitiveHighlight(hl);\n\t\t\t}\n\t\t\tscanInstance.addAlert(alert);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setProperty(String name, Object value) {\n\t\tscanInstance.setProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setStringProperty(String name, String value) {\n\t\tscanInstance.setStringProperty(name, value);\n\t}\n\n\t@Override\n\tpublic void setIntegerProperty(String name, int value) {\n\t\tscanInstance.setIntegerProperty(name, value);\n\t}\n\n\t@Override\n\tpublic Object getProperty(String name) {\n\t\treturn scanInstance.getProperty(name);\n\t}\n\n\t@Override\n\tpublic String getStringProperty(String name) {\n\t\treturn scanInstance.getStringProperty(name);\n\t}\n\n\t@Override\n\tpublic Integer getIntegerProperty(String name) {\n\t\treturn scanInstance.getIntegerProperty(name);\n\t}\n\n\t@Override\n\tpublic List<String> propertyKeys() {\n\t\treturn scanInstance.propertyKeys();\n\t}\n\t\n\n\t@Override\n\tpublic void addStringHighlight(String str) {\n\t\tstringHighlights.add(str);\n\t}\n\n\t@Override\n\tpublic void addRegexHighlight(String regex) {\n\t\ttry {\n\t\t\tPattern.compile(regex);\n\t\t\tregexHighlights.add(regex);\n\t\t} catch (PatternSyntaxException e) {\n\t\t\tlogger.warning(\"Invalid regular expression '\"+ regex +\"' passed to addHighlightRegex(): \"+ e.getDescription());\n\t\t}\n\t}\n\t\n\t@Override \n\tpublic void addRegexCaseInsensitiveHighlight(String regex) {\n\t\ttry {\n\t\t\tPattern.compile(regex);\n\t\t\tregexCaseInsensitiveHighlights.add(regex);\n\t\t} catch (PatternSyntaxException e) {\n\t\t\tlogger.warning(\"Invalid regular expression '\"+ regex +\"' passed to addRegexCaseInsensitiveHighlights(): \"+ e.getDescription());\n\t\t}\n\t}\n\t\t\n\t\n\t@Override\n\tpublic void reset() {\n\t\tstringHighlights.clear();\n\t\tregexHighlights.clear();\n\t}\n\t\n\t@Override\n\tpublic boolean alertExists(String key) {\n\t\treturn scanInstance.hasAlertKey(key);\n\t}\n\t\n\tpublic InternetDomainName internetDomainName(String domain) {\n\t\treturn InternetDomainName.from(domain);\n\t\t\n\t}\n\t\n\tpublic boolean isValidInternetDomainName(String domain) {\n\t\treturn InternetDomainName.isValid(domain);\n\t}\n\t\n\tpublic String base64decode(String encoded) {\n\t\tbyte[] decoded = BaseEncoding.base64().decode(encoded);\n\t\treturn new String(decoded);\n\t}\n\t\n\tpublic String base64encode(String input) {\n\t\tString encoded = BaseEncoding.base64().encode(input.getBytes());\n\t\treturn encoded;\n\t}\n\t\n\tpublic long getScanId() {\n\t\treturn scanInstance.getScanId();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ResponseProcessorScript.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpRequest;\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.WrappedException;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.scanner.modules.IEnableableModule;\nimport com.subgraph.vega.api.scanner.modules.IResponseProcessingModule;\n\npublic class ResponseProcessorScript implements IResponseProcessingModule, IEnableableModule {\n\tprivate static final Logger logger = Logger.getLogger(\"modules\");\n\t\n\tprivate final ScriptedModule module;\n\tprivate final ScriptedModuleRunningTime runningTime;\n\t\n\tprivate boolean isEnabled;\n\t\n\t\n\tpublic ResponseProcessorScript(ScriptedModule module, boolean isEnabled, ScriptedModuleRunningTime runningTime) {\n\t\tthis.module = module;\n\t\tthis.isEnabled = isEnabled;\n\t\tthis.runningTime = runningTime;\n\t}\n\n\tpublic ResponseProcessorScript(ScriptedModule module) {\n\t\tthis.module = module;\n\t\tthis.isEnabled = module.isDefaultEnabled();\n\t\tthis.runningTime = new ScriptedModuleRunningTime(module.getModuleName());\n\t}\n\n\tpublic ScriptedModule getModule() {\n\t\treturn module;\n\t}\n\n\t@Override\n\tpublic void processResponse(IScanInstance scanInstance, HttpRequest request, IHttpResponse response,\n\t\t\tIWorkspace workspace) {\n\t\tfinal ResponseModuleContext ctx = new ResponseModuleContext(workspace, scanInstance);\n\t\ttry {\n\t\t\tContext cx = Context.enter();\n\t\t\tScriptable instance = module.createInstanceScope(cx);\n\t\t\tfinal Object[] arguments = new Object[] { request, createResponse(response, cx, instance), ctx };\n\t\t\tfinal long startTS = System.currentTimeMillis();\n\t\t\tmodule.runModule(cx, instance, arguments);\n\t\t\tfinal long endTS = System.currentTimeMillis();\n\t\t\trunningTime.addTimestamp((int) (endTS - startTS), request.getRequestLine().getUri());\n\t\t} catch (WrappedException e) {\n\t\t\tlogger.log(Level.WARNING, new RhinoExceptionFormatter(\"Wrapped exception running module script: \"+ module.getModuleName(), e).toString());\n\t\t} catch (RhinoException e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.warning(new RhinoExceptionFormatter(\"Exception running module script: \"+ module.getModuleName(), e).toString());\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t}\n\n\tprivate Scriptable createResponse(IHttpResponse response, Context cx, Scriptable scope) {\n\t\tObject responseOb = Context.javaToJS(response, scope);\n\t\tObject[] args = { responseOb };\n\t\treturn cx.newObject(scope, \"Response\", args);\n\t}\n\n\t@Override\n\tpublic boolean responseCodeFilter(int code) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean mimeTypeFilter(String mimeType) {\n\t     return mimeType.toLowerCase().matches(\"^.*?(text|html|script|xml|json).*$\");\n\t}\n\n\t@Override\n\tpublic String getModuleName() {\n\t\treturn module.getModuleName();\n\t}\n\n\t@Override\n\tpublic String getModuleCategoryName() {\n\t\treturn module.getCategoryName();\n\t}\n\n\t@Override\n\tpublic ScriptedModuleRunningTime getRunningTimeProfile() {\n\t\treturn runningTime;\n\t}\n\n\t@Override\n\tpublic void setEnabled(boolean flag) {\n\t\tisEnabled = flag;\n\t}\n\n\t@Override\n\tpublic boolean isEnabled() {\n\t\treturn isEnabled;\n\t}\n\n\t@Override\n\tpublic boolean isDifferential() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean isTimeSensitive() {\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/RhinoExceptionFormatter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.WrappedException;\n\npublic class RhinoExceptionFormatter {\n\tprivate final String message;\n\tprivate final RhinoException e;\n\tpublic RhinoExceptionFormatter(String message, RhinoException e) {\n\t\tthis.message = message;\n\t\tthis.e = e;\n\t}\n\t\n\tpublic String toString() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tsb.append(message +\"\\nSource file: \"+ e.sourceName() + \" at line \"+ e.lineNumber() +\" and column \"+ e.columnNumber() + \"\\n\");\n\t\tif(e.details() != null)\n\t\t\tsb.append(e.details() + \"\\n\");\n\t\tif(e.lineSource() != null) {\n\t\t\tsb.append(e.lineSource() + \"\\n\");\n\t\t\tif(e.columnNumber() != 0) {\n\t\t\t\tfor(int i = 1; i < e.columnNumber(); i++)\n\t\t\t\t\tsb.append(\" \");\n\t\t\t\tsb.append(\"^\\n\");\n\t\t\t}\n\t\t}\n\t\tif(e instanceof WrappedException) {\n\t\t\tWrappedException wrapped = (WrappedException) e;\n\t\t\tThrowable ex = wrapped.getWrappedException();\n\t\t\tfor(StackTraceElement el: ex.getStackTrace()) {\n\t\t\t\tsb.append(\"\\tat \");\n\t\t\t\tsb.append(el);\n\t\t\t\tsb.append(\"\\n\");\n\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn sb.toString();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ScriptCompiler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.io.IOException;\nimport java.io.Reader;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.Script;\nimport org.mozilla.javascript.Scriptable;\n\npublic class ScriptCompiler {\n\t\n\tprivate final Scriptable parentScope;\n\t\n\tpublic ScriptCompiler(Scriptable scope) {\n\t\tthis.parentScope = scope;\n\t}\n\t\n\tpublic boolean compile(ScriptFile scriptFile) {\n\t\ttry {\n\t\t\tfinal Context cx = Context.enter();\n\t\t\tfinal Scriptable scope = newScope(cx);\n\t\t\treturn compile(scriptFile, cx, scope);\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t}\n\n\tpublic boolean compile(ScriptFile scriptFile, Context cx, Scriptable scope) {\n\t\ttry {\n\t\t\tfinal Scriptable compiledScript =  compileReader(scriptFile.createReader(), scriptFile.getPath(), cx, scope);\n\t\t\tif(compiledScript != null)  {\n\t\t\t\tscriptFile.setCompiledScript(compiledScript);\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tscriptFile.setCompileFailed(\"I/O error compiling script \"+ scriptFile.getPath() + \": \"+ e.getMessage());\n\t\t\treturn false;\n\t\t} catch (RhinoException e) {\n\t\t\tfinal String msg = \"Failed to compile script \"+ scriptFile.getPath();\n\t\t\tscriptFile.setCompileFailed(new RhinoExceptionFormatter(msg, e).toString());\n\t\t\treturn false;\n\t\t} catch (Exception e) {\n\t\t\tscriptFile.setCompileFailed(\"Unexpected exception compiling script: \"+ e);\n\t\t\treturn false;\n\t\t}\n\t}\n\t\t\n\tpublic Scriptable compileReader(Reader r, String path, Context cx, Scriptable scriptScope) throws IOException {\n\t\tcx.setLanguageVersion(Context.VERSION_1_7);\n\t\tfinal Script script = cx.compileReader(r, path, 1, null);\t\t\t\n\t\tscript.exec(cx, scriptScope);\n\t\treturn scriptScope;\n\t}\n\t\n\tpublic Scriptable newScope(Context cx) {\n\t\tfinal Scriptable scope = cx.newObject(parentScope);\n\t\tscope.setPrototype(parentScope);\n\t\tscope.setParentScope(null);\n\t\treturn scope;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ScriptFile.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.net.URL;\n\nimport org.mozilla.javascript.Scriptable;\n\npublic class ScriptFile {\n\tpublic enum CompileStatus { NOT_COMPILED, COMPILE_FAILED, COMPILE_SUCCEEDED };\n\tprivate final URL scriptURL;\n\tprivate final File scriptFile;\n\t\n\tprivate long fileLastModified;\n\tprivate CompileStatus compileStatus;\n\tprivate Scriptable compiledScript;\n\tprivate String compileFailureMessage = \"\";\n\t\n\tpublic ScriptFile(File scriptFile) {\n\t\tthis(scriptFile, null, scriptFile.lastModified());\n\t}\n\t\n\tpublic ScriptFile(URL scriptURL) {\n\t\tthis(null, scriptURL, 0);\n\t}\n\t\n\tprivate ScriptFile(File scriptFile, URL scriptURL, long lastModified) {\n\t\tthis.scriptFile = scriptFile;\n\t\tthis.scriptURL = scriptURL;\n\t\tthis.fileLastModified = lastModified;\n\t\tthis.compileStatus = CompileStatus.NOT_COMPILED;\n\t\tthis.compileFailureMessage = \"\";\n\t}\n\t\n\tpublic String getPath() {\n\t\tif(scriptFile != null)\n\t\t\treturn scriptFile.getAbsolutePath();\n\t\telse if(scriptURL != null)\n\t\t\treturn scriptURL.getPath();\n\t\telse \n\t\t\treturn null;\n\t}\n\t\n\tpublic Reader createReader() throws IOException {\n\t\tif(scriptFile != null)\n\t\t\treturn new FileReader(scriptFile);\n\t\telse if(scriptURL != null) \n\t\t\treturn new InputStreamReader(scriptURL.openStream());\n\t\telse\n\t\t\treturn null;\n\t}\n\t\n\tvoid setCompiledScript(Scriptable script) {\n\t\tthis.compiledScript = script;\n\t\tcompileFailureMessage = \"\";\n\t\tsetCompileStatus(CompileStatus.COMPILE_SUCCEEDED);\n\t}\n\t\n\tvoid setCompileFailed(String failureMessage) {\n\t\tcompileFailureMessage = failureMessage;\n\t\tcompiledScript = null;\n\t\tsetCompileStatus(CompileStatus.COMPILE_FAILED);\n\t}\n\t\n\tpublic String getCompileFailureMessage() {\n\t\treturn compileFailureMessage;\n\t}\n\t\n\tprivate void setCompileStatus(CompileStatus status) {\n\t\tthis.compileStatus = status;\n\t\tif(scriptFile != null)\n\t\t\tfileLastModified = scriptFile.lastModified();\n\t}\n\t\n\tpublic CompileStatus getCompileStatus() {\n\t\treturn compileStatus;\n\t}\n\t\n\tpublic Scriptable getCompiledScript() {\n\t\treturn compiledScript;\n\t}\n\t\n\tpublic boolean hasFileChanged() {\n\t\tif(scriptURL != null)\n\t\t\treturn false;\n\t\telse\n\t\t\treturn (scriptFile.lastModified() > fileLastModified);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ScriptLoader.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport java.io.File;\nimport java.io.FileFilter;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.logging.Logger;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.ContextFactory;\nimport org.mozilla.javascript.ImporterTopLevel;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\n\nimport com.subgraph.vega.api.scanner.modules.ModuleScriptType;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ModuleValidator.ModuleValidationException;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptFile.CompileStatus;\n\npublic class ScriptLoader {\n\tprivate final Logger logger = Logger.getLogger(\"script-loader\");\n\tprivate final Scriptable globalScope;\n\tprivate final File moduleRoot;\n\tprivate final PreludeLoader preludeLoader;\n\tprivate final ScriptCompiler moduleCompiler;\n\tprivate final boolean preludeLoadFailed;\n\t\n\tprivate final Map<File, ScriptedModule> modulePathMap = new HashMap<File, ScriptedModule>();\n\t\n\t/* Script files are tracked separately from modules mainly so that we can track files have failed to compile. */\n\tprivate final Map<File, ScriptFile> scriptPathMap = new HashMap<File, ScriptFile>();\n\t\n\tprivate final FileFilter scriptFilter = new FileFilter() {\n\t\tpublic boolean accept(File pathname) {\n\t\t\treturn pathname.isFile() && pathname.getName().endsWith(\".js\");\n\t\t}\n\t};\n\t\n\tprivate final FileFilter directoryFilter = new FileFilter() {\n\t\tpublic boolean accept(File pathname) {\n\t\t\treturn pathname.isDirectory();\n\t\t}\n\t};\n\t\n\tpublic ScriptLoader(File moduleRoot) {\n\t\tlogger.info(\"Loading scripts from \"+ moduleRoot.getAbsolutePath());\n\t\tthis.moduleRoot = moduleRoot;\n\t\tenableDynamicScope();\n\t\tglobalScope = createGlobalScope();\n\t\tpreludeLoader = new PreludeLoader(new File(moduleRoot, \"prelude\"), globalScope);\n\t\tpreludeLoadFailed = (preludeLoader.load() == false);\n\t\tif(preludeLoadFailed)\n\t\t\tmoduleCompiler = null;\n\t\telse\n\t\t\tmoduleCompiler = new ScriptCompiler(preludeLoader.getPreludeScope());\n\t}\n\t\n\tprivate void enableDynamicScope() {\n\t\tContextFactory.initGlobal(new ContextFactory() {\n\t\t\t@Override\n\t\t\tprotected boolean hasFeature(Context cx, int featureIndex) {\n\t\t\t\tif(featureIndex == Context.FEATURE_DYNAMIC_SCOPE)\n\t\t\t\t\treturn true;\n\t\t\t\telse\n\t\t\t\t\treturn super.hasFeature(cx, featureIndex);\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate Scriptable createGlobalScope() {\n\t\ttry {\n\t\t\tfinal Context cx = Context.enter();\n\t\t\tfinal ScriptableObject importer = new ImporterTopLevel(cx, true);\n\t\t\treturn cx.initStandardObjects(importer, true);\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t}\n\t\n\tpublic List<ScriptedModule> getAllModulesByType(ModuleScriptType type) {\n\t\tfinal List<ScriptedModule> result = new ArrayList<ScriptedModule>();\n\t\tsynchronized(modulePathMap) {\n\t\t\tfor(ScriptedModule m: modulePathMap.values()) {\n\t\t\t\tif(!m.isDisabled() && (type == null || type == m.getModuleType())) {\n\t\t\t\t\tresult.add(m);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic List<ScriptedModule> getAllModules() {\n\t\treturn getAllModulesByType(null);\n\t}\n\t\n\tpublic Scriptable getPreludeScope() {\n\t\treturn preludeLoader.getPreludeScope();\n\t}\n\n\tprivate ScriptedModule compileModuleScript(ScriptFile scriptFile) {\n\t\tfinal ModuleValidator validator = compileAndValidate(scriptFile);\n\t\tif(validator == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new ScriptedModule(scriptFile, validator);\n\t}\n\t\n\tprivate boolean recompileModule(ScriptedModule module) {\n\t\tfinal ModuleValidator validator = compileAndValidate(module.getScriptFile());\n\t\tif(validator == null)\n\t\t\treturn false;\n\t\tmodule.updateFromValidator(validator);\n\t\treturn true;\n\t}\n\t\n\tprivate ModuleValidator compileAndValidate(ScriptFile scriptFile) {\n\t\tif(!moduleCompiler.compile(scriptFile) || scriptFile.getCompileStatus() != CompileStatus.COMPILE_SUCCEEDED) {\n\t\t\tlogger.warning(scriptFile.getCompileFailureMessage());\n\t\t\treturn null;\n\t\t}\n\t\treturn validateModule(scriptFile.getCompiledScript(), scriptFile.getPath());\n\t}\n\n\tprivate ModuleValidator validateModule(Scriptable module, String modulePath) {\n\t\tfinal ModuleValidator validator = new ModuleValidator(module);\n\t\ttry {\n\t\t\tvalidator.validate();\n\t\t\treturn validator;\n\t\t} catch (ModuleValidationException e) {\n\t\t\tlogger.warning(\"Failed to validate module script \"+ modulePath +\" :\"+ e.getMessage());\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate List<File> allScriptPaths() {\n\t\tfinal File scriptRoot = new File(moduleRoot, \"modules\");\n\t\tfinal List<File> scriptFiles = new ArrayList<File>();\n\t\tcrawlDirectory(scriptRoot, scriptFiles);\n\t\treturn scriptFiles;\n\t}\n\t\n\tprivate void crawlDirectory(File dir, List<File> files) {\n\t\tfor(File f: dir.listFiles(scriptFilter)) {\n\t\t\tfiles.add(f);\n\t\t}\n\t\t\n\t\tfor(File d: dir.listFiles(directoryFilter)) {\n\t\t\tcrawlDirectory(d, files);\n\t\t}\n\t}\n\t\n\tpublic boolean reloadModules() {\n\t\tboolean somethingChanged = false;\n\t\tif(preludeLoadFailed) {\n\t\t\treturn false;\n\t\t}\n\n\t\tsynchronized(modulePathMap) {\n\t\t\tsynchronizeScriptPaths();\n\t\t\tfor(Map.Entry<File, ScriptFile> entry: scriptPathMap.entrySet()) {\n\t\t\t\tif(compileScriptFileIfNeeded(entry.getKey(), entry.getValue())) {\n\t\t\t\t\tsomethingChanged = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn somethingChanged;\n\t}\n\n\tprivate void synchronizeScriptPaths() {\n\t\tfinal Set<File> pathSet = new HashSet<File>();\n\n\t\tfor(File path: allScriptPaths()) {\n\t\t\tpathSet.add(path);\n\t\t\tif(!scriptPathMap.containsKey(path)) { \n\t\t\t\tscriptPathMap.put(path, new ScriptFile(path));\n\t\t\t}\n\t\t}\n\n\t\tfinal List<File> keys = new ArrayList<File>(scriptPathMap.keySet());\n\t\tfor(File path: keys) {\n\t\t\tif(!pathSet.contains(path)) {\n\t\t\t\tmodulePathMap.remove(path);\n\t\t\t\tscriptPathMap.remove(path);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate boolean compileScriptFileIfNeeded(File path, ScriptFile scriptFile) {\n\t\tif(!isCompileNeeded(scriptFile)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif(modulePathMap.containsKey(path)) {\n\t\t\tif(!recompileModule(modulePathMap.get(path))) {\n\t\t\t\tmodulePathMap.remove(path);\n\t\t\t}\n\t\t} else {\n\t\t\tfinal ScriptedModule module = compileModuleScript(scriptFile);\n\t\t\tif(module != null) {\n\t\t\t\tmodulePathMap.put(path, module);\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate boolean isCompileNeeded(ScriptFile scriptFile) {\n\t\treturn ((scriptFile.getCompileStatus() == CompileStatus.NOT_COMPILED) || scriptFile.hasFileChanged());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ScriptedModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Function;\nimport org.mozilla.javascript.Scriptable;\n\nimport com.subgraph.vega.api.scanner.modules.ModuleScriptType;\n\npublic class ScriptedModule {\n\tprivate final ScriptFile scriptFile;\n\t\n\tprivate String categoryName;\n\tprivate String moduleName;\n\tprivate ModuleScriptType moduleType;\n\tprivate Function runFunction;\n\tprivate boolean isDisabledInScript;\n\tprivate boolean isDefaultEnabled;\n\tprivate boolean isTimeSensitive;\n\tprivate boolean isDifferential;\n\n\tpublic ScriptedModule(ScriptFile scriptFile, String category, ModuleValidator validator) {\n\t\tthis.scriptFile = scriptFile;\n\t\tupdateFromValidator(validator);\n\t\tcategoryName = category;\n\t}\n\n\tpublic ScriptedModule(ScriptFile scriptFile, ModuleValidator validator) {\n\t\t\n\t\tthis.scriptFile = scriptFile;\n\t\tupdateFromValidator(validator);\n\t}\n\t\n\tpublic void updateFromValidator(ModuleValidator validator) {\n\t\tcategoryName = validator.getCategoryName();\n\t\tmoduleName = validator.getName();\n\t\tmoduleType = validator.getType();\n\t\trunFunction = validator.getRunFunction();\n\t\tisDisabledInScript = validator.isDisabled();\n\t\tisDefaultEnabled = validator.isDefaultEnabled();\n\t\tisTimeSensitive = validator.isTimeSensitive();\n\t\tisDifferential = validator.isDifferential();\n\t}\n\n\tpublic Scriptable createInstanceScope(Context cx) {\n\t\tScriptable scope = cx.newObject(scriptFile.getCompiledScript());\n\t\tscope.setPrototype(scriptFile.getCompiledScript());\n\t\tscope.setParentScope(null);\n\t\treturn scope;\n\t}\n\t\n\tpublic void runModule(Context cx, Scriptable instanceScope) {\n\t\trunModule(cx, instanceScope, new Object[0]);\n\t}\n\n\tpublic void runModule(Context cx, Scriptable instanceScope, Object[] arguments) {\n\t\trunFunction.call(cx, instanceScope, instanceScope, arguments);\n\t}\n\t\n\tpublic ScriptFile getScriptFile() {\n\t\treturn scriptFile;\n\t}\n\t\n\tpublic String getCategoryName() {\n\t\treturn categoryName;\n\t}\n\n\tpublic String getModuleName() {\n\t\treturn moduleName;\n\t}\n\t\n\tpublic boolean isDifferential() {\n\t\treturn isDifferential;\n\t}\n\n\tpublic boolean isTimeSensitive() {\n\t\treturn isTimeSensitive;\n\t}\n\n\tpublic ModuleScriptType getModuleType() {\n\t\treturn moduleType;\n\t}\n\t\n\tpublic Scriptable getModuleScope() {\n\t\treturn scriptFile.getCompiledScript();\n\t}\n\t\n\tpublic boolean isDefaultEnabled() {\n\t\treturn isDefaultEnabled;\n\t}\n\n\tpublic boolean isDisabled() {\n\t\treturn isDisabledInScript;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/ScriptedModuleRunningTime.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRunningTime;\n\npublic class ScriptedModuleRunningTime implements IScannerModuleRunningTime {\n\n\tfinal private String name;\n\t\n\tprivate int invocationCount = 0;\n\tprivate int totalMilliseconds = 0;\n\tprivate int worstTime = -1;\n\tprivate String worstTimeTarget;\n\t\n\tpublic ScriptedModuleRunningTime(String name) {\n\t\tthis.name = name;\n\t}\n\t\n\t\n\t@Override\n\tpublic synchronized void reset() {\n\t\tinvocationCount = 0;\n\t\ttotalMilliseconds = 0;\n\t\tworstTime = -1;\n\t}\n\n\t@Override\n\tpublic int getInvocationCount() {\n\t\treturn invocationCount;\n\t}\n\n\t@Override\n\tpublic double getAverageTime() {\n\t\tif(invocationCount == 0)\n\t\t\treturn 0.0f;\n\t\t\n\t\treturn ((double) totalMilliseconds / (double) invocationCount);\n\t}\n\n\t@Override\n\tpublic int getTotalTime() {\n\t\treturn totalMilliseconds;\n\t}\n\n\t@Override\n\tpublic int getWorstTime() {\n\t\treturn worstTime;\n\t}\n\t\n\tvoid addTimestamp(int ts, String target) {\n\t\tsynchronized(this) {\n\t\t\tinvocationCount += 1;\n\t\t\ttotalMilliseconds += ts;\n\t\t\tif(worstTime < 0 || ts > worstTime) {\n\t\t\t\tworstTime = ts;\n\t\t\t\tworstTimeTarget = target;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic String toString() {\n\t\treturn String.format(\"Invocations: %3d Average: %8.3f ms [worst: %4d ms @(%s) ] for %s\", invocationCount, getAverageTime(), worstTime, worstTimeTarget, name);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/AnchorJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.w3c.dom.html2.HTMLAnchorElement;\n\npublic class AnchorJS extends HTMLElementJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tpublic AnchorJS() {\n\t}\n\t\n\tpublic AnchorJS(HTMLAnchorElement element, DocumentJS document) {\n\t\tsuper(element, document);\n\t}\n\t\n\t@Override \n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Anchor\";\n\t}\n\t\n\tpublic String jsGet_name() {\n\t\treturn element.getAttribute(\"name\");\n\t}\n\t\n\tpublic void jsFunction_focus() {\n\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/AttrJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.Attr;\n\npublic class AttrJS extends NodeJS {\n\t\n\tprivate static final long serialVersionUID = 1L;\n\tprivate final Attr attr;\n\t\n\tpublic AttrJS() {\n\t\tthis.attr = null;\n\t}\n\t\n\tpublic AttrJS(Attr attr, DocumentJS document) {\n\t\tsuper(attr, document);\n\t\tthis.attr = attr;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Attr\";\n\t}\n\t\n\tpublic String jsGet_name() {\n\t\treturn attr.getName();\n\t}\n\t\n\tpublic Scriptable jsGet_ownerElement() {\n\t\treturn exportNode(attr.getOwnerElement());\n\t}\n\t\n\tpublic boolean jsGet_specified() {\n\t\treturn attr.getSpecified();\n\t}\n\t\n\tpublic String jsGet_value() {\n\t\treturn attr.getValue();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/CharacterDataJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.w3c.dom.CharacterData;\nimport org.w3c.dom.DOMException;\n\npublic class CharacterDataJS extends NodeJS {\n\t\n\tprivate static final long serialVersionUID = 1L;\n\tprivate final CharacterData characterData;\n\t\n\tpublic CharacterDataJS() {\n\t\tthis.characterData = null;\n\t}\n\t\n\tpublic CharacterDataJS(CharacterData data, DocumentJS document) {\n\t\tsuper(data, document);\n\t\tthis.characterData = data;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"CharacterData\";\n\t}\n\t\n\tpublic String jsGet_data() {\n\t\treturn characterData.getData();\n\t}\n\t\n\tpublic int jsGet_length() {\n\t\treturn characterData.getLength();\n\t}\n\t\n\tpublic void jsFunction_appendData(String arg) throws DOMException {\n\t\tcharacterData.appendData(arg);\n\t}\n\t\n\tpublic void jsFunction_deleteData(int offset, int count) throws DOMException {\n\t\tcharacterData.deleteData(offset, count);\n\t}\n\t\n\tpublic void jsFunction_insertData(int offset, String arg) throws DOMException {\n\t\tcharacterData.insertData(offset, arg);\n\t}\n\t\n\tpublic void jsFunction_replaceData(int offset, int length, String arg) throws DOMException {\n\t\tcharacterData.replaceData(offset, length, arg);\n\t}\n\t\n\tpublic String jsFunction_substringData(int offset, int count) throws DOMException {\n\t\treturn characterData.substringData(offset, count);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/CommentJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.w3c.dom.Comment;\n\npublic class CommentJS extends NodeJS {\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tpublic CommentJS() {\n\t}\n\t\n\tpublic CommentJS(Comment comment, DocumentJS document) {\n\t\tsuper(comment, document);\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Comment\";\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/DocumentJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Node;\n\npublic class DocumentJS extends NodeJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\tprotected Document document;\n\tprivate Map<Node, NodeJS> nodeCache = new HashMap<Node, NodeJS>();\n\t\n\tpublic DocumentJS() {\n\t\tthis.document = null;\n\t}\n\t\n\tNodeJS findCachedNode(Node node) {\n\t\treturn nodeCache.get(node);\n\t}\n\tvoid putCachedNode(Node node, NodeJS nodeJS) {\n\t\tnodeCache.put(node, nodeJS);\n\t}\n\t\n\tpublic DocumentJS(Document document) {\n\t\tsuper(document, null);\n\t\tthis.document = document;\n\t\tsetDocumentJS(this);\n\t}\n\t\n\tpublic void jsConstructor(Object ob) {\n\t\tfinal Document d = (Document) Context.jsToJava(ob, Document.class);\n\t\tthis.document = d;\n\t\tsetNode(d);\n\t\tsetDocumentJS(this);\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Document\";\n\t}\n\t\n\tpublic Scriptable jsGet_doctype() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsGet_documentElement() {\n\t\treturn exportNode(document.getDocumentElement());\n\t}\n\t\n\tpublic Scriptable jsGet_implementation() {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_addEventListener(String type, Scriptable listener, boolean useCapture) {\n\t\t\n\t}\n\t\n\tpublic void jsFunction_attachEvent(String type, Scriptable listener) {\n\t\t\n\t}\n\t\n\tpublic Scriptable jsFunction_createAttribute(String name) {\n\t\treturn exportNode(document.createAttribute(name));\n\t}\n\t\n\tpublic Scriptable jsFunction_createAttributeNS(String namespaceURI, String qualifiedName) {\n\t\treturn exportNode(document.createAttributeNS(namespaceURI, qualifiedName));\n\t}\n\t\n\tpublic Scriptable jsFunction_createCDataSection(String data) throws DOMException {\n\t\treturn exportNode(document.createCDATASection(data));\n\t}\n\t\n\tpublic Scriptable jsFunction_createComment(String data) {\n\t\treturn exportNode(document.createComment(data));\n\t}\n\t\n\tpublic Scriptable jsFunction_createDocumentFragment() {\n\t\treturn exportNode(document.createDocumentFragment());\n\t}\n\t\n\tpublic Scriptable jsFunction_createElement(String tagName) {\n\t\treturn exportNode(document.createElement(tagName));\n\t}\n\t\n\tpublic Scriptable jsFunction_createElementNS(String namespaceURI, String qualifiedName) throws DOMException {\n\t\treturn exportNode(document.createElementNS(namespaceURI, qualifiedName));\n\t}\n\t\n\tpublic Scriptable jsFunction_createEvent(String eventType) throws DOMException {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsFunction_createProcessingInstruction(String target, String data) throws DOMException {\n\t\treturn exportNode(document.createProcessingInstruction(target, data));\n\t}\n\t\n\tpublic Scriptable jsFunction_createRange() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsFunction_createTextNode(String data) {\n\t\treturn exportNode(document.createTextNode(data));\n\t}\n\t\n\tpublic void jsFunction_detachEvent(String type, Scriptable listener) {\n\t\t\n\t}\n\t\n\tpublic boolean jsFunction_dispatchEvent(Scriptable evt) {\n\t\treturn false;\n\t}\n\t\n\tpublic Scriptable jsFunction_getElementById(String elementId) {\n\t\treturn exportNode(document.getElementById(elementId));\n\t}\n\n\tpublic Scriptable jsFunction_getElementsByTagName(String tagName) {\n\t\treturn exportNodeList(document.getElementsByTagName(tagName));\n\t}\n\t\n\tpublic Scriptable jsFunction_getElementsByTagNameNS(String namespaceURI, String localName) {\n\t\treturn exportNodeList(document.getElementsByTagNameNS(namespaceURI, localName));\n\t}\n\t\n\tpublic Scriptable jsFunction_importNode(Scriptable importedNode, boolean deep) throws DOMException {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_removeEventListener(String type, Scriptable listener, boolean useCapture) {\n\t\t\n\t}\t\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/ElementJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Element;\n\npublic class ElementJS extends NodeJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tprotected final Element element;\n\t\n\tpublic ElementJS() {\n\t\tthis.element = null;\n\t}\n\t\n\tpublic ElementJS(Element element, DocumentJS document) {\n\t\tsuper(element, document);\n\t\tthis.element = element;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Element\";\n\t}\n\t\n\tpublic String jsGet_tagName() {\n\t\treturn element.getTagName();\n\t}\n\t\n\tpublic void jsFunction_addEventListener(String type, Scriptable listener, boolean useCapture) {\n\t\t\n\t}\n\t\n\tpublic void jsFunction_attachEvent(String type, Scriptable listener) {\n\t\t\n\t}\n\t\n\tpublic void jsFunction_detachEvent(String type, Scriptable listener) {\n\t\t\n\t}\n\t\n\tpublic boolean jsFunction_dispatchEvent(Scriptable evt) {\n\t\treturn false;\n\t}\n\t\n\tpublic String jsFunction_getAttribute(String name) {\n\t\treturn element.getAttribute(name);\n\t}\n\t\n\tpublic Scriptable jsFunction_getAttributeNode(String name) {\n\t\treturn exportNode(element.getAttributeNode(name));\n\t}\n\t\n\tpublic Scriptable jsFunction_getAttributeNodeNS(String namespaceURI, String localName) {\n\t\treturn exportNode(element.getAttributeNodeNS(namespaceURI, localName));\n\t}\n\t\n\tpublic String jsFunction_getAttributeNS(String namespaceURI, String localName) {\n\t\treturn element.getAttributeNS(namespaceURI, localName);\n\t}\n\t\n\tpublic Scriptable jsFunction_getElementsByTagName(String name) {\n\t\treturn exportNodeList(element.getElementsByTagName(name));\t\t\n\t}\n\t\n\tpublic Scriptable jsFunction_getElementsByTagNameNS(String namespaceURI, String localName) {\n\t\treturn exportNodeList(element.getElementsByTagNameNS(namespaceURI, localName));\n\t}\n\t\n\tpublic boolean jsFunction_hasAttribute(String name) {\n\t\treturn element.hasAttribute(name);\n\t}\n\t\n\tpublic boolean jsFunction_hasAttributeNS(String namespaceURI, String localName) {\n\t\treturn element.hasAttributeNS(namespaceURI, localName);\n\t}\n\t\n\tpublic void jsFunction_removeAttribute(String name) {\n\t\telement.removeAttribute(name);\n\t}\n\t\n\tpublic Scriptable jsFunction_removeAttributeNode(Scriptable oldAttr) {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_removeAttributeNS(String namespaceURI, String localName) {\n\t\telement.removeAttributeNS(namespaceURI, localName);\n\t}\n\t\n\tpublic void jsFunction_removeEventListener(String type, Scriptable listener, boolean useCapture) {\n\t\t\n\t}\n\t\n\tpublic void jsFunction_setAttribute(String name, String value) throws DOMException {\n\t\telement.setAttribute(name, value);\n\t}\n\t\n\tpublic Scriptable jsFunction_setAttributeNode(Scriptable newAttr) throws DOMException {\n\t\t\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsFunction_setAttributeNodeJS(Scriptable newAttr) throws DOMException {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {\n\t\telement.setAttributeNS(namespaceURI, qualifiedName, value);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/FormJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.w3c.dom.html2.HTMLFormElement;\n\npublic class FormJS extends HTMLElementJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tprivate final HTMLFormElement formElement;\n\t\n\tpublic FormJS() {\n\t\tthis.formElement = null;\n\t}\n\t\n\tpublic FormJS(HTMLFormElement element, DocumentJS document) {\n\t\tsuper(element, document);\n\t\tthis.formElement = element;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\tpublic Scriptable jsGet_elements() {\n\t\tfinal HTMLCollectionJS collection = new HTMLCollectionJS(formElement.getElements(), ScriptableObject.getTopLevelScope(this), getDocumentJS());\n\t\texportObject(collection);\n\t\treturn collection;\n\t}\n\t\n\tpublic int jsGet_length() {\n\t\treturn formElement.getLength();\n\t}\n\t\n\tpublic String jsGet_acceptCharset() {\n\t\treturn formElement.getAcceptCharset();\n\t}\n\t\n\tpublic String jsGet_action() {\n\t\treturn formElement.getAction();\n\t}\n\t\n\tpublic String jsGet_enctype() {\n\t\treturn formElement.getEnctype();\n\t}\n\t\n\tpublic String jsGet_method() {\n\t\treturn formElement.getMethod();\n\t}\n\t\n\tpublic String jsGet_name() {\n\t\treturn formElement.getName();\n\t}\n\t\n\tpublic String jsGet_target() {\n\t\treturn formElement.getTarget();\n\t}\n\t\n\tpublic void jsFunction_reset() {\n\t\tformElement.reset();\n\t}\n\t\n\tpublic void jsFunction_submit() {\n\t\tformElement.submit();\n\t}\n\t\n\tpublic Scriptable jsGet_onsubmit() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsGet_onreset() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/HTMLCollectionJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.html2.HTMLCollection;\nimport org.w3c.dom.html2.HTMLElement;\n\npublic class HTMLCollectionJS extends ScriptableObject {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate final List<Scriptable> byIndex = new ArrayList<Scriptable>();\n\tprivate final Map<String, Scriptable> byName = new HashMap<String, Scriptable>();\n\tprivate final Map<String, Scriptable> byId = new HashMap<String, Scriptable>();\n\t\n\tpublic HTMLCollectionJS() {\n\t\t\n\t}\n\t\n\tpublic HTMLCollectionJS(HTMLCollection elements, Scriptable scope, DocumentJS document) {\n\t\tfor(int i = 0; i < elements.getLength(); i++) {\n\t\t\tNode n = elements.item(i);\n\t\t\tif(n instanceof HTMLElement) {\n\t\t\t\taddHTMLElement((HTMLElement) n, scope, document);\n\t\t\t}\t\t\t\n\t\t}\n\t}\n\t\n\tprivate void addHTMLElement(HTMLElement element, Scriptable scope, DocumentJS document) {\n\t\tScriptable ob = HTMLElementJS.domHTMLElementToJS(element, document);\n\t\tob.setParentScope(scope);\n\t\tob.setPrototype(ScriptableObject.getClassPrototype(scope, ob.getClassName()));\n\t\tbyIndex.add(ob);\n\t\tString id = element.getId();\n\t\tString name = element.getAttribute(\"name\");\n\t\tif(id != null)\n\t\t\tbyId.put(id, ob);\n\t\tif(name != null)\n\t\t\tbyName.put(name, ob);\n\t}\n\t\n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"HTMLCollection\";\n\t}\n\t\n\t@Override\n\tpublic Object get(String name, Scriptable start) {\n\t\tObject ob = jsFunction_namedItem(name);\n\t\tif(ob != null)\n\t\t\treturn ob;\n\t\telse\n\t\t\treturn super.get(name, start);\n\t}\n\t\n\tpublic int jsGet_length() {\n\t\treturn byIndex.size();\n\t}\n\t\n\tpublic Scriptable jsFunction_item(int index) {\n\t\tif(index < 0 || index >= byIndex.size())\n\t\t\treturn null;\n\t\treturn byIndex.get(index);\n\t}\n\t\n\tpublic Object jsFunction_namedItem(String name) {\n\t\tif(byId.containsKey(name)) {\n\t\t\treturn byId.get(name);\n\t\t} else {\n\t\t\treturn byName.get(name);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/HTMLDocumentJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.w3c.dom.html2.HTMLDocument;\n\npublic class HTMLDocumentJS extends DocumentJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate HTMLDocument htmlDocument;\n\t\n\tpublic HTMLDocumentJS() {\n\t\thtmlDocument = null;\n\t}\n\t\n\tpublic HTMLDocumentJS(HTMLDocument document) {\n\t\tsuper(document);\n\t\tthis.htmlDocument = document;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t\tfinal HTMLDocument d = (HTMLDocument) Context.jsToJava(ob, HTMLDocument.class);\n\t\tthis.htmlDocument = d;\n\t\tthis.document = d;\n\t\tsetNode(d);\n\t\tsetDocumentJS(this);\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"HTMLDocument\";\n\t}\n\t\n\tpublic Scriptable jsGet_anchors() {\n\t\tHTMLCollectionJS collection = new HTMLCollectionJS(htmlDocument.getAnchors(), ScriptableObject.getTopLevelScope(this), this);\n\t\texportObject(collection);\n\t\treturn collection;\n\t}\n\t\n\tpublic Scriptable jsGet_applets() {\n\t\tHTMLCollectionJS collection = new HTMLCollectionJS(htmlDocument.getApplets(), ScriptableObject.getTopLevelScope(this), this);\n\t\texportObject(collection);\n\t\treturn collection;\n\t}\n\t\n\tpublic Scriptable jsGet_body() {\n\t\treturn exportNode(htmlDocument.getBody());\n\t}\n\t\n\tpublic String jsGet_cookie() {\n\t\treturn htmlDocument.getCookie();\n\t}\n\t\n\tpublic String jsGet_domain() {\n\t\treturn htmlDocument.getDomain();\n\t}\n\t\n\tpublic Scriptable jsGet_forms() {\n\t\tHTMLCollectionJS collection = new HTMLCollectionJS(htmlDocument.getForms(), ScriptableObject.getTopLevelScope(this), this);\n\t\texportObject(collection);\n\t\treturn collection;\n\t}\n\t\n\tpublic Scriptable jsGet_images() {\n\t\tHTMLCollectionJS collection = new HTMLCollectionJS(htmlDocument.getImages(), ScriptableObject.getTopLevelScope(this), this);\n\t\texportObject(collection);\n\t\treturn collection;\n\t}\n\t\n\tpublic Scriptable jsGet_links() {\n\t\tHTMLCollectionJS collection = new HTMLCollectionJS(htmlDocument.getLinks(), ScriptableObject.getTopLevelScope(this), this);\n\t\texportObject(collection);\n\t\treturn collection;\n\t}\n\t\n\tpublic String jsGet_referrer() {\n\t\treturn htmlDocument.getReferrer();\n\t}\n\t\n\tpublic String jsGet_title() {\n\t\treturn htmlDocument.getTitle();\n\t}\n\t\n\tpublic String jsGet_URL() {\n\t\treturn htmlDocument.getURL();\n\t}\n\t\n\tpublic void jsFunction_close() {\n\t\thtmlDocument.close();\n\t}\n\t\n\tpublic Scriptable jsFunction_getElementsByName(String elementName) {\t\t\n\t\tfinal NodeListJS nodeList = new NodeListJS(htmlDocument.getElementsByName(elementName), ScriptableObject.getTopLevelScope(this), this);\n\t\texportObject(nodeList);\n\t\treturn nodeList;\n\t}\n\t\n\tpublic void jsFunction_open() {\n\t\thtmlDocument.open();\n\t}\n\t\n\tpublic void jsFunction_write(String text) {\n\t\thtmlDocument.write(text);\n\t}\n\t\n\tpublic void jsFunction_writeln(String text) {\n\t\thtmlDocument.writeln(text);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/HTMLElementJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.html2.HTMLAnchorElement;\nimport org.w3c.dom.html2.HTMLElement;\nimport org.w3c.dom.html2.HTMLFormElement;\nimport org.w3c.dom.html2.HTMLInputElement;\nimport org.w3c.dom.html2.HTMLLinkElement;\nimport org.w3c.dom.html2.HTMLOptionElement;\nimport org.w3c.dom.html2.HTMLSelectElement;\n\nimport com.subgraph.vega.api.html.IInnerHtmlProvidingElement;\n\npublic class HTMLElementJS extends ElementJS {\n\n\tstatic HTMLElementJS domHTMLElementToJS(HTMLElement element, DocumentJS document) {\n\t\tif(element instanceof HTMLAnchorElement) {\n\t\t\treturn new AnchorJS((HTMLAnchorElement) element, document);\n\t\t} else if(element instanceof HTMLFormElement) {\n\t\t\treturn new FormJS((HTMLFormElement) element, document);\n\t\t} else if(element instanceof HTMLInputElement) {\n\t\t\treturn new InputJS((HTMLInputElement) element, document);\n\t\t} else if(element instanceof HTMLLinkElement) {\n\t\t\treturn new LinkJS((HTMLLinkElement) element);\n\t\t} else if(element instanceof HTMLOptionElement) {\n\t\t\treturn new OptionJS((HTMLOptionElement) element, document);\n\t\t} else if(element instanceof HTMLSelectElement) {\n\t\t\treturn new SelectJS((HTMLSelectElement) element, document);\n\t\t} else {\n\t\t\treturn new HTMLElementJS(element, document);\n\t\t}\n\t}\n\t\n\tprivate static final long serialVersionUID = 1L;\n\tprivate final HTMLElement htmlElement;\n\t\n\tpublic HTMLElementJS() {\n\t\tthis.htmlElement = null;\n\t}\n\t\n\tpublic HTMLElementJS(HTMLElement element, DocumentJS document) {\n\t\tsuper(element, document);\n\t\tthis.htmlElement = element;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"HTMLElement\";\n\t}\n\t\n\tpublic String jsGet_className() {\n\t\treturn htmlElement.getClassName();\n\t}\n\t\n\tpublic Scriptable jsGet_currentStyle() {\n\t\treturn null;\n\t}\n\t\n\tpublic String jsGet_dir() {\n\t\treturn htmlElement.getDir();\n\t}\n\t\n\tpublic String jsGet_id() {\n\t\treturn htmlElement.getId();\n\t}\n\t\n\tpublic String jsGet_innerHTML() {\n\t\tif(htmlElement instanceof IInnerHtmlProvidingElement) {\n\t\t\treturn ((IInnerHtmlProvidingElement) htmlElement).getInnerHtml();\n\t\t} else {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\t\n\tpublic String jsGet_lang() {\n\t\treturn htmlElement.getLang();\n\t}\n\t\n\tpublic int jsGet_offsetHeight() {\n\t\treturn 0;\n\t}\n\t\n\tpublic int jsGet_offsetWidth() {\n\t\treturn 0;\n\t}\n\t\n\tpublic int jsGet_offsetLeft() {\n\t\treturn 0;\n\t}\n\t\n\tpublic int jsGet_offsetTop() {\n\t\treturn 0;\n\t}\n\t\n\tpublic Scriptable jsGet_offsetParent() {\n\t\treturn null;\n\t}\n\t\n\tpublic int jsGet_scrollHeight() {\n\t\treturn 0;\n\t}\n\t\n\tpublic int jsGet_scrollWidth() {\n\t\treturn 0;\n\t}\n\t\n\tpublic int jsGet_scrollLeft() {\n\t\treturn 0;\n\t}\n\t\n\tpublic int jsGet_scrollTop() {\n\t\treturn 0;\n\t}\n\t\n\tpublic Scriptable jsGet_style() {\n\t\treturn null;\n\t}\n\t\n\tpublic String jsGet_title() {\n\t\treturn htmlElement.getTitle();\n\t}\n\t\n\tpublic Scriptable jsGet_onclick() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsGet_ondblclick() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onkeydown() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onkeypress() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onkeyup() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onmousedown() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onmousemove() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onmouseout() {\n\t\treturn null;\n\t}\n\n\tpublic Scriptable jsGet_onmouseover() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsGet_onmouseup() {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_scrollIntoView(boolean top) {\n\t\t\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/InputJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.html2.HTMLInputElement;\n\npublic class InputJS extends HTMLElementJS {\n\t\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tprivate final HTMLInputElement inputElement;\n\t\n\tpublic InputJS() {\n\t\tthis.inputElement = null;\n\t}\n\t\n\tpublic InputJS(HTMLInputElement element, DocumentJS document) {\n\t\tsuper(element, document);\n\t\tthis.inputElement = element;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Input\";\n\t}\n\t\n\tpublic String jsGet_accept() {\n\t\treturn inputElement.getAccept();\n\t}\n\t\n\tpublic String jsGet_accessKey() {\n\t\treturn inputElement.getAccessKey();\n\t}\n\t\n\tpublic String jsGet_align() {\n\t\treturn inputElement.getAlign();\n\t}\n\t\n\tpublic String jsGet_alt() {\n\t\treturn inputElement.getAlt();\n\t}\n\t\n\tpublic boolean jsGet_checked() {\n\t\treturn inputElement.getChecked();\n\t}\n\t\n\tpublic boolean jsGet_defaultChecked() {\n\t\treturn inputElement.getDefaultChecked();\n\t}\n\t\n\tpublic String jsGet_defaultValue() {\n\t\treturn inputElement.getDefaultValue();\n\t}\n\t\n\tpublic boolean jsGet_disabled() {\n\t\treturn inputElement.getDisabled();\n\t}\n\t\n\tpublic Scriptable jsGet_form() {\n\t\treturn exportNode(inputElement.getForm());\n\t}\n\t\n\tpublic int jsGet_maxLength() {\n\t\treturn inputElement.getMaxLength();\n\t}\n\t\n\tpublic String jsGet_name() {\n\t\treturn inputElement.getName();\n\t}\n\t\n\tpublic boolean jsGet_readOnly() {\n\t\treturn inputElement.getReadOnly();\n\t}\n\t\n\tpublic int jsGet_size() {\n\t\treturn inputElement.getSize();\n\t}\n\t\n\tpublic String jsGet_src() {\n\t\treturn inputElement.getSrc();\n\t}\n\t\n\tpublic int jsGet_tabIndex() {\n\t\treturn inputElement.getTabIndex();\n\t}\n\t\n\tpublic String jsGet_type() {\n\t\treturn inputElement.getType();\n\t}\n\t\n\tpublic String jsGet_useMap() {\n\t\treturn inputElement.getUseMap();\n\t}\n\t\n\tpublic String jsGet_value() {\n\t\treturn inputElement.getValue();\n\t}\n\t\n\tpublic void jsFunction_blur() {\n\t\tinputElement.blur();\n\t}\n\t\n\tpublic void jsFunction_click() {\n\t\tinputElement.click();\n\t}\n\t\n\tpublic void jsFunction_focus() {\n\t\tinputElement.focus();\n\t}\n\t\n\tpublic Scriptable jsGet_onblur() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsGet_onchange() {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsGet_onfocus() {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_select() {\n\t\tinputElement.select();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/LinkJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.w3c.dom.html2.HTMLLinkElement;\n\npublic class LinkJS extends HTMLElementJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tprivate final HTMLLinkElement linkElement;\n\t\n\tpublic LinkJS() {\n\t\tthis.linkElement = null;\n\t}\n\t\n\tpublic LinkJS(HTMLLinkElement linkElement) {\n\t\tthis.linkElement = linkElement;\n\t}\n\t\n\t@Override \n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Link\";\n\t}\n\t\n\tpublic String jsGet_href() {\n\t\treturn linkElement.getHref();\n\t}\n\t\n\tpublic String jsGet_charset() {\n\t\treturn linkElement.getCharset();\n\t}\n\t\n\t\n\tpublic String jsGet_hreflang() {\n\t\treturn linkElement.getHreflang();\n\t}\n\t\t\n\tpublic String jsGet_rel() {\n\t\treturn linkElement.getRev();\n\t}\n\t\n\tpublic String jsGet_rev() {\n\t\treturn linkElement.getRev();\n\t}\n\t\n\tpublic String jsGet_target() {\n\t\treturn linkElement.getTarget();\n\t}\n\t\n\tpublic String jsGet_type() {\n\t\treturn linkElement.getType();\n\t}\n\t\n\tpublic void jsFunction_blur() {\n\t\t\n\t}\n\t\n\tpublic void jsFunction_focus() {\n\t\t\n\t}\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/NodeJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.FunctionObject;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.w3c.dom.Attr;\nimport org.w3c.dom.CharacterData;\nimport org.w3c.dom.Comment;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Element;\nimport org.w3c.dom.NamedNodeMap;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\nimport org.w3c.dom.Text;\nimport org.w3c.dom.html2.HTMLDocument;\nimport org.w3c.dom.html2.HTMLElement;\n\npublic class NodeJS extends ScriptableObject {\n\t\n\tstatic NodeJS domNodeToJS(Node node, DocumentJS document) {\n\t\tsynchronized(document) {\n\t\t\tif(node == null)\n\t\t\t\treturn null;\n\t\t\tNodeJS cachedNode = document.findCachedNode(node);\n\t\t\tif(cachedNode != null)\n\t\t\t\treturn cachedNode;\n\t\t\tNodeJS newNode = createNodeJSFromDomNode(node, document);\n\t\t\tif(newNode != null)\n\t\t\t\tdocument.putCachedNode(node, newNode);\n\t\t\treturn newNode;\n\t\t}\n\t}\n\t\n\tprivate static NodeJS createNodeJSFromDomNode(Node node, DocumentJS document) {\n\t\tif(node == null) {\n\t\t\treturn null;\n\t\t} else if (node instanceof HTMLElement) {\n\t\t\treturn HTMLElementJS.domHTMLElementToJS((HTMLElement) node, document);\n\t\t} else if (node instanceof HTMLDocument) {\n\t\t\treturn document;\n\t\t} else if(node instanceof Comment) {\n\t\t\treturn new CommentJS((Comment) node, document);\n\t\t} else if(node instanceof Text) {\n\t\t\treturn new TextJS((Text) node, document);\n\t\t} else if(node instanceof CharacterData) {\n\t\t\treturn new CharacterDataJS((CharacterData) node, document);\n\t\t} else if(node instanceof Attr) {\n\t\t\treturn new AttrJS((Attr) node, document);\n\t\t} else if(node instanceof Document) {\n\t\t\treturn document;\n\t\t} else if(node instanceof Element) {\n\t\t\treturn new ElementJS((Element) node, document);\n\t\t} else {\n\t\t\treturn new NodeJS(node, document);\n\t\t}\n\t}\n\t\n\t\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tprivate Node node;\n\tprivate DocumentJS documentJS;\n\tpublic NodeJS() {\n\t\tthis.node = null;\n\t\tthis.documentJS = null;\n\t}\n\t\n\tpublic NodeJS(Node node, DocumentJS document) {\n\t\tif(node == null)\n\t\t\tthrow new NullPointerException(\"Node cannot be null\");\n\t\tthis.node = node;\n\t\tthis.documentJS = document;\n\t}\n\n\tprotected void setNode(Node node) {\n\t\tthis.node = node;\n\t}\n\t\n\tprotected void setDocumentJS(DocumentJS document) {\n\t\tthis.documentJS = document;\n\t}\n\t\n\tDocumentJS getDocumentJS() {\n\t\treturn documentJS;\n\t}\n\t\n\tpublic void jsConstructor(Object ob) {\t\t\n\t}\n\t\n\tprotected void exportObject(Scriptable ob) {\n\t\tif(ob == null)\n\t\t\treturn;\n\t\tfinal Scriptable scope = ScriptableObject.getTopLevelScope(this);\n\t\tob.setParentScope(scope);\n\t\tob.setPrototype(ScriptableObject.getClassPrototype(scope, ob.getClassName()));\n\t}\n\t\n\tprotected NodeJS exportNode(Node node) {\n\t\tif(node == null)\n\t\t\treturn null;\n\t\tNodeJS nodeJS = domNodeToJS(node, documentJS);\n\t\texportObject(nodeJS);\n\t\treturn nodeJS;\n\t}\n\t\n\tprotected NodeListJS exportNodeList(NodeList nodeList) {\n\t\tif(nodeList == null)\n\t\t\treturn null;\n\t\tNodeListJS nl = new NodeListJS(nodeList, ScriptableObject.getTopLevelScope(this), documentJS);\n\t\texportObject(nl);\n\t\treturn nl;\n\t}\n\t\n\tprivate Scriptable createNodeArray(Object[] nodes) {\n\t\tfinal Scriptable scope = ScriptableObject.getTopLevelScope(this);\n\t\tfinal Context cx = Context.getCurrentContext();\n\t\tScriptable array =  cx.newArray(scope, nodes);\n\t\texportObject(array);\n\t\treturn array;\n\t}\n\t\n\tpublic Scriptable jsGet_attributes() {\n\t\tfinal NamedNodeMap attributes = node.getAttributes();\n\t\tfinal Object[] nodes = new Object[attributes.getLength()];\n\t\t\n\t\tfor(int i = 0; i < attributes.getLength(); i++)  {\n\t\t\tnodes[i] = exportNode(attributes.item(i));\n\t\t}\t\t\n\t\treturn createNodeArray(nodes);\n\t}\n\t\n\tpublic Scriptable jsGet_childNodes() {\n\t\treturn exportNodeList(node.getChildNodes());\n\t}\n\t\n\tpublic Scriptable jsGet_firstChild() {\n\t\treturn exportNode(node.getFirstChild());\n\t}\n\t\n\tpublic Scriptable jsGet_lastChild() {\n\t\treturn exportNode(node.getLastChild());\n\t}\n\t\n\tpublic String jsGet_localname() {\n\t\treturn node.getLocalName();\n\t}\n\t\n\tpublic String jsGet_namespaceURI() {\n\t\treturn node.getNamespaceURI();\n\t}\n\t\n\tpublic Scriptable jsGet_nextSibling() {\n\t\treturn exportNode(node.getNextSibling());\n\t}\n\t\n\tpublic String jsGet_nodeName() {\n\t\treturn node.getNodeName();\n\t}\n\t\n\tpublic int jsGet_nodeType() {\n\t\treturn node.getNodeType();\n\t}\n\t\n\tpublic String jsGet_nodeValue() {\n\t\treturn node.getNodeValue();\n\t}\n\t\n\t\n\tpublic Scriptable jsGet_ownerDocument() {\n\t\treturn exportNode(node.getOwnerDocument());\n\t}\n\t\n\tpublic Scriptable jsGet_parentNode() {\n\t\treturn exportNode(node.getParentNode());\n\t}\n\t\n\tpublic String jsGet_prefix() {\n\t\treturn node.getPrefix();\n\t}\n\t\n\tpublic Scriptable jsGet_previousSibling() {\n\t\treturn exportNode(node.getPreviousSibling());\n\t}\n\t\n\tpublic Scriptable jsFunction_appendChild(Scriptable newChild) throws DOMException {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsFunction_cloneNode(boolean deep) {\n\t\treturn null;\n\t}\n\t\n\tpublic boolean jsFunction_hasAttributes() {\n\t\treturn node.hasAttributes();\n\t}\n\t\n\tpublic boolean jsFunction_hasChildNodes() {\n\t\treturn node.hasChildNodes();\n\t}\n\t\n\tpublic Scriptable jsFunction_insertBefore(Scriptable newChild, Scriptable refChild)  throws DOMException {\n\t\treturn null;\n\t}\n\t\n\tpublic boolean jsFunction_isSupported(String feature, String version) {\n\t\treturn node.isSupported(feature, version);\n\t}\n\t\n\tpublic void jsFunction_normalize() {\n\t\tnode.normalize();\n\t}\n\t\n\tpublic Scriptable jsFunction_removeChild(Scriptable oldChild) throws DOMException {\n\t\treturn null;\n\t}\n\t\n\tpublic Scriptable jsFunction_replaceChild(Scriptable newChild, Scriptable oldChild) throws DOMException {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Node\";\n\t}\n\t\n\tpublic static void finishInit(Scriptable scope, FunctionObject ctor, Scriptable prototype) {\n\t\tctor.defineProperty(\"ELEMENT_NODE\", Node.ELEMENT_NODE, READONLY);\n\t\tctor.defineProperty(\"ATTRIBUTE_NODE\", Node.ATTRIBUTE_NODE, READONLY);\n\t\tctor.defineProperty(\"TEXT_NODE\", Node.TEXT_NODE, READONLY);\n\t\tctor.defineProperty(\"CDATA_SECTION_NODE\", Node.CDATA_SECTION_NODE, READONLY);\n\t\tctor.defineProperty(\"PROCESSING_INSTRUCTION_NODE\", Node.PROCESSING_INSTRUCTION_NODE, READONLY);\n\t\tctor.defineProperty(\"COMMENT_NODE\", Node.COMMENT_NODE, READONLY);\n\t\tctor.defineProperty(\"DOCUMENT_NODE\", Node.DOCUMENT_NODE, READONLY);\n\t\tctor.defineProperty(\"DOCUMENT_TYPE_NODE\", Node.DOCUMENT_TYPE_NODE, READONLY);\n\t\tctor.defineProperty(\"DOCUMENT_FRAGMENT_NODE\", Node.DOCUMENT_FRAGMENT_NODE, READONLY);\n\t}\n\t\n\tpublic int jsFunction_compareDocumentPosition(Scriptable other) {\n\t\tif(!(other instanceof NodeJS)) {\n\t\t\tthrow Context.reportRuntimeError(\"compareDocumentPosition must be called with a Node argument\");\n\t\t}\n\t\tfinal Node otherNode = ((NodeJS)other).node;\n\t\treturn node.compareDocumentPosition(otherNode);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/NodeListJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.w3c.dom.Node;\nimport org.w3c.dom.NodeList;\n\npublic class NodeListJS extends ScriptableObject {\n\t\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate final List<Scriptable> nodeList = new ArrayList<Scriptable>();\n\t\n\tpublic NodeListJS() {\n\t}\n\t\n\tpublic NodeListJS(NodeList nodeList, Scriptable scope, DocumentJS document) {\n\t\tfor(int i = 0; i < nodeList.getLength(); i++) {\n\t\t\taddNode(nodeList.item(i), scope, document);\n\t\t}\n\t}\n\t\n\tprivate void addNode(Node n, Scriptable scope, DocumentJS document) {\n\t\tScriptable ob = NodeJS.domNodeToJS(n, document);\n\t\tob.setParentScope(scope);\n\t\tob.setPrototype(ScriptableObject.getClassPrototype(scope, ob.getClassName()));\n\t\tnodeList.add(ob);\n\t}\n\t\n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\n\tpublic int jsGet_length() {\n\t\treturn nodeList.size();\n\t}\n\t\n\tpublic Scriptable jsFunction_item(int index) {\n\t\tif(index < 0 || index >= nodeList.size())\n\t\t\treturn null;\n\t\treturn nodeList.get(index);\n\t}\n\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"NodeList\";\n\t}\n\t\n\t@Override\n\tpublic Object get(int index, Scriptable start) {\n\t\tScriptable ob = jsFunction_item(index);\n\t\tif(ob != null)\n\t\t\treturn ob;\n\t\telse\n\t\t\treturn super.get(index, start);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/OptionJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.html2.HTMLOptionElement;\n\npublic class OptionJS extends HTMLElementJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate final HTMLOptionElement optionElement;\n\t\n\tpublic OptionJS() {\n\t\toptionElement = null;\n\t}\n\t\n\tpublic OptionJS(HTMLOptionElement element, DocumentJS document) {\n\t\tsuper(element, document);\n\t\tthis.optionElement = element;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\t@Override \n\tpublic String getClassName() {\n\t\treturn \"Option\";\n\t}\n\t\n\tpublic boolean jsGet_defaultSelected() {\n\t\treturn optionElement.getDefaultSelected();\n\t}\n\t\n\tpublic boolean jsGet_disabled() {\n\t\treturn optionElement.getDisabled();\n\t}\n\n\tpublic Scriptable jsGet_form() {\n\t\treturn exportNode(optionElement.getForm());\n\t}\n\t\n\tpublic int jsGet_index() {\n\t\treturn optionElement.getIndex();\n\t}\n\t\n\tpublic String jsGet_label() {\n\t\treturn optionElement.getLabel();\n\t}\n\t\n\tpublic boolean jsGet_selected() {\n\t\treturn optionElement.getSelected();\n\t}\n\t\n\tpublic String jsGet_text() {\n\t\treturn optionElement.getText();\n\t}\n\t\n\tpublic String jsGet_value() {\n\t\treturn optionElement.getValue();\n\t}\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/SelectJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.html2.HTMLSelectElement;\n\npublic class SelectJS extends HTMLElementJS {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tprivate final HTMLSelectElement selectElement;\n\t\n\tpublic SelectJS() {\n\t\tselectElement = null;\n\t}\n\t\n\tpublic SelectJS(HTMLSelectElement element, DocumentJS document) {\n\t\tsuper(element, document);\n\t\tthis.selectElement = element;\n\t}\n\t\n\t@Override\n\tpublic void jsConstructor(Object ob) {\n\t\t\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Select\";\n\t}\n\t\n\tpublic Scriptable jsGet_form() {\n\t\treturn exportNode(selectElement.getForm());\n\t}\n\t\n\tpublic int jsGet_length() {\n\t\treturn selectElement.getLength();\n\t}\n\t\n\tpublic Object jsGet_options() {\n\t\treturn null;\n\t}\n\t\n\tpublic int jsGet_selectedIndex() {\n\t\treturn selectElement.getSelectedIndex();\n\t}\n\t\n\tpublic String jsGet_type() {\n\t\treturn selectElement.getType();\n\t}\n\t\n\tpublic boolean jsGet_disabled() {\n\t\treturn selectElement.getDisabled();\n\t}\n\t\n\tpublic boolean jsGet_multiple() {\n\t\treturn selectElement.getMultiple();\n\t}\n\t\n\tpublic String jsGet_name() {\n\t\treturn selectElement.getName();\n\t}\n\t\n\tpublic int jsGet_size() {\n\t\treturn selectElement.getSize();\n\t}\n\t\n\tpublic int jsGet_tabIndex() {\n\t\treturn selectElement.getTabIndex();\n\t}\n\t\n\tpublic void jsFunction_add(Scriptable element, Scriptable before) {\n\t\t\n\t}\n\t\n\tpublic void jsFunction_blur() {\n\t\t\n\t}\n\tpublic void jsFunction_focus() {\n\t\t\n\t}\n\t\n\tpublic Scriptable jsGet_onchange() {\n\t\treturn null;\n\t}\n\t\n\tpublic void jsFunction_remove(int index) {\n\t\tselectElement.remove(index);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/dom/TextJS.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.dom;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.w3c.dom.DOMException;\nimport org.w3c.dom.Text;\n\npublic class TextJS extends CharacterDataJS {\n\t\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate final Text textNode;\n\t\n\tpublic TextJS() {\n\t\tthis.textNode = null;\n\t}\n\t\n\tpublic TextJS(Text textNode, DocumentJS document) {\n\t\tsuper(textNode, document);\n\t\tthis.textNode = textNode;\n\t}\n\t\n\tpublic void jsConstructor(Object ob) {\n\t}\n\t\n\t@Override\n\tpublic String getClassName() {\n\t\treturn \"Text\";\n\t}\n\n\tpublic Scriptable jsFunction_splitText(int offset) throws DOMException {\n\t\treturn exportNode(textNode.splitText(offset));\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/tests/DomTestModule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.tests;\n\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.io.StringWriter;\nimport java.net.URL;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.Scriptable;\nimport org.osgi.framework.Bundle;\n\nimport com.subgraph.vega.api.html.IHTMLParseResult;\nimport com.subgraph.vega.api.html.IHTMLParser;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.impl.scanner.modules.scripting.AbstractScriptModule;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptedModule;\n\npublic class DomTestModule extends AbstractScriptModule {\n\n\tprivate final Bundle bundle;\n\tprivate final ScriptedModule testScript;\n\tprivate final IHTMLParser htmlParser;\n\t\n\tpublic DomTestModule(ScriptedModule module, Bundle bundle, IHTMLParser parser) {\n\t\tsuper(module);\n\t\ttestScript = module;\n\t\tthis.bundle = bundle;\n\t\tthis.htmlParser = parser;\n\t}\n\t\n\tpublic void run(IWorkspace workspace) throws IOException {\n\t\tString html = lookupModuleString(\"html\");\n\t\tIHTMLParseResult parseResult = loadHTML(html);\n\t\tfinal List<ExportedObject> exports = new ArrayList<ExportedObject>();\n\t\texport(exports, \"testDom\", parseResult.getDOMDocument());\n\t\texport(exports, \"workspace\", workspace);\n\t\trunScript(exports, \"domtest\");\n\t\t\n\t}\n\n\tprivate String lookupModuleString(String name) {\n\t\tScriptable moduleObject = getModuleObject();\n\t\tObject ob = moduleObject.get(name, testScript.getModuleScope());\n\t\tif(ob == Scriptable.NOT_FOUND) {\n\t\t\tthrow new IllegalArgumentException(\"Could not find \"+ name);\n\t\t}\n\t\tif(!(ob instanceof String)) {\n\t\t\tthrow new IllegalArgumentException(\"Property \"+ name +\" is not a string\");\n\t\t}\n\t\treturn (String) ob;\n\t\t\n\t}\n\t\n\tprivate Scriptable getModuleObject() {\n\t\tfinal Scriptable scope = testScript.getModuleScope();\n\t\tfinal Object ob = scope.get(\"module\", scope);\n\t\tif(ob == Scriptable.NOT_FOUND) \n\t\t\tthrow new IllegalArgumentException();\n\t\treturn Context.toObject(ob, scope);\n\t}\n\t\n\tIHTMLParseResult loadHTML(String name) throws IOException {\n\t\tURL url = bundle.getEntry(\"/tests/html/\"+ name);\n\t\tif(url == null)\n\t\t\tthrow new FileNotFoundException(\"Could not locate test html file /data/test/\"+ name);\n\t\tfinal InputStream input = url.openStream();\n\t\tfinal String html = streamToString(input);\n\t\treturn htmlParser.parseString(html, null);\n\t}\n\t\n\tString streamToString(InputStream input) throws IOException {\n\t\tReader r = new InputStreamReader(input);\n\t\tStringWriter sw = new StringWriter();\n\t\tchar[] buffer = new char[2048];\n\t\t\n\t\twhile(true) {\n\t\t\tint n = r.read(buffer);\n\t\t\tif(n == -1) {\n\t\t\t\treturn sw.toString();\n\t\t\t}\n\t\t\tsw.write(buffer, 0, n);\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isDifferential() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean isTimeSensitive() {\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/tests/QunitLoader.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.tests;\n\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.lang.reflect.InvocationTargetException;\nimport java.net.URL;\nimport java.util.logging.Logger;\n\nimport org.mozilla.javascript.Context;\nimport org.mozilla.javascript.RhinoException;\nimport org.mozilla.javascript.Scriptable;\nimport org.mozilla.javascript.ScriptableObject;\nimport org.osgi.framework.Bundle;\n\nimport com.subgraph.vega.impl.scanner.modules.scripting.RhinoExceptionFormatter;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptCompiler;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.AnchorJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.AttrJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.CharacterDataJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.CommentJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.DocumentJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.ElementJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.FormJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.HTMLCollectionJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.HTMLDocumentJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.InputJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.LinkJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.NodeJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.NodeListJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.OptionJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.SelectJS;\nimport com.subgraph.vega.impl.scanner.modules.scripting.dom.TextJS;\n\npublic class QunitLoader {\n\tprivate final static String QUNIT_PATH = \"/tests/qunit/qunit.js\";\n\tprivate final Logger logger = Logger.getLogger(\"qunit-loader\");\n\tprivate final ScriptCompiler qunitCompiler;\n \tprivate final Bundle bundle;\n\t\n\tprivate Scriptable qunitScope;\n\t\n\tQunitLoader(Scriptable globalScope, Bundle bundle) {\n\t\tthis.qunitCompiler = new ScriptCompiler(globalScope);\n\t\tthis.bundle = bundle;\n\t}\n\t\n\tvoid load() {\n\t\ttry {\n\t\t\tContext cx = Context.enter();\n\t\t\tScriptable scope = qunitCompiler.newScope(cx);\n\t\t\tqunitCompiler.compileReader(openQunit(QUNIT_PATH), QUNIT_PATH, cx, scope);\n\t\t\tScriptableObject.defineClass(scope, NodeJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, DocumentJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, ElementJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, AttrJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, CharacterDataJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, TextJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, AnchorJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, FormJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, CommentJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, HTMLCollectionJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, HTMLDocumentJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, InputJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, LinkJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, OptionJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, SelectJS.class, true, true);\n\t\t\tScriptableObject.defineClass(scope, NodeListJS.class, true, true);\n\t\t\tqunitScope = scope;\t\t\t\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch(RhinoException e) {\n\t\t\tlogger.warning(new RhinoExceptionFormatter(\"Failed to compile module prelude script.\", e).toString());\n\t\t} catch (IllegalAccessException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (InstantiationException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (InvocationTargetException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\tContext.exit();\n\t\t}\n\t\t\n\t}\n\n\tprivate Reader openQunit(String path) throws IOException {\n\t\tfinal URL url = bundle.getEntry(path);\n\t\tif(url == null)\n\t\t\tthrow new FileNotFoundException(\"Could not locate qunit library at \"+ path);\n\t\tfinal InputStream input = url.openStream();\n\t\treturn new InputStreamReader(input);\n\t}\n\t\n\tScriptable getScope() {\n\t\treturn qunitScope;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/src/com/subgraph/vega/impl/scanner/modules/scripting/tests/TestScriptLoader.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.impl.scanner.modules.scripting.tests;\n\nimport java.net.URL;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Enumeration;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport org.mozilla.javascript.Scriptable;\nimport org.osgi.framework.Bundle;\n\nimport com.subgraph.vega.impl.scanner.modules.scripting.ModuleValidator;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ModuleValidator.ModuleValidationException;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptCompiler;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptFile;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptFile.CompileStatus;\nimport com.subgraph.vega.impl.scanner.modules.scripting.ScriptedModule;\n\npublic class TestScriptLoader {\n\tprivate final Logger logger = Logger.getLogger(\"script-loader\");\n\tprivate final QunitLoader qunitLoader;\n\tprivate final ScriptCompiler moduleCompiler;\n\tprivate final Bundle bundle;\n\tprivate final List<ScriptedModule> allModules = new ArrayList<ScriptedModule>();\n\t\n\t\n\tpublic TestScriptLoader(Scriptable globalScope, Bundle bundle) {\n\t\tthis.bundle = bundle;\n\t\tqunitLoader = new QunitLoader(globalScope, bundle);\n\t\tqunitLoader.load();\n\t\tmoduleCompiler = new ScriptCompiler(qunitLoader.getScope());\n\t}\n\t\n\tpublic void load() {\n\t\tallModules.clear();\n\t\tfor(URL scriptURL: allTestScripts()) {\n\t\t\tScriptedModule compiledModule = compileModule(new ScriptFile(scriptURL));\n\t\t\tif(compiledModule != null && !compiledModule.isDisabled())\n\t\t\t\tallModules.add(compiledModule);\n\t\t}\n\t}\n\t\n\tpublic List<ScriptedModule> getAllModules() {\n\t\treturn Collections.unmodifiableList(allModules);\n\t}\n\t\n\tprivate ScriptedModule compileModule(ScriptFile scriptFile) {\t\n\t\tif(!moduleCompiler.compile(scriptFile) || scriptFile.getCompileStatus() != CompileStatus.COMPILE_SUCCEEDED) {\n\t\t\tlogger.warning(scriptFile.getCompileFailureMessage());\n\t\t\treturn null;\n\t\t}\n\t\t\t\n\t\tfinal ModuleValidator validator = validateModule(scriptFile.getCompiledScript(), scriptFile.getPath());\n\t\tif(validator == null)\n\t\t\treturn null;\n\t\t\t\n\t\treturn new ScriptedModule(scriptFile, \"Test Modules\", validator);\n\t}\n\t\n\tprivate ModuleValidator validateModule(Scriptable module, String modulePath) {\n\t\tfinal ModuleValidator validator = new ModuleValidator(module);\n\t\ttry {\n\t\t\tvalidator.validate();\n\t\t\treturn validator;\n\t\t} catch (ModuleValidationException e) {\n\t\t\tlogger.warning(\"Failed to validate test module \"+ modulePath +\" :\"+ e.getMessage());\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate List<URL> allTestScripts() {\n\t\tList<URL> scriptURLs = new ArrayList<URL>();\n\t\tEnumeration<?> entries = bundle.findEntries(\"/tests/scripts\", \"*\", true);\n\t\twhile(entries.hasMoreElements()) {\n\t\t\tURL u = (URL) entries.nextElement();\n\t\t\tscriptURLs.add(u);\n\t\t}\n\t\treturn scriptURLs;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/tests/html/jquery-test.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\" dir=\"ltr\" id=\"html\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\t<title>jQuery Test Suite</title>\n\t<link rel=\"Stylesheet\" media=\"screen\" href=\"qunit/qunit/qunit.css\" />\n\t<link rel=\"Stylesheet\" media=\"screen\" href=\"data/testsuite.css\" />\n\t<!-- Includes -->\n\t<script src=\"data/testinit.js\"></script>\n\n\t<script src=\"../src/core.js\"></script>\n\t<script src=\"../src/support.js\"></script>\n\t<script src=\"../src/data.js\"></script>\n\t<script src=\"../src/queue.js\"></script>\n\t<script src=\"../src/attributes.js\"></script>\n\t<script src=\"../src/event.js\"></script>\n\t<script src=\"../src/sizzle/sizzle.js\"></script>\n\t<script src=\"../src/sizzle-jquery.js\"></script>\n\t<script src=\"../src/traversing.js\"></script>\n\t<script src=\"../src/manipulation.js\"></script>\n\t<script src=\"../src/css.js\"></script>\n\t<script src=\"../src/ajax.js\"></script>\n\t<script src=\"../src/effects.js\"></script>\n\t<script src=\"../src/offset.js\"></script>\n\t<script src=\"../src/dimensions.js\"></script>\n\n\t<script src=\"qunit/qunit/qunit.js\"></script>\n\t<script src=\"data/testrunner.js\"></script>\n\n\t<script src=\"unit/core.js\"></script>\n\t<script src=\"unit/data.js\"></script>\n\t<script src=\"unit/queue.js\"></script>\n\t<script src=\"unit/attributes.js\"></script>\n\t<script src=\"unit/event.js\"></script>\n\t<script src=\"unit/selector.js\"></script>\n\t<script src=\"unit/traversing.js\"></script>\n\t<script src=\"unit/manipulation.js\"></script>\n\t<script src=\"unit/css.js\"></script>\n\t<script src=\"unit/ajax.js\"></script>\n\t<script src=\"unit/effects.js\"></script>\n\t<script src=\"unit/offset.js\"></script>\n\t<script src=\"unit/dimensions.js\"></script>\n</head>\n\n<body id=\"body\">\n\t<h1 id=\"qunit-header\">jQuery Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\n\t<!-- Test HTML -->\n\t<div id=\"nothiddendiv\" style=\"height:1px;background:white;\" class=\"nothiddendiv\">\n\t\t<div id=\"nothiddendivchild\"></div>\n\t</div>\n\t<!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be \"safe\" and clean up after themselves -->\n\t<iframe id=\"loadediframe\" name=\"loadediframe\" style=\"display:none;\" src=\"data/iframe.html\"></iframe>\n\t<dl id=\"dl\" style=\"position:absolute;top:-32767px;left:-32767px;\">\n\t<div id=\"main\">\n\t\t<p id=\"firstp\">See <a id=\"simon1\" href=\"http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector\" rel=\"bookmark\">this blog entry</a> for more information.</p>\n\t\t<p id=\"ap\">\n\t\t\tHere are some links in a normal paragraph: <a id=\"google\" href=\"http://www.google.com/\" title=\"Google!\">Google</a>,\n\t\t\t<a id=\"groups\" href=\"http://groups.google.com/\" class=\"GROUPS\">Google Groups (Link)</a>.\n\t\t\tThis link has <code><a href=\"http://smin\" id=\"anchor1\">class=\"blog\"</a></code>:\n\t\t\t<a href=\"http://diveintomark.org/\" class=\"blog\" hreflang=\"en\" id=\"mark\">diveintomark</a>\n\n\t\t</p>\n\t\t<div id=\"foo\">\n\t\t\t<p id=\"sndp\">Everything inside the red border is inside a div with <code>id=\"foo\"</code>.</p>\n\t\t\t<p lang=\"en\" id=\"en\">This is a normal link: <a id=\"yahoo\" href=\"http://www.yahoo.com/\" class=\"blogTest\">Yahoo</a></p>\n\t\t\t<p id=\"sap\">This link has <code><a href=\"#2\" id=\"anchor2\">class=\"blog\"</a></code>: <a href=\"http://simon.incutio.com/\" class=\"blog link\" id=\"simon\">Simon Willison's Weblog</a></p>\n\n\t\t</div>\n\t\t<span id=\"name+value\"></span>\n\t\t<p id=\"first\">Try them out:</p>\n\t\t<ul id=\"firstUL\"></ul>\n\t\t<ol id=\"empty\"></ol>\n\t\t<form id=\"form\" action=\"formaction\">\n\t\t\t<label for=\"action\" id=\"label-for\">Action:</label>\n\t\t\t<input type=\"text\" name=\"action\" value=\"Test\" id=\"text1\" maxlength=\"30\"/>\n\t\t\t<input type=\"text\" name=\"text2\" value=\"Test\" id=\"text2\" disabled=\"disabled\"/>\n\t\t\t<input type=\"radio\" name=\"radio1\" id=\"radio1\" value=\"on\"/>\n\n\t\t\t<input type=\"radio\" name=\"radio2\" id=\"radio2\" checked=\"checked\"/>\n\t\t\t<input type=\"checkbox\" name=\"check\" id=\"check1\" checked=\"checked\"/>\n\t\t\t<input type=\"checkbox\" id=\"check2\" value=\"on\"/>\n\n\t\t\t<input type=\"hidden\" name=\"hidden\" id=\"hidden1\"/>\n\t\t\t<input type=\"text\" style=\"display:none;\" name=\"foo[bar]\" id=\"hidden2\"/>\n\n\t\t\t<input type=\"text\" id=\"name\" name=\"name\" value=\"name\" />\n\t\t\t<input type=\"search\" id=\"search\" name=\"search\" value=\"search\" />\n\n\t\t\t<button id=\"button\" name=\"button\" type=\"button\">Button</button>\n\n\t\t\t<textarea id=\"area1\" maxlength=\"30\">foobar</textarea>\n\n\t\t\t<select name=\"select1\" id=\"select1\">\n\t\t\t\t<option id=\"option1a\" class=\"emptyopt\" value=\"\">Nothing</option>\n\t\t\t\t<option id=\"option1b\" value=\"1\">1</option>\n\t\t\t\t<option id=\"option1c\" value=\"2\">2</option>\n\t\t\t\t<option id=\"option1d\" value=\"3\">3</option>\n\t\t\t</select>\n\t\t\t<select name=\"select2\" id=\"select2\">\n\t\t\t\t<option id=\"option2a\" class=\"emptyopt\" value=\"\">Nothing</option>\n\t\t\t\t<option id=\"option2b\" value=\"1\">1</option>\n\t\t\t\t<option id=\"option2c\" value=\"2\">2</option>\n\t\t\t\t<option id=\"option2d\" selected=\"selected\" value=\"3\">3</option>\n\t\t\t</select>\n\t\t\t<select name=\"select3\" id=\"select3\" multiple=\"multiple\">\n\t\t\t\t<option id=\"option3a\" class=\"emptyopt\" value=\"\">Nothing</option>\n\t\t\t\t<option id=\"option3b\" selected=\"selected\" value=\"1\">1</option>\n\t\t\t\t<option id=\"option3c\" selected=\"selected\" value=\"2\">2</option>\n\t\t\t\t<option id=\"option3d\" value=\"3\">3</option>\n\t\t\t\t<option id=\"option3e\">no value</option>\n\t\t\t</select>\n\t\t\t<select name=\"select4\" id=\"select4\" multiple=\"multiple\">\n\t\t\t\t<optgroup disabled=\"disabled\">\n\t\t\t\t\t<option id=\"option4a\" class=\"emptyopt\" value=\"\">Nothing</option>\n\t\t\t\t\t<option id=\"option4b\" disabled=\"disabled\" selected=\"selected\" value=\"1\">1</option>\n\t\t\t\t\t<option id=\"option4c\" selected=\"selected\" value=\"2\">2</option>\n\t\t\t\t</optgroup>\n\t\t\t\t<option selected=\"selected\" disabled=\"disabled\" id=\"option4d\" value=\"3\">3</option>\n\t\t\t\t<option id=\"option4e\">no value</option>\n\t\t\t</select>\n\t\t\t<select name=\"select5\" id=\"select5\">\n\t\t\t\t<option id=\"option5a\" value=\"3\">1</option>\n\t\t\t\t<option id=\"option5b\" value=\"2\">2</option>\n\t\t\t\t<option id=\"option5c\" value=\"1\">3</option>\n\t\t\t</select>\n\n\t\t\t<object id=\"object1\" codebase=\"stupid\">\n\t\t\t\t<param name=\"p1\" value=\"x1\" />\n\t\t\t\t<param name=\"p2\" value=\"x2\" />\n\t\t\t</object>\n\n\t\t\t<span id=\"台北Táiběi\"></span>\n\t\t\t<span id=\"台北\" lang=\"中文\"></span>\n\t\t\t<span id=\"utf8class1\" class=\"台北Táiběi 台北\"></span>\n\t\t\t<span id=\"utf8class2\" class=\"台北\"></span>\n\t\t\t<span id=\"foo:bar\" class=\"foo:bar\"></span>\n\t\t\t<span id=\"test.foo[5]bar\" class=\"test.foo[5]bar\"></span>\n\n\t\t\t<foo_bar id=\"foobar\">test element</foo_bar>\n\t\t</form>\n\t\t<b id=\"floatTest\">Float test.</b>\n\t\t<iframe id=\"iframe\" name=\"iframe\"></iframe>\n\t\t<form id=\"lengthtest\">\n\t\t\t<input type=\"text\" id=\"length\" name=\"test\"/>\n\t\t\t<input type=\"text\" id=\"idTest\" name=\"id\"/>\n\t\t</form>\n\t\t<table id=\"table\"></table>\n\n\t\t<form id=\"name-tests\">\n\t\t\t<!-- Inputs with a grouped name attribute. -->\n\t\t\t<input name=\"types[]\" id=\"types_all\" type=\"checkbox\" value=\"all\" />\n\t\t\t<input name=\"types[]\" id=\"types_anime\" type=\"checkbox\" value=\"anime\" />\n\t\t\t<input name=\"types[]\" id=\"types_movie\" type=\"checkbox\" value=\"movie\" />\n\t\t</form>\n\n\t\t<form id=\"testForm\" action=\"#\" method=\"get\">\n\t\t\t<textarea name=\"T3\" rows=\"2\" cols=\"15\">?\nZ</textarea>\n\t\t\t<input type=\"hidden\" name=\"H1\" value=\"x\" />\n\t\t\t<input type=\"hidden\" name=\"H2\" />\n\t\t\t<input name=\"PWD\" type=\"password\" value=\"\" />\n\t\t\t<input name=\"T1\" type=\"text\" />\n\t\t\t<input name=\"T2\" type=\"text\" value=\"YES\" readonly=\"readonly\" />\n\t\t\t<input type=\"checkbox\" name=\"C1\" value=\"1\" />\n\t\t\t<input type=\"checkbox\" name=\"C2\" />\n\t\t\t<input type=\"radio\" name=\"R1\" value=\"1\" />\n\t\t\t<input type=\"radio\" name=\"R1\" value=\"2\" />\n\t\t\t<input type=\"text\" name=\"My Name\" value=\"me\" />\n\t\t\t<input type=\"reset\" name=\"reset\" value=\"NO\" />\n\t\t\t<select name=\"S1\">\n\t\t\t\t<option value=\"abc\">ABC</option>\n\t\t\t\t<option value=\"abc\">ABC</option>\n\t\t\t\t<option value=\"abc\">ABC</option>\n\t\t\t</select>\n\t\t\t<select name=\"S2\" multiple=\"multiple\" size=\"3\">\n\t\t\t\t<option value=\"abc\">ABC</option>\n\t\t\t\t<option value=\"abc\">ABC</option>\n\t\t\t\t<option value=\"abc\">ABC</option>\n\t\t\t</select>\n\t\t\t<select name=\"S3\">\n\t\t\t\t<option selected=\"selected\">YES</option>\n\t\t\t</select>\n\t\t\t<select name=\"S4\">\n\t\t\t\t<option value=\"\" selected=\"selected\">NO</option>\n\t\t\t</select>\n\t\t\t<input type=\"submit\" name=\"sub1\" value=\"NO\" />\n\t\t\t<input type=\"submit\" name=\"sub2\" value=\"NO\" />\n\t\t\t<input type=\"image\" name=\"sub3\" value=\"NO\" />\n\t\t\t<button name=\"sub4\" type=\"submit\" value=\"NO\">NO</button>\n\t\t\t<input name=\"D1\" type=\"text\" value=\"NO\" disabled=\"disabled\" />\n\t\t\t<input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\" name=\"D2\" value=\"NO\" />\n\t\t\t<input type=\"radio\" name=\"D3\" value=\"NO\" checked=\"checked\" disabled=\"disabled\" />\n\t\t\t<select name=\"D4\" disabled=\"disabled\">\n\t\t\t\t<option selected=\"selected\" value=\"NO\">NO</option>\n\t\t\t</select>\n\t\t</form>\n\t\t<div id=\"moretests\">\n\t\t\t<form>\n\t\t\t\t<div id=\"checkedtest\" style=\"display:none;\">\n\t\t\t\t\t<input type=\"radio\" name=\"checkedtestradios\" checked=\"checked\"/>\n\t\t\t\t\t<input type=\"radio\" name=\"checkedtestradios\" value=\"on\"/>\n\t\t\t\t\t<input type=\"checkbox\" name=\"checkedtestcheckboxes\" checked=\"checked\"/>\n\t\t\t\t\t<input type=\"checkbox\" name=\"checkedtestcheckboxes\" />\n\t\t\t\t</div>\n\t\t\t</form>\n\t\t\t<div id=\"nonnodes\"><span>hi</span> there <!-- mon ami --></div>\n\t\t\t<div id=\"t2037\">\n\t\t\t\t<div><div class=\"hidden\">hidden</div></div>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div id=\"tabindex-tests\">\n\t\t\t<ol id=\"listWithTabIndex\" tabindex=\"5\">\n\t\t\t\t<li id=\"foodWithNegativeTabIndex\" tabindex=\"-1\">Rice</li>\n\t\t\t\t<li id=\"foodNoTabIndex\">Beans</li>\n\t\t\t\t<li>Blinis</li>\n\t\t\t\t<li>Tofu</li>\n\t\t\t</ol>\n\n\t\t\t<div id=\"divWithNoTabIndex\">I'm hungry. I should...</div>\n\t\t\t<span>...</span><a href=\"#\" id=\"linkWithNoTabIndex\">Eat lots of food</a><span>...</span> |\n\t\t\t<span>...</span><a href=\"#\" id=\"linkWithTabIndex\" tabindex=\"2\">Eat a little food</a><span>...</span> |\n\t\t\t<span>...</span><a href=\"#\" id=\"linkWithNegativeTabIndex\" tabindex=\"-1\">Eat no food</a><span>...</span>\n\t\t\t<span>...</span><a id=\"linkWithNoHrefWithNoTabIndex\">Eat a burger</a><span>...</span>\n\t\t\t<span>...</span><a id=\"linkWithNoHrefWithTabIndex\" tabindex=\"1\">Eat some funyuns</a><span>...</span>\n\t\t\t<span>...</span><a id=\"linkWithNoHrefWithNegativeTabIndex\" tabindex=\"-1\">Eat some funyuns</a><span>...</span>\n\t\t</div>\n\n\t\t<div id=\"liveHandlerOrder\">\n\t\t\t<span id=\"liveSpan1\"><a href=\"#\" id=\"liveLink1\"></a></span>\n\t\t\t<span id=\"liveSpan2\"><a href=\"#\" id=\"liveLink2\"></a></span>\n\t\t</div>\n\n\t\t<div id=\"siblingTest\">\n\t\t\t<em id=\"siblingfirst\">1</em>\n\t\t\t<em id=\"siblingnext\">2</em>\n\t\t</div>\n\t</div>\n\t</dl>\n\t<div id=\"fx-test-group\" style=\"position:absolute;width:1px;height:1px;overflow:hidden;\">\n\t\t<div id=\"fx-queue\" name=\"test\">\n\t\t\t<div id=\"fadein\" class='chain test' name='div'>fadeIn<div>fadeIn</div></div>\n\t\t\t<div id=\"fadeout\" class='chain test out'>fadeOut<div>fadeOut</div></div>\n\n\t\t\t<div id=\"show\" class='chain test'>show<div>show</div></div>\n\t\t\t<div id=\"hide\" class='chain test out'>hide<div>hide</div></div>\n\n\t\t\t<div id=\"togglein\" class='chain test'>togglein<div>togglein</div></div>\n\t\t\t<div id=\"toggleout\" class='chain test out'>toggleout<div>toggleout</div></div>\n\n\n\t\t\t<div id=\"slideup\" class='chain test'>slideUp<div>slideUp</div></div>\n\t\t\t<div id=\"slidedown\" class='chain test out'>slideDown<div>slideDown</div></div>\n\n\t\t\t<div id=\"slidetogglein\" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>\n\t\t\t<div id=\"slidetoggleout\" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>\n\n\t\t\t<div id=\"fadeto\" class='chain test'>fadeTo<div>fadeTo</div></div>\n\t\t</div>\n\n\t\t<div id=\"fx-tests\"></div>\n\t</div>\n</body>\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/tests/qunit/qunit.js",
    "content": "\nfunction push(result, actual, expected, message) {\n\tmessage = message || (result ? \"okay\" : \"failed\");\n\t\n\texpected = QUnit.jsDump.parse(expected);\n\tactual = QUnit.jsDump.parse(actual);\n\tvar output = message; + ', expected: ' + expected;\n\tif (actual != expected) {\n\t\tresult = false;\n\t\toutput += \"\\nexpected: \"+ expected;\n\t\toutput += \"\\nresult:   \" + actual + '\\ndiff:    ' + QUnit.diff(expected, actual);\n\t} else {\n\t\t output += ', expected: ' + expected;\n\t}\n\tlog(result, output);\n}\n\nvar total = 0;\nvar passed = 0;\nvar failed = 0;\n\nvar log = function (a, msg) {\n\t\n\tvar status = \".\";\n\tif(a) {\n\t\tstatus = \"[PASSED]\";\n\t\tpassed += 1;\n\t}\n\telse {\n\t\tstatus = \"[FAILED]\";\n\t\tfailed += 1;\n\t}\n\ttotal += 1;\n\t\n\tprint(status + \" : \"+ msg);\n};\n\nvar summary = function() {\n\tprint(\"Total tests: \"+ total);\n\tprint(\"Passed: \" + passed);\n\tprint(\"Failed: \"+ failed);\n};\n/**\n * Asserts true.\n * @example ok( \"asdfasdf\".length > 5, \"There must be at least 5 chars\" );\n */\n\nvar ok = function(a, msg) {\n\tlog(a, msg);\n\t};\n\n\t/**\n\t * Checks that the first two arguments are equal, with an optional message.\n\t * Prints out both actual and expected values.\n\t *\n\t * Prefered to ok( actual == expected, message )\n\t *\n\t * @example equal( format(\"Received {0} bytes.\", 2), \"Received 2 bytes.\" );\n\t *\n\t * @param Object actual\n\t * @param Object expected\n\t * @param String message (optional)\n\t */\nvar equal = function(actual, expected, message) {\n\t\tpush(expected == actual, actual, expected, message);\n};\n\nvar\tnotEqual = function(actual, expected, message) {\n\t\tpush(expected != actual, actual, expected, message);\n};\n;\n\t\nvar\tdeepEqual= function(actual, expected, message) {\n\t\tpush(QUnit.equiv(actual, expected), actual, expected, message);\n\t};\n\nvar\tnotDeepEqual = function(actual, expected, message) {\n\t\tpush(!QUnit.equiv(actual, expected), actual, expected, message);\n\t};\n\nvar\tstrictEqual = function(actual, expected, message) {\n\t\tpush(expected === actual, actual, expected, message);\n\t};\n\n\nvar\tnotStrictEqual= function(actual, expected, message) {\n\t\tpush(expected !== actual, actual, expected, message);\n\t};\n\nvar\traises = function(fn,  message) {\n\t\ttry {\n\t\t\tfn();\n\t\t\tok( false, message );\n\t\t}\n\t\tcatch (e) {\n\t\t\tok( true, message );\n\t\t}\n\t};\nvar equals = equal;\nvar same = deepEqual;\n\n\n\n\n\n\n\n\n\n\n\n\nfunction validTest( name ) {\n\tvar i = config.filters.length,\n\t\trun = false;\n\n\tif ( !i ) {\n\t\treturn true;\n\t}\n\t\n\twhile ( i-- ) {\n\t\tvar filter = config.filters[i],\n\t\t\tnot = filter.charAt(0) == '!';\n\n\t\tif ( not ) {\n\t\t\tfilter = filter.slice(1);\n\t\t}\n\n\t\tif ( name.indexOf(filter) !== -1 ) {\n\t\t\treturn !not;\n\t\t}\n\n\t\tif ( not ) {\n\t\t\trun = true;\n\t\t}\n\t}\n\n\treturn run;\n}\n\n\n\n// returns a new Array with the elements that are in a but not in b\nfunction diff( a, b ) {\n\tvar result = a.slice();\n\tfor ( var i = 0; i < result.length; i++ ) {\n\t\tfor ( var j = 0; j < b.length; j++ ) {\n\t\t\tif ( result[i] === b[j] ) {\n\t\t\t\tresult.splice(i, 1);\n\t\t\t\ti--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction fail(message, exception, callback) {\n\tif ( typeof console !== \"undefined\" && console.error && console.warn ) {\n\t\tconsole.error(message);\n\t\tconsole.error(exception);\n\t\tconsole.warn(callback.toString());\n\n\t} else if ( window.opera && opera.postError ) {\n\t\topera.postError(message, exception, callback.toString);\n\t}\n}\n\nfunction extend(a, b) {\n\tfor ( var prop in b ) {\n\t\ta[prop] = b[prop];\n\t}\n\n\treturn a;\n}\n\n\n\nfunction id(name) {\n\treturn !!(typeof document !== \"undefined\" && document && document.getElementById) &&\n\t\tdocument.getElementById( name );\n}\n\nQUnit = {};\n\n\nQUnit.is = function( type, obj ) {\n\treturn QUnit.objectType( obj ) == type;\n},\n\nQUnit.objectType = function( obj ) {\n\tif (typeof obj === \"undefined\") {\n\t\t\treturn \"undefined\";\n\n\t// consider: typeof null === object\n\t}\n\tif (obj === null) {\n\t\t\treturn \"null\";\n\t}\n\n\tvar type = Object.prototype.toString.call( obj )\n\t\t.match(/^\\[object\\s(.*)\\]$/)[1] || '';\n\n\tswitch (type) {\n\t\t\tcase 'Number':\n\t\t\t\t\tif (isNaN(obj)) {\n\t\t\t\t\t\t\treturn \"nan\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn \"number\";\n\t\t\t\t\t}\n\t\t\tcase 'String':\n\t\t\tcase 'Boolean':\n\t\t\tcase 'Array':\n\t\t\tcase 'Date':\n\t\t\tcase 'RegExp':\n\t\t\tcase 'Function':\n\t\t\t\t\treturn type.toLowerCase();\n\t}\n\tif (typeof obj === \"object\") {\n\t\t\treturn \"object\";\n\t}\n\treturn undefined;\n},\n\n// Test for equality any JavaScript type.\n// Discussions and reference: http://philrathe.com/articles/equiv\n// Test suites: http://philrathe.com/tests/equiv\n// Author: Philippe Rathé <prathe@gmail.com>\nQUnit.equiv = function () {\n\n    var innerEquiv; // the real equiv function\n    var callers = []; // stack to decide between skip/abort functions\n    var parents = []; // stack to avoiding loops from circular referencing\n\n    // Call the o related callback with the given arguments.\n    function bindCallbacks(o, callbacks, args) {\n        var prop = QUnit.objectType(o);\n        if (prop) {\n            if (QUnit.objectType(callbacks[prop]) === \"function\") {\n                return callbacks[prop].apply(callbacks, args);\n            } else {\n                return callbacks[prop]; // or undefined\n            }\n        }\n    }\n    \n    var callbacks = function () {\n\n        // for string, boolean, number and null\n        function useStrictEquality(b, a) {\n            if (b instanceof a.constructor || a instanceof b.constructor) {\n                // to catch short annotaion VS 'new' annotation of a declaration\n                // e.g. var i = 1;\n                //      var j = new Number(1);\n                return a == b;\n            } else {\n                return a === b;\n            }\n        }\n\n        return {\n            \"string\": useStrictEquality,\n            \"boolean\": useStrictEquality,\n            \"number\": useStrictEquality,\n            \"null\": useStrictEquality,\n            \"undefined\": useStrictEquality,\n\n            \"nan\": function (b) {\n                return isNaN(b);\n            },\n\n            \"date\": function (b, a) {\n                return QUnit.objectType(b) === \"date\" && a.valueOf() === b.valueOf();\n            },\n\n            \"regexp\": function (b, a) {\n                return QUnit.objectType(b) === \"regexp\" &&\n                    a.source === b.source && // the regex itself\n                    a.global === b.global && // and its modifers (gmi) ...\n                    a.ignoreCase === b.ignoreCase &&\n                    a.multiline === b.multiline;\n            },\n\n            // - skip when the property is a method of an instance (OOP)\n            // - abort otherwise,\n            //   initial === would have catch identical references anyway\n            \"function\": function () {\n                var caller = callers[callers.length - 1];\n                return caller !== Object &&\n                        typeof caller !== \"undefined\";\n            },\n\n            \"array\": function (b, a) {\n                var i, j, loop;\n                var len;\n\n                // b could be an object literal here\n                if ( ! (QUnit.objectType(b) === \"array\")) {\n                    return false;\n                }   \n                \n                len = a.length;\n                if (len !== b.length) { // safe and faster\n                    return false;\n                }\n                \n                //track reference to avoid circular references\n                parents.push(a);\n                for (i = 0; i < len; i++) {\n                    loop = false;\n                    for(j=0;j<parents.length;j++){\n                        if(parents[j] === a[i]){\n                            loop = true;//dont rewalk array\n                        }\n                    }\n                    if (!loop && ! innerEquiv(a[i], b[i])) {\n                        parents.pop();\n                        return false;\n                    }\n                }\n                parents.pop();\n                return true;\n            },\n\n            \"object\": function (b, a) {\n                var i, j, loop;\n                var eq = true; // unless we can proove it\n                var aProperties = [], bProperties = []; // collection of strings\n\n                // comparing constructors is more strict than using instanceof\n                if ( a.constructor !== b.constructor) {\n                    return false;\n                }\n\n                // stack constructor before traversing properties\n                callers.push(a.constructor);\n                //track reference to avoid circular references\n                parents.push(a);\n                \n                for (i in a) { // be strict: don't ensures hasOwnProperty and go deep\n                    loop = false;\n                    for(j=0;j<parents.length;j++){\n                        if(parents[j] === a[i])\n                            loop = true; //don't go down the same path twice\n                    }\n                    aProperties.push(i); // collect a's properties\n\n                    if (!loop && ! innerEquiv(a[i], b[i])) {\n                        eq = false;\n                        break;\n                    }\n                }\n\n                callers.pop(); // unstack, we are done\n                parents.pop();\n\n                for (i in b) {\n                    bProperties.push(i); // collect b's properties\n                }\n\n                // Ensures identical properties name\n                return eq && innerEquiv(aProperties.sort(), bProperties.sort());\n            }\n        };\n    }();\n\n    innerEquiv = function () { // can take multiple arguments\n        var args = Array.prototype.slice.apply(arguments);\n        if (args.length < 2) {\n            return true; // end transition\n        }\n\n        return (function (a, b) {\n            if (a === b) {\n                return true; // catch the most you can\n            } else if (a === null || b === null || typeof a === \"undefined\" || typeof b === \"undefined\" || QUnit.objectType(a) !== QUnit.objectType(b)) {\n                return false; // don't lose time with error prone cases\n            } else {\n                return bindCallbacks(a, callbacks, [b, a]);\n            }\n\n        // apply transition with (1..n) arguments\n        })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));\n    };\n\n    return innerEquiv;\n\n}();\n\n/**\n * jsDump\n * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com\n * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)\n * Date: 5/15/2008\n * @projectDescription Advanced and extensible data dumping for Javascript.\n * @version 1.0.0\n * @author Ariel Flesler\n * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}\n */\nQUnit.jsDump = (function() {\n\tfunction quote( str ) {\n\t\treturn '\"' + str.toString().replace(/\"/g, '\\\\\"') + '\"';\n\t};\n\tfunction literal( o ) {\n\t\treturn o + '';\t\n\t};\n\tfunction join( pre, arr, post ) {\n\t\tvar s = jsDump.separator(),\n\t\t\tbase = jsDump.indent(),\n\t\t\tinner = jsDump.indent(1);\n\t\tif ( arr.join )\n\t\t\tarr = arr.join( ',' + s + inner );\n\t\tif ( !arr )\n\t\t\treturn pre + post;\n\t\treturn [ pre, inner + arr, base + post ].join(s);\n\t};\n\tfunction array( arr ) {\n\t\tvar i = arr.length,\tret = Array(i);\t\t\t\t\t\n\t\tthis.up();\n\t\twhile ( i-- )\n\t\t\tret[i] = this.parse( arr[i] );\t\t\t\t\n\t\tthis.down();\n\t\treturn join( '[', ret, ']' );\n\t};\n\t\n\tvar reName = /^function (\\w+)/;\n\t\n\tvar jsDump = {\n\t\tparse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance\n\t\t\tvar\tparser = this.parsers[ type || this.typeOf(obj) ];\n\t\t\ttype = typeof parser;\t\t\t\n\t\t\t\n\t\t\treturn type == 'function' ? parser.call( this, obj ) :\n\t\t\t\t   type == 'string' ? parser :\n\t\t\t\t   this.parsers.error;\n\t\t},\n\t\ttypeOf:function( obj ) {\n\t\t\tvar type;\n\t\t\tif ( obj === null ) {\n\t\t\t\ttype = \"null\";\n\t\t\t} else if (typeof obj === \"undefined\") {\n\t\t\t\ttype = \"undefined\";\n\t\t\t} else if (QUnit.is(\"RegExp\", obj)) {\n\t\t\t\ttype = \"regexp\";\n\t\t\t} else if (QUnit.is(\"Date\", obj)) {\n\t\t\t\ttype = \"date\";\n\t\t\t} else if (QUnit.is(\"Function\", obj)) {\n\t\t\t\ttype = \"function\";\n\t\t\t} else if (obj.setInterval && obj.document && !obj.nodeType) {\n\t\t\t\ttype = \"window\";\n\t\t\t} else if (obj.nodeType === 9) {\n\t\t\t\ttype = \"document\";\n\t\t\t} else if (obj.nodeType) {\n\t\t\t\ttype = \"node\";\n\t\t\t} else if (typeof obj === \"object\" && typeof obj.length === \"number\" && obj.length >= 0) {\n\t\t\t\ttype = \"array\";\n\t\t\t} else {\n\t\t\t\ttype = typeof obj;\n\t\t\t}\n\t\t\treturn type;\n\t\t},\n\t\tseparator:function() {\n\t\t\treturn this.multiline ?\tthis.HTML ? '<br />' : '\\n' : this.HTML ? '&nbsp;' : ' ';\n\t\t},\n\t\tindent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing\n\t\t\tif ( !this.multiline )\n\t\t\t\treturn '';\n\t\t\tvar chr = this.indentChar;\n\t\t\tif ( this.HTML )\n\t\t\t\tchr = chr.replace(/\\t/g,'   ').replace(/ /g,'&nbsp;');\n\t\t\treturn Array( this._depth_ + (extra||0) ).join(chr);\n\t\t},\n\t\tup:function( a ) {\n\t\t\tthis._depth_ += a || 1;\n\t\t},\n\t\tdown:function( a ) {\n\t\t\tthis._depth_ -= a || 1;\n\t\t},\n\t\tsetParser:function( name, parser ) {\n\t\t\tthis.parsers[name] = parser;\n\t\t},\n\t\t// The next 3 are exposed so you can use them\n\t\tquote:quote, \n\t\tliteral:literal,\n\t\tjoin:join,\n\t\t//\n\t\t_depth_: 1,\n\t\t// This is the list of parsers, to modify them, use jsDump.setParser\n\t\tparsers:{\n\t\t\twindow: '[Window]',\n\t\t\tdocument: '[Document]',\n\t\t\terror:'[ERROR]', //when no parser is found, shouldn't happen\n\t\t\tunknown: '[Unknown]',\n\t\t\t'null':'null',\n\t\t\tundefined:'undefined',\n\t\t\t'function':function( fn ) {\n\t\t\t\tvar ret = 'function',\n\t\t\t\t\tname = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE\n\t\t\t\tif ( name )\n\t\t\t\t\tret += ' ' + name;\n\t\t\t\tret += '(';\n\t\t\t\t\n\t\t\t\tret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');\n\t\t\t\treturn join( ret, this.parse(fn,'functionCode'), '}' );\n\t\t\t},\n\t\t\tarray: array,\n\t\t\tnodelist: array,\n\t\t\targuments: array,\n\t\t\tobject:function( map ) {\n\t\t\t\tvar ret = [ ];\n\t\t\t\tthis.up();\n\t\t\t\tfor ( var key in map )\n\t\t\t\t\tret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );\n\t\t\t\tthis.down();\n\t\t\t\treturn join( '{', ret, '}' );\n\t\t\t},\n\t\t\tnode:function( node ) {\n\t\t\t\tvar open = this.HTML ? '&lt;' : '<',\n\t\t\t\t\tclose = this.HTML ? '&gt;' : '>';\n\t\t\t\t\t\n\t\t\t\tvar tag = node.nodeName.toLowerCase(),\n\t\t\t\t\tret = open + tag;\n\t\t\t\t\t\n\t\t\t\tfor ( var a in this.DOMAttrs ) {\n\t\t\t\t\tvar val = node[this.DOMAttrs[a]];\n\t\t\t\t\tif ( val )\n\t\t\t\t\t\tret += ' ' + a + '=' + this.parse( val, 'attribute' );\n\t\t\t\t}\n\t\t\t\treturn ret + close + open + '/' + tag + close;\n\t\t\t},\n\t\t\tfunctionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function\n\t\t\t\tvar l = fn.length;\n\t\t\t\tif ( !l ) return '';\t\t\t\t\n\t\t\t\t\n\t\t\t\tvar args = Array(l);\n\t\t\t\twhile ( l-- )\n\t\t\t\t\targs[l] = String.fromCharCode(97+l);//97 is 'a'\n\t\t\t\treturn ' ' + args.join(', ') + ' ';\n\t\t\t},\n\t\t\tkey:quote, //object calls it internally, the key part of an item in a map\n\t\t\tfunctionCode:'[code]', //function calls it internally, it's the content of the function\n\t\t\tattribute:quote, //node calls it internally, it's an html attribute value\n\t\t\tstring:quote,\n\t\t\tdate:quote,\n\t\t\tregexp:literal, //regex\n\t\t\tnumber:literal,\n\t\t\t'boolean':literal\n\t\t},\n\t\tDOMAttrs:{//attributes to dump from nodes, name=>realName\n\t\t\tid:'id',\n\t\t\tname:'name',\n\t\t\t'class':'className'\n\t\t},\n\t\tHTML:false,//if true, entities are escaped ( <, >, \\t, space and \\n )\n\t\tindentChar:'   ',//indentation unit\n\t\tmultiline:false //if true, items in a collection, are separated by a \\n, else just a space.\n\t};\n\n\treturn jsDump;\n})();\n\n// from Sizzle.js\nfunction getText( elems ) {\n\tvar ret = \"\", elem;\n\n\tfor ( var i = 0; elems[i]; i++ ) {\n\t\telem = elems[i];\n\n\t\t// Get the text from text nodes and CDATA nodes\n\t\tif ( elem.nodeType === 3 || elem.nodeType === 4 ) {\n\t\t\tret += elem.nodeValue;\n\n\t\t// Traverse everything else, except comment nodes\n\t\t} else if ( elem.nodeType !== 8 ) {\n\t\t\tret += getText( elem.childNodes );\n\t\t}\n\t}\n\n\treturn ret;\n};\n\n/*\n * Javascript Diff Algorithm\n *  By John Resig (http://ejohn.org/)\n *  Modified by Chu Alan \"sprite\"\n *\n * Released under the MIT license.\n *\n * More Info:\n *  http://ejohn.org/projects/javascript-diff-algorithm/\n *  \n * Usage: QUnit.diff(expected, actual)\n * \n * QUnit.diff(\"the quick brown fox jumped over\", \"the quick fox jumps over\") == \"the  quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over\"\n */\nQUnit.diff = (function() {\n\tfunction diff(o, n){\n\t\tvar ns = new Object();\n\t\tvar os = new Object();\n\t\t\n\t\tfor (var i = 0; i < n.length; i++) {\n\t\t\tif (ns[n[i]] == null) \n\t\t\t\tns[n[i]] = {\n\t\t\t\t\trows: new Array(),\n\t\t\t\t\to: null\n\t\t\t\t};\n\t\t\tns[n[i]].rows.push(i);\n\t\t}\n\t\t\n\t\tfor (var i = 0; i < o.length; i++) {\n\t\t\tif (os[o[i]] == null) \n\t\t\t\tos[o[i]] = {\n\t\t\t\t\trows: new Array(),\n\t\t\t\t\tn: null\n\t\t\t\t};\n\t\t\tos[o[i]].rows.push(i);\n\t\t}\n\t\t\n\t\tfor (var i in ns) {\n\t\t\tif (ns[i].rows.length == 1 && typeof(os[i]) != \"undefined\" && os[i].rows.length == 1) {\n\t\t\t\tn[ns[i].rows[0]] = {\n\t\t\t\t\ttext: n[ns[i].rows[0]],\n\t\t\t\t\trow: os[i].rows[0]\n\t\t\t\t};\n\t\t\t\to[os[i].rows[0]] = {\n\t\t\t\t\ttext: o[os[i].rows[0]],\n\t\t\t\t\trow: ns[i].rows[0]\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (var i = 0; i < n.length - 1; i++) {\n\t\t\tif (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&\n\t\t\tn[i + 1] == o[n[i].row + 1]) {\n\t\t\t\tn[i + 1] = {\n\t\t\t\t\ttext: n[i + 1],\n\t\t\t\t\trow: n[i].row + 1\n\t\t\t\t};\n\t\t\t\to[n[i].row + 1] = {\n\t\t\t\t\ttext: o[n[i].row + 1],\n\t\t\t\t\trow: i + 1\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (var i = n.length - 1; i > 0; i--) {\n\t\t\tif (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&\n\t\t\tn[i - 1] == o[n[i].row - 1]) {\n\t\t\t\tn[i - 1] = {\n\t\t\t\t\ttext: n[i - 1],\n\t\t\t\t\trow: n[i].row - 1\n\t\t\t\t};\n\t\t\t\to[n[i].row - 1] = {\n\t\t\t\t\ttext: o[n[i].row - 1],\n\t\t\t\t\trow: i - 1\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn {\n\t\t\to: o,\n\t\t\tn: n\n\t\t};\n\t}\n\t\n\treturn function(o, n){\n\t\to = o.replace(/\\s+$/, '');\n\t\tn = n.replace(/\\s+$/, '');\n\t\tvar out = diff(o == \"\" ? [] : o.split(/\\s+/), n == \"\" ? [] : n.split(/\\s+/));\n\n\t\tvar str = \"\";\n\t\t\n\t\tvar oSpace = o.match(/\\s+/g);\n\t\tif (oSpace == null) {\n\t\t\toSpace = [\" \"];\n\t\t}\n\t\telse {\n\t\t\toSpace.push(\" \");\n\t\t}\n\t\tvar nSpace = n.match(/\\s+/g);\n\t\tif (nSpace == null) {\n\t\t\tnSpace = [\" \"];\n\t\t}\n\t\telse {\n\t\t\tnSpace.push(\" \");\n\t\t}\n\t\t\n\t\tif (out.n.length == 0) {\n\t\t\tfor (var i = 0; i < out.o.length; i++) {\n\t\t\t\tstr += '<del>' + out.o[i] + oSpace[i] + \"</del>\";\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (out.n[0].text == null) {\n\t\t\t\tfor (n = 0; n < out.o.length && out.o[n].text == null; n++) {\n\t\t\t\t\tstr += '<del>' + out.o[n] + oSpace[n] + \"</del>\";\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor (var i = 0; i < out.n.length; i++) {\n\t\t\t\tif (out.n[i].text == null) {\n\t\t\t\t\tstr += '<ins>' + out.n[i] + nSpace[i] + \"</ins>\";\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tvar pre = \"\";\n\t\t\t\t\t\n\t\t\t\t\tfor (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {\n\t\t\t\t\t\tpre += '<del>' + out.o[n] + oSpace[n] + \"</del>\";\n\t\t\t\t\t}\n\t\t\t\t\tstr += \" \" + out.n[i].text + nSpace[i] + pre;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn str;\n\t}\n})();\n\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.scanner.modules/tests/scripts/jquery-tests.js",
    "content": "\nvar module = {\n\tname : \"DOM testing module\",\n\ttype : \"dom-test\",\n\thtml : \"jquery-test.html\"\n};\n\n\nfunction q() {\n\tvar r = [];\n\tfor(var i = 0; i < arguments.length; i++) {\n\t\tr.push(doc.getElementById(arguments[i]));\n\t}\n\treturn r;\n}\n\nfunction t(a,b,c) {\n\tvar f = jQuery(b).get(), s = \"\";\n\tfor(var i = 0; i < f.length; i++) {\n\t\ts += (s && \",\") + '\"' + f[i].id + '\"';\n\t}\n\tsame(f, q.apply(q,c), a + \" (\"+ b + \")\");\n}\n\nfunction print(msg) {\n    java.lang.System.out.println(msg);\n}\n\nfunction run() {\n\tprint(\"Running dom test\");\n\t\n\tthis.doc = new HTMLDocument(testDom);\n\tjQuery.setDocument(doc);\n\t\n\tbasic_tests();\n\tbroken_tests();\n\tid_test();\n\tclass_tests();\n\tname_tests();\n\tmultiple_tests();\n\tchild_and_adjacent_tests();\n\tattributes_tests();\n\tpseudo_child_tests();\n\tpseudo_misc_tests();\n\tpseudo_not_tests();\n\tpseudo_position_tests();\n\tpseudo_form_tests();\n\ttrac_bugs();\n\t\n\tsummary();\n\n}\n\nfunction basic_tests() {\n\tvar sz = jQuery(\"*\").size();\n\tok(sz >= 30, \"Select all, size is \"+ sz);\n\tvar all = jQuery(\"*\"), good = true;\n\tfor(var i = 0; i < all.length; i++)\n\t\tif(all[i].nodeType == 8)\n\t\t\tgood = false;\n\tok(good, \"Select all elements, no comment nodes\");\n\t\n\tt( \"Element Selector\", \"p\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \"Element Selector\", \"body\", [\"body\"] );\n\tt( \"Element Selector\", \"html\", [\"html\"] );\n\tt( \"Parent Element\", \"div p\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tequals( jQuery(\"param\", \"#object1\").length, 2, \"Object/param as context\" );\n\tsame( jQuery(\"p\", doc.getElementsByTagName(\"div\")).get(), q(\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"), \"Finding elements with a context.\" );\n\tsame( jQuery(\"p\", \"div\").get(), q(\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"), \"Finding elements with a context.\" );\n\tsame( jQuery(\"p\", jQuery(\"div\")).get(), q(\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"), \"Finding elements with a context.\" );\n\tsame( jQuery(\"div\").find(\"p\").get(), q(\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"), \"Finding elements with a context.\" );\n\n\tsame( jQuery(\"#form\").find(\"select\").get(), q(\"select1\",\"select2\",\"select3\",\"select4\",\"select5\"), \"Finding selects with a context.\" );\n\t\n\tok( jQuery(\"#length\").length, '<input name=\"length\"> cannot be found under IE, see #945' );\n\tok( jQuery(\"#lengthtest input\").length, '<input name=\"length\"> cannot be found under IE, see #945' );\n\n\t// Check for unique-ness and sort order\n\tsame( jQuery(\"p, div p\").get(), jQuery(\"p\").get(), \"Check for duplicates: p, div p\" );\n\n\tt( \"Checking sort order\", \"h2, h1\", [\"qunit-header\", \"qunit-banner\", \"qunit-userAgent\"] );\n\tt( \"Checking sort order\", \"h2:first, h1:first\", [\"qunit-header\", \"qunit-banner\"] );\n\tt( \"Checking sort order\", \"p, p a\", [\"firstp\", \"simon1\", \"ap\", \"google\", \"groups\", \"anchor1\", \"mark\", \"sndp\", \"en\", \"yahoo\", \"sap\", \"anchor2\", \"simon\", \"first\"] );\n}\nfunction broken_tests() {\n\tfunction broken(name, selector) {\n\t\ttry {\n\t\t\tjQuery(selector);\n\t\t\tok( false, name + \": \" + selector );\n\t\t} catch(e){\n\t\t\tok(  typeof e === \"string\" && e.indexOf(\"Syntax error\") >= 0,\n\t\t\t\tname + \": \" + selector );\n\t\t}\n\t}\n\t\n\tbroken( \"Broken Selector\", \"[\", [] );\n\tbroken( \"Broken Selector\", \"(\", [] );\n\tbroken( \"Broken Selector\", \"{\", [] );\n\tbroken( \"Broken Selector\", \"<\", [] );\n\tbroken( \"Broken Selector\", \"()\", [] );\n\tbroken( \"Broken Selector\", \"<>\", [] );\n\tbroken( \"Broken Selector\", \"{}\", [] );\n\tbroken( \"Doesn't exist\", \":visble\", [] );\n}\n\nfunction id_test() {\n\tt( \"ID Selector\", \"#body\", [\"body\"] );\n\tt( \"ID Selector w/ Element\", \"body#body\", [\"body\"] );\n\tt( \"ID Selector w/ Element\", \"ul#first\", [] );\n\tt( \"ID selector with existing ID descendant\", \"#firstp #simon1\", [\"simon1\"] );\n\tt( \"ID selector with non-existant descendant\", \"#firstp #foobar\", [] );\n\t \n\tt( \"Escaped ID\", \"#foo\\\\:bar\", [\"foo:bar\"] );\n\tt( \"Escaped ID\", \"#test\\\\.foo\\\\[5\\\\]bar\", [\"test.foo[5]bar\"] );\n\tt( \"Descendant escaped ID\", \"div #foo\\\\:bar\", [\"foo:bar\"] );\n\tt( \"Descendant escaped ID\", \"div #test\\\\.foo\\\\[5\\\\]bar\", [\"test.foo[5]bar\"] );\n\tt( \"Child escaped ID\", \"form > #foo\\\\:bar\", [\"foo:bar\"] );\n\tt( \"Child escaped ID\", \"form > #test\\\\.foo\\\\[5\\\\]bar\", [\"test.foo[5]bar\"] );\n\t\n\tt( \"ID Selector, child ID present\", \"#form > #radio1\", [\"radio1\"] ); // bug #267\n\tt( \"ID Selector, not an ancestor ID\", \"#form #first\", [] );\n\tt( \"ID Selector, not a child ID\", \"#form > #option1a\", [] );\n\t\n\tt( \"All Children of ID\", \"#foo > *\", [\"sndp\", \"en\", \"sap\"] );\n\tt( \"All Children of ID with no children\", \"#firstUL > *\", [] );\n\n\tt( \"ID Selector on Form with an input that has a name of 'id'\", \"#lengthtest\", [\"lengthtest\"] );\n\t\n\tt( \"ID selector with non-existant ancestor\", \"#asdfasdf #foobar\", [] ); // bug #986\n\n\tsame( jQuery(\"body\").find(\"div#form\").get(), [], \"ID selector within the context of another element\" );\n\n\tt( \"Underscore ID\", \"#types_all\", [\"types_all\"] );\n\tt( \"Dash ID\", \"#fx-queue\", [\"fx-queue\"] );\n\n\tt( \"ID with weird characters in it\", \"#name\\\\+value\", [\"name+value\"] );\n}\n\nfunction class_tests() {\n\tt( \"Class Selector\", \".blog\", [\"mark\",\"simon\"] );\n\tt( \"Class Selector\", \".GROUPS\", [\"groups\"] );\n\tt( \"Class Selector\", \".blog.link\", [\"simon\"] );\n\tt( \"Class Selector w/ Element\", \"a.blog\", [\"mark\",\"simon\"] );\n\tt( \"Parent Class Selector\", \"p .blog\", [\"mark\",\"simon\"] );\n\n\tsame( jQuery(\".blog\", doc.getElementsByTagName(\"p\")).get(), q(\"mark\", \"simon\"), \"Finding elements with a context.\" );\n\tsame( jQuery(\".blog\", \"p\").get(), q(\"mark\", \"simon\"), \"Finding elements with a context.\" );\n\tsame( jQuery(\".blog\", jQuery(\"p\")).get(), q(\"mark\", \"simon\"), \"Finding elements with a context.\" );\n\tsame( jQuery(\"p\").find(\".blog\").get(), q(\"mark\", \"simon\"), \"Finding elements with a context.\" );\n\n\tt( \"Escaped Class\", \".foo\\\\:bar\", [\"foo:bar\"] );\n\tt( \"Escaped Class\", \".test\\\\.foo\\\\[5\\\\]bar\", [\"test.foo[5]bar\"] );\n\tt( \"Descendant scaped Class\", \"div .foo\\\\:bar\", [\"foo:bar\"] );\n\tt( \"Descendant scaped Class\", \"div .test\\\\.foo\\\\[5\\\\]bar\", [\"test.foo[5]bar\"] );\n\tt( \"Child escaped Class\", \"form > .foo\\\\:bar\", [\"foo:bar\"] );\n\tt( \"Child escaped Class\", \"form > .test\\\\.foo\\\\[5\\\\]bar\", [\"test.foo[5]bar\"] );\n\n}\n\nfunction name_tests() {\n\tt( \"Name selector\", \"input[name=action]\", [\"text1\"] );\n\tt( \"Name selector with single quotes\", \"input[name='action']\", [\"text1\"] );\n\tt( \"Name selector with double quotes\", 'input[name=\"action\"]', [\"text1\"] );\n\n\tt( \"Name selector non-input\", \"[name=test]\", [\"length\", \"fx-queue\"] );\n\tt( \"Name selector non-input\", \"[name=div]\", [\"fadein\"] );\n\tt( \"Name selector non-input\", \"*[name=iframe]\", [\"iframe\"] );\n\n\tt( \"Name selector for grouped input\", \"input[name='types[]']\", [\"types_all\", \"types_anime\", \"types_movie\"] )\n\n\tsame( jQuery(\"#form\").find(\"input[name=action]\").get(), q(\"text1\"), \"Name selector within the context of another element\" );\n\tsame( jQuery(\"#form\").find(\"input[name='foo[bar]']\").get(), q(\"hidden2\"), \"Name selector for grouped form element within the context of another element\" );\n\n}\n\nfunction multiple_tests() {\n\tt( \"Comma Support\", \"h2, p\", [\"qunit-banner\",\"qunit-userAgent\",\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"]);\n\tt( \"Comma Support\", \"h2 , p\", [\"qunit-banner\",\"qunit-userAgent\",\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"]);\n\tt( \"Comma Support\", \"h2 , p\", [\"qunit-banner\",\"qunit-userAgent\",\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"]);\n\tt( \"Comma Support\", \"h2,p\", [\"qunit-banner\",\"qunit-userAgent\",\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"]);\n}\n\nfunction child_and_adjacent_tests() {\n\tt( \"Child\", \"p > a\", [\"simon1\",\"google\",\"groups\",\"mark\",\"yahoo\",\"simon\"] );\n\tt( \"Child\", \"p> a\", [\"simon1\",\"google\",\"groups\",\"mark\",\"yahoo\",\"simon\"] );\n\tt( \"Child\", \"p >a\", [\"simon1\",\"google\",\"groups\",\"mark\",\"yahoo\",\"simon\"] );\n\tt( \"Child\", \"p>a\", [\"simon1\",\"google\",\"groups\",\"mark\",\"yahoo\",\"simon\"] );\n\tt( \"Child w/ Class\", \"p > a.blog\", [\"mark\",\"simon\"] );\n\tt( \"All Children\", \"code > *\", [\"anchor1\",\"anchor2\"] );\n\n\tt( \"All Grandchildren\", \"p > * > *\", [\"anchor1\",\"anchor2\"] );\n\tt( \"Adjacent\", \"a + a\", [\"groups\"] );\n\tt( \"Adjacent\", \"a +a\", [\"groups\"] );\n\tt( \"Adjacent\", \"a+ a\", [\"groups\"] );\n\tt( \"Adjacent\", \"a+a\", [\"groups\"] );\n\tt( \"Adjacent\", \"p + p\", [\"ap\",\"en\",\"sap\"] );\n\tt( \"Adjacent\", \"p#firstp + p\", [\"ap\"] );\n\tt( \"Adjacent\", \"p[lang=en] + p\", [\"sap\"] );\n\tt( \"Adjacent\", \"a.GROUPS + code + a\", [\"mark\"] );\n\tt( \"Comma, Child, and Adjacent\", \"a + a, code > a\", [\"groups\",\"anchor1\",\"anchor2\"] );\n\tt( \"Element Preceded By\", \"p ~ div\", [\"foo\", \"moretests\",\"tabindex-tests\", \"liveHandlerOrder\", \"siblingTest\"] );\n\tt( \"Element Preceded By\", \"#first ~ div\", [\"moretests\",\"tabindex-tests\", \"liveHandlerOrder\", \"siblingTest\"] );\n\tt( \"Element Preceded By\", \"#groups ~ a\", [\"mark\"] );\n\tt( \"Element Preceded By\", \"#length ~ input\", [\"idTest\"] );\n\tt( \"Element Preceded By\", \"#siblingfirst ~ em\", [\"siblingnext\"] );\n\n\tt( \"Verify deep class selector\", \"div.blah > p > a\", [] );\n\n\tt( \"No element deep selector\", \"div.foo > span > a\", [] );\n\n\tsame( jQuery(\"> :first\", doc.getElementById(\"nothiddendiv\")).get(), q(\"nothiddendivchild\"), \"Verify child context positional selctor\" );\n\tsame( jQuery(\"> :eq(0)\", doc.getElementById(\"nothiddendiv\")).get(), q(\"nothiddendivchild\"), \"Verify child context positional selctor\" );\n\tsame( jQuery(\"> *:first\", doc.getElementById(\"nothiddendiv\")).get(), q(\"nothiddendivchild\"), \"Verify child context positional selctor\" );\n\n\tt( \"Non-existant ancestors\", \".fototab > .thumbnails > a\", [] );\n}\n\nfunction attributes_tests() {\n\tt( \"Attribute Exists\", \"a[title]\", [\"google\"] );\n\tt( \"Attribute Exists\", \"*[title]\", [\"google\"] );\n\tt( \"Attribute Exists\", \"[title]\", [\"google\"] );\n\tt( \"Attribute Exists\", \"a[ title ]\", [\"google\"] );\n\t\n\tt( \"Attribute Equals\", \"a[rel='bookmark']\", [\"simon1\"] );\n\tt( \"Attribute Equals\", 'a[rel=\"bookmark\"]', [\"simon1\"] );\n\tt( \"Attribute Equals\", \"a[rel=bookmark]\", [\"simon1\"] );\n\tt( \"Attribute Equals\", \"a[href='http://www.google.com/']\", [\"google\"] );\n\tt( \"Attribute Equals\", \"a[ rel = 'bookmark' ]\", [\"simon1\"] );\n\n\tdoc.getElementById(\"anchor2\").href = \"#2\";\n\tt( \"href Attribute\", \"p a[href^=#]\", [\"anchor2\"] );\n\tt( \"href Attribute\", \"p a[href*=#]\", [\"simon1\", \"anchor2\"] );\n\n\tt( \"for Attribute\", \"form label[for]\", [\"label-for\"] );\n\tt( \"for Attribute in form\", \"#form [for=action]\", [\"label-for\"] );\n\n\tt( \"Attribute containing []\", \"input[name^='foo[']\", [\"hidden2\"] );\n\tt( \"Attribute containing []\", \"input[name^='foo[bar]']\", [\"hidden2\"] );\n\tt( \"Attribute containing []\", \"input[name*='[bar]']\", [\"hidden2\"] );\n\tt( \"Attribute containing []\", \"input[name$='bar]']\", [\"hidden2\"] );\n\tt( \"Attribute containing []\", \"input[name$='[bar]']\", [\"hidden2\"] );\n\tt( \"Attribute containing []\", \"input[name$='foo[bar]']\", [\"hidden2\"] );\n\tt( \"Attribute containing []\", \"input[name*='foo[bar]']\", [\"hidden2\"] );\n\t\n\tt( \"Multiple Attribute Equals\", \"#form input[type='radio'], #form input[type='hidden']\", [\"radio1\", \"radio2\", \"hidden1\"] );\n\tt( \"Multiple Attribute Equals\", \"#form input[type='radio'], #form input[type=\\\"hidden\\\"]\", [\"radio1\", \"radio2\", \"hidden1\"] );\n\tt( \"Multiple Attribute Equals\", \"#form input[type='radio'], #form input[type=hidden]\", [\"radio1\", \"radio2\", \"hidden1\"] );\n\n\t\n\tt( \"Attribute Begins With\", \"a[href ^= 'http://www']\", [\"google\",\"yahoo\"] );\n\tt( \"Attribute Ends With\", \"a[href $= 'org/']\", [\"mark\"] );\n\tt( \"Attribute Contains\", \"a[href *= 'google']\", [\"google\",\"groups\"] );\n\tt( \"Attribute Is Not Equal\", \"#ap a[hreflang!='en']\", [\"google\",\"groups\",\"anchor1\"] );\n\n\tt(\"Empty values\", \"#select1 option[value='']\", [\"option1a\"]);\n\tt(\"Empty values\", \"#select1 option[value!='']\", [\"option1b\",\"option1c\",\"option1d\"]);\n\t\n\tt(\"Select options via :selected\", \"#select1 option:selected\", [\"option1a\"] );\n\tt(\"Select options via :selected\", \"#select2 option:selected\", [\"option2d\"] );\n\tt(\"Select options via :selected\", \"#select3 option:selected\", [\"option3b\", \"option3c\"] );\n\t\n\tt( \"Grouped Form Elements\", \"input[name='foo[bar]']\", [\"hidden2\"] );\n}\n\nfunction pseudo_child_tests() {\n\tt( \"First Child\", \"p:first-child\", [\"firstp\",\"sndp\"] );\n\tt( \"Last Child\", \"p:last-child\", [\"sap\"] );\n\tt( \"Only Child\", \"#main a:only-child\", [\"simon1\",\"anchor1\",\"yahoo\",\"anchor2\",\"liveLink1\",\"liveLink2\"] );\n\tt( \"Empty\", \"ul:empty\", [\"firstUL\"] );\n\tt( \"Is A Parent\", \"p:parent\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\n\tt( \"First Child\", \"p:first-child\", [\"firstp\",\"sndp\"] );\n\tt( \"Nth Child\", \"p:nth-child(1)\", [\"firstp\",\"sndp\"] );\n\tt( \"Not Nth Child\", \"p:not(:nth-child(1))\", [\"ap\",\"en\",\"sap\",\"first\"] );\n\t\n\tt( \"Last Child\", \"p:last-child\", [\"sap\"] );\n\tt( \"Last Child\", \"#main a:last-child\", [\"simon1\",\"anchor1\",\"mark\",\"yahoo\",\"anchor2\",\"simon\",\"liveLink1\",\"liveLink2\"] );\n\t\n\tt( \"Nth-child\", \"#main form#form > *:nth-child(2)\", [\"text1\"] );\n\tt( \"Nth-child\", \"#main form#form > :nth-child(2)\", [\"text1\"] );\n\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3)\", [\"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(0n+3)\", [\"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(1n+0)\", [\"option1a\", \"option1b\", \"option1c\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(1n)\", [\"option1a\", \"option1b\", \"option1c\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(n)\", [\"option1a\", \"option1b\", \"option1c\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(even)\", [\"option1b\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(odd)\", [\"option1a\", \"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(2n)\", [\"option1b\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(2n+1)\", [\"option1a\", \"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n)\", [\"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n+1)\", [\"option1a\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n+2)\", [\"option1b\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n+3)\", [\"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n-1)\", [\"option1b\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n-2)\", [\"option1a\", \"option1d\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n-3)\", [\"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(3n+0)\", [\"option1c\"] );\n\tt( \"Nth-child\", \"#form select:first option:nth-child(-n+3)\", [\"option1a\", \"option1b\", \"option1c\"] );\n\n}\n\nfunction pseudo_misc_tests() {\n\tt( \"Headers\", \":header\", [\"qunit-header\", \"qunit-banner\", \"qunit-userAgent\"] );\n\tt( \"Has Children - :has()\", \"p:has(a)\", [\"firstp\",\"ap\",\"en\",\"sap\"] );\n\n\tt( \"Text Contains\", \"a:contains(Google)\", [\"google\",\"groups\"] );\n\tt( \"Text Contains\", \"a:contains(Google Groups)\", [\"groups\"] );\n\n\tt( \"Text Contains\", \"a:contains(Google Groups (Link))\", [\"groups\"] );\n\tt( \"Text Contains\", \"a:contains((Link))\", [\"groups\"] );\n\n}\n\nfunction pseudo_not_tests() {\n\tt( \"Not\", \"a.blog:not(.link)\", [\"mark\"] );\n\n\tt( \"Not - multiple\", \"#form option:not(:contains(Nothing),#option1b,:selected)\", [\"option1c\", \"option1d\", \"option2b\", \"option2c\", \"option3d\", \"option3e\", \"option4e\", \"option5b\", \"option5c\"] );\n\tt( \"Not - recursive\", \"#form option:not(:not(:selected))[id^='option3']\", [ \"option3b\", \"option3c\"] );\n\n\tt( \":not() failing interior\", \"p:not(.foo)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not() failing interior\", \"p:not(div.foo)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not() failing interior\", \"p:not(p.foo)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not() failing interior\", \"p:not(#blargh)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not() failing interior\", \"p:not(div#blargh)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not() failing interior\", \"p:not(p#blargh)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\n\tt( \":not Multiple\", \"p:not(a)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not Multiple\", \"p:not(a, b)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not Multiple\", \"p:not(a, b, div)\", [\"firstp\",\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \":not Multiple\", \"p:not(p)\", [] );\n\tt( \":not Multiple\", \"p:not(a,p)\", [] );\n\tt( \":not Multiple\", \"p:not(p,a)\", [] );\n\tt( \":not Multiple\", \"p:not(a,p,b)\", [] );\n\tt( \":not Multiple\", \":input:not(:image,:input,:submit)\", [] );\n\n\tt( \"No element not selector\", \".container div:not(.excluded) div\", [] );\n\n\tt( \":not() Existing attribute\", \"#form select:not([multiple])\", [\"select1\", \"select2\", \"select5\"]);\n\tt( \":not() Equals attribute\", \"#form select:not([name=select1])\", [\"select2\", \"select3\", \"select4\",\"select5\"]);\n\tt( \":not() Equals quoted attribute\", \"#form select:not([name='select1'])\", [\"select2\", \"select3\", \"select4\", \"select5\"]);\n\n\tt( \":not() Multiple Class\", \"#foo a:not(.blog)\", [\"yahoo\",\"anchor2\"] );\n\tt( \":not() Multiple Class\", \"#foo a:not(.link)\", [\"yahoo\",\"anchor2\"] );\n\tt( \":not() Multiple Class\", \"#foo a:not(.blog.link)\", [\"yahoo\",\"anchor2\"] );\n\n}\n\nfunction pseudo_position_tests() {\n\tt( \"nth Element\", \"p:nth(1)\", [\"ap\"] );\n\tt( \"First Element\", \"p:first\", [\"firstp\"] );\n\tt( \"Last Element\", \"p:last\", [\"first\"] );\n\tt( \"Even Elements\", \"p:even\", [\"firstp\",\"sndp\",\"sap\"] );\n\tt( \"Odd Elements\", \"p:odd\", [\"ap\",\"en\",\"first\"] );\n\tt( \"Position Equals\", \"p:eq(1)\", [\"ap\"] );\n\tt( \"Position Greater Than\", \"p:gt(0)\", [\"ap\",\"sndp\",\"en\",\"sap\",\"first\"] );\n\tt( \"Position Less Than\", \"p:lt(3)\", [\"firstp\",\"ap\",\"sndp\"] );\n\n\tt( \"Check position filtering\", \"div#nothiddendiv:eq(0)\", [\"nothiddendiv\"] );\n\tt( \"Check position filtering\", \"div#nothiddendiv:last\", [\"nothiddendiv\"] );\n\tt( \"Check position filtering\", \"div#nothiddendiv:not(:gt(0))\", [\"nothiddendiv\"] );\n\tt( \"Check position filtering\", \"#foo > :not(:first)\", [\"en\", \"sap\"] );\n\tt( \"Check position filtering\", \"select > :not(:gt(2))\", [\"option1a\", \"option1b\", \"option1c\"] );\n\tt( \"Check position filtering\", \"select:lt(2) :not(:first)\", [\"option1b\", \"option1c\", \"option1d\", \"option2a\", \"option2b\", \"option2c\", \"option2d\"] );\n\tt( \"Check position filtering\", \"div.nothiddendiv:eq(0)\", [\"nothiddendiv\"] );\n\tt( \"Check position filtering\", \"div.nothiddendiv:last\", [\"nothiddendiv\"] );\n\tt( \"Check position filtering\", \"div.nothiddendiv:not(:lt(0))\", [\"nothiddendiv\"] );\n\n\tt( \"Check element position\", \"div div:eq(0)\", [\"nothiddendivchild\"] );\n\tt( \"Check element position\", \"div div:eq(5)\", [\"t2037\"] );\n\tt( \"Check element position\", \"div div:eq(28)\", [\"hide\"] );\n\tt( \"Check element position\", \"div div:first\", [\"nothiddendivchild\"] );\n\tt( \"Check element position\", \"div > div:first\", [\"nothiddendivchild\"] );\n\tt( \"Check element position\", \"#dl div:first div:first\", [\"foo\"] );\n\tt( \"Check element position\", \"#dl div:first > div:first\", [\"foo\"] );\n\tt( \"Check element position\", \"div#nothiddendiv:first > div:first\", [\"nothiddendivchild\"] );\n\n}\n\nfunction pseudo_form_tests() {\n\tt( \"Form element :input\", \"#form :input\", [\"text1\", \"text2\", \"radio1\", \"radio2\", \"check1\", \"check2\", \"hidden1\", \"hidden2\", \"name\", \"search\", \"button\", \"area1\", \"select1\", \"select2\", \"select3\", \"select4\", \"select5\"] );\n\tt( \"Form element :radio\", \"#form :radio\", [\"radio1\", \"radio2\"] );\n\tt( \"Form element :checkbox\", \"#form :checkbox\", [\"check1\", \"check2\"] );\n\tt( \"Form element :text\", \"#form :text:not(#search)\", [\"text1\", \"text2\", \"hidden2\", \"name\"] );\n\tt( \"Form element :radio:checked\", \"#form :radio:checked\", [\"radio2\"] );\n\tt( \"Form element :checkbox:checked\", \"#form :checkbox:checked\", [\"check1\"] );\n\tt( \"Form element :radio:checked, :checkbox:checked\", \"#form :radio:checked, #form :checkbox:checked\", [\"radio2\", \"check1\"] );\n\n\tt( \"Selected Option Element\", \"#form option:selected\", [\"option1a\",\"option2d\",\"option3b\",\"option3c\",\"option4b\",\"option4c\",\"option4d\",\"option5a\"] );\n}\n\nfunction trac_bugs() {\n\tsame( jQuery(\"div\").has(\"em\").get(), q(\"main\", \"siblingTest\"), \"Trac ticket #20 has()\");\n\tsame( jQuery(\"#nonnodes\").text(), \"hi there \", \"Trac ticket #23 text()\");\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.sslprobe</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/.settings/org.eclipse.jdt.core.prefs",
    "content": "eclipse.preferences.version=1\norg.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\norg.eclipse.jdt.core.compiler.compliance=1.8\norg.eclipse.jdt.core.compiler.problem.assertIdentifier=error\norg.eclipse.jdt.core.compiler.problem.enumIdentifier=error\norg.eclipse.jdt.core.compiler.source=1.8\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/.settings/org.eclipse.pde.core.prefs",
    "content": "eclipse.preferences.version=1\npluginProject.extensions=false\nresolve.requirebundle=false\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Sslprobe\nBundle-SymbolicName: com.subgraph.vega.sslprobe\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.sslprobe.Activator\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.8,\n JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.google.common.collect,\n com.subgraph.vega.api.model.alerts,\n org.apache.http;version=\"4.2.3\",\n org.osgi.framework;version=\"1.3.0\"\nExport-Package: com.subgraph.vega.sslprobe\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/CertificateAnalyzer.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.security.InvalidKeyException;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.NoSuchProviderException;\nimport java.security.PublicKey;\nimport java.security.SignatureException;\nimport java.security.interfaces.RSAPublicKey;\n\nimport javax.security.cert.CertificateException;\nimport javax.security.cert.X509Certificate;\n\npublic class CertificateAnalyzer {\n\n\tprivate X509Certificate certificate;\n\tprivate boolean error = false;\n\t\n\tCertificateAnalyzer () {\n\t\t\n\t}\n\t\n\tpublic void addCert(X509Certificate certificate) {\n\t\tthis.certificate = certificate;\n\t}\n\t\n\t\n\tpublic boolean selfSigned() {\n\t\t\n\t\tPublicKey k = certificate.getPublicKey();\n\t\ttry { \n\t\t\tcertificate.verify(k);\n\t\t} catch (InvalidKeyException e) {\n\t\t\tSystem.out.println(\"Invalid key, not self signed\");\n\t\t\treturn false;\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\treturn false;\n\t\t} catch (NoSuchProviderException e) {\n\t\t\treturn false;\n\t\t} catch (SignatureException e) {\n\t\t\treturn false;\n\t\t} catch (CertificateException e) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tpublic boolean isSignedSHA1() {\n\t\treturn certificate.getSigAlgName().startsWith(\"SHA1\");\n\t}\n\t\n\tpublic boolean isSignedMD5() {\n\t\treturn certificate.getSigAlgName().startsWith(\"MD5\");\n\t}\n\t\n\tpublic boolean isRSA() {\n\t\treturn \"RSA\".equals(certificate.getPublicKey().getAlgorithm());\n\t}\n\n\tpublic int getRSAModulusBitLength() {\n\t\tif (this.isRSA()) {\n\t\t\tRSAPublicKey r = (RSAPublicKey) certificate.getPublicKey();\n\t\t\treturn r.getModulus().bitLength();\n\t\t}\n\t\telse return -1;\n\t}\n\t\n\tpublic void setError(boolean error) {\n\t\tthis.error = error;\n\t}\n\t\n\tpublic X509Certificate getCertificate() {\n\t\treturn this.certificate;\n\t}\n\t\n\tpublic boolean isError() {\n\t\treturn this.error;\n\t}\n\t\n\t@Override\n\tpublic int hashCode() {\n\t\treturn (certificate == null) ? 0 : certificate.getSerialNumber().hashCode();\n\t}\n\n\t@Override\n\tpublic boolean equals(Object obj) {\n\t\tif (this == obj) {\n\t\t\treturn true;\n\t\t} else if (obj == null || getClass() != obj.getClass()) {\n\t\t\treturn false;\n\t\t} \n\t\t\n\t\tfinal CertificateAnalyzer other = (CertificateAnalyzer) obj;\n\t\t\n\t\tif (certificate == null) {\n\t\t\treturn other.certificate == null;\n\t\t}\n\t\t\n\t\tif(certificate.getSerialNumber() == null) {\n\t\t\treturn other.certificate.getSerialNumber() == null;\n\t\t}\n\t\t\n\t\treturn certificate.getSerialNumber().equals(other.certificate.getSerialNumber());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/CipherSuites.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.Collections;\r\nimport java.util.HashMap;\r\nimport java.util.List;\r\nimport java.util.Map;\r\n\r\nimport com.google.common.collect.Lists;\r\n\r\npublic class CipherSuites {\r\n\r\n\tstatic private final List<TLSCipherSpec> TLS_CIPHERS = new ArrayList<TLSCipherSpec>();\r\n\tstatic private final Map<Integer, TLSCipherSpec> TLS_CIPHER_MAP = new HashMap<Integer, TLSCipherSpec>();\r\n\tstatic private final List<SSLv2CipherSpec> SSLv2_CIPHERS = new ArrayList<SSLv2CipherSpec>();\r\n\tstatic private final Map<Integer, SSLv2CipherSpec> SSLv2_CIPHER_MAP = new HashMap<Integer, SSLv2CipherSpec>();\r\n\r\n\t\r\n\tstatic public List<List<TLSCipherSpec>> paritionTLSCiphers(int maxSize) {\r\n\t\treturn Lists.partition(TLS_CIPHERS, maxSize);\r\n\t}\r\n\t\r\n\tstatic TLSCipherSpec lookupTLSCipher(int constant) {\r\n\t\treturn TLS_CIPHER_MAP.get(constant);\r\n\t}\r\n\t\r\n\t\r\n\tstatic public List<SSLv2CipherSpec> getV2CipherSuites() {\r\n\t\treturn Collections.unmodifiableList(new ArrayList<SSLv2CipherSpec>(SSLv2_CIPHERS));\r\n\t}\r\n\r\n\tstatic public SSLv2CipherSpec lookupSSLv2Cipher(int constant) {\r\n\t\treturn SSLv2_CIPHER_MAP.get(constant);\r\n\t}\r\n\r\n\tstatic private void addCipher(String name, int number, TLSCipherSpec.keyStrength strength, boolean anonDH, boolean pfs, boolean rc4) {\r\n\t\tfinal TLSCipherSpec cipherSpec = new TLSCipherSpec(name, number, strength, anonDH, pfs, rc4);\r\n\t\tTLS_CIPHER_MAP.put(number, cipherSpec);\r\n\t\tTLS_CIPHERS.add(cipherSpec);\r\n\t}\r\n\t\r\n\tstatic private void addCipher(String name, byte[] number, SSLv2CipherSpec.keyStrength strength, boolean rc4) {\r\n\t\tfinal SSLv2CipherSpec spec = new SSLv2CipherSpec(name, number, strength, rc4);\r\n\t\tSSLv2_CIPHER_MAP.put(spec.getNum(), spec);\r\n\t\tSSLv2_CIPHERS.add(spec);\r\n\t}\r\n\t\r\n\t\r\n\t\r\n\tstatic {\r\n\t\t\r\n\t\t/* Initialize cipher list: http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml */\r\n\r\n\t\taddCipher(\"TLS_NULL_WITH_NULL_NULL\", 0x00, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_NULL_MD5\", 0x01, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_NULL_SHA\", 0x02, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_EXPORT_WITH_RC4_40_MD5\", 0x03, TLSCipherSpec.keyStrength.EXPORT, false, false, true);\r\n\t\taddCipher(\"TLS_RSA_WITH_RC4_128_MD5\", 0x04, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_RSA_WITH_RC4_128_SHA\", 0x05, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5\", 0x06, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_IDEA_CBC_SHA\", 0x07, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_EXPORT_WITH_DES40_CBC_SHA\", 0x08, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_DES_CBC_SHA\", 0x09, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_3DES_EDE_CBC_SHA\", 0x0A, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA\", 0x0B, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_DES_CBC_SHA\", 0x0C, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA\", 0x0D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA\", 0x0E, TLSCipherSpec.keyStrength.EXPORT, false, false,false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_DES_CBC_SHA\", 0x0F, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA\", 0x10, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA\", 0x11, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_DES_CBC_SHA\", 0x12, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA\", 0x013, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA\", 0x14, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_DES_CBC_SHA\", 0x15, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA\", 0x16, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_EXPORT_WITH_RC4_40_MD5\", 0x17, TLSCipherSpec.keyStrength.EXPORT, true, false, true);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_RC4_128_MD5\", 0x18, TLSCipherSpec.keyStrength.HIGH, true, false, true);\r\n\t\taddCipher(\"TLS_DH_Anon_EXPORT_WITH_DES40_CBC_SHA\", 0x19, TLSCipherSpec.keyStrength.EXPORT, true, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_DES_CBC_SHA\", 0x1A, TLSCipherSpec.keyStrength.LOW, true, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_3DES_EDE_CBC_SHA\", 0x1B, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_KRB5_WITH_DES_CBC_SHA\", 0x1E, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_WITH_3DES_EDE_CBC_SHA\", 0x1F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_WITH_RC4_128_SHA\", 0x20, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_KRB5_WITH_IDEA_CBC_SHA\", 0x21, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_WITH_DES_CBC_MD5\", 0x22, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_WITH_3DES_EDE_CBC_MD5\", 0x23, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_WITH_RC4_128_MD5\", 0x24, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_KRB5_WITH_IDEA_CBC_MD5\", 0x25, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA\", 0x26, TLSCipherSpec.keyStrength.LOW, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA\", 0x27, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_EXPORT_WITH_RC4_40_SHA\", 0x28, TLSCipherSpec.keyStrength.EXPORT, false, false, true);\r\n\t\taddCipher(\"TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5\", 0x29, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5\", 0x2A, TLSCipherSpec.keyStrength.EXPORT, false, false, false);\r\n\t\taddCipher(\"TLS_KRB5_EXPORT_WITH_RC4_40_MD5\", 0x2B, TLSCipherSpec.keyStrength.EXPORT, false, false, true);\r\n\t\taddCipher(\"TLS_PSK_WITH_NULL_SHA\", 0x2C, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_NULL_SHA\", 0x2D, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_NULL_SHA\", 0x2E, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_128_CBC_SHA\", 0x2F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_AES_128_CBC_SHA\", 0x30, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_AES_128_CBC_SHA\", 0x31, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_AES_128_CBC_SHA\", 0x32, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_128_CBC_SHA\", 0x33, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_AES_128_CBC_SHA\", 0x34, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_256_CBC_SHA\", 0x35, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_AES_256_CBC_SHA\", 0x36, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_AES_256_CBC_SHA\", 0x37, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_AES_265_CBC_SHA\", 0x38, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_256_CBC_SHA\", 0x39, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_AES_256_CBC_SHA\", 0x3A, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_NULL_SHA256\", 0x3B, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_128_CBC_SHA256\",  0x3C, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_256_CBC_SHA256\", 0x3D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_AES_128_CBC_SHA256\", 0x3E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_AES_128_CBC_SHA256\", 0x3F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_AES_128_CBC_SHA256\", 0x40, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_CAMELLIA_128_CBC_SHA\", 0x41, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA\", 0x42, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA\", 0x43, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA\", 0x44, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA\", 0x45, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_CAMELLIA_128_CBC_SHA\", 0x46, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256\", 0x67, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_AES_256_CBC_SHA256\", 0x68, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_AES_256_CBC_SHA256\", 0x69, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_AES_256_CBC_SHA256\", 0x6A, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_256_CBC_SHA256\", 0x6B, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_AES_128_CBC_SHA256\", 0x6C, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_AES_256_CBC_SHA256\", 0x6D, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_CAMELLIA_256_CBC_SHA\", 0x84, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA\", 0x85, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA\", 0x86, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA\", 0x87, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA\", 0x88, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_CAMELLIA_256_CBC_SHA\", 0x89, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_PSK_WITH_RC4_128_SHA\", 0x8A, TLSCipherSpec.keyStrength.HIGH, false, false, true); /* pre-shared key */\r\n\t\taddCipher(\"TLS_PSK_WITH_3DES_EDE_CBC_SHA\", 0x8B, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_128_CBC_SHA\", 0x8C, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_256_CBC_SHA\", 0x8D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_RC4_128_SHA\", 0x8E, TLSCipherSpec.keyStrength.HIGH, false, true, true);\r\n\t\taddCipher(\"DHE_PSK_WITH_3DES_EDE_CBC_SHA\", 0x8F, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_128_CBC_SHA\", 0x90, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_256_CBC_SHA\", 0x91, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_RC4_128_SHA\", 0x92, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA\", 0x93, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_AES_128_CBC_SHA\", 0x94, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_AES_256_CBC_SHA\", 0x95, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_SEED_CBC_SHA\", 0x96, TLSCipherSpec.keyStrength.HIGH, false, false, false); /* SEED / 128-bit key block cipher */\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_SEED_CBC_SHA\", 0x97, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_SEED_CBC_SHA\", 0x98, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_SEED_CBC_SHA\", 0x99, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_SEED_CBC_SHA\", 0x9A, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_SEED_CBC_SHA\", 0x9B, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_128_GCM_SHA256\", 0x9C, TLSCipherSpec.keyStrength.HIGH, false, false, false); /* Galois counter mode */\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_256_GCM_SHA384\", 0x9D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_128_GCM_SHA256\", 0x9E, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_256_GCM_SHA384\", 0x9F, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_AES_128_GCM_SHA256\", 0xA0, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_AES_256_GCM_SHA384\", 0xA1, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_AES_128_GCM_SHA256\", 0xA2, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_AES_256_GCM_SHA384\", 0xA3, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_AES_128_GCM_SHA256\", 0xA4, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_AES_256_GCM_SHA384\", 0xA5, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_AES_128_GCM_SHA256\", 0xA6, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_DH_anon_WITH_AES_256_GCM_SHA384\", 0xA7, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_128_GCM_SHA256\", 0xA8, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_256_GCM_SHA384\", 0xA9, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_128_GCM_SHA256\", 0xAA, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_256_GCM_SHA384\", 0xAB, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_AES_128_GCM_SHA256\", 0xAC, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_AES_256_GCM_SHA384\", 0xAD, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_128_CBC_SHA256\", 0xAE, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_256_CBC_SHA384\", 0xAF, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_PSK_WITH_NULL_SHA256\", 0xB0, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_NULL_SHA384\", 0xB1, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_128_CBC_SHA256\", 0xB2, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_256_CBC_SHA384\", 0xB3, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_NULL_SHA256\", 0xB4, TLSCipherSpec.keyStrength.NONE, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_NULL_SHA384\", 0xB5, TLSCipherSpec.keyStrength.NONE, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_AES_128_CBC_SHA256\", 0xB6, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_AES_256_CBC_SHA384\", 0xB7, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_NULL_SHA256\", 0xB8, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_NULL_SHA384\", 0xB9, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xBA, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256\", 0xBB, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xBC, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256\", 0xBD, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xBE, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_CAMELLIA_128_CBC_SHA256\", 0xBF, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256\", 0xC0, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256\", 0xC1, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256\", 0xC2, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256\", 0xC3, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256\", 0xC4, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256\", 0xC5, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\t/* TODO: 0xFF TLS_EMPTY_RENEGOTIATION_INFO_SCSV */\r\n\t\t\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_NULL_SHA\", 0xC001, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_RC4_128_SHA\", 0xC002, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA\", 0xC003, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA\", 0xC004, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA\", 0xC005, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_NULL_SHA\", 0xC006, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA\", 0xC007, TLSCipherSpec.keyStrength.HIGH, false, true, true);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA\", 0xC008, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA\", 0xC009, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA\", 0xC00A, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_NULL_SHA\", 0xC00B, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_RC4_128_SHA\", 0xC00C, TLSCipherSpec.keyStrength.HIGH, false, false, true);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA\", 0xC00D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_AES_128_CBC_SHA\", 0xC00E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_AES_256_CBC_SHA\", 0xC00F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_NULL_SHA\", 0xC010, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_RC4_128_SHA\", 0xC011, TLSCipherSpec.keyStrength.HIGH, false, true, true);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA\", 0xC012, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA\", 0xC013, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA\", 0xC014, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_Anon_WITH_NULL_SHA\", 0xC015, TLSCipherSpec.keyStrength.NONE, true, false, false);\r\n\t\taddCipher(\"TLS_ECDH_Anon_WITH_RC4_128_SHA\", 0xC016, TLSCipherSpec.keyStrength.HIGH, true, false, true);\r\n\t\taddCipher(\"TLS_ECDH_Anon_WITH_3DES_EDE_CBC_SHA\", 0xC017, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_ECDH_Anon_WITH_AES_128_CBC_SHA\", 0xC018, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_ECDH_Anon_WITH_AES_256_CBC_SHA\", 0xC019, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA\", 0xC01A, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA\", 0xC01B, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA\", 0xC01C, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_WITH_AES_128_CBC_SHA\", 0xC01D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA\", 0xC01E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA\", 0xC01F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_WITH_AES_256_CBC_SHA\", 0xC020, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA\", 0xC021, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA\", 0xC022, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256\", 0xC023, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384\", 0xC024, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256\", 0xC025, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384\", 0xC026, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256\", 0xC027, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384\", 0xC028, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256\", 0xC029, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384\", 0xC02A, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256\", 0xC02B, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384\", 0xC02C, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256\", 0xC02D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384\", 0xC02E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\", 0xC02F, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384\", 0xC030, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256\", 0xC031, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384\", 0xC032, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_RC4_128_SHA\", 0xC033, TLSCipherSpec.keyStrength.HIGH, false, true, true);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA\", 0xC034, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA\", 0xC035, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA\", 0xC036, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256\", 0xC037, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384\", 0xC038, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_NULL_SHA\", 0xC039, TLSCipherSpec.keyStrength.NONE, false, false, false);    /* EC DHE/PSK + null cipher */\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_NULL_SHA256\", 0xC03A, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_NULL_SHA384\", 0xC03B, TLSCipherSpec.keyStrength.NONE, false, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_ARIA_128_CBC_SHA256\", 0xC03C, TLSCipherSpec.keyStrength.HIGH, false, false, false); /* ARIA */\r\n\t\taddCipher(\"TLS_RSA_WITH_ARIA_256_CBC_SHA384\", 0xC03D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256\", 0xC03E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384\", 0xC03F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256\", 0xC040, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384\", 0xC041, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256\", 0xC042, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384\", 0xC043, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256\", 0xC044, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384\", 0xC045, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_ARIA_128_CBC_SHA256\", 0xC046, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_ARIA_256_CBC_SHA384\", 0xC047, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256\", 0xC048, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384\", 0xC049, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256\", 0xC04A, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384\", 0xC04B, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256\", 0xC04C, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384\", 0xC04D, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256\", 0xC04E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384\", 0xC04F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_ARIA_128_GCM_SHA256\", 0xC050, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_ARIA_256_GCM_SHA384\", 0xC051, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256\", 0xC052, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384\", 0xC053, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256\", 0xC054, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384\", 0xC055, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256\", 0xC056, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384\", 0xC057, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256\", 0xC058, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384\", 0xC059, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_ARIA_128_GCM_SHA256\", 0xC05A, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_ARIA_256_GCM_SHA384\", 0xC05B, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256\", 0xC05C, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384\", 0xC05D, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256\", 0xC05E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384\", 0xC05F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256\", 0xC060, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384\", 0xC061, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256\", 0xC062, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384\", 0xC063, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_ARIA_128_CBC_SHA256\", 0xC064, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_ARIA_256_CBC_SHA384\", 0xC065, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256\", 0xC066, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384\", 0xC067, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256\", 0xC068, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384\", 0xC069, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_ARIA_128_GCM_SHA256\", 0xC06A, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_ARIA_256_GCM_SHA384\", 0xC06B, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256\", 0xC06C, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384\", 0xC06D, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256\", 0xC06E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384\", 0xC06F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256\", 0xC070, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384\", 0xC071, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xC072, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384\", 0xC073, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xC074, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384\", 0xC075, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xc076, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384\", 0xC077, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256\", 0xC078, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384\", 0xC079, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC07A, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC07B, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC07C, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC07D, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC07E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC07F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256\", 0xC080, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384\", 0xC081, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256\", 0xC082, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384\", 0xC083, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_CAMELLIA_128_GCM_SHA256\", 0xC084, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\taddCipher(\"TLS_DH_Anon_WITH_CAMELLIA_256_GCM_SHA384\", 0xC085, TLSCipherSpec.keyStrength.HIGH, true, false, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC086, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC087, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC088, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC089, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC08A, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC08B, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256\", 0xC08C, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384\", 0xC08D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256\", 0xC08E, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384\", 0xC08F, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256\", 0xC090, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384\", 0xC091, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256\", 0xC092, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384\", 0xC093, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256\", 0xC094, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384\", 0xC095, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256\", 0xC096, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384\", 0xC097, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256\", 0xC098, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384\", 0xC099, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256\", 0xC09A, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384\", 0xC09B, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_128_CCM\", 0xC09C, TLSCipherSpec.keyStrength.HIGH, false, false, false); /* AES CCM */\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_256_CCM\", 0xC09D, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_128_CCM\", 0xC09E, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_256_CCM\", 0xC09F, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\t\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_128_CCM_8\", 0xC0A0, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_RSA_WITH_AES_256_CCM_8\", 0xC0A1, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_128_CCM_8\", 0xC0A2, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_RSA_WITH_AES_256_CCM_8\", 0xC0A3, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_128_CCM\", 0xC0A4, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_256_CCM\", 0xC0A5, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_128_CCM\", 0xC0A6, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_DHE_PSK_WITH_AES_256_CCM\", 0xC0A7, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_128_CCM_8\", 0xC0A8, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_WITH_AES_256_CCM_8\", 0xC0A9, TLSCipherSpec.keyStrength.HIGH, false, false, false);\r\n\t\taddCipher(\"TLS_PSK_DHE_WITH_AES_128_CCM_8\", 0xC0AA, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\taddCipher(\"TLS_PSK_DHE_WITH_AES_256_CCM_8\", 0xC0AB, TLSCipherSpec.keyStrength.HIGH, false, true, false);\r\n\t\t\r\n\t\t/* 0xC0, 0xAC-0xFF unassigned */\r\n\t\t/* 0xC1-FD, * unassigned */\r\n\t\t/* 0xFE, 0xFE-FF reserved to avoid conflicts */\r\n\t\t/* 0xFF, 0x00-FF reserved for private use */\r\n\t    addCipher(\"SSL2_DES_192_EDE3_CBC_WITH_MD5\", new byte[]{0x07, 0x00, (byte)0xc0}, SSLv2CipherSpec.keyStrength.HIGH, false);\r\n\t    addCipher(\"SSL2_DES_192_EDE3_CBC_WITH_SHA\", new byte[]{0x07, 0x01, (byte)0xc0}, SSLv2CipherSpec.keyStrength.HIGH, false);\r\n\t    addCipher(\"SSL2_DES_64_CBC_WITH_MD5\", new byte[]{0x06, 0x00, 0x40}, SSLv2CipherSpec.keyStrength.LOW, false);\r\n\t    addCipher(\"SSL2_DES_64_CBC_WITH_SHA\", new byte[]{0x06, 0x01, 0x40}, SSLv2CipherSpec.keyStrength.LOW, false);\r\n\t    addCipher(\"SSL2_IDEA_128_CBC_WITH_MD5\", new byte[]{0x05, 0x00, (byte) 0x80}, SSLv2CipherSpec.keyStrength.HIGH, false);\r\n\t    addCipher(\"SSL2_RC2_CBC_WITH_MD5\", new byte[]{0x03, 0x00, (byte) 0x80}, SSLv2CipherSpec.keyStrength.HIGH, false);\r\n\t    addCipher(\"SSL2_RC4_128_WITH_MD5\", new byte[]{0x01, 0x00, (byte) 0x80}, SSLv2CipherSpec.keyStrength.HIGH, true);\r\n\t    addCipher(\"SSL2_DES_64_CBC_WITH_MD5\", new byte[]{0x06, 0x00, 0x40}, SSLv2CipherSpec.keyStrength.LOW, false);\r\n\t    addCipher(\"SSL2_RC2_CBC_128_CBC_WITH_MD5\", new byte[]{0x04, 0x00, (byte)0x80}, SSLv2CipherSpec.keyStrength.HIGH, false);\r\n\t    addCipher(\"SSL2_RC4_128_EXPORT40_WITH_MD5\", new byte[]{0x02, 0x00, (byte)0x80}, SSLv2CipherSpec.keyStrength.EXPORT, true);\r\n\t    addCipher(\"SSL2_NULL_WITH_MD5\", new byte[]{0x00, 0x00, 0x00}, SSLv2CipherSpec.keyStrength.NONE, false);\r\n\t    addCipher(\"SSL2_NULL\", new byte[]{(byte)0xff, 0x08, 0x10}, SSLv2CipherSpec.keyStrength.NONE, false);\r\n\t    addCipher(\"SSL2_DES_64_CFB64_WITH_MD5_1\", new byte[]{(byte)0xff, 0x08, 0x00}, SSLv2CipherSpec.keyStrength.LOW, false);\r\n\t    addCipher(\"SSL2_RC4_64_WITH_MD5\", new byte[]{0x08, 0x00, (byte)0x80}, SSLv2CipherSpec.keyStrength.LOW, true);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/ProbeBase.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\r\n\r\nimport java.io.Closeable;\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\nimport java.io.OutputStream;\r\nimport java.net.InetSocketAddress;\r\nimport java.net.Socket;\r\nimport java.net.UnknownHostException;\r\nimport java.nio.ByteBuffer;\r\nimport java.util.concurrent.Callable;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\n\r\nimport javax.net.SocketFactory;\r\n\r\nabstract public class ProbeBase<T> implements Callable<T>, Runnable {\r\n\tprivate final static Logger logger = Logger.getLogger(ProbeBase.class.getName());\r\n\tprivate final SocketFactory socketFactory;\r\n\tprivate Socket socket;\r\n\tprivate InputStream input;\r\n\tprivate OutputStream output;\r\n\t\r\n\t\r\n\t\r\n\tprotected final SSLServerScanResult scanResult;\r\n\t\r\n\tProbeBase(SSLServerScanResult scanResult) {\r\n\t\tthis(scanResult, SocketFactory.getDefault());\r\n\t}\r\n\r\n\tProbeBase(SSLServerScanResult scanResult, SocketFactory socketFactory) {\r\n\t\tthis.scanResult = scanResult;\r\n\t\tthis.scanResult.incrementOutstandingProbeCount();\r\n\t\tthis.socketFactory = socketFactory;\r\n\t}\r\n\t\r\n\r\n\t\r\n\tprotected void skip(ByteBuffer bb, int n) {\r\n\t\tbb.position(bb.position() + n);\r\n\t}\r\n\r\n\tprotected void hexDump(ByteBuffer bb) {\r\n\t\tint n = 0;\r\n\t\twhile(bb.hasRemaining()) {\r\n\t\t\tint b = bb.get() & 0xFF;\r\n\t\t\tn += 1;\r\n\t\t\tif(n % 16 == 0) {\r\n\t\t\t\tSystem.out.print(\"\\n\");\r\n\t\t\t}\r\n\t\t\tSystem.out.printf(\"%02X \", b);\r\n\t\t}\r\n\t\tSystem.out.println();\r\n\t\tbb.rewind();\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void run() {\r\n\t\ttry {\r\n\t\t\tcall();\r\n\t\t} catch (Exception e) {\r\n\t\t\tlogger.log(Level.WARNING, \"Unexpected exception during probe: \"+ e, e);\r\n\t\t}\r\n\t}\r\n\r\n\t@Override\r\n\tpublic T call() throws Exception {\r\n\t\ttry {\r\n\t\t\treturn runProbe();\r\n\t\t} catch (UnknownHostException e) {\r\n\t\t\tlogger.warning(\"Unknown host exception executing probe.\");\r\n\t\t\tscanResult.setTLSProbeFailure(\"Unknown host\");\r\n\t\t\treturn null;\r\n\t\t} catch (IOException e) {\r\n\t\t\tlogger.warning(\"I/O error while executing probe: \"+ e);\r\n\t\t\t//scanResult.setTLSProbeFailure(\"I/O error: \"+ e);\r\n\t\t\treturn null;\r\n\t\t} finally {\r\n\t\t\tscanResult.decrementOutstandingProbeCount();\r\n\t\t\tif(socket != null) {\r\n\t\t\t\tcloseQuietly(socket);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tprotected abstract T runProbe() throws Exception;\r\n\r\n\tprotected void closeConnection() {\r\n\t\tif(socket != null) {\r\n\t\t\t\r\n\t\t\tcloseQuietly(socket);\r\n\t\t\tsocket = null;\r\n\t\t\tinput = null;\r\n\t\t\toutput = null;\r\n\t\t}\r\n\t}\r\n\r\n\tprotected Socket getSocket() throws UnknownHostException, IOException {\r\n\t\tif(socket == null) {\r\n\t\t\tif (System.getProperty(\"socksEnabled\") != null) {\r\n\t\t\t\tif (System.getProperty(\"socksEnabled\").equals(\"true\")) {\r\n\t\t\t\t\tInetSocketAddress unresolved = InetSocketAddress.createUnresolved(scanResult.getTargetHost(), scanResult.getTargetPort());\r\n\t\t\t\t\tsocket = socketFactory.createSocket();\r\n\t\t\t\t\tsocket.connect(unresolved);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tsocket = socketFactory.createSocket(scanResult.getTargetHost(), scanResult.getTargetPort());\r\n\t\t\t\t}\r\n\t\t\t} else\r\n\t\t\t{\r\n\t\t\t\tsocket = socketFactory.createSocket(scanResult.getTargetHost(), scanResult.getTargetPort());\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn socket;\r\n\t}\r\n\t\r\n\tprotected InputStream getInputStream() throws IOException {\r\n\t\tif(input == null) {\r\n\t\t\tinput = getSocket().getInputStream();\r\n\t\t}\r\n\t\treturn input;\r\n\t}\r\n\t\r\n\tprotected OutputStream getOutputStream() throws IOException {\r\n\t\tif(output == null) {\r\n\t\t\toutput = getSocket().getOutputStream();\r\n\t\t}\r\n\t\treturn output;\r\n\t}\r\n\t\r\n\tprotected boolean readAll(byte[] buffer) throws IOException {\r\n\t\tint remaining = buffer.length;\r\n\t\tint offset = 0;\r\n\t\twhile(remaining > 0) {\r\n\t\t\tint n = getInputStream().read(buffer, offset, remaining);\r\n\t\t\tif(n == -1) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tremaining -= n;\r\n\t\t\toffset += n;\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\n\tprivate void closeQuietly(Socket socket) {\r\n\t\ttry {\r\n\t\t\tsocket.close();\r\n\t\t} catch (IOException e) {}\r\n\t}\r\n\t\r\n}\r\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/SSL2Protocol.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\r\n\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\nimport java.io.OutputStream;\r\nimport java.nio.ByteBuffer;\r\nimport java.util.Arrays;\r\nimport java.util.List;\r\n\r\npublic class SSL2Protocol {\r\n\t\r\n\tpublic final static int SSLV2_CLIENT_HELLO = 0x01;\r\n\tpublic final static int SSLV2_SERVER_HELLO = 0x04;\r\n\t\r\n\tprivate final static int SSLV2_HEADER_LENGTH = 2;\r\n\tprivate final static int SSLV2_VERSION = 0x0002;\r\n\tprivate final static int SSLV2_CHALLENGE_LENGTH = 0x10;\r\n\tprivate final static int SSLV2_CLIENT_HELLO_BASE_LENGTH = 9 + SSLV2_CHALLENGE_LENGTH;\r\n\t\r\n\tprivate final InputStream input;\r\n\tprivate final OutputStream output;\r\n\t\r\n\tpublic SSL2Protocol(InputStream input, OutputStream output) {\r\n\t\tthis.input = input;\r\n\t\tthis.output = output;\r\n\t}\r\n\t\r\n\tpublic ByteBuffer getNextHandshakeMessage() throws IOException {\r\n\t\tfinal int len = readRecordLength();\r\n\t\tif(len == -1) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tfinal ByteBuffer buffer = ByteBuffer.allocate(len);\r\n\t\tif(!readAll(buffer)) {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\treturn buffer;\r\n\t}\r\n\r\n\tprivate int readRecordLength() throws IOException {\r\n\t\tfinal byte[] bs = new byte[2];\r\n\t\tif(input.read(bs, 0, bs.length) != bs.length) {\r\n\t\t\treturn -1;\r\n\t\t}\r\n\t\treturn ((bs[0] & 0x7F) << 8) | (bs[1] & 0xFF);\r\n\t}\r\n\t\r\n\tprivate boolean readAll(ByteBuffer buffer) throws IOException {\r\n\t\twhile(buffer.hasRemaining()) {\r\n\t\t\tint n = input.read(buffer.array(), buffer.position(), buffer.remaining());\r\n\t\t\tif(n == -1) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tbuffer.position(buffer.position() + n);\r\n\t\t}\r\n\t\tbuffer.rewind();\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\tpublic void sendClientHello(List<SSLv2CipherSpec> ciphers) throws IOException {\r\n\t\tfinal ByteBuffer hello = createClientHello(ciphers);\r\n\t\twriteAll(hello);\r\n\t}\r\n\r\n\tprivate ByteBuffer createClientHello(List<SSLv2CipherSpec> ciphers) {\r\n\t\tfinal int length = SSLV2_HEADER_LENGTH + SSLV2_CLIENT_HELLO_BASE_LENGTH + (3 * ciphers.size());\r\n\t\tfinal ByteBuffer buffer = ByteBuffer.allocate(length);\r\n\t\tbuffer.putShort((short) (0x8000 | (length - SSLV2_HEADER_LENGTH)));\r\n\t\t\r\n\t\tbuffer.put((byte) SSLV2_CLIENT_HELLO);\r\n\t\tbuffer.putShort((short) SSLV2_VERSION);\r\n\t\tbuffer.putShort((short) (ciphers.size() * 3));\r\n\t\tbuffer.putShort((short) 0); // SID length\r\n\t\tbuffer.putShort((short) SSLV2_CHALLENGE_LENGTH);\r\n\t\tfor(SSLv2CipherSpec c: ciphers) {\r\n\t\t\tbuffer.put(c.getNumber());\r\n\t\t}\r\n\t\tfinal byte[] challenge = new byte[SSLV2_CHALLENGE_LENGTH];\r\n\t\tArrays.fill(challenge, (byte)0x01);\r\n\t\tbuffer.put(challenge);\r\n\t\tbuffer.flip();\r\n\t\treturn buffer;\r\n\t}\r\n\t\r\n\tprivate void writeAll(ByteBuffer buffer) throws IOException {\r\n\t\toutput.write(buffer.array(), buffer.position(), buffer.remaining());\r\n\t\tbuffer.position(buffer.position() + buffer.remaining());\r\n\t\toutput.flush();\r\n\t}\r\n}\r\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/SSLScanTaskManager.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.util.List;\nimport java.util.concurrent.CompletionService;\nimport java.util.concurrent.ExecutionException;\nimport java.util.concurrent.ExecutorCompletionService;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Future;\nimport java.util.concurrent.TimeUnit;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.internal.sslprobe.SSLServerScanResult.Flag;\n\n\npublic class SSLScanTaskManager {\n\tprivate final static Logger logger = Logger.getLogger(SSLScanTaskManager.class.getName());\n\t\n\tprivate final ExecutorService executor;\n\t   \n\tprivate static int CIPHERS_PER_REQUEST = 300;\n\t\n\tpublic SSLScanTaskManager(ExecutorService executor) {\n\t\tthis.executor = executor;\n\t}\n\n\tpublic void shutdown() throws InterruptedException {\n\t\texecutor.shutdown();\n\t\texecutor.awaitTermination(120,  TimeUnit.SECONDS);\n\t}\n\n\tpublic SSLServerScanResult scanServer(String host, int port) throws InterruptedException {\n\t\tlogger.info(\"Starting scan of \"+ host + \":\" + port);\n\t\tfinal SSLServerScanResult scanResult = new SSLServerScanResult(host, port);\n\t\t\t\n\t\tif(probeServerSupportedTLSCiphers(scanResult)) {\n\t\t\tprobeSupportedVersions(scanResult);\n\t\t\tprobeCipherPreference(scanResult);\n\t\t}\n\t\t\n\t\tprobeSSLv2Support(scanResult);\n\n\t\tscanResult.waitForOutstandingProbes();\n\t\t\n\t\treturn scanResult;\n\t}\n\t\t\n\tprivate void probeSSLv2Support(SSLServerScanResult scanResult) {\n\t\texecutor.execute(new SSLv2Probe(scanResult));\n\t}\n\t\n\tprivate boolean probeServerSupportedTLSCiphers(SSLServerScanResult scanResult) {\n\t\t\n\t\tfinal CompletionService<TLSProbeResult> completionService = new ExecutorCompletionService<TLSProbeResult>(executor);\n\t\t\n\t\tint outstandingProbes = sendInitialCipherProbes(completionService, scanResult);\n\n\t\twhile(outstandingProbes > 0) {\n\t\t\tTLSProbeResult result = getNextCompletedCipherProbe(completionService);\n\t\t\tif(result == null) {\n\t\t\t\treturn false;\n\t\t\t} else if(result.isError()) {\n\t\t\t\tscanResult.setTLSProbeFailure(result.getErrorMessage());\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(result == null || result.isError()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\toutstandingProbes -= 1;\n\t\t\tif(processTLSCipherProbeResult(completionService, scanResult, result)) {\n\t\t\t\toutstandingProbes += 1;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate int sendInitialCipherProbes(CompletionService<TLSProbeResult> cs, SSLServerScanResult scanResult) {\n\t\tint taskCount = 0;\n\t\tfor(List<TLSCipherSpec> ciphers: CipherSuites.paritionTLSCiphers(CIPHERS_PER_REQUEST)) {\n\t\t\ttaskCount += 1;\n\t\t\tTLSCipherProbeTask task = new TLSCipherProbeTask(scanResult, ciphers);\n\t\t\tcs.submit(task);\n\t\t}\n\t\treturn taskCount;\n\t}\n\t\n\tprivate TLSProbeResult getNextCompletedCipherProbe(CompletionService<TLSProbeResult> cs) {\n\t\ttry {\n\t\t\tfinal Future<TLSProbeResult> future = cs.take();\n\t\t\treturn future.get();\n\t\t} catch (InterruptedException e) {\n\t\t\tThread.currentThread().interrupt();\n\t\t\treturn null;\n\t\t} catch (ExecutionException e) {\n\t\t\tlogger.warning(\"Unexpected exception encountered sending TLS cipher probe: \"+ e.getCause());\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate boolean processTLSCipherProbeResult(CompletionService<TLSProbeResult> completionService, SSLServerScanResult scanResult, TLSProbeResult probeResult) {\n\t\tif(probeResult.getAcceptedCipher() == null) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tscanResult.addServerTLSCipher(probeResult.getAcceptedCipher());\n\t\tfor(CertificateAnalyzer probeCert: probeResult.getServerCertificates()) {\n\t\t\tscanResult.addServerCertificate(probeCert);\n\t\t}\n\t\t\t\n\t\tif(probeResult.getTLSCompressionSupport()) {\n\t\t\tscanResult.setFlag(Flag.TLS_COMPRESSION);\n\t\t}\n\n\t\tif(probeResult.getRejectedCiphers().size() == 0) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tfinal TLSCipherProbeTask task = new TLSCipherProbeTask(scanResult, probeResult.getRejectedCiphers());\n\t\tcompletionService.submit(task);\n\t\treturn true;\n\t}\n\t\n\t/* Enumerate supported versions of TLS + SSLv3 */\n\tprivate void probeSupportedVersions(SSLServerScanResult scanResult) {\n\t\tfinal List<TLSCipherSpec> serverTLSCiphers = scanResult.getServerTLSCiphers();\n\t\t\n\t\tif (!serverTLSCiphers.isEmpty()) {\n\t\t\tfor(Runnable task: TLSVersionProbe.getVersionProbes(scanResult)) {\n\t\t\t\texecutor.execute(task);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void probeCipherPreference(SSLServerScanResult scanResult) {\n\t\texecutor.execute(new TLSServerCipherPreferenceProbe(scanResult));\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/SSLServerScanResult.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.EnumSet;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport com.subgraph.vega.internal.sslprobe.TLSCipherSpec.keyStrength;\n\t\npublic class SSLServerScanResult {\n\n\tprivate final String targetHost;\n\tprivate final int targetPort;\n\t\n\tpublic enum Flag { \n\t\tPFS_SUPPORTED, PFS_SERVER_PREFERENCE, RC4_SERVER_PREFERENCE, RC4_SUPPORTED, WEAK_CIPHERS_SUPPORTED, \n\t\tEXPORT_CIPHERS_SUPPORTED, TLS_COMPRESSION, ANON_DH, SMALL_RSA_KEY, SELF_SIGNED_CERTIFICATE, \n\t\tSERVER_PREFERENCE, SSLV2, SSLV3, TLS1, TLS11, TLS12, MD5_SIGNED_CERTIFICATE, SHA1_SIGNED_CERTIFICATE\n\t};\n\t\t\n\tprivate Set<Flag> flags = Collections.synchronizedSet(EnumSet.noneOf(Flag.class));\n\t\n\tprivate boolean TLSProbeFailure;\n\tprivate String errorMessage;\n\t\n\tprivate Set<CertificateAnalyzer> certs;\n\tprivate List<TLSCipherSpec> serverTLSCiphers;\n\tprivate List <SSLv2CipherSpec> serverSSLv2Ciphers;\n\tprivate List<TLSCipherSpec> serverPreferenceOrder;\n\t\n\tprivate int outstandingProbeCount;\n\t\n\tSSLServerScanResult(String targetHost, int targetPort) {\n\t\tthis.targetHost = targetHost;\n\t\tthis.targetPort = targetPort;\n\t\tthis.certs = new HashSet<CertificateAnalyzer>();\n\t\tthis.serverTLSCiphers = new ArrayList<TLSCipherSpec>();\n\t}\n\n\tpublic String getTargetHost() {\n\t\treturn targetHost;\n\t}\n\t\n\tpublic int getTargetPort() {\n\t\treturn targetPort;\n\t}\n\n\tpublic synchronized void setTLSProbeFailure(String message) {\n\t\terrorMessage = message;\n\t\tTLSProbeFailure = true;\n\t}\n\t\n\tpublic synchronized void setServerTLSCiphersServerPreferenceOrder(List<TLSCipherSpec> ciphers) {\n\t\tthis.serverPreferenceOrder = ciphers;\n\t}\t\n\tpublic synchronized void setServerSSLv2Ciphers(List<SSLv2CipherSpec> ciphers) {\n\t\tthis.serverSSLv2Ciphers = ciphers;\n\t}\n\t\n\tpublic void addServerTLSCipher(TLSCipherSpec cipher) {\n\t\tanalyzeCipher(cipher);\n\t\tserverTLSCiphers.add(cipher);\n\t}\n\t\n\tpublic List<TLSCipherSpec> getServerTLSCiphers() {\n\t\treturn Collections.unmodifiableList(new ArrayList<TLSCipherSpec>(serverTLSCiphers));\n\t}\n\t\n\t\n\tpublic void addServerCertificate(CertificateAnalyzer certificate) {\n\t\tif(certs.add(certificate)) {\n\t\t\tanalyzeCertificate(certificate);\n\t\t}\n\t}\n\n\tprivate void analyzeCipher(TLSCipherSpec cipher) {\n\t\tif(cipher.getStrength() == keyStrength.EXPORT) {\n\t\t\tflags.add(Flag.EXPORT_CIPHERS_SUPPORTED);\n\t\t} else if(cipher.getStrength() == keyStrength.LOW) {\n\t\t\tflags.add(Flag.WEAK_CIPHERS_SUPPORTED);\n\t\t}\n\t\tif(cipher.isAnonDH()) {\n\t\t\tflags.add(Flag.ANON_DH);\n\t\t}\n\t\tif(cipher.isRC4()) {\n\t\t\tflags.add(Flag.RC4_SUPPORTED);\n\t\t}\n\t\tif(cipher.isPFS()){\n\t\t\tflags.add(Flag.PFS_SUPPORTED);\n\t\t}\n\t}\n\n\tprivate void analyzeCertificate(CertificateAnalyzer certificate) {\n\t\tif(certificate.selfSigned()) {\n\t\t\tflags.add(Flag.SELF_SIGNED_CERTIFICATE);\n\t\t}\n\n\t\tif(certificate.isRSA() && certificate.getRSAModulusBitLength() <= 1024) {\n\t\t\tflags.add(Flag.SMALL_RSA_KEY);\n\t\t}\n\t\t\n\t\tif(certificate.isSignedMD5()) {\n\t\t\tflags.add(Flag.MD5_SIGNED_CERTIFICATE);\n\t\t}\n\t\t\n\t\tif (certificate.isSignedSHA1()) {\n\t\t\tflags.add(Flag.SHA1_SIGNED_CERTIFICATE);\n\t\t}\n\t}\n\t\n\tpublic synchronized void setServerTLSCiphers(ArrayList<TLSCipherSpec> ciphers) {\n\t\tthis.serverTLSCiphers = ciphers;\n\t}\n\t\n\tpublic void setFlag(Flag flag) {\n\t\tflags.add(flag);\n\t}\n\n\tpublic boolean isSet(Flag flag) {\n\t\treturn flags.contains(flag);\n\t}\n\t\n\tpublic boolean getTLSProbeFailure() {\n\t\treturn this.TLSProbeFailure;\n\t}\n\t\n\tpublic String getErrorMessage() {\n\t\treturn errorMessage;\n\t}\n\t\n\tpublic List<TLSCipherSpec> getServerTLSCiphersServerPreferenceOrder() {\n\t\treturn serverPreferenceOrder;\n\t}\n\t\n\tpublic Collection<CertificateAnalyzer> getServerCertificates() {\n\t\treturn certs;\n\t}\n\t\n\tpublic List<SSLv2CipherSpec> getServerSSLv2Ciphers() {\n\t\treturn serverSSLv2Ciphers;\n\t}\n\t\n\tpublic synchronized void incrementOutstandingProbeCount() {\n\t\toutstandingProbeCount += 1;\n\t}\n\t\n\tpublic synchronized void decrementOutstandingProbeCount() {\n\t\toutstandingProbeCount -= 1;\n\t\tif(outstandingProbeCount == 0) {\n\t\t\tnotifyAll();\n\t\t}\t\t\t\n\t}\n\t\n\tpublic synchronized void waitForOutstandingProbes() throws InterruptedException {\n\t\twhile(outstandingProbeCount > 0) {\n\t\t\tthis.wait();\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/SSLv2CipherSpec.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\npublic class SSLv2CipherSpec {\n\n\tpublic enum keyStrength { HIGH, LOW, EXPORT, NONE };\n\n\tprivate String name;\n\tprivate byte[] number;\n\tprivate int num;\n\tprivate keyStrength strength;\n\tprivate boolean RC4;\n\t\n\tSSLv2CipherSpec(String name, byte[] number, keyStrength strength, boolean RC4) {\n\t\tthis.setNumber(number);\n\t\tthis.setName(name);\n\t\tthis.setStrength(strength);\n\t\tthis.setNum((number[2] & 0xFF) | ((number[1] & 0xFF) << 8) | ((number[0] & 0x0F) << 16));\n\t\tthis.setRC4(RC4);\n\t}\n\n\tpublic int getNum() {\n\t\treturn num;\n\t}\n\n\tpublic void setNum(int num) {\n\t\tthis.num = num;\n\t}\n\n\tpublic byte[] getNumber() {\n\t\treturn number;\n\t}\n\n\tpublic void setNumber(byte[] number) {\n\t\tthis.number = number;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic keyStrength getStrength() {\n\t\treturn strength;\n\t}\n\n\tpublic void setStrength(keyStrength strength) {\n\t\tthis.strength = strength;\n\t}\n\n\tpublic boolean isRC4() {\n\t\treturn RC4;\n\t}\n\n\tpublic void setRC4(boolean rC4) {\n\t\tRC4 = rC4;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/SSLv2Probe.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.io.IOException;\nimport java.nio.ByteBuffer;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport javax.security.cert.CertificateException;\nimport javax.security.cert.X509Certificate;\n\nimport com.subgraph.vega.internal.sslprobe.SSLServerScanResult.Flag;\n\npublic class SSLv2Probe extends ProbeBase<Void> {\n\n\tprivate final static Logger logger = Logger.getLogger(SSLv2Probe.class.getName());\n\t\n\tSSLv2Probe(SSLServerScanResult scanResult) {\n\t\tsuper(scanResult);\n\t}\n\t\n\tpublic Void runProbe() throws IOException {\n\t\tfinal SSL2Protocol proto = new SSL2Protocol(getInputStream(), getOutputStream());\n\t\tproto.sendClientHello(CipherSuites.getV2CipherSuites());\n\t\tfinal ByteBuffer msg = proto.getNextHandshakeMessage();\n\t\tif(msg != null) {\n\t\t\tprocessResponse(msg);\n\t\t} else {\n\t\t\tlogger.warning(\"Got EOF receiving SSLv2 Server Hello message\");\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate void processResponse(ByteBuffer msg) {\n\t\tint type = msg.get() & 0xFF;\n\t\tif(type != SSL2Protocol.SSLV2_SERVER_HELLO) {\n\t\t\tlogger.warning(\"Expecting SSLv2 Server Hello message (type = 0x04), but got type = \"+ type);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tmsg.get();      // session id hit\n\t\tmsg.get();      // certificate type\n\t\tmsg.getShort(); // version\n\t\tint certificateLength = msg.getShort() & 0xFFFF;\n\t\tint ciphersLength = msg.getShort() & 0xFFFF;\n\t\tmsg.getShort(); // connection id length\n\n\t\tprocessCertificate(msg, certificateLength);\n\t\tprocessCiphers(msg, ciphersLength);\n\t}\n\n\tprivate void processCertificate(ByteBuffer msg, int length) {\n\t\tfinal byte[] certData = new byte[length];\n\t\tmsg.get(certData);\n\t\tfinal CertificateAnalyzer cert = new CertificateAnalyzer();\n\t\ttry {\n\t\t\tfinal X509Certificate serverCertificate = X509Certificate.getInstance(certData);\n\t\t\tcert.addCert(serverCertificate);\n\t\t} catch (CertificateException e) {\n\t\t\tcert.setError(true);\n\t\t}\n\t\tscanResult.addServerCertificate(cert);\n\n\t}\n\t\n\tprivate void processCiphers(ByteBuffer msg, int length) {\n\t\tfinal List<SSLv2CipherSpec> ciphers = new ArrayList<SSLv2CipherSpec>();\n\t\tfor(int n = 0; n < length; n += 3) {\n\t\t\tint cc = unpackCipherConstant(msg);\n\t\t\tSSLv2CipherSpec spec = CipherSuites.lookupSSLv2Cipher(cc);\n\t\t\tif(spec != null) {\n\t\t\t\tciphers.add(spec);\n\t\t\t}\n\t\t}\n\t\tscanResult.setFlag(Flag.SSLV2);\n\t\tscanResult.setServerSSLv2Ciphers(ciphers);\n\t}\n\t\n\tprivate int unpackCipherConstant(ByteBuffer msg) {\n\t\tbyte[] bs = new byte[3];\n\t\tmsg.get(bs);\n\t\treturn ((bs[0] & 0xFF) << 16) | ((bs[1] & 0xFF) << 8) | (bs[2] & 0xFF); \n\t}\n}\n\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSAlertException.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\r\n\r\npublic class TLSAlertException extends Exception {\r\n\tprivate static final long serialVersionUID = 1L;\r\n\tprivate final int level;\r\n\tprivate final int description;\r\n\t\r\n\tpublic TLSAlertException(int level, int description) {\r\n\t\tthis.level = level;\r\n\t\tthis.description = description;\r\n\t}\r\n\t\r\n\tpublic int getLevel() {\r\n\t\treturn level;\r\n\t}\r\n\t\r\n\tpublic int getDescription() {\r\n\t\treturn description;\r\n\t}\r\n\t\r\n\tpublic String toString() {\r\n\t\treturn \"TLSAlertException(\"+ level + \", \"+ description + \")\";\r\n\t}\r\n}\r\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSCipherProbeTask.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.io.IOException;\nimport java.net.UnknownHostException;\nimport java.nio.ByteBuffer;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.concurrent.Callable;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport javax.security.cert.CertificateException;\nimport javax.security.cert.X509Certificate;\n\n\npublic class TLSCipherProbeTask extends ProbeBase<TLSProbeResult> implements Callable<TLSProbeResult> {\n\tprivate final Logger logger = Logger.getLogger(TLSCipherProbeTask.class.getName());\n\n\t\n\tprivate List<TLSCipherSpec> partition;  \n    \n\tTLSCipherProbeTask(SSLServerScanResult scanResult, List<TLSCipherSpec> partition) {\n\t\tsuper(scanResult);\n\t\tthis.partition = partition;\n\t}\n\t\n\t@Override\n\tpublic TLSProbeResult runProbe() throws Exception {\n\t\ttry {\n\t\t\tTLSProtocol proto = new TLSProtocol(getInputStream(), getOutputStream());\n\t\t\tproto.sendTLSClientHello(partition);\n\t\t\treturn analyzeServerResponses(proto);\n\t\t} catch (TLSAlertException e) {\n\t\t\tfinal TLSProbeResult result = new TLSProbeResult();\n\t\t\tresult.addCiphers(partition, null);\n\t\t\treturn result;\n\t\t} catch (UnknownHostException e) {\n\t\t\treturn createErrorResult(\"Unknown host\");\n\t\t} catch (IOException e) {\n\t\t\treturn createErrorResult(\"I/O error: \"+ e);\n\t\t}\n\t}\n\n\t\n\tprivate TLSProbeResult createErrorResult(String message) {\n\t\tfinal TLSProbeResult result = new TLSProbeResult();\n\t\tresult.setError(true, message);\n\t\treturn result;\n\t}\n\n\tprivate TLSProbeResult analyzeServerResponses(TLSProtocol proto) throws IOException, TLSAlertException {\n\t\tfinal TLSProbeResult result = new TLSProbeResult();\n\t\twhile(true) {\n\t\t\tByteBuffer msg = proto.getNextHandshakeMessage();\n\t\t\tif(msg == null) {\n\t\t\t\t//result.setError(true, \"EOF received reading TLS handshake message, adding to rejected list\");\n\t\t\t\taddDroppedRejected(result);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tfinal int type = msg.get() & 0xFF;\n\t\t\tfinal int len = proto.getInt24(msg);\n\t\t\tif(msg.remaining() < len) {\n\t\t\t\tlogger.info(\"Ignoring short handshake message\");\n\t\t\t} else {\n\t\t\t\tif(analyzeHandshakeResponse(proto, type, msg, result)) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} \n\t\t}\n\t}\n\t\n\tprivate boolean analyzeHandshakeResponse(TLSProtocol proto, int type, ByteBuffer msg, TLSProbeResult result) {\n\t\tswitch(type) {\n\t\tcase 0x02:\n\t\t\tanalyzeServerHello(proto, msg, result);\n\t\t\tbreak;\n\t\t\t\n\t\tcase 0x0B:\n\t\t\tanalyzeCertificateMessage(proto, msg, result);\n\t\t\tbreak;\n\t\t\t\n\t\tcase 0x0E:\n\t\t\treturn true;\n\t\t\t\n\t\tcase 0x0C:\n\t\t\tbreak;\n\t\t\t\n\t\tdefault:\n\t\t\tlogger.info(\"Unexpected handshake message received with type = \"+ type);\n\t\t\tbreak;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate void addDroppedRejected(TLSProbeResult result) {\n\t\tfinal List<TLSCipherSpec> rejected = new ArrayList<TLSCipherSpec>();\n\t\tfor(TLSCipherSpec c: partition) {\n\t\t\t\trejected.add(c);\n\t\t}\n\t\tresult.addRejectedCiphersOnly(rejected);\n\t}\n\t\n\tprivate void analyzeServerHello(TLSProtocol tls, ByteBuffer msg, TLSProbeResult result) {\n\t\tif(tls.extractCompressionFromServerHello(msg) != 0) {\n\t\t\tresult.setTLSCompressionSupport(true);\n\t\t}\n\t\tfinal int cipherConst = tls.extractCipherFromServerHello(msg);\n\t\tTLSCipherSpec cipher = CipherSuites.lookupTLSCipher(cipherConst);\n\t\tif(cipher == null) {\n\t\t\tlogger.warning(\"Could not find cipher constant \"+ cipherConst);\n\t\t\treturn;\n\t\t}\n\t\tfinal List<TLSCipherSpec> rejected = new ArrayList<TLSCipherSpec>();\n\t\tfor(TLSCipherSpec c: partition) {\n\t\t\tif(cipher != c) {\n\t\t\t\trejected.add(c);\n\t\t\t}\n\t\t}\n\t\tresult.addCiphers(rejected, cipher);\n\t}\n\t\n\tprivate void analyzeCertificateMessage(TLSProtocol proto, ByteBuffer msg, TLSProbeResult result) {\n\t\tfinal int chainLength = proto.getInt24(msg);\n\t\tif(msg.remaining() < chainLength) {\n\t\t\tlogger.warning(\"Message length is less than expected length of certificate chain\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal CertificateAnalyzer ca = new CertificateAnalyzer();\n\n\t\twhile(msg.hasRemaining()) {\n\t\t\tX509Certificate certificate = readCertificate(proto, msg);\n\t\t\tca.addCert(certificate);\n\t\t}\n\t\tresult.addCertificate(ca);\n\t}\n\t\n\tprivate X509Certificate readCertificate(TLSProtocol proto, ByteBuffer msg) {\n\t\tfinal int certLength = proto.getInt24(msg);\n\t\tbyte[] certBytes = new byte[certLength];\n\t\tmsg.get(certBytes);\n\t\ttry {\n\t\t\treturn X509Certificate.getInstance(certBytes);\n\t\t} catch (CertificateException e) {\n\t\t\tlogger.log(Level.WARNING, \"Error creating certificate from message bytes\", e);\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSCipherSpec.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\npublic class TLSCipherSpec {\n\n\tpublic enum keyStrength { HIGH, LOW, EXPORT, NONE };\n\t\n\tprivate final String name;\n\tprivate final int number;\n\tprivate final keyStrength strength;\n\tprivate final boolean anonDH;\n\tprivate final boolean PFS;\n\tprivate final boolean RC4;\n\n\tTLSCipherSpec(String name, int number, keyStrength strength, boolean anonDH, boolean PFS, boolean RC4) {\n\t\t\n\t\tthis.name = name;\n\t\tthis.number = number;\n\t\tthis.strength = strength;\n\t\tthis.anonDH = anonDH;\t\t\n\t\tthis.PFS = PFS;\n\t\tthis.RC4 = RC4;\n\t}\n\n\tpublic int getNumber() {\n\t\treturn number;\n\t}\n\n\tpublic keyStrength getStrength() {\n\t\treturn strength;\n\t}\n\n\tpublic boolean isAnonDH() {\n\t\treturn anonDH;\n\t}\n\n\tpublic boolean isRC4() {\n\t\treturn RC4;\n\t}\n\n\tpublic boolean isPFS() {\n\t\treturn PFS;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSProbeResult.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class TLSProbeResult {\n\t\n\tprivate List<TLSCipherSpec> rejectedCiphers;\n\tprivate TLSCipherSpec acceptedCipher;\n\tprivate ArrayList<CertificateAnalyzer> serverCertificates;\n\tprivate boolean TLScompressionSupport;\n\tprivate boolean error;\n\tprivate String errorMessage = \"\";\n\t\n\n\tTLSProbeResult() {\n\t\tserverCertificates = new ArrayList<CertificateAnalyzer>();\n\t}\n\t\n\tpublic void addCiphers(List<TLSCipherSpec> rejected, TLSCipherSpec accepted) {\n\t\tthis.setRejectedCiphers(rejected);\n\t\tthis.acceptedCipher = accepted;\n\t}\n\t\n\tpublic void addRejectedCiphersOnly(List<TLSCipherSpec> rejected) {\n\t\tthis.setRejectedCiphers(rejected);\n\t}\n\t\n\tpublic void addServerCertificate(CertificateAnalyzer cert) {\n\t\tserverCertificates.add(cert);\n\t}\n\t\n\tpublic void setTLSCompressionSupport(boolean tf) {\n\t\tthis.TLScompressionSupport = tf;\n\t}\n\t\n\tpublic void setError(boolean error, String message) {\n\t\tthis.error = error;\n\t\tthis.errorMessage = message;\n\t}\n\n\tpublic void addCertificate(CertificateAnalyzer ca) {\n\t\tthis.serverCertificates.add(ca);\n\t}\n\n\tpublic boolean isError() {\n\t\treturn this.error;\n\t}\n\t\n\tpublic String getErrorMessage() {\n\t\treturn errorMessage;\n\t}\n\n\tpublic TLSCipherSpec getAcceptedCipher() {\n\t\treturn this.acceptedCipher;\n\t}\n\n\tpublic ArrayList<CertificateAnalyzer> getServerCertificates() {\n\t\treturn this.serverCertificates;\n\t}\n\n\tpublic List<TLSCipherSpec> getRejectedCiphers() {\n\t\treturn rejectedCiphers;\n\t}\n\n\tpublic void setRejectedCiphers(List<TLSCipherSpec> rejectedCiphers) {\n\t\tthis.rejectedCiphers = rejectedCiphers;\n\t}\n\t\n\tpublic boolean getTLSCompressionSupport() {\n\t\treturn this.TLScompressionSupport;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSProtocol.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\r\n\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\nimport java.io.OutputStream;\r\nimport java.nio.ByteBuffer;\r\nimport java.util.List;\r\nimport java.util.Random;\r\n\r\npublic class TLSProtocol {\r\n\tprivate final static int TLS_RECORD_HEADER_LENGTH = 5;\r\n\tprivate final static int TLS_MAXIMUM_RECORD_LENGTH = 16 * 1024;\r\n\tprivate final static int MAXIMUM_HANDSHAKE_MESSAGE_LENGTH = 64 * 1024;\r\n\tprivate final static int TLS_RECORD_ALERT = 0x15;\r\n\tpublic final static int TLS_RECORD_HANDSHAKE = 0x16;\r\n\t\r\n\tprivate final static byte TLS_HANDSHAKE_CLIENTHELLO = 0x01;\r\n\tprivate final static byte[] DEFAULT_VERSION = { 0x03, 0x01 };\r\n\tprivate final static Random random = new Random();\r\n\t\r\n\t\r\n\tprivate final InputStream input;\r\n\tprivate final OutputStream output;\r\n\r\n\tprivate final ByteBuffer recordBuffer;\r\n\tprivate final ByteBuffer handshakeBuffer;\r\n\t\r\n\t\r\n\tTLSProtocol(InputStream input, OutputStream output) {\r\n\t\tthis.input = input;\r\n\t\tthis.output = output;\r\n\t\tthis.recordBuffer = ByteBuffer.allocate(TLS_RECORD_HEADER_LENGTH + TLS_MAXIMUM_RECORD_LENGTH);\r\n\t\tthis.handshakeBuffer = ByteBuffer.allocate(MAXIMUM_HANDSHAKE_MESSAGE_LENGTH);\r\n\t\thandshakeBuffer.flip();\r\n\t}\r\n\t\r\n\t\r\n\tByteBuffer getNextHandshakeMessage() throws IOException, TLSAlertException {\r\n\t\twhile(!hasFullHandshakeMessage()) {\r\n\t\t\tif(!readNextRecord()) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn extractNextHandshakeMessage();\r\n\t}\r\n\r\n\tprivate boolean hasFullHandshakeMessage() {\r\n\t\tfinal int r = handshakeBuffer.remaining();\r\n\t\treturn !(r < 4 || r < (peekHandshakeLength() + 4));\r\n\t}\r\n\r\n\tprivate int peekHandshakeLength() {\r\n\t\t// read 32 bits from current location and mask off first byte (type)\r\n\t\treturn handshakeBuffer.getInt(handshakeBuffer.position()) & 0x00FFFFFF;\r\n\t}\r\n\t\r\n\tprivate ByteBuffer extractNextHandshakeMessage() {\r\n\t\tfinal int length = peekHandshakeLength();\r\n\t\tfinal byte[] msg = new byte[length + 4];\r\n\t\thandshakeBuffer.get(msg);\r\n\t\thandshakeBuffer.compact().flip();\r\n\t\treturn ByteBuffer.wrap(msg);\r\n\t}\r\n\r\n\tprivate void appendMessageBytes(byte[] messageBytes) {\r\n\t\thandshakeBuffer.mark();\r\n\t\thandshakeBuffer.position(handshakeBuffer.limit());\r\n\t\thandshakeBuffer.limit(handshakeBuffer.capacity());\r\n\t\t\r\n\t\thandshakeBuffer.put(messageBytes);\r\n\t\t\r\n\t\thandshakeBuffer.limit(handshakeBuffer.position());\r\n\t\thandshakeBuffer.reset();\r\n\t}\r\n\t\r\n\tprivate boolean readNextRecord() throws IOException, TLSAlertException {\r\n\t\twhile(!hasFullRecord()) {\r\n\t\t\tif(!readToRecordBuffer()) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\trecordBuffer.flip();\r\n\t\tint type = recordBuffer.get() & 0xFF;\r\n\t\trecordBuffer.getShort();     /* version */\r\n\t\tint length = recordBuffer.getShort() & 0xFFFF;\r\n\t\tbyte[] messageBytes = new byte[length];\r\n\t\trecordBuffer.get(messageBytes);\r\n\t\trecordBuffer.compact();\r\n\t\t\r\n\t\tif(type == TLS_RECORD_HANDSHAKE) {\r\n\t\t\tappendMessageBytes(messageBytes);\r\n\t\t} else if (type == TLS_RECORD_ALERT) {\r\n\t\t\tif(messageBytes.length != 2) {\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\tthrow new TLSAlertException(messageBytes[0] & 0xFF, messageBytes[1] & 0xFF);\r\n\t\t} else {\r\n\t\t\t\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\tprivate boolean readToRecordBuffer() throws IOException {\r\n\t\tfinal byte[] array = recordBuffer.array();\r\n\t\tfinal int offset = recordBuffer.position();\r\n\t\tfinal int len = recordBuffer.remaining();\r\n\r\n\t\tfinal int n = input.read(array, offset, len);\r\n\t\tif(n == -1) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\trecordBuffer.position(recordBuffer.position() + n);\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\tboolean hasFullRecord() {\r\n\t\tif(recordBuffer.position() < 5) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tint length = recordBuffer.getShort(3) & 0xFFFF;\r\n\t\treturn recordBuffer.position() >= (length + 5);\r\n\t}\r\n\r\n\tvoid createTLSClientHello(ByteBuffer buffer, List<TLSCipherSpec> ciphers, byte[] versionBytes) {\r\n\t\tbuffer.clear();\r\n\t\tskip(buffer, 5);\r\n\t\tfinal int recordStart = buffer.position();\r\n\r\n\t\tbuffer.put(TLS_HANDSHAKE_CLIENTHELLO);\r\n\t\tbuffer.mark();\r\n\t\tskip(buffer, 3);\r\n\t\tint len = packClientHello(buffer, ciphers, versionBytes);\r\n\t\tint end = buffer.position();\r\n\t\tbuffer.reset();\r\n\t\tbuffer.put(packInt24(len));\r\n\t\t\r\n\t\tbuffer.rewind();\r\n\t\tpackRecordHeader(buffer, versionBytes, end - recordStart);\r\n\t\tbuffer.flip();\r\n\t}\r\n\t\r\n\tint packClientHello(ByteBuffer buffer, List<TLSCipherSpec> ciphers, byte[] versionBytes) {\r\n\t\tfinal int start = buffer.position();\r\n\t\tbuffer.put(versionBytes);\r\n\t\tbuffer.putInt(getTimeSeconds());\r\n\t\tbuffer.put(getRandomBytes());\r\n\t\tbuffer.put((byte) 0);\r\n\t\tbuffer.putShort((short) (2 * ciphers.size()));\r\n\t\tfor(TLSCipherSpec c: ciphers) {\r\n\t\t\tbuffer.putShort((short) c.getNumber());\r\n\t\t}\r\n\t\tbuffer.put((byte) 0x02);\r\n\t\tbuffer.put((byte) 0);\r\n\t\tbuffer.put((byte) 0x01);\r\n\t\treturn buffer.position() - start;\r\n\t}\r\n\t\r\n\tint extractCipherFromServerHello(ByteBuffer helloMessage) {\r\n\t\tskipStartOfServerHello(helloMessage);\r\n\t\treturn helloMessage.getShort() & 0xFFFF;\r\n\t}\r\n\t\r\n\tint extractCompressionFromServerHello(ByteBuffer helloMessage) {\r\n\t\tskipStartOfServerHello(helloMessage);\r\n\t\thelloMessage.getShort(); // Cipher\r\n\t\treturn helloMessage.get() & 0xFF;\r\n\t}\r\n\t\r\n\tprivate void skipStartOfServerHello(ByteBuffer helloMessage) {\r\n\t\thelloMessage.rewind();\r\n\t\tfinal int type = helloMessage.get() & 0xFF;\r\n\t\tif(type != 0x02) {\r\n\t\t\t\r\n\t\t}\r\n\t\tfinal int length = getInt24(helloMessage);\r\n\t\tif(helloMessage.remaining() < length) {\r\n\t\t\t\r\n\t\t}\r\n\t\tskip(helloMessage, 2); // version\r\n\t\tskip(helloMessage, 32); // random;\r\n\t\tfinal int sessionIdLength = helloMessage.get() & 0xFF;\r\n\t\tskip(helloMessage, sessionIdLength);\r\n\t}\r\n\t\r\n\tpublic int getInt24(ByteBuffer bb) {\r\n\t\tint val = 0;\r\n\t\tfor(int i = 0; i < 3; i++) {\r\n\t\t\tval <<= 8;\r\n\t\t\tval |= (bb.get() & 0xFF);\r\n\t\t}\r\n\t\treturn val;\r\n\t}\r\n\t\r\n\tvoid packRecordHeader(ByteBuffer buffer, byte[] versionBytes, int length) {\r\n\t\tbuffer.put((byte) TLS_RECORD_HANDSHAKE);\r\n\t\tbuffer.put(versionBytes);\r\n\t\tbuffer.putShort((short) length);\r\n\t}\r\n\t\r\n\r\n\tprivate int skip(ByteBuffer buffer, int n) {\r\n\t\tfinal int pos = buffer.position();\r\n\t\tbuffer.position(pos + n);\r\n\t\treturn pos;\r\n\t}\r\n\t\r\n\tpublic void sendTLSClientHello(List<TLSCipherSpec> ciphers) throws IOException {\r\n\t\tsendTLSClientHello(ciphers, null);\r\n\t}\r\n\t\r\n\tpublic void sendTLSClientHello(List<TLSCipherSpec> ciphers, byte[] versionBytes) throws IOException {\r\n\t\twriteAll(createTLSClientHello(ciphers, versionBytes));\r\n\t}\r\n\t\r\n\tprotected void writeAll(ByteBuffer buffer) throws IOException {\r\n\t\toutput.write(buffer.array(), buffer.position(), buffer.remaining());\r\n\t\tbuffer.position(buffer.position() + buffer.remaining());\r\n\t\toutput.flush();\r\n\t}\r\n\t\r\n\tprivate static ByteBuffer createTLSClientHello(List<TLSCipherSpec> ciphers, byte[] versionBytes) {\r\n\t\tfinal byte[] vb = (versionBytes == null) ? (DEFAULT_VERSION) : (versionBytes);\r\n\t\tfinal ByteBuffer buffer = ByteBuffer.allocate(getTLSHelloLength(ciphers.size()));\r\n\r\n\t\tfinal int tlsRecordLength = 44 + (2 * ciphers.size());\r\n\t\tfinal int tlsHandshakeLength = tlsRecordLength - 4;\r\n\t\t\r\n\t\tbuffer.put((byte) TLS_RECORD_HANDSHAKE);\r\n\t\tbuffer.put(vb);\r\n\t\tbuffer.putShort((short) tlsRecordLength);\r\n\t\tbuffer.put(TLS_HANDSHAKE_CLIENTHELLO);\r\n\t\tbuffer.put(packInt24(tlsHandshakeLength));\r\n\t\tbuffer.put(vb);\r\n\t\tbuffer.putInt(getTimeSeconds());\r\n\t\tbuffer.put(getRandomBytes());\r\n\t\tbuffer.put((byte) 0);\r\n\t\tbuffer.putShort((short) (2 * ciphers.size()));\r\n\t\tfor(TLSCipherSpec c: ciphers) {\r\n\t\t\tbuffer.putShort((short) c.getNumber());\r\n\t\t}\r\n\t\tbuffer.put((byte) 0x02);\r\n\t\tbuffer.put((byte) 0x00);\r\n\t\tbuffer.put((byte) 0x01);\r\n\t\tbuffer.flip();\r\n\t\treturn buffer;\r\n\t}\r\n\t\r\n\tstatic int getTLSHelloLength(int cipherCount) {\r\n\t\treturn 49 + (2 * cipherCount);\r\n\t}\r\n\t\r\n\tstatic byte[] packInt24(int n) {\r\n\t\tfinal byte[] bs = new byte[3];\r\n\t\tbs[0] = (byte) (n >> 16);\r\n\t\tbs[1] = (byte) (n >> 8);\r\n\t\tbs[2] = (byte) n;\r\n\t\treturn bs;\r\n\t}\r\n\t\r\n\tstatic private int getTimeSeconds() {\r\n\t\treturn (int) (System.currentTimeMillis() / 1000);\r\n\t}\r\n\t\r\n\tstatic private byte[] getRandomBytes() {\r\n\t\tfinal byte[] bs = new byte[28];\r\n\t\trandom.nextBytes(bs);\r\n\t\treturn bs;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSServerCipherPreferenceProbe.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.io.IOException;\nimport java.nio.ByteBuffer;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.internal.sslprobe.SSLServerScanResult.Flag;\n\n\npublic class TLSServerCipherPreferenceProbe extends ProbeBase<Void> {\n\tprivate final static Logger logger = Logger.getLogger(TLSServerCipherPreferenceProbe.class.getName());\n\n    TLSServerCipherPreferenceProbe(SSLServerScanResult scanResult) {\n    \tsuper(scanResult);\n    }\n\t\n    @Override\n    public Void runProbe() {\n    \tfinal List<TLSCipherSpec> ciphers = scanResult.getServerTLSCiphers();\n    \tif(ciphers.size() < 2) {\n    \t\treturn null;\n    \t}\n    \t\n    \tif(isServerPreference(ciphers)) {\n    \t\tscanResult.setFlag(Flag.SERVER_PREFERENCE);\n    \t\tfinal List<TLSCipherSpec> orderedCiphers = orderCiphersByServerPreference(ciphers);\n    \t\tif(orderedCiphers != null) {\n    \t\t\tscanResult.setServerTLSCiphersServerPreferenceOrder(orderedCiphers);\n\t\t\t}\n    \t}\n    \treturn null;\n    }\n\n    private boolean isServerPreference(List<TLSCipherSpec> ciphers) {\n  \t\t\treturn serverDemonstratePreference(ciphers.get(0), ciphers.get(1)) ||\n\t\t\t\t\tserverDemonstratePreference(ciphers.get(1), ciphers.get(0));\n    }\n    \n    private boolean serverDemonstratePreference(TLSCipherSpec c1, TLSCipherSpec c2) {\n    \tcloseConnection();\n    \ttry {\n    \t\tfinal TLSProtocol tls = new TLSProtocol(getInputStream(), getOutputStream());\n    \t\ttls.sendTLSClientHello(Arrays.asList(c1, c2));\n    \t\tfinal ByteBuffer msg = tls.getNextHandshakeMessage();\n    \t\tfinal int c = tls.extractCipherFromServerHello(msg);\n    \t\treturn c == c2.getNumber();\n    \t} catch (IOException e) {\n    \t\tlogger.warning(\"I/O error sending server order preference probe: \"+ e);\n    \t} catch (TLSAlertException e) {\n    \t\tlogger.info(\"TLS alert received sending server order preference probe: \"+ e);\n    \t}\n    \treturn false;\n    }\n  \n    private List<TLSCipherSpec> orderCiphersByServerPreference(List<TLSCipherSpec> ciphers) {\n    \tfinal List<TLSCipherSpec> preferenceList = new ArrayList<TLSCipherSpec>();\n    \tfinal List<TLSCipherSpec> workingList = new ArrayList<TLSCipherSpec>(ciphers);\n    \twhile(!workingList.isEmpty()) {\n    \t\tTLSCipherSpec chosen = chooseCipher(workingList);\n    \t\tif(chosen == null) {\n    \t\t\treturn null;\n\t\t\t} else {\n\t\t\t\tpreferenceList.add(chosen);\n\t\t\t\tworkingList.remove(chosen);\n\t\t\t}\n    \t}\n    \treturn preferenceList;\n    }\n    \n    private TLSCipherSpec chooseCipher(List<TLSCipherSpec> ciphers)  {\n    \tcloseConnection();\n    \ttry {\n    \t\tfinal TLSProtocol tls = new TLSProtocol(getInputStream(), getOutputStream());\n    \t\ttls.sendTLSClientHello(ciphers);\n    \t\tfinal int cipherConst = tls.extractCipherFromServerHello(tls.getNextHandshakeMessage());\n    \t\treturn CipherSuites.lookupTLSCipher(cipherConst);\n    \t} catch (IOException e) {\n    \t\tlogger.info(\"I/O error sending server cipher ordering probe: \"+ e);\n    \t} catch (TLSAlertException e) {\n    \t\tlogger.info(\"TLS alert received sending server cipher ordering probe: \"+ e);\n    \t}\n    \treturn null;\n    }\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/internal/sslprobe/TLSVersionProbe.java",
    "content": "package com.subgraph.vega.internal.sslprobe;\n\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.internal.sslprobe.SSLServerScanResult.Flag;\n\npublic class TLSVersionProbe extends ProbeBase<Void> {\n\tprivate final static Logger logger = Logger.getLogger(TLSVersionProbe.class.getName());\n\t\n\tprivate final static byte[] VER_SSLv3  = {0x03, 0x00};\n\tprivate final static byte[] VER_TLS1   = {0x03, 0x01};\n\tprivate final static byte[] VER_TLS1_1 = {0x03, 0x02};\n\tprivate final static byte[] VER_TLS1_2 = {0x03, 0x03};\n\t\n\tprivate final static List<byte[]> ALL_VERSIONS = \n\t\t\tArrays.asList(VER_SSLv3, VER_TLS1, VER_TLS1_1, VER_TLS1_2);\n\t\n\tstatic List<TLSVersionProbe> getVersionProbes(SSLServerScanResult scanResult) {\n\t\tfinal List<TLSVersionProbe> probes = new ArrayList<TLSVersionProbe>();\n\t\tfor(byte[] v: ALL_VERSIONS) {\n\t\t\tprobes.add(new TLSVersionProbe(scanResult, v));\n\t\t}\n\t\treturn probes;\n\t}\n\t\n    private final byte[] version;\n    \n    TLSVersionProbe(SSLServerScanResult scanResult, byte[] version) {\n    \tsuper(scanResult);\n    \tthis.version = version;\n    }\n\t\n    protected Void runProbe() throws IOException {\n    \tfinal TLSProtocol tls = new TLSProtocol(getInputStream(), getOutputStream());\n    \ttls.sendTLSClientHello(scanResult.getServerTLSCiphers(), version);\n    \tfinal byte[] responseBytes = new byte[3];\n    \tif(!readAll(responseBytes)) {\n    \t\tlogger.warning(\"Failed to read response in TLSVersionProbe\");\n    \t} else if(responseBytes[0] != TLSProtocol.TLS_RECORD_HANDSHAKE) {\n    \t\tlogger.warning(\"Unexpected record type received in response in TLSVersionProbe.  type = \"+ responseBytes[0]);\n    \t} else {\n    \t\tfinal boolean matches = responseBytes[1] == version[0] && responseBytes[2] == version[1];\n    \t\tif (matches == true) {\n    \t\t\tprocessProbeResult(matches);\n    \t\t}\n    \t}\n    \treturn null;\n    }\n\t\n\tprivate void processProbeResult(boolean supported) {\n\t\tif (version != null) {\n\t\t\tswitch (version[1]) {\n\t\t\tcase 0x00:\n\t\t\t\tscanResult.setFlag(Flag.SSLV3);\n\t\t\t\tbreak;\n\t\t\tcase 0x01:\n\t\t\t\tscanResult.setFlag(Flag.TLS1);\n\t\t\t\tbreak;\n\t\t\tcase 0x02:\n\t\t\t\tscanResult.setFlag(Flag.TLS11);\n\t\t\t\tbreak;\n\t\t\tcase 0x03:\n\t\t\t\tscanResult.setFlag(Flag.TLS12);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/sslprobe/Activator.java",
    "content": "package com.subgraph.vega.sslprobe;\n\nimport org.osgi.framework.BundleActivator;\nimport org.osgi.framework.BundleContext;\n\npublic class Activator implements BundleActivator {\n\n\tprivate static BundleContext context;\n\n\tstatic BundleContext getContext() {\n\t\treturn context;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext bundleContext) throws Exception {\n\t\tActivator.context = bundleContext;\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext bundleContext) throws Exception {\n\t\tActivator.context = null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.sslprobe/src/com/subgraph/vega/sslprobe/SSLProbe.java",
    "content": "package com.subgraph.vega.sslprobe;\n\n\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.internal.sslprobe.CertificateAnalyzer;\nimport com.subgraph.vega.internal.sslprobe.SSLScanTaskManager;\nimport com.subgraph.vega.internal.sslprobe.SSLServerScanResult;\nimport com.subgraph.vega.internal.sslprobe.SSLv2CipherSpec;\nimport com.subgraph.vega.internal.sslprobe.TLSCipherSpec;\nimport com.subgraph.vega.internal.sslprobe.SSLServerScanResult.Flag;\n\npublic class SSLProbe implements Runnable {\n\t\n\tprivate final int NTHREADS = 10;\n    private final ExecutorService executor = Executors.newFixedThreadPool(NTHREADS);\n    private SSLServerScanResult result;\n    \n    private final String host;\n    private final int port;\n    private final IScanInstance scanInstance;\n    private final String hostString;\n    \n\tprivate final Logger logger = Logger.getLogger(\"scanner\");\n\n    \n    public SSLProbe(IScanInstance instance, String hostname, int serverPort, String httpHostString) {\n    \thost = hostname;\n    \tport = serverPort;\n    \tscanInstance = instance;\n    \thostString = httpHostString;\n    }\n    \n    public void run() {\n    \n    \tSSLScanTaskManager taskmanager = new SSLScanTaskManager(executor);\n    \t\n    \ttry {\n    \t\tresult = taskmanager.scanServer(host, port);\n    \t\tsummarizeResults(result);\n\t\t\ttaskmanager.shutdown();\n\t\t} catch (InterruptedException e) {\n\t\t\te.printStackTrace();\n\t\t}\n \n    }\n    \n    private void summarizeResults(SSLServerScanResult res) {\n    \t\n    \tString output = \"SSL Server Configuration Probe\\n\";\n    \t\n    \toutput += \"Target: \"+res.getTargetHost() + \":\" + res.getTargetPort() + \"\\n\\n\";\n    \t\n    \tif(res.getTLSProbeFailure()) {\n    \t\toutput += \"Scan Failed (\"+ res.getErrorMessage() + \")\\n\";\n    \t//\treturn;\n    \t}\n    \n    \toutput += \"SSL/TLS Version Enumeration\\n\";\n    \toutput += \"---------------------------------------------------------\\n\";\n\n    \tboolean val = res.isSet(Flag.SSLV2);\n    \tif (val) {\n    \t\t\n    \t\t/* Alert here */\n    \t\t\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-v2-support\", host+\"-sslv2\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t\toutput += \"  [ BAD ]  SSL v2 Support: \"+val + \"\\n\";\n    \t\t\n    \t} else {\n    \t\toutput += \"  [ GOOD ]  SSL v2 Support: \"+ val + \"\\n\";\n    \t}\n    \tval = res.isSet(Flag.SSLV3);\n    \tif (val) {\n    \t\toutput += \"  [ BAD ]  SSL v3 Support: \"+ val + \"\\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-v3-support\",host + \"-sslv3\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t} else {\n    \t\toutput += \"  [ GOOD ]  SSL v3 Support: \"+ val + \"\\n\";\n    \t}\n    \toutput += \"  [ INFO ] TLS 1.0 Support: \"+res.isSet(Flag.TLS1) + \"\\n\";\n    \toutput += \"  [ INFO ] TLS 1.1 Support: \"+res.isSet(Flag.TLS11) + \"\\n\";\n    \toutput += \"  [ INFO ] TLS 1.2 Support: \"+res.isSet(Flag.TLS12) + \"\\n\";\n    \t\n    \toutput += \"\\nTLS Configuration Summary\\n\";\n    \toutput += \"--------------------------------------------------------\\n\";\n    \t\n    \tif (res.isSet(Flag.TLS_COMPRESSION)) {\n    \t\toutput += \"  [ BAD ]  TLS compression supported (CRIME attack).\\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-compression\",host + \"-compression\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t} else  {\n    \t\toutput += \"  [ GOOD ] TLS compression not supported.\\n\";\n    \t}\n    \tif (res.isSet(Flag.ANON_DH)) {\n    \t\toutput += \"  [ INFO ] Supported cipher spec found with Anon-DH key exchange.\\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-anonymous-dh\",host + \"-anonymous-dh\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t}\n\n    \tif (res.isSet(Flag.RC4_SUPPORTED)) {\n    \t\toutput += \"  [ INFO ] Supported ciphers using RC4 found (common).\\n\";\n    \t}\n    \t\n    \t/* Certificate analyzer results */\n    \t\n    \tif (res.isSet(Flag.SMALL_RSA_KEY)) {\n    \t\toutput += \"  [ BAD ]  Small RSA modulus (<= 1024 bit) found in a server certificate.\\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-small-key\",host + \"-small-key\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t}\n    \tif (res.isSet(Flag.SELF_SIGNED_CERTIFICATE)) {\n    \t\toutput += \"  [ INFO ] Self-signed certificate found.\\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-self-signed\",host + \"-self-signed\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t}\n    \t\n    \tif (res.isSet(Flag.MD5_SIGNED_CERTIFICATE)) {\n    \t\toutput += \"  [ BAD ] Certificate signed using MD5. \\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-md5-cert\", host + \"-md5-cert\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t}\n    \t\n    \tif (res.isSet(Flag.SHA1_SIGNED_CERTIFICATE)) {\n    \t\toutput += \"  [ BAD ] Certificate signed using SHA1. \\n\";\n    \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-sha1-cert\", host + \"-sha1-cert\");\n    \t\talert.setDiscretionaryHostname(hostString);\n    \t\talert.setResource(hostString);\n    \t\tscanInstance.addAlert(alert);\n    \t}\n    \t\n    \t/* End certificate analyzer results */\n    \t\n    \tif (res.isSet(Flag.SERVER_PREFERENCE)) {\n    \t\toutput += \"\\n\\n  [ GOOD ] Server cipher spec preference detected. Server preference order: \\n\";\n    \t\tint i = 1;\n    \t\tfor (TLSCipherSpec c : res.getServerTLSCiphersServerPreferenceOrder()) {\n    \t\t\toutput += \"    [\"+i+\"] \"+c.getName() + \"\\n\";\n    \t\t\tif (c.getStrength() == TLSCipherSpec.keyStrength.EXPORT) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec is export grade.\\n\";\n    \t\t\t} else if (c.getStrength() == TLSCipherSpec.keyStrength.LOW) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec is low security.\\n\";\n    \t\t\t} else if (c.getStrength() == TLSCipherSpec.keyStrength.NONE) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec does not include encryption.\\n\";\n    \t\t\t}\n    \t\t\tif (c.isAnonDH() == true) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec supports Anonymous DH.\\n\";    \t\t\t\t\n    \t\t\t}\n    \t\t\tif (c.isPFS() == true) {\n    \t\t\t\toutput += \"      [ GOOD ] Cipher spec offers PFS.\\n\";    \t\t\t\t\n    \t\t\t}\n    \t\t\tif (c.isRC4() == true) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec uses RC4.\\n\";    \t\t\t\t\n    \t\t\t}\n    \t\t\t\n    \t\t\ti++;\n    \t\t}\n    \t\tif (res.getServerTLSCiphersServerPreferenceOrder().get(0).isPFS() == false) {\n    \t\t\toutput += \"  [ BAD ]  Server most preferred cipher does not offer PFS: \"+res.getServerTLSCiphersServerPreferenceOrder().get(0).getName() + \"\\n\";\n        \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-pfs-not-preferred\",host + \"-pfs-not-preferred\");\n        \t\talert.setDiscretionaryHostname(hostString);\n        \t\talert.setResource(hostString);\n        \t\tscanInstance.addAlert(alert);\n    \t\t} else if (res.getServerTLSCiphersServerPreferenceOrder().get(0).isPFS() == true) {\n    \t\t\toutput += \"  [ GOOD ] Server most preferred cipher offers PFS: \"+res.getServerTLSCiphersServerPreferenceOrder().get(0).getName() + \"\\n\";\n    \t\t}\n    \t\tif (res.getServerTLSCiphersServerPreferenceOrder().get(0).isRC4() == true) {\n    \t\t\toutput += \"  [ BAD ]  Server most preferred cipher uses RC4: \"+res.getServerTLSCiphersServerPreferenceOrder().get(0).getName() + \"\\n\";\n        \t\tIScanAlert alert = scanInstance.createAlert(\"ssl-rc4-preference\",host + \"-rc4-preference\");\n        \t\talert.setResource(hostString);\n        \t\talert.setDiscretionaryHostname(hostString);\n        \t\tscanInstance.addAlert(alert);\n    \t\t}\n    \t\t\n    \t} else\n    \t{\n    \t\toutput += \"\\n  [ BAD ]  Client cipher spec preference detected. Supported cipher specs:\\n\";\n    \t\tif (res.getServerTLSCiphers().isEmpty() == false) {\n    \t\t\t\n    \t\t\tIScanAlert clientPreferenceAlert = scanInstance.createAlert(\"ssl-client-preference\",host + \"-client-preference\");\n    \t\t\tclientPreferenceAlert.setDiscretionaryHostname(hostString);\n        \t\tclientPreferenceAlert.setResource(hostString);\n    \t\t\tscanInstance.addAlert(clientPreferenceAlert);\n    \t\t\t\n    \t\t\tif (res.isSet(Flag.PFS_SUPPORTED)) {\n    \t    \t\toutput += \"  [ GOOD ]  Ciphers offering PFS supported.\\n\";\n    \t    \t} else {\n    \t    \t\toutput += \"  [ BAD ]  No ciphers offering PFS supported.\\n\";\n    \t    \t\tIScanAlert noPFSAlert = scanInstance.createAlert(\"ssl-no-pfs\", host + \"-no-pfs\");\n    \t    \t\tnoPFSAlert.setDiscretionaryHostname(hostString);\n    \t    \t\tnoPFSAlert.setResource(hostString);\n    \t    \t\tscanInstance.addAlert(noPFSAlert);\n    \t    \t}\n    \t\t\tfor (TLSCipherSpec c : res.getServerTLSCiphers()) {\n    \t\t\t\toutput += \"    [*] \"+c.getName() + \"\\n\";\n    \t\t\t\tif (c.getStrength() == TLSCipherSpec.keyStrength.EXPORT) {\n    \t\t\t\t\toutput += \"      [ BAD ] Cipher spec is export grade.\\n\";\n    \t\t\t\t} else if (c.getStrength() == TLSCipherSpec.keyStrength.LOW) {\n    \t\t\t\t\toutput += \"      [ BAD ] Cipher spec is low security.\\n\";\n    \t\t\t\t} else if (c.getStrength() == TLSCipherSpec.keyStrength.NONE) {\n    \t\t\t\t\toutput += \"      [ BAD ] Cipher spec does not include encryption.\\n\";\n    \t\t\t\t}\n    \t\t\t\tif (c.isAnonDH() == true) {\n    \t\t\t\t\toutput += \"      [ BAD ] Cipher spec supports Anonymous DH.\\n\";    \t\t\t\t\n    \t\t\t\t}\n    \t\t\t\tif (c.isPFS() == true) {\n    \t\t\t\t\toutput += \"      [ GOOD ] Cipher spec offers PFS.\\n\";    \t\t\t\t\n    \t\t\t\t}\n    \t\t\t\tif (c.isRC4() == true) {\n    \t\t\t\t\toutput += \"      [ BAD ] Cipher spec uses RC4.\\n\";    \t\t\t\t\n    \t\t\t\t}\n    \t\t\t}\n    \t\t}\n    \t\t\n    \t} if (res.isSet(Flag.SSLV2)) {\n    \t\toutput += \"\\nSSLv2 Ciphers Supported:\\n\";\n    \t\tfor (SSLv2CipherSpec c : res.getServerSSLv2Ciphers()) {\n    \t\t\toutput += \"    [*] \"+c.getName() + \"\\n\";\n    \t\t\tif (c.getStrength() == SSLv2CipherSpec.keyStrength.EXPORT) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec is export grade.\\n\";\n    \t\t\t} else if (c.getStrength() == SSLv2CipherSpec.keyStrength.LOW) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec is low security.\\n\";\n    \t\t\t} else if (c.getStrength() == SSLv2CipherSpec.keyStrength.NONE) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec does not include encryption.\\n\";\n    \t\t\t}\n    \t\t\tif (c.isRC4() == true) {\n    \t\t\t\toutput += \"      [ BAD ] Cipher spec uses RC4.\\n\";    \t\t\t\t\n    \t\t\t}\n    \t\t\t\n    \t\t}\n    \t}\n    \t\n    \toutput += \"\\nCertificate Analysis\\n\";\n    \toutput += \"--------------------------------------------------------\\n\";\n    \t\n        for (CertificateAnalyzer ca : res.getServerCertificates()) {\n        \toutput += \"  [*] Certificate: \"+ca.getCertificate().getSerialNumber() + \"\\n\";\n        \tif (ca.isRSA()) {\n        \t\tif (ca.getRSAModulusBitLength() <= 1024) {\n        \t\t\toutput += \"    [ BAD ]  RSA modulus <= 1024 found.\\n\";\n        \t\t}\n        \t\telse {\n        \t\t\toutput += \"    [ GOOD ] RSA modulus size: \" +ca.getRSAModulusBitLength() + \" bits.\\n\";\n        \t\t}\n        \t}\n        \tif (ca.selfSigned()) {\n        \t\toutput += \"    [ INFO ] Self-signed certificate found.\\n\";\n        \t} else {\n        \t\toutput += \"    [ INFO ] Not self signed.\\n\";\n        \t}\n        }\n        output += \"\\nSSL Probe completed.\\n\";\n        logger.log(Level.INFO, output);\n    }\n}\n\t\n\t"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.console</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Console\nBundle-SymbolicName: com.subgraph.vega.ui.console;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.console.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nImport-Package: com.subgraph.vega.api.console,\n com.subgraph.vega.api.events,\n com.subgraph.vega.ui.util.images\nService-Component: OSGI-INF/console-service.xml\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/OSGI-INF/console-service.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"vega.console\">\n   <implementation class=\"com.subgraph.vega.internal.console.ConsoleService\"/>\n   <service>\n      <provide interface=\"com.subgraph.vega.api.console.IConsole\"/>\n   </service>\n</scr:component>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               OSGI-INF/console-service.xml,\\\n               plugin.xml,\\\n               icons/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <view\n            class=\"com.subgraph.vega.ui.console.ConsoleView\"\n            icon=\"icons/console.png\"\n            id=\"com.subgraph.vega.views.console\"\n            name=\"Console\"\n            restorable=\"true\">\n      </view>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/src/com/subgraph/vega/internal/console/ConsoleService.java",
    "content": "package com.subgraph.vega.internal.console;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.console.IConsole;\nimport com.subgraph.vega.api.console.IConsoleDisplay;\nimport com.subgraph.vega.api.events.IEventHandler;\n\npublic class ConsoleService implements IConsole {\n\tprivate final static int MAX_BUFFER = 8192;\n\tprivate final List<IConsoleDisplay> displays = new ArrayList<IConsoleDisplay>();\n\tprivate StringBuilder outputBuffer = null;\n\tprivate StringBuilder errorBuffer = null;\n\t\n\t@Override\n\tpublic synchronized void write(String output) {\n\t\tif(!output.endsWith(\"\\n\"))\n\t\t\toutput = output + \"\\n\";\n\t\tif(displays.size() == 0) {\n\t\t\tbufferOutput(output);\n\t\t} else {\n\t\t\tfor(IConsoleDisplay display: displays) {\n\t\t\t\tdisplay.printOutput(output);\n\t\t\t}\n\t\t}\n\t}\n\t@Override\n\tpublic synchronized void debug(String output) {\n\t\tif(!output.endsWith(\"\\n\"))\n\t\t\toutput = output + \"\\n\";\n\t\tif(displays.size() == 0) {\n\t\t\tbufferOutput(output);\n\t\t} else {\n\t\t\tfor(IConsoleDisplay display: displays) {\n\t\t\t\tdisplay.printDebug(output);\n\t\t\t}\n\t\t}\n\t}\n\t@Override\n\tpublic synchronized void error(String output) {\n\t\tif(!output.endsWith(\"\\n\"))\n\t\t\toutput = output + \"\\n\";\n\t\tif(displays.size() == 0) {\n\t\t\tbufferError(output);\n\t\t} else {\n\t\t\tfor(IConsoleDisplay display: displays) {\n\t\t\t\tdisplay.printError(output);\n\t\t\t}\n\t\t}\t\t\n\t}\n\t\n\tprivate void bufferOutput(String output) {\n\t\tif(outputBuffer == null)\n\t\t\toutputBuffer = new StringBuilder();\n\t\tappendBuffer(output, outputBuffer);\n\t}\n\n\tprivate void bufferError(String output) {\n\t\tif(errorBuffer == null)\n\t\t\terrorBuffer = new StringBuilder();\n\t\tappendBuffer(output, errorBuffer);\n\t}\n\t\n\tprivate void appendBuffer(String output, StringBuilder buffer) {\n\t\tif(output == null)\n\t\t\treturn;\n\t\tif(output.length() > MAX_BUFFER)\n\t\t\toutput = output.substring(0, MAX_BUFFER);\n\t\tfinal int totalLength = buffer.length() + output.length();\n\t\tif(totalLength > MAX_BUFFER) {\n\t\t\tint trimCount = totalLength - MAX_BUFFER;\n\t\t\tbuffer.delete(0, trimCount);\n\t\t}\n\t\tbuffer.append(output);\n\t}\n\t\n\t@Override\n\tpublic synchronized void registerDisplay(IConsoleDisplay display) {\n\t\tdisplays.add(display);\n\t\tif(displays.size() == 1) {\n\t\t\tif(errorBuffer != null) {\n\t\t\t\tdisplay.printError(errorBuffer.toString());\n\t\t\t\terrorBuffer = null;\n\t\t\t}\n\t\t\tif(outputBuffer != null) {\n\t\t\t\tdisplay.printOutput(outputBuffer.toString());\n\t\t\t\toutputBuffer = null;\n\t\t\t}\n\t\t\t\n\t\t}\t\t\n\t}\n\t@Override\n\tpublic void addConsoleOutputListener(IEventHandler listener) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\t@Override\n\tpublic void removeConsoleOutputListener(IEventHandler listener) {\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/src/com/subgraph/vega/ui/console/Activator.java",
    "content": "package com.subgraph.vega.ui.console;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.console.IConsole;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.console\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IConsole, IConsole> consoleServiceTracker;\n\t\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t\tconsoleServiceTracker = new ServiceTracker<IConsole, IConsole>(context, IConsole.class.getName(), null);\n\t\tconsoleServiceTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\t\n\tpublic IConsole getConsoleService() {\n\t\treturn consoleServiceTracker.getService();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.console/src/com/subgraph/vega/ui/console/ConsoleView.java",
    "content": "package com.subgraph.vega.ui.console;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.action.Separator;\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StyleRange;\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.ui.IWorkbenchActionConstants;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.console.IConsoleDisplay;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class ConsoleView extends ViewPart implements IConsoleDisplay {\n\n\tfinal private static String CONSOLE_ICON = \"icons/console.png\";\n\tfinal private static String CONSOLE_OUTPUT_ICON = \"icons/console_output.png\";\n\tfinal private static String CONSOLE_ERROR_ICON = \"icons/console_error.png\";\n\t\n\tfinal private static int ALERT_TIME = 4000;\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\n\tprivate StyledText output;\n\tprivate MenuManager contextMenu;\n\t\n\tprivate long lastOutputTime = System.currentTimeMillis();\n\tprivate long lastErrorTime = System.currentTimeMillis();\n\tprivate boolean showingOutputIcon = false;\n\tprivate boolean showingErrorIcon = false;\n\t\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\toutput = new StyledText(parent, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);\n\n\t\toutput.setFont(JFaceResources.getTextFont());\n\t\t\n\t\t/* create and set context menu */\n\t\tcontextMenu = new MenuManager(\"#PopupMenu\");\n\t\tfillContextMenu(contextMenu);\n\t\toutput.setMenu(contextMenu.createContextMenu(output));\n\t\t// createActions();\n\t\tActivator.getDefault().getConsoleService().registerDisplay(this);\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\timageCache.dispose();\n\t\tcontextMenu.dispose();\n\t\tsuper.dispose();\n\t}\n\t\n\t@Override\n\tpublic void setFocus() {\n\t\tshowingErrorIcon = false;\n\t\tshowingOutputIcon = false;\n\t\tsetTitleImage();\n\t\toutput.setFocus();\n\t}\n\n\t@Override\n\tpublic void printOutput(final String message) {\n\t\tDisplay display = Display.getDefault();\n\t\tif (display.isDisposed()) {\n\t\t\tSystem.out.print(message);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tdisplay.asyncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tif(output.isDisposed()) \n\t\t\t\t\treturn;\n\t\t\t\toutput.append(message);\n\t\t\t\toutput.setCaretOffset(output.getCharCount());\n\t\t\t\toutput.showSelection();\n\t\t\t\t\n\t\t\t\tshowOutputIcon();\n\t\t\t}\n\t\t});\n\t}\n\n\t@Override\n\tpublic void printDebug(final String message) {\n\t\tfinal Display display = Display.getDefault();\n\t\tif (display.isDisposed()) {\n\t\t\tSystem.err.print(message);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tdisplay.asyncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tif(output.isDisposed()) \n\t\t\t\t\treturn;\n\t\t\t\toutput.append(message);\n\t\t\t\toutput.setStyleRange(new StyleRange(output.getCharCount()-message.length(), message.length(), display.getSystemColor(SWT.COLOR_BLUE), null));\n\t\t\t\toutput.setCaretOffset(output.getCharCount());\n\t\t\t\toutput.showSelection();\n\t\t\t\t\n\t\t\t\tshowOutputIcon();\n\t\t\t}\n\t\t});\n\t}\n\n\t@Override\n\tpublic void printError(final String message) {\n\t\tfinal Display display = Display.getDefault();\n\t\tif (display.isDisposed()) {\n\t\t\tSystem.err.print(message);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tdisplay.asyncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tif(output.isDisposed()) \n\t\t\t\t\treturn;\n\t\t\t\toutput.append(message);\n\t\t\t\toutput.setStyleRange(new StyleRange(output.getCharCount()-message.length(), message.length(), display.getSystemColor(SWT.COLOR_RED), null));\n\t\t\t\toutput.setCaretOffset(output.getCharCount());\n\t\t\t\toutput.showSelection();\n\t\t\t\t\n\t\t\t\tshowErrorIcon();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void fillContextMenu(IMenuManager menuMgr) {\n\t\tmenuMgr.add(new Action(\"Clear\"){\n\t\t\tpublic void run() {\n\t\t\t\toutput.setText(\"\");\n\t\t\t}\n\t\t});\n\t\t\n\t\t/* add standard separator to handle additions */\n\t\tmenuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));\n\t}\n\n\tprivate void setTitleImage() {\n\t\tif (showingErrorIcon) {\n\t\t\tsetTitleImage(imageCache.get(CONSOLE_ERROR_ICON));\n\t\t} else if (showingOutputIcon) {\n\t\t\tsetTitleImage(imageCache.get(CONSOLE_OUTPUT_ICON));\n\t\t} else {\n\t\t\tsetTitleImage(imageCache.get(CONSOLE_ICON));\n\t\t}\n\t}\n\n\tprivate void animateTitleImage() {\n\t\tsetTitleImage();\n\t\t\n\t\t/*\n\t\t * if the Console doesnt have the focus, keep the title image static to show\n\t\t * output or errors until the user gives focus to it, otherwise schedule\n\t\t * a reset of the icon decoration for a few seconds after the last output\n\t\t * or error happened\n\t\t */\n\t\tif (!output.isFocusControl())\n\t\t\treturn;\n\t\tfinal Display display = Display.getDefault();\n\t\tdisplay.timerExec(ALERT_TIME/2, new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tlong now = System.currentTimeMillis();\n\t\t\t\tif (lastErrorTime + ALERT_TIME <= now)\n\t\t\t\t\tshowingErrorIcon = false;\n\t\t\t\tif (lastOutputTime + ALERT_TIME <= now)\n\t\t\t\t\tshowingOutputIcon = false;\n\t\t\t\tsetTitleImage();\n\t\t\t\tif (showingErrorIcon || showingOutputIcon)\n\t\t\t\t\tdisplay.timerExec(ALERT_TIME/2, this);\n\t\t\t}\n\t\t});\n\t}\n\t\n\tpublic void showErrorIcon() {\n\t\tlastErrorTime = System.currentTimeMillis();\n\t\tif (!showingErrorIcon) {\n\t\t\tshowingErrorIcon = true;\n\t\t\tanimateTitleImage();\n\t\t}\n\t}\n\n\tpublic void showOutputIcon() {\n\t\tlastOutputTime = System.currentTimeMillis();\n\t\tif (!showingOutputIcon) {\n\t\t\tshowingOutputIcon = true;\n\t\t\tanimateTitleImage();\n\t\t}\n\t}\n\t/*\n    protected void createActions() {\n        IViewSite viewSite = getViewSite();\n        IActionBars actionBars = viewSite.getActionBars();\n//\t\tResourceBundle bundle = ConsoleResourceBundleMessages.getBundle();\n//        FindReplaceAction fraction = new FindReplaceAction(bundle, \"find_replace_action_\", this); //$NON-NLS-1$\n //       actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), TestHandler);\n        actionBars.updateActionBars();\n\n    }\n    */\n   \n   \n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.hexeditor</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Hexeditor\nBundle-SymbolicName: com.subgraph.vega.ui.hexeditor\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nRequire-Bundle: org.eclipse.ui;bundle-version=\"3.6.0\"\nExport-Package: com.subgraph.vega.ui.hexeditor\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\nimport org.eclipse.jface.viewers.ILazyContentProvider;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.Viewer;\n\npublic class HexEditContentProvider implements ILazyContentProvider {\n\n\tprivate final TableViewer tableViewer;\n\tprivate HexEditModel model;\n\t\n\tHexEditContentProvider(TableViewer viewer) {\n\t\tthis.tableViewer = viewer;\n\t}\n\t\n\t@Override\n\tpublic void updateElement(int index) {\n\t\tif(model == null)\n\t\t\treturn;\n\t\tfinal HexEditModelItem item = model.getItemForLine(index);\n\t\tif(item != null)\n\t\t\ttableViewer.replace(item, index);\t\t\n\t}\n\n\t@Override\n\tpublic void dispose() {}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tif(newInput instanceof HexEditModel) {\n\t\t\tmodel = (HexEditModel) newInput;\n\t\t\ttableViewer.setItemCount(model.getLineCount());\n\t\t} else {\n\t\t\tmodel = null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditControl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.CellNavigationStrategy;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnViewer;\nimport org.eclipse.jface.viewers.ColumnViewerEditor;\nimport org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;\nimport org.eclipse.jface.viewers.ColumnViewerEditorActivationListener;\nimport org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;\nimport org.eclipse.jface.viewers.ColumnViewerEditorDeactivationEvent;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.jface.viewers.TableViewerEditor;\nimport org.eclipse.jface.viewers.TableViewerFocusCellManager;\nimport org.eclipse.jface.viewers.ViewerCell;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ControlAdapter;\nimport org.eclipse.swt.events.ControlEvent;\nimport org.eclipse.swt.events.ControlListener;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\n\npublic class HexEditControl extends Composite {\n\tprivate final static int WORD_SIZE = 4;\n\tprivate final static int MINIMUM_DATA_COLUMNS = 4;\n\tprivate final HexEditFonts fonts;\n\tprivate TableViewer tableViewer;\n\tprivate HexEditModel model;\n\tprivate int currentDataColumnCount;\n\tprivate boolean editable = true;\n\tprivate volatile boolean enablePreserveSelection = true;\n\tpublic HexEditControl(Composite parent) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.fonts = new HexEditFonts(this);\n\t\tcurrentDataColumnCount = calculateDataColumnCount(getClientArea().width);\n\t\ttableViewer = createTableViewer();\n\t\ttableViewer.setContentProvider(new HexEditContentProvider(tableViewer));\n\t\tcreateColumns(currentDataColumnCount);\n\t\t\n\t\taddControlListener(createControlListener());\n\t}\n\t\n\tprivate TableViewer createTableViewer() {\n\t\tfinal TableViewer tv = new TableViewer(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL) {\n\t\t\t@Override\n\t\t\tprotected void preservingSelection(Runnable updateCode) { \n\t\t\t\tif(enablePreserveSelection)\n\t\t\t\t\tsuper.preservingSelection(updateCode);\n\t\t\t}\n\t\t};\n\t\t\n\t\ttv.getTable().setHeaderVisible(true);\t\n\t\ttv.setUseHashlookup(true);\n\t\tif(editable)\n\t\t\taddEditorSupport(tv);\n\t\treturn tv;\n\t}\n\t/*\n\t * Q: teh fuck is this?\n\t * A: http://bingjava.appspot.com/snippet.jsp?id=2213\n\t */\n\tprivate void addEditorSupport(TableViewer tv) {\n\t\tfinal CellNavigationStrategy cellNavigation = createCellNavigationStrategy(tv);\n\t\tfinal TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(tv, new FocusCellOwnerDrawHighlighter(tv), cellNavigation);\n\t\tfinal ColumnViewerEditorActivationStrategy activationStrategy = createEditorActivationStrategy(tv);\n\t\tTableViewerEditor.create(tv, focusCellManager, activationStrategy, \n\t\t\t\tColumnViewerEditor.TABBING_HORIZONTAL \n\t\t\t\t| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR\n\t\t\t\t| ColumnViewerEditor.TABBING_VERTICAL \n\t\t\t\t| ColumnViewerEditor.KEYBOARD_ACTIVATION);\n\t\ttv.getColumnViewerEditor().addEditorActivationListener(createEditorActivationListener(tv));\n\t}\n\tprivate CellNavigationStrategy createCellNavigationStrategy(TableViewer tv) {\n\t\tfinal Table t = tv.getTable();\n\t\treturn new CellNavigationStrategy() {\n\t\t\t@Override\n\t\t\tpublic ViewerCell findSelectedCell(ColumnViewer viewer, \n\t\t\t\t\tViewerCell currentSelectedCell, Event event) {\n\t\t\t\tfinal ViewerCell cell = super.findSelectedCell(viewer, currentSelectedCell, event);\n\t\t\t\tif(cell != null) {\n\t\t\t\t\tt.showColumn(t.getColumn(cell.getColumnIndex()));\n\t\t\t\t}\n\t\t\t\treturn cell;\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate ColumnViewerEditorActivationStrategy createEditorActivationStrategy(TableViewer tv) {\n\t\treturn new ColumnViewerEditorActivationStrategy(tv) {\n\t\t\tprotected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {\n\t\t\t\treturn  event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL \n\t\t\t\t||  event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION\n\t\t\t\t|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR);\n\t\t\t}\n\t\t};\n\t}\n\tprivate ColumnViewerEditorActivationListener createEditorActivationListener(TableViewer tv) {\n\t\tfinal Table t = tv.getTable();\n\t\treturn new ColumnViewerEditorActivationListener() {\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic void beforeEditorDeactivated(\n\t\t\t\t\tColumnViewerEditorDeactivationEvent event) {\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic void beforeEditorActivated(ColumnViewerEditorActivationEvent event) {\t\t\n\t\t\t\tViewerCell cell = (ViewerCell) event.getSource();\n\t\t\t\tt.showColumn(t.getColumn(cell.getColumnIndex()));\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic void afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic void afterEditorActivated(ColumnViewerEditorActivationEvent event) {\n\t\t\t}\n\t\t};\n\t}\n\t\n\tpublic void setInput(byte[] binaryData) {\n\t\tif(currentDataColumnCount == 0) {\n\t\t\tmodel = new HexEditModel(binaryData);\n\t\t} else {\n\t\t\tmodel = new HexEditModel(binaryData, currentDataColumnCount);\n\t\t}\n\t\tchangeModel(model);\n\t}\n\t\n\tpublic boolean isContentDirty() {\n\t\tif(model != null) {\n\t\t\treturn model.isDirty();\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tpublic byte[] getContent() {\n\t\treturn model.getContent();\n\t}\n\t\n\tprivate void changeModel(final HexEditModel model) {\n\t\t// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200214\n\t\tenablePreserveSelection = false;\n\t\ttableViewer.setInput(model);\n\t\tenablePreserveSelection = true;\t\t\n\t}\n\n\tprivate void createColumns(int dataColumnCount) {\n\t\ttableViewer.getTable().dispose();\n\t\ttableViewer = createTableViewer();\n\t\ttableViewer.setContentProvider(new HexEditContentProvider(tableViewer));\n\t\tfinal TableColumnLayout layout = new TableColumnLayout();\n\t\tcreateOffsetColumn(layout);\n\t\tfor(int i = 0; i < dataColumnCount; i++)\n\t\t\tcreateDataColumn(layout, i);\n\t\tcreateAsciiColumn(layout);\n\t\tsetLayout(layout);\n\t\ttableViewer.setLabelProvider(new HexEditLabelProvider(fonts));\n\t}\n\t\n\tprivate void createOffsetColumn(TableColumnLayout layout) {\n\t\tfinal TableColumn c = createColumn(\"Offset\", SWT.CENTER);\n\t\tc.setAlignment(SWT.RIGHT);\n\t\tlayout.setColumnData(c, new ColumnPixelData(fonts.getOffsetColumnWidth(), false, false));\n\t}\n\t\n\tprivate void createAsciiColumn(TableColumnLayout layout) {\n\t\tfinal TableColumn c = createColumn(\"\", SWT.CENTER);\n\t\tlayout.setColumnData(c, new ColumnWeightData(100));\n\t}\n\t\n\tprivate void createDataColumn(TableColumnLayout layout, int index) {\n\t\tfinal EditingSupport editor = (editable) ? (new HexEditTableEditor(tableViewer, index)) : (null);\n\t\tfinal TableColumn c = createColumn(String.format(\"%02X\", index), SWT.CENTER, editor);\n\t\tlayout.setColumnData(c, new ColumnPixelData(fonts.getDataColumnWidth(), false, false));\n\t}\n\t\n\tprivate TableColumn createColumn(String headerText, int align) {\n\t\treturn createColumn(headerText, align, null);\n\t}\n\n\tprivate TableColumn createColumn(String headerText, int align, EditingSupport editor) {\n\t\tfinal TableViewerColumn tvc = new TableViewerColumn(tableViewer, align);\n\t\tfinal TableColumn tc = tvc.getColumn();\n\t\ttc.setMoveable(false);\n\t\ttc.setResizable(false);\n\t\ttc.setText(headerText);\n\t\tif(editor != null)\n\t\t\ttvc.setEditingSupport(editor);\n\t\treturn tc;\n\t}\n\t\n\tprivate ControlListener createControlListener() {\n\t\treturn new ControlAdapter() {\n\t\t\t@Override\n\t\t\tpublic void controlResized(ControlEvent e) {\n\t\t\t\tdoResize();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void doResize() {\n\t\tfinal int width = getClientArea().width;\t\t\n\t\tfinal int cc = calculateDataColumnCount(width);\n\t\tif(cc != currentDataColumnCount) {\n\t\t\tchangeModel(null);\n\t\t\tcreateColumns(cc);\n\t\t\tif(model != null) {\n\t\t\t\t// Remembering old offset does not work on Linux.  Maybe because of these bugs:\n\t\t\t\t//\n\t\t\t\t// https://bugs.eclipse.org/bugs/show_bug.cgi?id=74739\n\t\t\t\t// https://bugs.eclipse.org/bugs/show_bug.cgi?id=202392\n\t\t\t\t// https://bugs.eclipse.org/bugs/show_bug.cgi?id=295666\n\t\t\t\tfinal HexEditModel newModel = model.getModelForRowLength(cc);\n\t\t\t\tfinal int topIndex = tableViewer.getTable().getTopIndex();\n\t\t\t\tfinal int topOffset = model.getOffsetForLine(topIndex);\n\t\t\t\tfinal int newTopIndex = newModel.getLineForOffset(topOffset);\n\t\t\t\tchangeModel(newModel);\n\t\t\t\tmodel = newModel;\t\t\t\t\n\t\t\t\tif(newTopIndex != 0) {\n\t\t\t\t\ttableViewer.getTable().setTopIndex(newTopIndex);\n\t\t\t\t}\t\t\n\t\t\t} else {\n\t\t\t\tchangeModel(model);\n\t\t\t}\n\t\t\tcurrentDataColumnCount = cc;\n\t\t}\n\t}\n\t\n\t\n\tprivate int calculateDataColumnCount(int pixelWidth) {\n\t\t/*\n\t\t * w = width\n\t\t * o = offsetColumnWidth\n\t\t * d = dataColumnWidth\n\t\t * a = asciiColumnWordWidth\n\t\t * n = words\n\t\t * \n\t\t * w = o + 4nd + na\n\t\t * w - o = n(4d + a)\n\t\t * n = (w - o) / (4d + a)\n\t\t */\n\t\t\n\t\tint space = (pixelWidth - fonts.getOffsetColumnWidth()) - 30;\n\t\tint perWord = WORD_SIZE * fonts.getDataColumnWidth() + fonts.getAsciiColumnWordWidth();\n\t\tint words = space / perWord;\n\t\tint columns = words * WORD_SIZE;\n\t\treturn (columns < MINIMUM_DATA_COLUMNS) ? (MINIMUM_DATA_COLUMNS) : (columns);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditFonts.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\nimport org.eclipse.jface.resource.FontRegistry;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Font;\nimport org.eclipse.swt.graphics.FontData;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Display;\n\npublic class HexEditFonts {\n\tprivate final static String HEX_ELEMENT_FONT = \"hex-element\";\n\tprivate final static String HEX_ASCII_FONT = \"hex-ascii\";\n\tprivate final static int FONT_PADDING = 10;\n\tprivate final FontRegistry fontRegistry;\n\n\tprivate final int offsetColumnWidth;\n\tprivate final int dataColumnWidth;\n\tprivate final int asciiColumnWordWidth;\n\t\n\tHexEditFonts(Composite parent) {\n\t\tfontRegistry = new FontRegistry();\n\t\taddFonts(parent.getDisplay());\n\t\toffsetColumnWidth = calculateOffsetColumnWidth(parent);\n\t\tdataColumnWidth = calculateDataColumnWidth(parent);\n\t\tasciiColumnWordWidth = calculateAsciiColumnWordWidth(parent);\n\t}\n\t\n\tprivate void addFonts(Display display) {\n\t\tadd(display, HEX_ELEMENT_FONT, 10, \"Monospace\", \"Courier\");\n\t\tadd(display, HEX_ASCII_FONT, 10, \"Monospace\", \"Courier\");\n\t}\n\t\n\tprivate void add(Display display, String tag, int size, String ...names) {\n\t\tfor(String fontName: names) {\n\t\t\tif(fontNameExists(display, fontName)) {\n\t\t\t\tfontRegistry.put(tag, new FontData[] { new FontData(fontName, size, SWT.NORMAL) });\n\t\t\t}\n\t\t}\n\t}\n\t\n\tboolean fontNameExists(Display display, String name) {\n\t\treturn display.getFontList(name, true).length > 0 || display.getFontList(name, false).length > 0;\n\t}\n\tFont getElementFont() {\n\t\treturn fontRegistry.get(HEX_ELEMENT_FONT);\n\t}\n\t\n\tFont getAsciiFont() {\n\t\treturn fontRegistry.get(HEX_ASCII_FONT);\n\t}\n\t\n\tint getOffsetColumnWidth() {\n\t\treturn offsetColumnWidth;\n\t}\n\t\n\tint getDataColumnWidth() {\n\t\treturn dataColumnWidth;\n\t}\n\t\n\tint getAsciiColumnWordWidth() {\n\t\treturn asciiColumnWordWidth;\n\t}\n\t\n\tprivate int calculateOffsetColumnWidth(Composite composite) {\n\t\tfinal GC gc = new GC(composite);\n\t\treturn getColumnWidth(HEX_ELEMENT_FONT, \"000000\", gc);\n\t}\n\t\n\tprivate int calculateDataColumnWidth(Composite composite) {\n\t\tfinal GC gc = new GC(composite);\n\t\treturn getColumnWidth(HEX_ELEMENT_FONT, \"00\", gc);\n\t}\n\t\n\tprivate int calculateAsciiColumnWordWidth(Composite composite) {\n\t\tfinal GC gc = new GC(composite);\n\t\treturn getColumnWidth(HEX_ASCII_FONT, \"0000\", gc);\n\t}\n\t\n\t\n\tprivate int getColumnWidth(String fontTag, String str, GC gc) {\n\t\tgc.setFont(fontRegistry.get(fontTag));\n\t\tPoint extent = gc.textExtent(str);\n\t\treturn extent.x + (FONT_PADDING * 2);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\nimport org.eclipse.jface.viewers.ITableFontProvider;\nimport org.eclipse.jface.viewers.ITableLabelProvider;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Font;\nimport org.eclipse.swt.graphics.Image;\n\npublic class HexEditLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider  {\n\n\tprivate final HexEditFonts fonts;\n\t\n\tHexEditLabelProvider(HexEditFonts fonts) {\n\t\tthis.fonts = fonts;\n\t}\n\t\n\t@Override\n\tpublic Image getColumnImage(Object element, int columnIndex) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getColumnText(Object element, int columnIndex) {\n\t\tif(!(element instanceof HexEditModelItem))\n\t\t\treturn null;\n\t\tfinal HexEditModelItem item = (HexEditModelItem) element;\n\t\tif(columnIndex == 0)\n\t\t\treturn String.format(\"%04X:\", item.getOffset());\n\t\telse if(columnIndex > 0 && columnIndex <= item.getRowLength()) {\n\t\t\tint value = item.getByteAt(columnIndex - 1);\n\t\t\tif(value == -1)\n\t\t\t\treturn \"\";\n\t\t\telse\n\t\t\t\treturn String.format(\"%02X\", value);\n\t\t} else if(columnIndex == item.getRowLength() + 1) {\n\t\t\treturn renderAscii(item);\n\t\t} else {\n\t\t\treturn \"???\";\n\t\t}\n\t}\n\t\n\tprivate String renderAscii(HexEditModelItem item) {\n\t\tfinal StringBuilder buffer = new StringBuilder();\n\t\tfinal int len = item.getRowByteCount();\n\t\tfinal byte[] rowData = new byte[len];\n\t\titem.getData(rowData);\n\t\tfor(int i = 0; i < item.getRowLength(); i++) {\n\t\t\tif(i >= rowData.length)\n\t\t\t\tbuffer.append(\" \");\n\t\t\telse\n\t\t\t\tbuffer.append(renderByte(rowData[i]));\n\t\t}\n\t\treturn buffer.toString();\n\t}\n\t\n\tprivate String renderByte(byte b) {\n\t\tif(isPrintable(b))\n\t\t\treturn Character.toString((char)b);\n\t\telse \n\t\t\treturn \".\";\n\t}\n\t\n\tprivate boolean isPrintable(byte b) {\n\t\treturn (b >= 32 && b <= 126);\n\t}\n\n\t@Override\n\tpublic Font getFont(Object element, int columnIndex) {\n\t\tif(!(element instanceof HexEditModelItem))\n\t\t\treturn null;\n\t\tfinal HexEditModelItem item = (HexEditModelItem) element;\n\t\tif(columnIndex <= item.getRowLength())\n\t\t\treturn fonts.getElementFont();\n\t\telse\n\t\t\treturn fonts.getAsciiFont();\n\t}\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditModel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\npublic class HexEditModel {\n\tfinal static int DEFAULT_ROW_LENGTH = 16;\n\t\n\tprivate final byte[] binaryData;\n\tprivate final int rowLength;\n\tprivate final int lineCount;\n\t\n\tprivate boolean dirtyFlag;\n\t\n\tpublic HexEditModel(byte[] binaryData) {\n\t\tthis(binaryData, DEFAULT_ROW_LENGTH, false);\n\t}\n\n\tpublic HexEditModel(byte[] binaryData, int rowLength) {\n\t\tthis(binaryData, rowLength, false);\n\t}\n\t\n\tpublic HexEditModel(byte[] binaryData, int rowLength, boolean dirtyFlag) {\n\t\tif(rowLength <= 0)\n\t\t\tthrow new IllegalArgumentException();\n\t\tthis.binaryData = binaryData;\n\t\tthis.rowLength = rowLength;\n\t\tthis.lineCount = (binaryData.length + (rowLength - 1)) / rowLength;\n\t\tthis.dirtyFlag = dirtyFlag;\n\t}\n\n\tbyte[] getContent() {\n\t\treturn binaryData;\n\t}\n\n\tboolean isDirty() {\n\t\treturn dirtyFlag;\n\t}\n\n\tint getOffsetForLine(int line) {\n\t\tif (line >= lineCount) {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\treturn line * rowLength;\n\t\t}\n\t}\n\n\tint getLineForOffset(int offset) {\n\t\tif (offset >= binaryData.length) {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\treturn offset / rowLength;\n\t\t}\n\t}\n\n\tint getLineCount() {\n\t\treturn lineCount;\n\t}\n\t\n\tvoid markDirty() {\n\t\tdirtyFlag = true;\n\t}\n\n\tHexEditModel getModelForRowLength(int rowLength) {\n\t\treturn new HexEditModel(binaryData, rowLength, dirtyFlag);\n\t}\n\n\tHexEditModelItem getItemForLine(int line) {\n\t\tif(line >= lineCount)\n\t\t\tthrow new IllegalArgumentException();\n\t\t\n\t\tint lineOffset = rowLength * line;\n\t\tif(line == lineCount - 1) {\n\t\t\tint lastLineLength = binaryData.length - lineOffset;\n\t\t\treturn new HexEditModelItem(this, lineOffset, binaryData, lastLineLength, rowLength);\n\t\t}\n\t\treturn new HexEditModelItem(this, lineOffset, binaryData, rowLength, rowLength);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditModelItem.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\npublic class HexEditModelItem {\n\tprivate final HexEditModel model;\n\tprivate final int itemOffset;\n\tprivate final byte[] data;\n\tprivate final int rowCount;\n\tprivate final int rowLength;\n\t\n\t\n\tHexEditModelItem(HexEditModel model, int offset, byte[] data, int rowCount, int rowLength) {\n\t\tthis.model = model;\n\t\tthis.itemOffset = offset;\n\t\tthis.data = data;\n\t\t// XXX We can calculate this, right?\n\t\tthis.rowCount = rowCount;\n\t\tthis.rowLength = rowLength;\n\t}\n\t\n\tint getOffset() {\n\t\treturn itemOffset;\n\t}\n\t\n\tint getRowByteCount() {\n\t\treturn rowCount;\n\t}\n\tint getRowLength() {\n\t\treturn rowLength;\n\t}\n\n\tint getByteAt(int index) {\n\t\tif(index < 0 || index >= rowLength)\n\t\t\tthrow new IllegalArgumentException();\n\t\t\n\t\tif(index + itemOffset >= data.length)\n\t\t\treturn -1;\n\t\t\n\t\treturn data[index + itemOffset] & 0xFF;\n\t}\n\t\n\tvoid setByteAt(int index, int value) {\n\t\tif(index < 0 || index >= rowCount)\n\t\t\tthrow new IllegalArgumentException();\n\t\tdata[index + itemOffset] = (byte) value;\n\t\tmodel.markDirty();\n\t}\n\n\tvoid getData(byte[] buffer) {\n\t\tgetData(buffer, 0);\n\t}\n\n\tvoid getData(byte[] buffer, int offset) {\n\t\tif((buffer.length - offset) < rowCount)\n\t\t\tthrow new IllegalArgumentException();\n\t\tSystem.arraycopy(data, itemOffset, buffer, offset, rowCount);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.hexeditor/src/com/subgraph/vega/ui/hexeditor/HexEditTableEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.hexeditor;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TextCellEditor;\n\npublic class HexEditTableEditor extends EditingSupport {\n\n\tprivate final TableViewer viewer;\n\tprivate final int index;\n\t\n\tHexEditTableEditor(TableViewer viewer, int index) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t\tthis.index = index;\n\t}\n\t\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn new TextCellEditor(viewer.getTable());\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\tif(element instanceof HexEditModelItem) {\n\t\t\tHexEditModelItem item = (HexEditModelItem) element;\n\t\t\tint value = item.getByteAt(index);\n\t\t\treturn String.format(\"%02X\", value);\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\tif(!(element instanceof HexEditModelItem))\n\t\t\treturn;\n\t\tfinal HexEditModelItem item = (HexEditModelItem) element;\n\t\ttry {\n\t\t\tint n = Integer.parseInt(String.valueOf(value), 16);\n\t\t\tif(n >= 0 && n <= 0xFF) {\n\t\t\t\titem.setByteAt(index, n);\n\t\t\t\tviewer.refresh(element, true);\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.http</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ds.core.builder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Http\nBundle-SymbolicName: com.subgraph.vega.ui.http;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.subgraph.vega.api.analysis,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.http.proxy,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.conditions,\n com.subgraph.vega.api.model.conditions.match,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.tags,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.ui.httpeditor,\n com.subgraph.vega.ui.httpeditor.parser,\n com.subgraph.vega.ui.tags.taggableeditor,\n com.subgraph.vega.ui.tagsl.taggablepopup,\n com.subgraph.vega.ui.util.dialogs,\n com.subgraph.vega.ui.util.images,\n com.subgraph.vega.ui.util.modules,\n com.subgraph.vega.ui.util.preferences,\n org.apache.http;version=\"4.1.0\",\n org.apache.http.client;version=\"4.1.1\",\n org.apache.http.client.methods,\n org.apache.http.protocol;version=\"4.1.0\"\nRequire-Bundle: org.eclipse.ui;bundle-version=\"3.6.0\",\n org.eclipse.core.runtime;bundle-version=\"3.6.0\"\nBundle-Activator: com.subgraph.vega.ui.http.Activator\nBundle-ActivationPolicy: lazy\nExport-Package: com.subgraph.vega.ui.http,\n com.subgraph.vega.ui.http.builder,\n com.subgraph.vega.ui.http.request.view,\n com.subgraph.vega.ui.http.requestlogviewer\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/build.properties",
    "content": "output.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/\nsource.. = src/\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <view\n            allowMultiple=\"true\"\n            class=\"com.subgraph.vega.ui.http.request.view.HttpRequestView\"\n            icon=\"icons/requestview.png\"\n            id=\"com.subgraph.vega.views.http\"\n            name=\"Requests\"\n            restorable=\"true\">\n      </view>\n      <view\n            allowMultiple=\"false\"\n            class=\"com.subgraph.vega.ui.http.intercept.InterceptView\"\n            icon=\"icons/intercept.png\"\n            id=\"com.subgraph.vega.views.intercept\"\n            name=\"Intercept\"\n            restorable=\"true\">\n      </view>\n      <view\n            allowMultiple=\"false\"\n            class=\"com.subgraph.vega.ui.http.statusview.StatusView\"\n            icon=\"icons/proxy_status.png\"\n            id=\"com.subgraph.vega.views.proxystatus\"\n            name=\"Proxy Status\"\n            restorable=\"true\">\n      </view>\n      <view\n            allowMultiple=\"true\"\n            class=\"com.subgraph.vega.ui.http.requesteditviewer.RequestEditView\"\n            icon=\"icons/requestEdit.png\"\n            id=\"com.subgraph.vega.views.requestEdit\"\n            name=\"Request Editor\"\n            restorable=\"false\">\n      </view>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.StartProxyHandler\"\n            commandId=\"com.subgraph.vega.commands.startProxy\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.proxyState\">\n               <equals\n                     value=\"disabled\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.StopProxyHandler\"\n            commandId=\"com.subgraph.vega.commands.stopProxy\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.proxyState\">\n               <equals\n                     value=\"enabled\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.SendRequest\"\n            commandId=\"com.subgraph.vega.commands.sendRequest\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.OpenRequestView\"\n            commandId=\"com.subgraph.vega.commands.openRequestView\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.OpenRequestViewFilter\"\n            commandId=\"com.subgraph.vega.commands.openRequestFilter\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.ResetRequestFilter\"\n            commandId=\"com.subgraph.vega.commands.resetRequestFilter\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.ConfigureProxyModules\"\n            commandId=\"com.subgraph.vega.commands.proxyConfigureModules\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.ProxyPassthrough\"\n            commandId=\"com.subgraph.vega.commands.proxyPassthrough\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.InterceptForwardTransaction\"\n            commandId=\"com.subgraph.vega.commands.interceptForward\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.interceptQueueState\">\n               <equals\n                     value=\"pending\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.InterceptDropTransaction\"\n            commandId=\"com.subgraph.vega.commands.interceptDrop\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.interceptQueueState\">\n               <or>\n                  <equals\n                        value=\"pending\">\n                  </equals>\n                  <equals\n                        value=\"requestSent\">\n                  </equals>\n               </or>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.http.commands.ProxyScanHandler\"\n            commandId=\"com.subgraph.vega.commands.proxyScan\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.proxyState\">\n               <equals\n                     value=\"enabled\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <category\n            description=\"Commands for controlling the HTTP proxy\"\n            id=\"com.subgraph.vega.commands.proxyCategory\"\n            name=\"Proxy Commands\">\n      </category>\n      <command\n            categoryId=\"com.subgraph.vega.commands.proxyCategory\"\n            description=\"Start the HTTP Proxy\"\n            id=\"com.subgraph.vega.commands.startProxy\"\n            name=\"Start HTTP Proxy\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.proxyCategory\"\n            description=\"Stop the HTTP Proxy\"\n            id=\"com.subgraph.vega.commands.stopProxy\"\n            name=\"Stop HTTP Proxy\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.proxyCategory\"\n            description=\"Configure Proxy Response Processing Modules\"\n            id=\"com.subgraph.vega.commands.proxyConfigureModules\"\n            name=\"Configure Proxy Response Processing Modules\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.proxyCategory\"\n            id=\"com.subgraph.vega.commands.proxyPassthrough\"\n            name=\"Toggle HTTP proxy passthrough\">\n         <state\n               class=\"com.subgraph.vega.ui.http.commands.ToggleState\"\n               id=\"org.eclipse.ui.commands.toggleState\">\n         </state>\n      </command>\n      <category\n            description=\"Commands for controlling the request editor\"\n            id=\"com.subgraph.vega.commands.requestEditorCategory\"\n            name=\"Request Editor Commands\">\n      </category>\n      <command\n            categoryId=\"com.subgraph.vega.commands.requestEditorCategory\"\n            description=\"Send the HTTP Request\"\n            id=\"com.subgraph.vega.commands.sendRequest\"\n            name=\"Send Request\">\n      </command>\n      <category\n            id=\"com.subgraph.vega.commands.requestViewCategory\"\n            name=\"Commands for controlling the Request View\">\n      </category>\n      <command\n            categoryId=\"com.subgraph.vega.commands.requestViewCategory\"\n            id=\"com.subgraph.vega.commands.openRequestView\"\n            name=\"Open New Request Viewer\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.requestViewCategory\"\n            id=\"com.subgraph.vega.commands.openRequestFilter\"\n            name=\"Open Request View Filter\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.requestViewCategory\"\n            id=\"com.subgraph.vega.commands.resetRequestFilter\"\n            name=\"Reset Request View Filter\">\n      </command>\n      <category\n            description=\"Commands for controlling the HTTP proxy interceptor\"\n            id=\"com.subgraph.vega.commands.interceptCategory\"\n            name=\"Proxy Interceptor Commands\">\n      </category>\n      <command\n            categoryId=\"com.subgraph.vega.commands.interceptCategory\"\n            id=\"com.subgraph.vega.commands.interceptForward\"\n            name=\"Forward Transaction\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.interceptCategory\"\n            id=\"com.subgraph.vega.commands.interceptDrop\"\n            name=\"Drop Transaction\">\n      </command>\n      <command\n            categoryId=\"com.subgraph.vega.commands.proxyCategory\"\n            id=\"com.subgraph.vega.commands.proxyScan\"\n            name=\"Start Proxy Scan\">\n         <state\n               class=\"com.subgraph.vega.ui.http.commands.ToggleState\"\n               id=\"org.eclipse.ui.commands.toggleState\">\n         </state>\n      </command>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            locationURI=\"toolbar:org.eclipse.ui.main.toolbar\">\n         <toolbar\n               id=\"com.subgraph.vega.toolbars.main\">\n            <command\n                  commandId=\"com.subgraph.vega.commands.startProxy\"\n                  icon=\"icons/start_16x16.png\"\n                  style=\"push\"\n                  tooltip=\"Start HTTP Proxy\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.proxy\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.commands.stopProxy\"\n                  icon=\"icons/stop_16x16.png\"\n                  style=\"push\"\n                  tooltip=\"Stop HTTP Proxy\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.proxy\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.commands.proxyConfigureModules\"\n                  icon=\"icons/configure.png\"\n                  style=\"push\"\n                  tooltip=\"Configure which scanner modules are run on proxy traffic\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.proxy\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.commands.proxyPassthrough\"\n                  icon=\"icons/passthrough.png\"\n                  style=\"toggle\"\n                  tooltip=\"Make proxy forward all transactions without processing or interception\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.proxy\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.commands.proxyScan\"\n                  icon=\"icons/proxy_scan.png\"\n                  style=\"toggle\"\n                  tooltip=\"Start Proxy Scan\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.proxy\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n         </toolbar>\n      </menuContribution>\n      <menuContribution\n            locationURI=\"toolbar:com.subgraph.vega.views.requestEdit\">\n         <command\n               commandId=\"com.subgraph.vega.commands.sendRequest\"\n               icon=\"icons/start_16x16.png\"\n               label=\"Send Request\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:com.subgraph.vega.views.http\">\n         <command\n               commandId=\"com.subgraph.vega.commands.openRequestView\"\n               icon=\"icons/new_request_view.png\"\n               label=\"Open New Request Viewer\"\n               style=\"push\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.commands.resetRequestFilter\"\n               icon=\"icons/reset_filter.png\"\n               label=\"Reset Request Filter\"\n               style=\"push\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.commands.openRequestFilter\"\n               icon=\"icons/filter.gif\"\n               id=\"openfilter\"\n               label=\"Open Request Filter\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:com.subgraph.vega.views.intercept\">\n         <command\n               commandId=\"com.subgraph.vega.commands.interceptForward\"\n               icon=\"icons/start_16x16.png\"\n               label=\"Forward Transaction\"\n               style=\"push\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.commands.interceptDrop\"\n               icon=\"icons/stop_16x16.png\"\n               label=\"Drop Transaction\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n    \n   </extension>\n   <extension\n         point=\"org.eclipse.ui.services\">\n      <sourceProvider\n            provider=\"com.subgraph.vega.ui.http.commands.ProxyStateSourceProvider\">\n         <variable\n               name=\"vega.proxyState\"\n               priorityLevel=\"workbench\">\n         </variable>\n      </sourceProvider>\n      <sourceProvider\n            provider=\"com.subgraph.vega.ui.http.commands.InterceptQueueStateSourceProvider\">\n         <variable\n               name=\"vega.interceptQueueState\"\n               priorityLevel=\"workbench\">\n         </variable>\n      </sourceProvider>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.preferencePages\">\n      <page\n            class=\"com.subgraph.vega.ui.http.preferencepage.HttpPreferencePage\"\n            id=\"com.subgraph.vega.ui.http.preferences.proxy\"\n            name=\"Proxy\">\n      </page>\n      <page\n            category=\"com.subgraph.vega.ui.http.preferences.proxy\"\n            class=\"com.subgraph.vega.ui.http.preferencepage.ProxyListenerPreferencePage\"\n            id=\"com.subgraph.vega.ui.http.preferences.proxyListener\"\n            name=\"Listener\">\n      </page>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.runtime.preferences\">\n      <initializer\n            class=\"com.subgraph.vega.ui.http.preferencepage.HttpPreferenceInitializer\">\n      </initializer>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectives\">\n      <perspective\n            class=\"com.subgraph.vega.internal.ui.http.ProxyPerspectiveFactory\"\n            icon=\"icons/proxy.png\"\n            id=\"com.subgraph.vega.perspectives.proxy\"\n            name=\"Proxy\">\n      </perspective>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectiveExtensions\">\n      <perspectiveExtension\n            targetID=\"com.subgraph.vega.perspectives.proxy\">\n         <view\n               id=\"com.subgraph.vega.views.scaninfo\"\n               minimized=\"false\"\n               relationship=\"stack\"\n               relative=\"com.subgraph.vega.views.intercept\"\n               visible=\"false\">\n         </view>\n      </perspectiveExtension>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/internal/ui/http/ProxyPerspectiveFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.http;\n\nimport org.eclipse.ui.IFolderLayout;\nimport org.eclipse.ui.IPageLayout;\nimport org.eclipse.ui.IPerspectiveFactory;\n\nimport com.subgraph.vega.ui.http.intercept.InterceptView;\nimport com.subgraph.vega.ui.http.request.view.HttpRequestView;\nimport com.subgraph.vega.ui.http.statusview.StatusView;\n\npublic class ProxyPerspectiveFactory implements IPerspectiveFactory {\n\tpublic final static String ID = \"com.subgraph.vega.perspectives.proxy\";\n\t\n\tprivate final static String PROXY_FOLDER = \"proxy\";\n\tprivate final static String WEBSITE_VIEW = \"com.subgraph.vega.views.website\";\n\tprivate final static String ALERT_VIEW = \"com.subgraph.vega.views.alert\";\n\n\n\t@Override\n\tpublic void createInitialLayout(IPageLayout layout) {\n\t\tIFolderLayout proxyFolder = layout.createFolder(PROXY_FOLDER, IPageLayout.TOP, 0f, layout.getEditorArea());\n\t\tproxyFolder.addView(HttpRequestView.ID_PROXY);\n\t\tlayout.getViewLayout(HttpRequestView.ID_PROXY).setCloseable(false);\n\t\tproxyFolder.addView(InterceptView.ID);\n\t\tlayout.getViewLayout(InterceptView.ID).setCloseable(false);\n\t\tproxyFolder.addView(StatusView.ID);\n\t\tlayout.getViewLayout(StatusView.ID).setCloseable(false);\n\t\tlayout.addView(WEBSITE_VIEW, IPageLayout.LEFT, 0.25f, PROXY_FOLDER);\n\t\tlayout.getViewLayout(WEBSITE_VIEW).setCloseable(false);\n\t\t\n\t\tlayout.addFastView(ALERT_VIEW, 0.25f);\n\t\tlayout.getViewLayout(ALERT_VIEW).setCloseable(false);\n\n\t\tlayout.setEditorAreaVisible(false);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/internal/ui/http/ProxyServiceTrackerCustomizer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.http;\n\nimport org.osgi.framework.BundleContext;\nimport org.osgi.framework.ServiceReference;\nimport org.osgi.util.tracker.ServiceTrackerCustomizer;\n\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptorEventHandler;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListener;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyServiceEventHandler;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\n\npublic class ProxyServiceTrackerCustomizer implements ServiceTrackerCustomizer<IHttpProxyService, IHttpProxyService> {\n\tprivate final BundleContext context;\n\tprivate final ProxyStatusLineContribution statusLineContribution;\n\tprivate IHttpProxyService proxyService;\n\tprivate IHttpProxyServiceEventHandler proxyEventHandler;\n\tprivate IHttpInterceptor interceptor;\n\tprivate IHttpInterceptorEventHandler interceptorEventHandler;\n\n\tpublic ProxyServiceTrackerCustomizer(BundleContext context, ProxyStatusLineContribution statusLineContribution) {\n\t\tthis.context = context;\n\t\tthis.statusLineContribution = statusLineContribution;\n\t\tproxyEventHandler = new IHttpProxyServiceEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void notifyStart(int listenerCount) {\n\t\t\t\thandleNotifyStart(listenerCount);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyStartListener(IHttpProxyListener listener) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyStop() {\n\t\t\t\thandleNotifyStop();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyStopListener(IHttpProxyListener listener) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyConfigChange(int listenerCount) {\n\t\t\t\thandleNotifyConfigChange(listenerCount);\n\t\t\t}\n\t\t};\n\t\tinterceptorEventHandler = new IHttpInterceptorEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void notifyQueue(IProxyTransaction transaction, int idx) {\n\t\t\t\thandleNotifyQueue(transaction);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyRemove(int idx) {\n\t\t\t\thandleNotifyRemove();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyEmpty() {\n\t\t\t\thandleNotifyEmpty();\n\t\t\t}\n\t\t};\n\t}\n\t\n\t@Override\n\tpublic IHttpProxyService addingService(ServiceReference<IHttpProxyService> reference) {\n\t\tproxyService = context.getService(reference);\n\t\tproxyService.registerEventHandler(proxyEventHandler);\n\t\tif (proxyService.isRunning()) {\n\t\t\tstatusLineContribution.setProxyRunning(proxyService.getListenerConfigsCount());\n\t\t} else {\n\t\t\tstatusLineContribution.setProxyStopped();\n\t\t}\n\t\tinterceptor = proxyService.getInterceptor();\n\t\tinterceptor.addEventHandler(interceptorEventHandler);\n\t\treturn proxyService;\n\t}\n\n\t@Override\n\tpublic void modifiedService(ServiceReference<IHttpProxyService> reference, IHttpProxyService service) {\n\t\t// TODO Auto-generated method stub\n\t}\n\n\t@Override\n\tpublic void removedService(ServiceReference<IHttpProxyService> reference, IHttpProxyService service) {\n\t\t// TODO Auto-generated method stub\n\t}\n\n\tprivate void handleNotifyStart(int numListeners) {\n\t\tstatusLineContribution.setProxyRunning(numListeners);\n\t}\n\n\tprivate void handleNotifyStop() {\n\t\tstatusLineContribution.setProxyStopped();\n\t}\n\t\n\tprivate void handleNotifyConfigChange(int numListeners) {\n\t\tif (proxyService.isRunning()) {\n\t\t\tstatusLineContribution.setProxyRunning(numListeners);\n\t\t} else {\n\t\t\tstatusLineContribution.setProxyStopped();\n\t\t}\n\t}\n\n\tprivate void handleNotifyQueue(IProxyTransaction transaction) {\n\t\tstatusLineContribution.setProxyPending(interceptor.transactionQueueSize());\n\t}\n\t\n\tprivate void handleNotifyRemove() {\n\t\tstatusLineContribution.setProxyPending(interceptor.transactionQueueSize());\n\t}\n\n\tprivate void handleNotifyEmpty() {\n\t\tstatusLineContribution.setProxyPending(0);\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/internal/ui/http/ProxyStatusLineContribution.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.http;\n\nimport java.util.Date;\nimport java.util.Timer;\nimport java.util.TimerTask;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.jface.action.ContributionItem;\nimport org.eclipse.jface.action.StatusLineLayoutData;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.CLabel;\nimport org.eclipse.swt.events.MouseAdapter;\nimport org.eclipse.swt.events.MouseEvent;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.ui.IPageListener;\nimport org.eclipse.ui.IPartListener2;\nimport org.eclipse.ui.IViewPart;\nimport org.eclipse.ui.IViewReference;\nimport org.eclipse.ui.IWindowListener;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.IWorkbenchPartReference;\nimport org.eclipse.ui.IWorkbenchWindow;\nimport org.eclipse.ui.PlatformUI;\n\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.intercept.InterceptView;\nimport com.subgraph.vega.ui.http.statusview.StatusView;\n\npublic class ProxyStatusLineContribution extends ContributionItem {\n\tprivate final static int BLINK_INTERVAL = 500;\n\tprivate final static Image proxyAlert = Activator.getImageDescriptor(\"icons/proxy_alert.png\").createImage();\n\tprivate final static Image proxyRunning = Activator.getImageDescriptor(\"icons/proxy_running.png\").createImage();\n\tprivate final static Image proxyStopped = Activator.getImageDescriptor(\"icons/proxy_stopped.png\").createImage();\n\tprivate final Logger logger = Logger.getLogger(\"proxy\");\n\tprivate CLabel label;\n\tprivate final Timer alertBlinkTimer = new Timer();\n\tprivate TimerTask alertBlinkTask;\n\tprivate boolean alertEnabled;\n\tprivate String runningMessage;\n\tprivate int viewCnt = 0; /** Count of currently visible views that display interceptor information */\n\tprivate int queueCnt = 0;\n\tprivate Date lastViewChange = new Date();\n\n\tpublic ProxyStatusLineContribution() {\n\t\tsuper();\n\t\tcreateListeners();\n\t}\n\n\t@Override\n\tpublic void fill(Composite parent) {\t\t\n\t\tnew Label(parent, SWT.SEPARATOR);\n\t\tlabel = new CLabel(parent, SWT.SHADOW_NONE);\n\t\tsetProxyStopped();\n\t\tStatusLineLayoutData layoutData = new StatusLineLayoutData();\n\t\tlayoutData.widthHint = 220;\n\t\tlabel.setLayoutData(layoutData);\n\t\tlabel.addMouseListener(new MouseAdapter() {\n\t\t\t@Override\n\t\t\tpublic void mouseDown(MouseEvent e) {\n\t\t\t\tsynchronized(alertBlinkTimer) {\n\t\t\t\t\tif(queueCnt != 0) {\n\t\t\t\t\t\thandleAlertClick();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void createListeners() {\n\t\tIWindowListener listener = new IWindowListener() {\n\t\t\t@Override\n\t\t\tpublic void windowActivated(IWorkbenchWindow window) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void windowDeactivated(IWorkbenchWindow window) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void windowClosed(IWorkbenchWindow window) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void windowOpened(IWorkbenchWindow window) {\n\t\t\t\tcreatePageListener(window);\n\t\t\t}\n\t\t};\n\t\tIWorkbench wb = PlatformUI.getWorkbench();\n\t\twb.addWindowListener(listener);\n\t}\n\n\tprivate void createPageListener(IWorkbenchWindow window) {\n\t\tIPageListener listener = new IPageListener() {\n\t\t\t@Override\n\t\t\tpublic void pageActivated(IWorkbenchPage page) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void pageClosed(IWorkbenchPage page) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void pageOpened(IWorkbenchPage page) {\n\t\t\t\tcreatePartListener(page);\n\t\t\t}\n\t\t};\n\t\twindow.addPageListener(listener);\t\t\n\t\tIWorkbenchPage workbenchPages[] = window.getPages();\n\t\tfor (int idx = 0; idx < workbenchPages.length; idx++) {\n\t\t\tcreatePartListener(workbenchPages[idx]);\n\t\t}\n\t}\n\n\tprivate void createPartListener(IWorkbenchPage page) {\n\t\tIPartListener2 listener = new IPartListener2() {\n\t\t\t@Override\n\t\t\tpublic void partActivated(IWorkbenchPartReference partRef) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partBroughtToTop(IWorkbenchPartReference partRef) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partClosed(IWorkbenchPartReference partRef) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partDeactivated(IWorkbenchPartReference partRef) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partOpened(IWorkbenchPartReference partRef) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partHidden(IWorkbenchPartReference partRef) {\n\t\t\t\tfinal IWorkbenchPart part = partRef.getPart(false);\n\t\t\t\tif (part instanceof InterceptView || part instanceof StatusView) {\n\t\t\t\t\tsynchronized (alertBlinkTimer) {\n\t\t\t\t\t\tlastViewChange = new Date();\n\t\t\t\t\t\tviewCnt--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partVisible(IWorkbenchPartReference partRef) {\n\t\t\t\tfinal IWorkbenchPart part = partRef.getPart(false);\n\t\t\t\tif (part instanceof InterceptView || part instanceof StatusView) {\n\t\t\t\t\tsynchronized (alertBlinkTimer) {\n\t\t\t\t\t\tlastViewChange = new Date();\n\t\t\t\t\t\tviewCnt++;\n\t\t\t\t\t\t// we don't cancel the alert here in case there are other callbacks still to be invoked\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void partInputChanged(IWorkbenchPartReference partRef) {\n\t\t\t}\n\t\t};\t\t\n\t\tpage.addPartListener(listener);\n\t}\n\n\tpublic void setProxyRunning(int listenerCount) {\n\t\trunningMessage = \"Proxy running on \" + listenerCount + \" listeners\";\n\t\tsynchronized(alertBlinkTimer) {\n\t\t\tif (!alertEnabled) {\n\t\t\t\tsetLabelImageAndText(proxyRunning, runningMessage);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void setProxyPending(int size) {\n\t\tsetInterceptionQueueSize(size);\n\t}\n\t\n\tpublic void setProxyStopped() {\n\t\tstopAlert();\n\t\tsetLabelImageAndText(proxyStopped, \"Proxy is not running\");\n\t}\n\t\n\t/**\n\t * Determine how many InterceptView and InterceptQueueView views are visible to the user.\n\t */\n\tprivate int countViewsVisible() {\n\t\tint cnt = 0;\n\t\tIWorkbench wb = PlatformUI.getWorkbench();\n\t\tif (wb != null) {\n\t\t\tIWorkbenchWindow windows[] = wb.getWorkbenchWindows();\n\t\t\tfor (int windowIdx = 0; windowIdx < windows.length; windowIdx++) {\n\t\t\t\tIWorkbenchPage pages[] = windows[windowIdx].getPages();\n\t\t\t\tfor (int pageIdx = 0; pageIdx < pages.length; pageIdx++) {\n\t\t\t\t\tIViewReference references[] = pages[pageIdx].getViewReferences();\n\t\t\t\t\tfor (int referenceIdx = 0; referenceIdx < references.length; referenceIdx++) {\n\t\t\t\t\t\tIViewPart part = references[referenceIdx].getView(false);\n\t\t\t\t\t\tif (part instanceof InterceptView || part instanceof StatusView) {\n\t\t\t\t\t\t\tif (pages[pageIdx].isPartVisible(part) == true) {\n\t\t\t\t\t\t\t\tcnt++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn cnt;\n\t}\n\n\tprivate void setInterceptionQueueSize(final int size) {\n\t\tlabel.getDisplay().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsynchronized(alertBlinkTimer) {\n\t\t\t\t\tqueueCnt = size;\n\t\t\t\t\tif (size > 0) {\n\t\t\t\t\t\tif (!alertEnabled) {\n\t\t\t\t\t\t\t// views are counted each time due to a problem with Eclipse. when the application is opened\n\t\t\t\t\t\t\t// out of focus, IPartListener2.partVisible callbacks are invoked when focus is gained,\n\t\t\t\t\t\t\t// invalidating the initial view count. for now we have to count every time here.\n\t\t\t\t\t\t\tviewCnt = countViewsVisible();\n\t\t\t\t\t\t\tif (viewCnt == 0) {\n\t\t\t\t\t\t\t\tstartAlert();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal String msg = \"(\"+ size + \") messages intercepted\";\n\t\t\t\t\t\tsetLabelImageAndTextFromUiThread(proxyAlert, msg);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstopAlert();\n\t\t\t\t\t\tsetLabelImageAndTextFromUiThread(proxyRunning, runningMessage);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Must be invoked in a synchronized block */\n\tprivate void startAlert() {\n\t\tif(alertBlinkTask == null) {\n\t\t\talertBlinkTask = createAlertTask();\n\t\t\talertBlinkTimer.scheduleAtFixedRate(alertBlinkTask, BLINK_INTERVAL, BLINK_INTERVAL);\n\t\t\talertEnabled = true;\n\t\t}\n\t}\n\n\t/** Must be invoked in a synchronized block */\n\tprivate void stopAlert() {\n\t\talertEnabled = false;\n\t\tif(alertBlinkTask != null) {\n\t\t\talertBlinkTask.cancel();\n\t\t\talertBlinkTask = null;\n\t\t}\n\t}\n\n\tprivate TimerTask createAlertTask() {\n\t\treturn new TimerTask() {\n\t\t\tprivate boolean state = true;\n\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsynchronized(alertBlinkTimer) {\n\t\t\t\t\tif (viewCnt != 0) {\n\t\t\t\t\t\tDate currentTime = new Date();\n\t\t\t\t\t\tif (currentTime.getTime() - lastViewChange.getTime() >= BLINK_INTERVAL) {\n\t\t\t\t\t\t\tstopAlert();\n\t\t\t\t\t\t\tif (!state) {\n\t\t\t\t\t\t\t\tsetLabelImage(proxyAlert);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstate = !state;\n\t\t\t\tif(state) {\n\t\t\t\t\tsetLabelImage(proxyAlert);\n\t\t\t\t} else {\n\t\t\t\t\tsetLabelImage(proxyStopped);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void setLabelImage(Image image) {\n\t\tsetLabelImageAndText(image, null);\n\t}\n\t\n\tprivate void setLabelImageAndText(final Image image, final String text) {\n\t\tif(label == null || label.isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\tlabel.getDisplay().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsetLabelImageAndTextFromUiThread(image, text);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void setLabelImageAndTextFromUiThread(final Image image, final String text) {\n\t\tif(image != null) {\n\t\t\tlabel.setImage(image);\n\t\t}\n\t\tif(text != null) {\n\t\t\tlabel.setText(text);\n\t\t}\n\t\tlabel.pack(true);\n\t\tlabel.getParent().layout();\n\t}\n\t\n\tprivate void handleAlertClick() {\n\t\tIWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\n\t\ttry {\n\t\t\twindow.getActivePage().showView(InterceptView.ID);\n\t\t} catch (Exception e) {\n\t\t\tlogger.log(Level.WARNING, \"Failed to open interception view\", e);\n\t\t}\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/internal/ui/http/requestlogviewer/FilterTask.java",
    "content": "package com.subgraph.vega.internal.ui.http.requestlogviewer;\n\nimport java.util.ArrayList;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.swt.widgets.Display;\n\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic class FilterTask {\n\tprivate final static int UPDATE_VIEWER_INTERVAL = 500;\n\tprivate final static int INITIAL_CHUNK_SIZE = 200;\n\tprivate final static int LOAD_CHUNK_SIZE = 1000;\n\tprivate final IRequestLog requestLog;\n\tprivate final IHttpConditionSet filter;\n\tprivate final TableViewer viewer;\n\tprivate final Display display;\n\t/* records with (id < nextRequestId) */\n\tprivate final List<IRequestLogRecord> records;\n\t/* records with (id >= nextRequestId) */\n\tprivate final List<IRequestLogRecord> addedRecords;\n\tprivate final Thread thread;\n\tprivate final Object lock = new Object();\n\t\n\tprivate volatile boolean isStarted;\n\tprivate volatile boolean isCancelled;\n\tprivate boolean isFinished;\n\tprivate volatile long nextRequestId;\n\tprivate int lastSize;\n\t\n\tFilterTask(TableViewer viewer, IRequestLog requestLog, IHttpConditionSet filter) {\n\t\tthis.viewer = viewer;\n\t\tthis.display = viewer.getControl().getDisplay();\n\t\tthis.requestLog = requestLog;\n\t\tthis.filter = filter;\n\t\tthis.records = new ArrayList<IRequestLogRecord>();\n\t\tthis.addedRecords = new ArrayList<IRequestLogRecord>();\n\t\tthis.thread = new Thread(createRunnable());\n\t}\n\t\n\tIRequestLogRecord getRecordForIndex(int index) {\n\t\tsynchronized(lock) {\n\t\t\tif(index < records.size()) {\n\t\t\t\treturn records.get(index);\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tvoid addNewRecord(IRequestLogRecord record) {\n\t\tsynchronized (lock) {\n\t\t\tif(isFinished) {\n\t\t\t\trecords.add(record);\n\t\t\t} else {\n\t\t\t\tif(record.getRequestId() >= nextRequestId) {\n\t\t\t\t\taddedRecords.add(record);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvoid applyFilter() {\n\t\tsynchronized (lock) {\n\t\t\tif(isStarted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnextRequestId = requestLog.getNextRequestId();\n\t\t\tisStarted = true;\n\t\t\tthread.start();\n\t\t}\n\t}\n\n\tvoid cancel() {\n\t\tisCancelled = true;\n\t}\n\t\n\tprivate void loadRecords() {\n\t\tfinal Iterator<IRequestLogRecord> it = requestLog.getRecordIteratorByConditionSet(filter);\n\t\tif(loadChunk(it, INITIAL_CHUNK_SIZE)) {\n\t\t\treturn;\n\t\t}\n\t\tif(records.size() > 0) {\n\t\t\tselectViewerItem(records.get(0));\n\t\t}\n\t\twhile(it.hasNext()) {\n\t\t\tif(loadChunk(it, LOAD_CHUNK_SIZE)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tperformFinalMerge();\n\t}\n\n\tprivate boolean loadChunk(Iterator<IRequestLogRecord> it, int chunkSize) {\n\t\tfinal int size;\n\t\tsynchronized(lock) {\n\t\t\tfor(int i = 0; i < chunkSize && it.hasNext(); i++) {\n\t\t\t\tif(isCancelled) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tfinal IRequestLogRecord record = it.next();\n\t\t\t\tif(record.getRequestId() < nextRequestId) {\n\t\t\t\t\trecords.add(record);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsize = records.size();\n\t\t}\n\t\tapplyRecordCountToViewer(size);\n\t\treturn false;\n\t}\n\t\n\tprivate void performFinalMerge() {\n\t\tfinal int size;\n\t\tsynchronized (lock) {\n\t\t\trecords.addAll(addedRecords);\n\t\t\taddedRecords.clear();\n\t\t\tsize = records.size();\n\t\t\tisFinished = true;\n\t\t\tlock.notifyAll();\n\t\t}\n\t\tapplyRecordCountToViewer(size);\n\t}\n\n\t\n\t\n\tprivate void selectViewerItem(final IRequestLogRecord record) {\n\t\tdisplay.asyncExec(new Runnable() {\n\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(!viewer.getControl().isDisposed() && !isCancelled) {\n\t\t\t\t\tviewer.setSelection(new StructuredSelection(record));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t});\n\t}\n\tprivate void applyRecordCountToViewer(final int recordCount) {\n\t\tdisplay.asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(!viewer.getControl().isDisposed() && !isCancelled) {\n\t\t\t\t\tviewer.setItemCount(recordCount);\n\t\t\t\t\tviewer.refresh(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate Runnable createRunnable() {\n\t\treturn new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tloadRecords();\n\t\t\t\trunUpdateViewerLoop();\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate void runUpdateViewerLoop() {\n\t\twhile(!isCancelled) {\n\t\t\ttry {\n\t\t\t\tThread.sleep(UPDATE_VIEWER_INTERVAL);\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(isCancelled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsynchronized(lock) {\n\t\t\t\tif(records.size() != lastSize) {\n\t\t\t\t\tlastSize = records.size();\n\t\t\t\t\tapplyRecordCountToViewer(lastSize);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic int getRowForRecord(IRequestLogRecord record) {\n\t\tsynchronized (lock) {\n\t\t\twhile(!isFinished) {\n\t\t\t\ttry {\n\t\t\t\t\tlock.wait();\n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn records.indexOf(record);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/internal/ui/http/requestlogviewer/HttpViewLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.http.requestlogviewer;\n\nimport java.util.Map;\nimport java.util.TreeMap;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpResponse;\nimport org.eclipse.jface.viewers.ITableColorProvider;\nimport org.eclipse.jface.viewers.ITableLabelProvider;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.widgets.Display;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic class HttpViewLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider {\n\tprivate final Map<Integer, Color> colorMap = new TreeMap<Integer, Color>();\n\t\n\t@Override\n\tpublic void dispose() {\n\t\tfor (Color color: colorMap.values()) {\n\t\t\tcolor.dispose();\n\t\t}\n\t}\n\n\t@Override\n\tpublic Image getColumnImage(Object element, int columnIndex) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getColumnText(Object element, int columnIndex) {\n\t\tif(!(element instanceof IRequestLogRecord))\n\t\t\treturn null;\n\t\tfinal IRequestLogRecord record = (IRequestLogRecord) element;\n\t\tswitch(columnIndex) {\n\t\tcase 0:\n\t\t\treturn Long.toString(record.getRequestId());\n\t\tcase 1:\n\t\t\treturn record.getHttpHost().toURI();\n\t\tcase 2:\n\t\t\treturn record.getRequest().getRequestLine().getMethod();\n\t\tcase 3:\n\t\t\treturn record.getRequest().getRequestLine().getUri();\n\t\tcase 4:\n\t\t\treturn Integer.valueOf(record.getResponse().getStatusLine().getStatusCode()).toString();\n\t\tcase 5:\n\t\t\treturn getResponseLength(record.getResponse());\n\t\tcase 6:\n\t\t\treturn Long.toString(record.getRequestMilliseconds());\n\t\tcase 7:\n\t\t\tfinal int count = record.getTagCount();\n\t\t\tif (count != 0) {\n\t\t\t\treturn Integer.toString(count);\n\t\t\t} else {\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tpublic String getResponseLength(HttpResponse response) {\n\t\tfinal Header lengthHeader = response.getFirstHeader(\"Content-Length\");\n\t\tif(lengthHeader != null)\n\t\t\treturn lengthHeader.getValue();\n\t\t\n\t\tif(response.getEntity() == null)\n\t\t\treturn \"\";\n\t\t\n\t\treturn Long.toString(response.getEntity().getContentLength());\n\t}\n\n\t@Override\n\tpublic Color getForeground(Object element, int columnIndex) {\n\t\tIRequestLogRecord record = (IRequestLogRecord) element;\n\t\tif (record.getTagCount() != 0) {\n\t\t\treturn getColorInverse(record.getTag(0).getRowColor());\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic Color getBackground(Object element, int columnIndex) {\n\t\tIRequestLogRecord record = (IRequestLogRecord) element;\n\t\tif (record.getTagCount() != 0) {\n\t\t\treturn getColor(record.getTag(0).getRowColor());\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate Color getColor(int colorCode) {\n\t\tColor color = colorMap.get(colorCode);\n\t\tif (color == null) {\n\t\t\tcolor = new Color(Display.getCurrent(), (colorCode >> 16) & 0xff, (colorCode >> 8) & 0xff, colorCode & 0xff);\n\t\t\tcolorMap.put(colorCode, color);\n\t\t}\n\t\treturn color;\n\t}\n\t\n\t// REVISIT: this isn't very nice.\n\tprivate Color getColorInverse(int colorCode) {\n\t\tfinal int inverseR = 255 - ((colorCode >> 16) & 0xff);\n\t\tfinal int inverseG = 255 - ((colorCode >> 8) & 0xff);\n\t\tfinal int inverseB = 255 - (colorCode & 0xff);\n\n\t\treturn getColor(inverseR << 16 | inverseG << 8 | inverseB);\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/internal/ui/http/requestlogviewer/RequestViewContentProvider.java",
    "content": "package com.subgraph.vega.internal.ui.http.requestlogviewer;\n\nimport org.eclipse.jface.viewers.ILazyContentProvider;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.swt.graphics.Color;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.conditions.ConditionSetChanged;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.requests.IRequestLogNewRecordListener;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.model.requests.RequestLogNewRecordEvent;\n\npublic class RequestViewContentProvider implements ILazyContentProvider, IRequestLogNewRecordListener {\n\n\tprivate final String conditionSetId;\n\tprivate final Color activeFilterColor;\n\tprivate final IEventHandler conditionSetListener;\n\t\n\tprivate IModel model;\n\tprivate IWorkspace currentWorkspace;\n\tprivate IEventHandler workspaceListener;\n\tprivate TableViewer tableViewer;\n\t\n\tprivate IHttpConditionSet filterCondition;\n\tprivate FilterTask currentResult;\n\t\n\tpublic RequestViewContentProvider(String instanceId, Color activeFilterColor) {\n\t\tif(instanceId != null) {\n\t\t\tconditionSetId = IHttpConditionManager.CONDITION_SET_FILTER + \".\" + instanceId;\n\t\t} else {\n\t\t\tconditionSetId = IHttpConditionManager.CONDITION_SET_FILTER;\n\t\t}\n\t\tconditionSetListener = createConditionSetListener();\n\t\tworkspaceListener = createWorkspaceListener();\n\t\tthis.activeFilterColor = activeFilterColor;\n\t}\n\t\n\tpublic IHttpConditionSet getConditionSet() {\n\t\treturn filterCondition;\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\tcleanupListeners();\n\t\tactiveFilterColor.dispose();\n\t\tif(currentResult != null) {\n\t\t\tcurrentResult.cancel();\n\t\t\tcurrentResult = null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tif(!(viewer instanceof TableViewer)) {\n\t\t\ttableViewer = null;\n\t\t\treturn;\n\t\t}\n\t\ttableViewer = (TableViewer) viewer;\n\t\t\n\t\tif(newInput instanceof IModel) {\n\t\t\tsetNewInput((IModel) newInput);\n\t\t} else {\n\t\t\tsetNullInput();\n\t\t}\n\t\t\t\n\t}\n\n\tprivate void setNullInput() {\n\t\tcleanupListeners();\n\t\ttableViewer.setItemCount(0);\n\t\tmodel = null;\n\t\tcurrentWorkspace = null;\n\t\tfilterCondition = null;\n\t}\n\t\n\tprivate void setNewInput(IModel model) {\n\t\tthis.model = model;\n\t\tif(model == null) {\n\t\t\tsetNullInput();\n\t\t\treturn;\n\t\t}\n\t\tfilterCondition = model.addConditionSetTracker(conditionSetId, conditionSetListener);\n\t\tfilterCondition.setMatchOnEmptySet(true);\n\t\t\n\t\tcurrentWorkspace = model.addWorkspaceListener(workspaceListener);\n\t\tif(currentWorkspace != null) {\n\t\t\tcurrentWorkspace.getRequestLog().addNewRecordListener(this, filterCondition);\n\t\t}\n\t\treloadRecords();\n\t}\n\t\n\tprivate void cleanupListeners() {\n\t\tif(currentWorkspace != null) {\n\t\t\tcurrentWorkspace.getRequestLog().removeNewRecordListener(this);\n\t\t}\n\t\tif(model != null) {\n\t\t\tif(filterCondition != null) {\n\t\t\t\tmodel.removeConditionSetTracker(conditionSetId, conditionSetListener);\n\t\t\t\tfilterCondition = null;\n\t\t\t}\n\t\t\tmodel.removeWorkspaceListener(workspaceListener);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void updateElement(int index) {\n\t\tif(currentResult == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IRequestLogRecord record = currentResult.getRecordForIndex(index);\n\t\tif(record != null) {\n\t\t\ttableViewer.replace(record, index);\n\t\t}\n\t}\n\n\tprivate IEventHandler createConditionSetListener() {\n\t\treturn new IEventHandler() {\n\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof ConditionSetChanged) {\n\t\t\t\t\tfinal IHttpConditionSet conditionSet = ((ConditionSetChanged) event).getConditionSet();\n\t\t\t\t\tsetConditionFilter(conditionSet);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate IEventHandler createWorkspaceListener() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent)\n\t\t\t\t\tonWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceResetEvent)\n\t\t\t\t\tonWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceCloseEvent)\n\t\t\t\t\tonWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\treloadRecords();\n\t\t\t}\t\t\t\n\t\t};\n\t}\n\tprivate void onWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tcurrentWorkspace.getRequestLog().removeNewRecordListener(this);\n\t\tcurrentWorkspace = event.getWorkspace();\n\t\tcurrentWorkspace.getRequestLog().addNewRecordListener(this, filterCondition);\n\t}\n\t\n\tprivate void onWorkspaceReset(WorkspaceResetEvent event) {\n\t\tcurrentWorkspace.getRequestLog().removeNewRecordListener(this);\n\t\tcurrentWorkspace = event.getWorkspace();\n\t\tcurrentWorkspace.getRequestLog().addNewRecordListener(this, filterCondition);\n\t\t\n\t}\n\t\n\tprivate void onWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tcurrentWorkspace.getRequestLog().removeNewRecordListener(this);\n\t}\n\n\tprivate void setConditionFilter(IHttpConditionSet conditionSet) {\n\t\tif(conditionSet != null) {\n\t\t\tconditionSet.setMatchOnEmptySet(true);\n\t\t}\n\t\thighlightTableForConditionFilter(conditionSet);\n\t\tfinal IRequestLog requestLog = currentWorkspace.getRequestLog();\n\t\tfilterCondition = conditionSet;\n\t\trequestLog.removeNewRecordListener(this);\n\t\trequestLog.addNewRecordListener(this, conditionSet);\n\t\treloadRecords();\n\t}\n\n\tprivate void highlightTableForConditionFilter(IHttpConditionSet conditionSet) {\n\t\tif(conditionSet != null && conditionSet.hasActiveConditions(false)) {\n\t\t\ttableViewer.getTable().setBackground(activeFilterColor);\n\t\t} else {\n\t\t\ttableViewer.getTable().setBackground(null);\n\t\t}\n\t}\n\n\tprivate void reloadRecords() {\n\t\tif(currentResult != null) {\n\t\t\tcurrentResult.cancel();\n\t\t}\n\t\tif(currentWorkspace == null) {\n\t\t\treturn;\n\t\t}\n\t\tcurrentResult = new FilterTask(tableViewer, currentWorkspace.getRequestLog(), filterCondition);\n\t\tcurrentResult.applyFilter();\n\t}\n\n\t@Override\n\tpublic void onNewRecord(RequestLogNewRecordEvent event) {\n\t\tif(currentResult != null) {\n\t\t\tcurrentResult.addNewRecord(event.getNewRecord());\n\t\t}\n\t}\n\t\n\tpublic int getRowForRecord(IRequestLogRecord record) {\n\t\tif(currentResult != null) {\n\t\t\treturn currentResult.getRowForRecord(record);\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/Activator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http;\n\nimport java.util.ArrayList;\n\nimport org.eclipse.jface.action.ContributionItem;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.jface.util.IPropertyChangeListener;\nimport org.eclipse.jface.util.PropertyChangeEvent;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzerFactory;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyTransactionManipulator;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\nimport com.subgraph.vega.internal.ui.http.ProxyServiceTrackerCustomizer;\nimport com.subgraph.vega.internal.ui.http.ProxyStatusLineContribution;\nimport com.subgraph.vega.ui.http.preferencepage.IPreferenceConstants;\nimport com.subgraph.vega.ui.http.preferencepage.ProxyListenerPreferencePage;\n\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.http\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\tprivate ProxyServiceTrackerCustomizer proxyServiceTrackerCustomizer;\n\tprivate ServiceTracker<IHttpProxyService, IHttpProxyService> proxyServiceTracker;\n\tprivate ServiceTracker<IHttpRequestEngineFactory, IHttpRequestEngineFactory> httpRequestEngineFactoryServiceTracker;\n\tprivate ServiceTracker<IContentAnalyzerFactory, IContentAnalyzerFactory> contentAnalyzerFactoryTracker;\n\tprivate ServiceTracker<IScannerModuleRegistry, IScannerModuleRegistry> scannerModuleRegistryTracker;\n\n\tprivate ProxyStatusLineContribution statusLineContribution = new ProxyStatusLineContribution();\n\t\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t\t\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t\t\n\t\tproxyServiceTrackerCustomizer = new ProxyServiceTrackerCustomizer(context, statusLineContribution);\n\t\tproxyServiceTracker = new ServiceTracker<IHttpProxyService, IHttpProxyService>(context, IHttpProxyService.class.getName(), proxyServiceTrackerCustomizer);\n\t\tproxyServiceTracker.open();\n\t\tsetProxyListenerAddresses();\n\t\tsetProxyTransactionManipulator();\n\t\t\n\t\thttpRequestEngineFactoryServiceTracker = new ServiceTracker<IHttpRequestEngineFactory, IHttpRequestEngineFactory>(context, IHttpRequestEngineFactory.class.getName(), null);\n\t\thttpRequestEngineFactoryServiceTracker.open();\n\n\t\tcontentAnalyzerFactoryTracker = new ServiceTracker<IContentAnalyzerFactory, IContentAnalyzerFactory>(context, IContentAnalyzerFactory.class.getName(), null);\n\t\tcontentAnalyzerFactoryTracker.open();\n\n\t\tscannerModuleRegistryTracker = new ServiceTracker<IScannerModuleRegistry, IScannerModuleRegistry>(context, IScannerModuleRegistry.class.getName(), null);\n\t\tscannerModuleRegistryTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\t/**\n\t * Returns an image descriptor for the image file at the given\n\t * plug-in relative path\n\t *\n\t * @param path the path\n\t * @return the image descriptor\n\t */\n\tpublic static ImageDescriptor getImageDescriptor(String path) {\n\t\treturn imageDescriptorFromPlugin(PLUGIN_ID, path);\n\t}\n\t\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\t\n\tpublic IHttpProxyService getProxyService() {\n\t\treturn proxyServiceTracker.getService();\n\t}\n\t\n\tpublic IHttpRequestEngineFactory getHttpRequestEngineFactoryService() {\n\t\treturn httpRequestEngineFactoryServiceTracker.getService();\n\t}\n\n\tpublic IContentAnalyzerFactory getContentAnalyzerFactoryService() {\n\t\treturn contentAnalyzerFactoryTracker.getService();\n\t}\n\t\n\tpublic IScannerModuleRegistry getScannerModuleRegistry() {\n\t\treturn scannerModuleRegistryTracker.getService();\n\t}\n\n\tpublic ContributionItem getStatusLineContribution() {\n\t\treturn statusLineContribution;\n\t}\n\t\n\tprivate void setProxyListenerAddresses() {\n\t\tupdateProxyListenerAddresses();\n\t\tgetPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\t\t\tif (event.getProperty() == IPreferenceConstants.P_PROXY_LISTENERS) {\n\t\t\t\t\tupdateProxyListenerAddresses();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void updateProxyListenerAddresses() {\n\t\tfinal ArrayList<IHttpProxyListenerConfig> listenerList = new ArrayList<IHttpProxyListenerConfig>();\n\t\tfinal String prefListeners = getPreferenceStore().getString(IPreferenceConstants.P_PROXY_LISTENERS);\n\t\tProxyListenerPreferencePage.parsePreferencesString(listenerList, prefListeners);\n\t\tfinal IHttpProxyService proxyService = getProxyService();\n\t\tproxyService.setListenerConfigs((IHttpProxyListenerConfig[]) listenerList.toArray(new IHttpProxyListenerConfig[0]));\n\t}\n\t\n\tprivate void setProxyTransactionManipulator() {\n\t\tfinal IHttpProxyTransactionManipulator manipulator = getProxyService().getTransactionManipulator();\n\t\tfinal IPreferenceStore preferenceStore = getPreferenceStore();\n\t\tmanipulator.setUserAgent(preferenceStore.getString(IPreferenceConstants.P_USER_AGENT));\n\t\tmanipulator.setUserAgentOverride(preferenceStore.getBoolean(IPreferenceConstants.P_USER_AGENT_OVERRIDE));\n\t\tmanipulator.setBrowserCacheDisable(preferenceStore.getBoolean(IPreferenceConstants.P_DISABLE_BROWSER_CACHE));\n\t\tmanipulator.setProxyCacheDisable(preferenceStore.getBoolean(IPreferenceConstants.P_DISABLE_PROXY_CACHE));\n\t\tpreferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\t\t\tfinal IHttpProxyTransactionManipulator manipulator = getProxyService().getTransactionManipulator();\n\t\t\t\tfinal String property = event.getProperty();\n\t\t\t\tif (property == IPreferenceConstants.P_USER_AGENT) {\n\t\t\t\t\tmanipulator.setUserAgent(preferenceStore.getString(IPreferenceConstants.P_USER_AGENT));\n\t\t\t\t} else if (property == IPreferenceConstants.P_USER_AGENT_OVERRIDE) {\n\t\t\t\t\tmanipulator.setUserAgentOverride(preferenceStore.getBoolean(IPreferenceConstants.P_USER_AGENT_OVERRIDE));\n\t\t\t\t} else if (property == IPreferenceConstants.P_DISABLE_BROWSER_CACHE) {\n\t\t\t\t\tmanipulator.setBrowserCacheDisable(preferenceStore.getBoolean(IPreferenceConstants.P_DISABLE_BROWSER_CACHE));\n\t\t\t\t} else if (property == IPreferenceConstants.P_DISABLE_PROXY_CACHE) {\n\t\t\t\t\tmanipulator.setProxyCacheDisable(preferenceStore.getBoolean(IPreferenceConstants.P_DISABLE_PROXY_CACHE));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/BuilderParseException.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\npublic class BuilderParseException extends Exception {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\tBuilderParseException(String message) {\n\t\tsuper(message);\n\t}\n\n\tBuilderParseException(String message, Throwable throwable) {\n\t\tsuper(message, throwable);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/HeaderEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport java.util.Iterator;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpMessageBuilder;\n\n/**\n * Manages visual components used to edit HTTP message headers. \n */\npublic class HeaderEditor extends Composite implements IHttpBuilderPart {\n\tprivate IHttpMessageBuilder messageBuilder;\n\tprivate TableViewer tableViewerHeaders;\n\tprivate boolean headersTableHasSelection;\n\tprivate Button buttonCreate;\n\tprivate Button buttonRemove;\n\tprivate Button buttonMoveUp;\n\tprivate Button buttonMoveDown;\n\tprivate int heightInRows;\n\t\n\t/**\n\t * @param heightInRows Height of header table in text rows, or 0 to fill available space. \n\t */\n\tpublic HeaderEditor(Composite parent, final IHttpMessageBuilder messageBuilder, int heightInRows) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new GridLayout(2, false));\n\t\tthis.messageBuilder = messageBuilder;\n\t\tthis.heightInRows = heightInRows;\n\n\t\tGridData gd;\n\t\tif (heightInRows != 0) {\n\t\t\tgd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);\n\t\t} else {\n\t\t\tgd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);\n\t\t}\n\t\tfinal Composite compTable = createHeaderTable(this, gd, this.heightInRows);\n\t\tcompTable.setLayoutData(gd);\n\t\tfinal Composite compTableButtons = createHeaderTableButtons(this);\n\t\tcompTableButtons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\n\t\ttableViewerHeaders.setInput(messageBuilder);\n\t}\n\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic void setEditable(boolean editable) {\n\t\tbuttonCreate.setEnabled(editable);\n\t\tbuttonRemove.setEnabled(editable && headersTableHasSelection);\n\t\tbuttonMoveUp.setEnabled(editable && headersTableHasSelection);\n\t\tbuttonMoveDown.setEnabled(editable && headersTableHasSelection);\n\t}\n\n\t@Override\n\tpublic void refresh() {\n\t\ttableViewerHeaders.refresh();\n\t}\n\n\t@Override\n\tpublic void processContents() {\n\t\t// nothing to do: headers are modified in table \n\t}\n\n\tprivate Composite createHeaderTable(Composite parent, GridData gd, int heightInRows) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\ttableViewerHeaders = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\ttableViewerHeaders.setContentProvider(new HeaderTableContentProvider());\n\t\ttableViewerHeaders.addSelectionChangedListener(createSelectionChangedListener());\n\t\tcreateHeaderTableColumns(tableViewerHeaders, tcl);\n\t\tfinal Table table = tableViewerHeaders.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t\tif (heightInRows != 0) {\n\t\t\tgd.heightHint = table.getItemHeight() * heightInRows;\n\t\t}\n\n\t\treturn rootControl;\n\t}\n\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\theadersTableHasSelection = !event.getSelection().isEmpty(); \n\t\t\t\tbuttonRemove.setEnabled(headersTableHasSelection);\n\t\t\t\tbuttonMoveUp.setEnabled(headersTableHasSelection);\n\t\t\t\tbuttonMoveDown.setEnabled(headersTableHasSelection);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void createHeaderTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"Name\", \"Value\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnPixelData(120, true, true),\n\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t};\n\t\tfinal EditingSupport editorList[] = {\n\t\t\t\tnew HeaderNameEditingSupport(viewer),\n\t\t\t\tnew HeaderValueEditingSupport(viewer),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpHeaderBuilder) element).getName();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpHeaderBuilder) element).getValue();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\tfor (int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setEditingSupport(editorList[i]);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\t\n\t}\n\n\tprivate Composite createHeaderTableButtons(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, true));\n\n\t\tbuttonCreate = new Button(rootControl, SWT.PUSH);\n\t\tbuttonCreate.setText(\"create\");\n\t\tbuttonCreate.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tbuttonCreate.addSelectionListener(createSelectionListenerButtonCreate());\n\t\tbuttonRemove = new Button(rootControl, SWT.PUSH);\n\t\tbuttonRemove.setText(\"remove\");\n\t\tbuttonRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tbuttonRemove.setEnabled(false);\n\t\tbuttonRemove.addSelectionListener(createSelectionListenerButtonRemove());\n\t\tbuttonMoveUp = new Button(rootControl, SWT.PUSH);\n\t\tbuttonMoveUp.setText(\"move up\");\n\t\tbuttonMoveUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tbuttonMoveUp.setEnabled(false);\n\t\tbuttonMoveUp.addSelectionListener(createSelectionListenerButtonMoveUp());\n\t\tbuttonMoveDown = new Button(rootControl, SWT.PUSH);\n\t\tbuttonMoveDown.setText(\"move down\");\n\t\tbuttonMoveDown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tbuttonMoveDown.setEnabled(false);\n\t\tbuttonMoveDown.addSelectionListener(createSelectionListenerButtonMoveDown());\n\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonCreate() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmessageBuilder.addHeader(\"\", \"\");\n\t\t\t\ttableViewerHeaders.refresh();\n\t\t\t\ttableViewerHeaders.editElement(tableViewerHeaders.getElementAt(tableViewerHeaders.getTable().getItemCount() - 1), 0);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonRemove() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) tableViewerHeaders.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tmessageBuilder.removeHeader((IHttpHeaderBuilder) i.next());\n\t\t\t\t}\n\t\t\t\ttableViewerHeaders.refresh();\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate SelectionListener createSelectionListenerButtonMoveUp() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) tableViewerHeaders.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tint idx = messageBuilder.getHeaderIdxOf((IHttpHeaderBuilder) i.next());\n\t\t\t\t\tif (idx != 0) {\n\t\t\t\t\t\tmessageBuilder.swapHeader(idx - 1, idx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttableViewerHeaders.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonMoveDown() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) tableViewerHeaders.getSelection();\n\t\t\t\tint idx[] = new int[selection.size()];\n\t\t\t\tint offset = 1;\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext(); offset++) {\n\t\t\t\t\tidx[idx.length - offset] = messageBuilder.getHeaderIdxOf((IHttpHeaderBuilder) i.next());\n\t\t\t\t}\n\n\t\t\t\tif (idx[0] + 1 != messageBuilder.getHeaderCnt()) {\n\t\t\t\t\tfor (int i = 0; i < idx.length; i++) {\n\t\t\t\t\t\tmessageBuilder.swapHeader(idx[i], idx[i] + 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttableViewerHeaders.refresh();\n\t\t\t}\n\t\t};\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/HeaderNameEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TextCellEditor;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\n\npublic class HeaderNameEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\t\n\tpublic HeaderNameEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn new TextCellEditor(viewer.getTable());\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\treturn ((IHttpHeaderBuilder) element).getName();\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\t((IHttpHeaderBuilder) element).setName((String) value);\n\t\tviewer.refresh();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/HeaderTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.http.requests.IHttpMessageBuilder;\n\npublic class HeaderTableContentProvider implements IStructuredContentProvider {\n\tprivate IHttpMessageBuilder builder;\n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tbuilder = (IHttpMessageBuilder) newInput;\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn builder.getHeaders();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/HeaderValueEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TextCellEditor;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\n\npublic class HeaderValueEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\t\n\tpublic HeaderValueEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn new TextCellEditor(viewer.getTable());\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\treturn ((IHttpHeaderBuilder) element).getValue();\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\t((IHttpHeaderBuilder) element).setValue((String) value);\n\t\tviewer.refresh();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/IHttpBuilderPart.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport org.eclipse.swt.widgets.Control;\n\npublic interface IHttpBuilderPart {\n\tControl getControl();\n\tvoid setEditable(boolean editable);\n\tvoid refresh();\n\tvoid processContents() throws BuilderParseException;\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/RequestAddressEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.FontMetrics;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\n\npublic class RequestAddressEditor extends Composite implements IHttpBuilderPart {\n\tprivate String requestSchemes[] = {\n\t\t\"http\",\n\t\t\"https\",\n\t};\n\n\tprivate IHttpRequestBuilder requestBuilder;\n\tprivate ComboViewer requestScheme;\n\tprivate Text requestHost;\n\tprivate Text requestPort;\n\n\tpublic RequestAddressEditor(Composite parent, final IHttpRequestBuilder requestBuilder) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.requestBuilder = requestBuilder;\n\n\t\tfinal GridLayout controlLayout = new GridLayout(3, false);\n\t\tcontrolLayout.marginWidth = 0;\n\t\tcontrolLayout.marginHeight = 0;\n\t\tcontrolLayout.marginLeft = 0;\n\t\tcontrolLayout.marginTop = 0;\n\t\tcontrolLayout.marginRight = 0;\n\t\tcontrolLayout.marginBottom = 0;\n\t\tsetLayout(controlLayout);\n\n\t\tfinal Composite schemeControl = new Composite(this, SWT.NONE);\n\t\tschemeControl.setLayout(new GridLayout(2, false));\n\t\tschemeControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\tLabel label = new Label(schemeControl, SWT.NONE);\n\t\tlabel.setText(\"Scheme:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\trequestScheme = new ComboViewer(schemeControl, SWT.READ_ONLY);\n\t\trequestScheme.setContentProvider(new ArrayContentProvider());\n\t\trequestScheme.setLabelProvider(new LabelProvider() {\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn (String)element;\n\t\t\t}\n\t\t});\n\t\trequestScheme.setInput(requestSchemes);\n\t\trequestScheme.setSelection(new StructuredSelection(requestSchemes[0]));\n\t\trequestScheme.addSelectionChangedListener(createSelectionChangedListenerRequestScheme());\n\n\t\tfinal Composite hostControl = new Composite(this, SWT.NONE);\n\t\thostControl.setLayout(new GridLayout(2, false));\n\t\thostControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));\n\t\tlabel = new Label(hostControl, SWT.NONE);\n\t\tlabel.setText(\"Host:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\trequestHost = new Text(hostControl, SWT.BORDER | SWT.SINGLE);\n\t\trequestHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));\n\n\t\tfinal Composite portControl = new Composite(this, SWT.NONE);\n\t\tportControl.setLayout(new GridLayout(2, false));\n\t\tportControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\tlabel = new Label(portControl, SWT.NONE);\n\t\tlabel.setText(\"Port:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\trequestPort = new Text(portControl, SWT.BORDER | SWT.SINGLE);\n\t\tfinal FontMetrics requestPortFm = new GC(requestPort).getFontMetrics();\n\t\tGridData requestPortGd = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);\n\t\trequestPortGd.widthHint = requestPortFm.getAverageCharWidth() * 7;\n\t\trequestPort.setLayoutData(requestPortGd);\n\t\trequestPort.addListener(SWT.Verify, new Listener() {\n\t      public void handleEvent(Event e) {\n\t          String string = e.text;\n\t          char[] chars = new char[string.length()];\n\t          string.getChars(0, chars.length, chars, 0);\n\t          for (int i = 0; i < chars.length; i++) {\n\t        \t  if (!('0' <= chars[i] && chars[i] <= '9')) {\n\t        \t\t  e.doit = false;\n\t        \t\t  return;\n\t        \t  }\n\t          }\n\t      }\n\t\t});\n\t\t\n\t\trefresh();\n\t}\n\t\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic void setEditable(boolean editable) {\n\t\trequestScheme.getCombo().setEnabled(editable);\n\t\trequestHost.setEditable(editable);\n\t\trequestPort.setEditable(editable);\n\t}\n\n\t@Override\n\tpublic void refresh() {\n\t\trequestScheme.setSelection(new StructuredSelection(requestBuilder.getScheme()));\n\t\trequestHost.setText(requestBuilder.getHost());\n\t\trequestPort.setText(Integer.toString(requestBuilder.getHostPort()));\n\t}\n\n\t@Override\n\tpublic void processContents() {\n\t\tfinal String scheme = (String)((IStructuredSelection) requestScheme.getSelection()).getFirstElement();\n\t\trequestBuilder.setScheme(scheme);\n\t\trequestBuilder.setHost(requestHost.getText().trim());\n\t\ttry {\n\t\t\trequestBuilder.setHostPort(Integer.parseInt(requestPort.getText().trim()));\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid host port\");\n\t\t}\n\t}\n\n\tprivate ISelectionChangedListener createSelectionChangedListenerRequestScheme() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(final SelectionChangedEvent e) {\n\t\t\t\tfinal String scheme = (String)((IStructuredSelection)requestScheme.getSelection()).getFirstElement();\n\t\t\t\tif (scheme.equals(\"https\")) {\n\t\t\t\t\trequestPort.setText(\"443\");\n\t\t\t\t} else {\n\t\t\t\t\trequestPort.setText(\"80\");\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/RequestEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\n\n/**\n * Manages RequestAddressEditor and RequestMessageEditor widgets to edit a request.\n */\npublic class RequestEditor extends Composite implements IHttpBuilderPart {\n\tprivate RequestAddressEditor requestAddressEditor;\n\tprivate RequestMessageEditor messageEditor;\n\n\tpublic RequestEditor(Composite parent, final IHttpRequestBuilder requestBuilder) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new GridLayout(1, false));\n\t\trequestAddressEditor = new RequestAddressEditor(this, requestBuilder);\n\t\trequestAddressEditor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));\n\t\tmessageEditor = new RequestMessageEditor(this, requestBuilder);\n\t\tmessageEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));\n\t}\n\t\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\t\n\t@Override\n\tpublic void setEditable(boolean editable) {\n\t\trequestAddressEditor.setEditable(editable);\n\t\tmessageEditor.setEditable(editable);\n\t}\n\n\t@Override\n\tpublic void refresh() {\n\t\trequestAddressEditor.refresh();\n\t\tmessageEditor.refresh();\n\t}\n\n\t@Override\n\tpublic void processContents() throws BuilderParseException {\n\t\trequestAddressEditor.processContents();\n\t\tmessageEditor.processContents();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/RequestMessageEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URISyntaxException;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.ui.httpeditor.HttpMessageEditor;\nimport com.subgraph.vega.ui.httpeditor.parser.HttpRequestParser;\n\n/**\n * Manages visual components to edit a HTTP request message.\n */\npublic class RequestMessageEditor extends Composite implements IHttpBuilderPart {\n\tprivate final IHttpRequestBuilder builder;\n\tprivate final HttpRequestParser requestParser;\n\tprivate HttpMessageEditor messageViewer;\n\n\tpublic RequestMessageEditor(Composite parent, final IHttpRequestBuilder builder) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new FillLayout());\n\t\tthis.builder = builder;\n\t\trequestParser = new HttpRequestParser(this.builder, false);\n\n\t\tmessageViewer = new HttpMessageEditor(this);\n\t\tmessageViewer.setEditable(true);\n\t\tmessageViewer.setDisplayImages(true);\n\t\tmessageViewer.setDisplayImagesAsHex(true);\n\t\trefresh();\n\t}\n\t\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic void setEditable(boolean editable) {\n\t\tmessageViewer.setEditable(editable);\n\t}\n\n\t@Override\n\tpublic void refresh() {\n\t\tmessageViewer.displayHttpRequest(builder);\n\t}\n\n\t@Override\n\tpublic void processContents() throws BuilderParseException {\n\t\ttry {\n\t\t\trequestParser.parseRequest(messageViewer.getContent());\n\t\t\tif (messageViewer.isEntityContentDirty()) {\n\t\t\t\tbuilder.setEntity(messageViewer.getEntityContent());\n\t\t\t}\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tthrow new BuilderParseException(\"Error getting entity\", e);\n\t\t} catch (URISyntaxException e) {\n\t\t\tthrow new BuilderParseException(\"Error parsing URI\", e);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/builder/ResponseMessageEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.builder;\n\nimport java.io.UnsupportedEncodingException;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\nimport com.subgraph.vega.ui.httpeditor.HttpMessageEditor;\nimport com.subgraph.vega.ui.httpeditor.parser.HttpResponseParser;\n\n/**\n * Manages visual components to edit a HTTP response message.\n */\npublic class ResponseMessageEditor extends Composite implements IHttpBuilderPart {\n\tprivate final IHttpResponseBuilder builder;\n\tprivate final HttpResponseParser responseParser;\n\tprivate HttpMessageEditor messageViewer;\n\n\tpublic ResponseMessageEditor(Composite parent, final IHttpResponseBuilder builder) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new FillLayout());\n\t\tthis.builder = builder;\n\t\tresponseParser = new HttpResponseParser(this.builder, false);\n\n\t\tmessageViewer = new HttpMessageEditor(this);\n\t\tmessageViewer.setEditable(true);\n\t\tmessageViewer.setDisplayImages(true);\n\t\tmessageViewer.setDisplayImagesAsHex(true);\n\t\trefresh();\n\t}\n\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic void setEditable(boolean editable) {\n\t\tmessageViewer.setEditable(editable);\n\t}\n\n\t@Override\n\tpublic void refresh() {\n\t\tmessageViewer.displayHttpResponse(builder);\n\t}\n\n\t@Override\n\tpublic void processContents() throws BuilderParseException {\n\t\ttry {\n\t\t\tresponseParser.parseResponse(messageViewer.getContent());\n\t\t\tif (messageViewer.isEntityContentDirty()) {\n\t\t\t\tbuilder.setEntity(messageViewer.getEntityContent());\n\t\t\t}\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tthrow new BuilderParseException(\"Error getting entity\", e);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/AbstractProxyCommandHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.handlers.HandlerUtil;\nimport org.eclipse.ui.services.ISourceProviderService;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\nabstract class AbstractProxyCommandHandler extends AbstractHandler {\n\t\n\t@Override\n\tpublic Object execute(ExecutionEvent event) {\n\t\tIHttpProxyService proxyService = Activator.getDefault().getProxyService();\n\t\tif(proxyService == null) {\n\t\t\tShell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayError(shell, \"Proxy service is null\");\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tISourceProviderService sourceProviderService = (ISourceProviderService) HandlerUtil.getActiveWorkbenchWindow(event).getService(ISourceProviderService.class);\n\t\tProxyStateSourceProvider proxyState = (ProxyStateSourceProvider) sourceProviderService.getSourceProvider(ProxyStateSourceProvider.PROXY_STATE);\n\t\tif(proxyState == null) {\n\t\t\tShell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayError(shell, \"Proxy state provider is null\");\n\t\t\treturn null;\n\t\t}\n\t\texecuteCommand(proxyService, proxyState);\n\t\treturn null;\n\t}\n\t\n\tabstract protected void executeCommand(IHttpProxyService proxyService, ProxyStateSourceProvider proxyState);\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/ConfigureProxyModules.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.jface.window.Window;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.proxy.ConfigureProxyModulesContent;\nimport com.subgraph.vega.ui.util.dialogs.ConfigDialogCreator;\n\npublic class ConfigureProxyModules extends AbstractHandler {\n\tprivate Window dialog;\n\t\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tif(dialog != null && dialog.getShell() != null) {\n\t\t\tdialog.close();\n\t\t\tdialog = null;\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tfinal IHttpProxyService proxy = Activator.getDefault().getProxyService();\n\t\tList<IScannerModule> allModules = new ArrayList<IScannerModule>();\n\t\tallModules.addAll(proxy.getResponseProcessingModules());\n\t\tallModules.addAll(proxy.getProxyScanModules());\n\t\t\n\t\tdialog = ConfigDialogCreator.createDialog(event, new ConfigureProxyModulesContent(allModules));\n\t\tdialog.setBlockOnOpen(true);\n\t\tdialog.open();\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/InterceptDropTransaction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.http.intercept.InterceptView;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class InterceptDropTransaction extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tInterceptView view;\n\t\ttry {\n\t\t\tview = (InterceptView) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(InterceptView.ID);\n\t\t} catch (PartInitException e) {\n\t\t\tShell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayExceptionError(shell, e);\n\t\t\treturn null;\n\t\t}\n\t\tview.dropTransaction();\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/InterceptForwardTransaction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.http.intercept.InterceptView;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class InterceptForwardTransaction extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tInterceptView view;\n\t\ttry {\n\t\t\tview = (InterceptView) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(InterceptView.ID);\n\t\t} catch (PartInitException e) {\n\t\t\tShell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayExceptionError(shell, e);\n\t\t\treturn null;\n\t\t}\n\t\tview.forwardTransaction();\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/InterceptQueueStateSourceProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.ui.AbstractSourceProvider;\nimport org.eclipse.ui.ISources;\n\npublic class InterceptQueueStateSourceProvider extends AbstractSourceProvider {\n\tpublic static final String INTERCEPT_QUEUE_STATE = \"vega.interceptQueueState\";\n\tpublic static final String QUEUE_PENDING = \"pending\"; // intercepted request or response pending an action\n\tpublic static final String QUEUE_REQUEST_SENT = \"requestSent\"; // request sent, awaiting response\n\tpublic static final String QUEUE_EMPTY = \"idle\";\n\tprivate boolean isPending = false;\n\tprivate boolean isSent = false;\n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic Map<?, ?> getCurrentState() {\n\t\tMap<String, String> stateMap = new HashMap<String, String>(1);\n\t\tstateMap.put(INTERCEPT_QUEUE_STATE, getCurrentQueueState());\n\t\treturn stateMap;\n\t}\n\n\t@Override\n\tpublic String[] getProvidedSourceNames() {\n\t\treturn new String[] { INTERCEPT_QUEUE_STATE, };\n\t}\n\n\tprivate String getCurrentQueueState() {\n\t\tif (isPending == true) {\n\t\t\treturn QUEUE_PENDING;\n\t\t} else if (isSent == true) {\n\t\t\treturn QUEUE_REQUEST_SENT;\n\t\t} else {\n\t\t\treturn QUEUE_EMPTY;\n\t\t}\n\t}\n\n\tpublic void setPending(boolean isPending) {\n\t\tthis.isPending = isPending;\n\t\tthis.isSent = false;\n\t\tfireSourceChanged(ISources.WORKBENCH, INTERCEPT_QUEUE_STATE, getCurrentQueueState());\n\t}\n\t\n\tpublic void setSent(boolean isSent) {\n\t\tthis.isSent = isSent;\n\t\tthis.isPending = false;\n\t\tfireSourceChanged(ISources.WORKBENCH, INTERCEPT_QUEUE_STATE, getCurrentQueueState());\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/OpenRequestView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.UUID;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.commands.IHandler;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.http.request.view.HttpRequestView;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class OpenRequestView extends AbstractHandler implements IHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal String secondaryId = UUID.randomUUID().toString();\n\t\ttry {\n\t\t\tHandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(HttpRequestView.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);\n\t\t} catch (PartInitException e) {\n\t\t\tShell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayExceptionError(shell, e);\n\t\t\treturn null;\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/OpenRequestViewFilter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.commands.IHandler;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.http.request.view.HttpRequestView;\nimport com.subgraph.vega.ui.http.requestfilters.RequestFilterConfigContent;\nimport com.subgraph.vega.ui.util.dialogs.ConfigDialogCreator;\n\npublic class OpenRequestViewFilter extends AbstractHandler implements IHandler {\n\tprivate Window dialog;\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif (activePart instanceof HttpRequestView) {\n\t\t\tif (dialog != null && dialog.getShell() != null) {\n\t\t\t\tdialog.close();\n\t\t\t\tdialog = null;\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tfinal String secondaryId = ((HttpRequestView) activePart).getViewSite().getSecondaryId();\n\t\t\tdialog = ConfigDialogCreator.createDialog(event, new RequestFilterConfigContent(secondaryId));\n\t\t\tdialog.open();\n\t\t} else {\n\t\t\tfinal Logger logger = Logger.getLogger(\"proxy\");\n\t\t\tlogger.log(Level.WARNING, \"OpenRequestViewFilter command occurred from unexpected origin\");\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/ProxyPassthrough.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class ProxyPassthrough extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\n\t\tIHttpProxyService proxyService = Activator.getDefault().getProxyService();\n\t\tif(proxyService == null) {\n\t\t\tShell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayError(shell, \"Proxy service is null\");\n\t\t\treturn null;\n\t\t}\n\n\t\tfinal boolean oldValue = HandlerUtil.toggleCommandState(event.getCommand());\n\t\tproxyService.setPassthrough(!oldValue);\n\t\t\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/ProxyScanHandler.java",
    "content": "package com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.runtime.Platform;\nimport org.eclipse.core.runtime.preferences.IPreferencesService;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.ui.http.Activator;\n\npublic class ProxyScanHandler extends AbstractHandler {\n\tpublic static final String SCANNER_PLUGIN = \"com.subgraph.vega.ui.scanner\";\n\tpublic static final String P_LOG_ALL_REQUESTS = \"LogAllRequests\";\n\tpublic static final String P_DISPLAY_DEBUG_OUTPUT = \"DisplayDebugOutput\";\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\t\t\t\n\t\tboolean oldValue = HandlerUtil.toggleCommandState(event.getCommand());\n\t\t\n\t\tfinal IHttpProxyService proxyService = Activator.getDefault().getProxyService();\n\t\tIScannerConfig scannerConfig = proxyService.getProxyScanConfig();\n\t\tif(scannerConfig != null) {\n\t\t\tconfigureScanner(scannerConfig);\n\t\t}\n\t\tproxyService.setProxyScanEnabled(!oldValue);\n\t\treturn null;\n\t}\n\t\n\tprivate void configureScanner(IScannerConfig config) {\n\t\tfinal IPreferencesService preferencesService = Platform.getPreferencesService();\n\t\tfinal boolean logAll = preferencesService.getBoolean(SCANNER_PLUGIN, P_LOG_ALL_REQUESTS, false, null);\n\t\tfinal boolean displayDebug = preferencesService.getBoolean(SCANNER_PLUGIN, P_DISPLAY_DEBUG_OUTPUT, false, null);\n\t\tconfig.setLogAllRequests(logAll);\n\t\tconfig.setDisplayDebugOutput(displayDebug);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/ProxyStateSourceProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.ui.AbstractSourceProvider;\nimport org.eclipse.ui.ISources;\n\npublic class ProxyStateSourceProvider extends AbstractSourceProvider {\n\tpublic final static String PROXY_STATE = \"vega.proxyState\";\n\tfinal static String PROXY_ENABLED = \"enabled\";\n\tfinal static String PROXY_DISABLED = \"disabled\";\n\tprivate boolean isRunning = false;\n\t\n\t@Override\n\tpublic void dispose() {\t\t\n\t}\n\n\t@Override\n\tpublic Map<?, ?> getCurrentState() {\n\t\tMap<String, String> stateMap = new HashMap<String, String>(3);\n\t\tstateMap.put(PROXY_STATE, getCurrentProxyState());\n\t\treturn stateMap;\n\t}\n\n\t@Override\n\tpublic String[] getProvidedSourceNames() {\n\t\treturn new String[] { PROXY_STATE };\n\t}\n\n\tpublic void setProxyRunning(boolean enabled) {\n\t\tif (isRunning!= enabled) {\n\t\t\tisRunning = enabled;\n\t\t\tfireSourceChanged(ISources.WORKBENCH, PROXY_STATE, getCurrentProxyState());\n\t\t}\n\t}\n\t\n\tprivate String getCurrentProxyState() {\n\t\tif (isRunning) {\n\t\t\treturn PROXY_ENABLED;\n\t\t} else { \n\t\t\treturn PROXY_DISABLED;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/ResetRequestFilter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.commands.IHandler;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.request.view.HttpRequestView;\n\npublic class ResetRequestFilter extends AbstractHandler implements IHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif (activePart instanceof HttpRequestView) {\n\t\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\t\tfinal IWorkspace workspace = model.getCurrentWorkspace();\n\t\t\tif(workspace != null) {\n\t\t\t\tfinal String secondaryId = ((HttpRequestView) activePart).getViewSite().getSecondaryId();\n\t\t\t\tfinal String conditionSetId;\n\t\t\t\tif (secondaryId != null) {\n\t\t\t\t\tconditionSetId = IHttpConditionManager.CONDITION_SET_FILTER + \".\" + secondaryId;\n\t\t\t\t} else {\n\t\t\t\t\tconditionSetId = IHttpConditionManager.CONDITION_SET_FILTER;\n\t\t\t\t}\n\t\t\t\tfinal IHttpConditionManager conditionManager = workspace.getHttpConditionMananger();\n\t\t\t\tfinal IHttpConditionSet filterSet = conditionManager.getConditionSet(conditionSetId);\n\t\t\t\tfilterSet.clearConditions(false);\n\t\t\t\tfilterSet.clearTemporaryConditions(false);\n\t\t\t\tfilterSet.notifyChanged();\n\t\t\t\tconditionManager.saveConditionSet(conditionSetId, filterSet);\n\t\t\t}\n\t\t} else {\n\t\t\tfinal Logger logger = Logger.getLogger(\"proxy\");\n\t\t\tlogger.log(Level.WARNING, \"ResetRequestFilter command occurred from unexpected origin\");\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/SendRequest.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.http.requesteditviewer.RequestEditView;\n\npublic class SendRequest extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tIWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(activePart instanceof RequestEditView) {\n\t\t\t((RequestEditView) activePart).sendRequest();\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/StartProxyHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport java.util.logging.Logger;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\n\npublic class StartProxyHandler extends AbstractProxyCommandHandler {\n\n\t@Override\n\tprotected void executeCommand(IHttpProxyService proxyService, ProxyStateSourceProvider proxyState) {\n\t\tLogger logger = Logger.getLogger(getClass().getName());\n\t\tlogger.info(\"Start proxy\");\n\t\t// REVISIT: pop up warning if proxy has no listeners configured?\n\t\tproxyService.start();\n\t\tproxyState.setProxyRunning(true);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/StopProxyHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.commands;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\n\npublic class StopProxyHandler extends AbstractProxyCommandHandler {\n\t@Override\n\tprotected void executeCommand(IHttpProxyService proxyService, ProxyStateSourceProvider proxyState) {\n\t\tproxyService.stop();\n\t\tproxyState.setProxyRunning(false);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/commands/ToggleState.java",
    "content": "package com.subgraph.vega.ui.http.commands;\n\nimport org.eclipse.core.commands.State;\n\npublic class ToggleState extends State {\n\t\n\tpublic ToggleState() {\n\t\tsetValue(Boolean.FALSE);\n\t}\n\n\tpublic void setStateValue(boolean value) {\n\t\tif(value) {\n\t\t\tsetValue(Boolean.TRUE);\n\t\t} else {\n\t\t\tsetValue(Boolean.FALSE);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/conditions/ConditionInput.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.conditions;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionIntegerMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionRangeMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionStringMatchAction;\n\npublic class ConditionInput {\n\tprivate final IHttpConditionManager conditionManager;\n\t\n\tprivate ConditionTypeComboViewer conditionTypeViewer;\n\tprivate MatchActionComboViewer matchActionViewer;\n\tprivate MatchActionArgumentPanel matchActionArguments;\n\t\n\tpublic ConditionInput(IHttpConditionManager conditionManager) {\n\t\tthis.conditionManager = conditionManager;\n\t}\n\t\n\tpublic ComboViewer createConditionTypeCombo(Composite parent) {\n\t\tconditionTypeViewer = new ConditionTypeComboViewer(parent, getConditionTypes(conditionManager));\n\t\tif(matchActionViewer != null)\n\t\t\tconditionTypeViewer.setMatchTypeViewer(matchActionViewer);\n\t\treturn conditionTypeViewer;\n\t}\n\t\n\tprivate List<IHttpConditionType> getConditionTypes(IHttpConditionManager manager) {\n\t\tif(manager == null)\n\t\t\treturn Collections.emptyList();\n\t\telse\n\t\t\treturn manager.getConditionTypes();\n\t}\n\tpublic ComboViewer createConditionMatchCombo(Composite parent) {\n\t\tmatchActionViewer = new MatchActionComboViewer(parent);\n\t\tif(conditionTypeViewer != null)\n\t\t\tconditionTypeViewer.setMatchTypeViewer(matchActionViewer);\n\t\tif(matchActionArguments != null)\n\t\t\tmatchActionViewer.setMatchActionArgumentPanel(matchActionArguments);\n\t\treturn matchActionViewer;\n\t}\n\t\n\tpublic Composite createInputPanel(Composite parent) {\n\t\tmatchActionArguments = new MatchActionArgumentPanel(parent);\n\t\tif(matchActionViewer != null)\n\t\t\tmatchActionViewer.setMatchActionArgumentPanel(matchActionArguments);\n\t\treturn matchActionArguments;\n\t}\n\t\n\tpublic void reset() {\n\t\tconditionTypeViewer.reset();\n\t\tmatchActionViewer.reset();\n\t}\n\n\tpublic IHttpCondition createConditionFromData() {\n\t\tfinal IHttpConditionMatchAction matchAction = matchActionViewer.getSelectedMatchAction();\n\t\tfinal IHttpConditionType conditionType = conditionTypeViewer.getSelectedConditionType();\n\t\tif(matchAction == null || conditionType == null)\n\t\t\treturn null;\n\t\t\n\t\tswitch(matchAction.getArgumentType()) {\n\t\tcase ARGUMENT_STRING:\n\t\t\treturn createStringCondition(conditionType, matchAction, matchActionArguments.getStringText());\n\t\tcase ARGUMENT_REGEX:\n\t\t\treturn createStringCondition(conditionType, matchAction, matchActionArguments.getRegexText());\n\t\tcase ARGUMENT_INTEGER:\n\t\t\treturn createIntegerCondition(conditionType, matchAction, matchActionArguments.getIntegerText());\n\t\tcase ARGUMENT_RANGE:\n\t\t\treturn createRangeCondition(conditionType, matchAction, matchActionArguments.getRangeLowText(), matchActionArguments.getRangeHighText());\n\t\t}\n\t\treturn null;\n\t}\n\t\n\t\n\tprivate IHttpCondition createStringCondition(IHttpConditionType type, IHttpConditionMatchAction matchAction, String value) {\n\t\tif(!value.isEmpty() && (matchAction instanceof IHttpConditionStringMatchAction)) {\n\t\t\t((IHttpConditionStringMatchAction) matchAction).setString(value);\n\t\t\treturn type.createConditionInstance(matchAction);\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate IHttpCondition createIntegerCondition(IHttpConditionType type, IHttpConditionMatchAction matchAction, String integerString) {\n\t\tif(integerString.isEmpty() || !(matchAction instanceof IHttpConditionIntegerMatchAction))\n\t\t\treturn null;\n\t\ttry {\n\t\t\tfinal int value = Integer.parseInt(integerString);\n\t\t\t((IHttpConditionIntegerMatchAction) matchAction).setInteger(value);\n\t\t\treturn type.createConditionInstance(matchAction);\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate IHttpCondition createRangeCondition(IHttpConditionType type, IHttpConditionMatchAction matchAction, String rangeLowText, String rangeHighText) {\n\t\tif(rangeLowText.isEmpty() || rangeHighText.isEmpty() || !(matchAction instanceof IHttpConditionRangeMatchAction))\n\t\t\treturn null;\n\t\ttry {\n\t\t\tfinal int low = Integer.parseInt(rangeLowText);\n\t\t\tfinal int high = Integer.parseInt(rangeHighText);\n\t\t\tif(low < 0 || high < 0 || low > high)\n\t\t\t\treturn null;\n\t\t\t((IHttpConditionRangeMatchAction) matchAction).setRange(low, high);\n\t\t\treturn type.createConditionInstance(matchAction);\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/conditions/ConditionTypeComboViewer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.conditions;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\n\npublic class ConditionTypeComboViewer extends ComboViewer {\n\tprivate MatchActionComboViewer matchActionViewer;\n\t\n\tpublic ConditionTypeComboViewer(Composite parent, List<IHttpConditionType> conditionTypes) {\n\t\tsuper(parent, SWT.READ_ONLY);\n\t\t\n\t\tsetContentProvider(new ArrayContentProvider());\n\t\tsetLabelProvider(createLabelProvider());\n\t\taddSelectionChangedListener(createSelectionChangedListener());\n\t\tsetInput(conditionTypes.toArray());\n\t\treset();\n\t}\n\t\n\t\n\tprivate ILabelProvider createLabelProvider() {\n\t\treturn new LabelProvider() {\n\t\t\t@Override\n\t\t\tpublic String getText(Object element) {\n\t\t\t\tif(element instanceof IHttpConditionType) \n\t\t\t\t\treturn ((IHttpConditionType) element).getName();\n\t\t\t\telse\n\t\t\t\t\treturn null;\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tsetMatchActionInputForSelection(event.getSelection());\n\t\t\t}\n\t\t};\n\t}\n\n\tpublic void reset() {\n\t\tfinal Object element = getElementAt(0);\n\t\tif(element != null)\n\t\t\tsetSelection(new StructuredSelection(element));\n\t}\n\n\tpublic void setMatchTypeViewer(MatchActionComboViewer viewer) {\n\t\tmatchActionViewer = viewer;\n\t\tsetMatchActionInputForSelection(getSelection());\n\t}\n\t\n\tprivate void setMatchActionInputForSelection(ISelection selection) {\n\t\tif(matchActionViewer == null || !(selection instanceof IStructuredSelection))\n\t\t\treturn;\n\t\tfinal IStructuredSelection ss = (IStructuredSelection) selection;\n\t\tif(!(ss.getFirstElement() instanceof IHttpConditionType))\n\t\t\treturn;\n\t\t\n\t\tfinal IHttpConditionType conditionType = (IHttpConditionType) ss.getFirstElement();\n\t\tmatchActionViewer.setMatchActionInput(conditionType.getMatchActions());\n\t}\n\t\n\tpublic IHttpConditionType getSelectedConditionType() {\n\t\tfinal IStructuredSelection selection = (IStructuredSelection) getSelection();\n\t\tif(selection.isEmpty())\n\t\t\treturn null;\n\t\treturn (IHttpConditionType) selection.getFirstElement();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/conditions/MatchActionArgumentPanel.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.conditions;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StackLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class MatchActionArgumentPanel extends Composite {\n\n\tprivate final StackLayout stackLayout;\n\t\n\tprivate final Composite matchStringInputPanel;\n\tprivate final Text matchStringText;\n\t\n\tprivate final Composite regexInputPanel;\n\tprivate final Text regexText;\n\t\n\tprivate final Composite integerInputPanel;\n\tprivate final Text integerText;\n\t\n\tprivate final Composite rangeInputPanel;\n\tprivate final Text rangeLowText;\n\tprivate final Text rangeHighText;\n\t\n\tpublic MatchActionArgumentPanel(Composite parent) {\n\t\tsuper(parent, SWT.NONE);\n\t\tstackLayout = new StackLayout();\n\t\tsetLayout(stackLayout);\n\t\t\n\t\tregexInputPanel = createStackedPanel(1);\n\t\tregexText = createTextField(regexInputPanel, \"regular expression\", true);\n\t\t\n\t\tmatchStringInputPanel = createStackedPanel(1);\n\t\tmatchStringText = createTextField(matchStringInputPanel, \"matching string\", true);\n\t\t\n\t\tintegerInputPanel = createStackedPanel(1);\n\t\tintegerText = createTextField(integerInputPanel, \"integer value\", true);\n\t\t\n\t\trangeInputPanel = createStackedPanel(3);\n\t\trangeLowText = createTextField(rangeInputPanel, \"from\", false);\n\t\tcreateRangeSeperator(rangeInputPanel);\n\t\trangeHighText = createTextField(rangeInputPanel, \"to\", false);\n\t}\n\t\n\tpublic void displayPanelForMatchAction(IHttpConditionMatchAction matchAction) {\n\t\tswitch(matchAction.getArgumentType()) {\n\t\tcase ARGUMENT_REGEX:\n\t\t\tdisplayRegexPanel();\n\t\t\tbreak;\n\t\tcase ARGUMENT_STRING:\n\t\t\tdisplayStringPanel();\n\t\t\tbreak;\n\t\tcase ARGUMENT_INTEGER:\n\t\t\tdisplayIntegerPanel();\n\t\t\tbreak;\n\t\tcase ARGUMENT_RANGE:\n\t\t\tdisplayRangePanel();\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tpublic void displayRegexPanel() {\n\t\tregexText.setText(\"\");\n\t\tstackLayout.topControl = regexInputPanel;\n\t\tlayout();\n\t}\n\t\n\tpublic String getRegexText() {\n\t\treturn regexText.getText();\n\t}\n\t\n\tpublic void displayStringPanel() {\n\t\tmatchStringText.setText(\"\");\n\t\tstackLayout.topControl = matchStringInputPanel;\n\t\tlayout();\n\t}\n\t\n\tpublic String getStringText() {\n\t\treturn matchStringText.getText();\n\t}\n\t\n\tpublic void displayIntegerPanel() {\n\t\tintegerText.setText(\"\");\n\t\tstackLayout.topControl = integerInputPanel;\n\t\tlayout();\n\t}\n\t\n\tpublic String getIntegerText() {\n\t\treturn integerText.getText();\n\t}\n\t\n\tpublic void displayRangePanel() {\n\t\trangeLowText.setText(\"\");\n\t\trangeHighText.setText(\"\");\n\t\tstackLayout.topControl = rangeInputPanel;\n\t\tlayout();\n\t}\n\t\n\tpublic String getRangeLowText() {\n\t\treturn rangeLowText.getText();\n\t}\n\t\n\tpublic String getRangeHighText() {\n\t\treturn rangeHighText.getText();\n\t}\n\n\tprivate Composite createStackedPanel(int columns) {\n\t\tfinal Composite panel = new Composite(this, SWT.NONE);\n\t\tpanel.setLayout(new GridLayout(columns, false));\n\t\treturn panel;\n\t}\n\t\n\tprivate Text createTextField(Composite parent, String message, boolean expandHorizontal) {\n\t\tfinal Text text = new Text(parent, SWT.BORDER | SWT.SINGLE);\n\t\ttext.setMessage(message);\n\t\ttext.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, expandHorizontal, false));\n\t\treturn text;\n\t}\n\t\n\tprivate Label createRangeSeperator(Composite parent) {\n\t\tfinal Label sep = new Label(parent, SWT.NONE);\n\t\tsep.setText(\" - \");\n\t\tsep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\treturn sep;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/conditions/MatchActionComboViewer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.conditions;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class MatchActionComboViewer extends ComboViewer {\n\n\tprivate MatchActionArgumentPanel argumentPanel;\n\t\n\tpublic MatchActionComboViewer(Composite parent) {\n\t\tsuper(parent, SWT.READ_ONLY);\n\t\tsetContentProvider(new ArrayContentProvider());\n\t\tsetLabelProvider(createLabelProvider());\n\t\taddSelectionChangedListener(createSelectionChangedListener());\n\t}\n\t\n\tpublic void setMatchActionArgumentPanel(MatchActionArgumentPanel argumentPanel) {\n\t\tthis.argumentPanel = argumentPanel;\n\t\tsetArgumentPanelBySelection(getSelection());\n\t}\n\t\n\tprivate ILabelProvider createLabelProvider() {\n\t\treturn new LabelProvider() {\n\t\t\t@Override\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn ((IHttpConditionMatchAction) element).getLabel();\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tsetArgumentPanelBySelection(event.getSelection());\n\t\t\t}\n\t\t};\n\t}\n\t\n\tpublic void reset() {\n\t\tfinal Object element = getElementAt(0);\n\t\tif(element != null)\n\t\t\tsetSelection(new StructuredSelection(element));\n\t}\n\n\tpublic void setMatchActionInput(List<IHttpConditionMatchAction> matchActions) {\n\t\tsetInput(matchActions.toArray());\n\t\treset();\n\t}\n\t\n\tpublic IHttpConditionMatchAction getSelectedMatchAction() {\n\t\tfinal IStructuredSelection selection = (IStructuredSelection) getSelection();\n\t\tif(selection.isEmpty())\n\t\t\treturn null;\n\t\treturn (IHttpConditionMatchAction) selection.getFirstElement();\n\t}\n\t\n\tprivate void setArgumentPanelBySelection(ISelection selection) {\n\t\tfinal IStructuredSelection ss = (IStructuredSelection) selection;\n\t\tif(argumentPanel != null && !ss.isEmpty() && (ss.getFirstElement() instanceof IHttpConditionMatchAction))\t\t\n\t\t\targumentPanel.displayPanelForMatchAction((IHttpConditionMatchAction) ss.getFirstElement());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/InterceptView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.part.ViewPart;\nimport org.eclipse.ui.services.ISourceProviderService;\n\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction.TransactionDirection;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.commands.InterceptQueueStateSourceProvider;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class InterceptView extends ViewPart {\n\tpublic final static String ID = \"com.subgraph.vega.views.intercept\";\n\tprivate SashForm parentComposite;\n\tprivate TransactionManager transactionManager;\n\tprivate TransactionInfo transactionInfo;\n\tprivate TransactionViewer transactionViewerRequest;\n\tprivate TransactionViewer transactionViewerResponse;\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tfinal IHttpInterceptor interceptor = Activator.getDefault().getProxyService().getInterceptor();\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tparentComposite = new SashForm(parent, SWT.VERTICAL);\n\t\ttransactionManager = new TransactionManager(this, interceptor);\n\t\tIHttpRequestEngineFactory requestEngineFactory = Activator.getDefault().getHttpRequestEngineFactoryService();\n\t\ttransactionInfo = new TransactionInfo(requestEngineFactory.createRequestBuilder(), requestEngineFactory.createResponseBuilder());\n\t\ttransactionManager.updateTransactionInfo(transactionInfo);\n\n\t\ttransactionViewerRequest = new TransactionViewer(parentComposite, model, transactionInfo, TransactionDirection.DIRECTION_REQUEST);\n\t\ttransactionViewerResponse = new TransactionViewer(parentComposite, model, transactionInfo, TransactionDirection.DIRECTION_RESPONSE);\n\t\ttransactionManager.setManagerActive();\n\t\tparentComposite.setWeights(new int[] { 50, 50, });\n\t\tparentComposite.pack();\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\tif (transactionManager != null) {\n\t\t\ttransactionManager.close();\n\t\t}\n\t\tsuper.dispose();\n\t}\n\n\t@Override\n\tpublic void setFocus() {\n\t}\n\n\tpublic void openTransaction(IProxyTransaction transaction) {\n\t\ttransactionManager.openTransaction(transaction);\n\t}\n\n\tpublic void notifyUpdate() {\n\t\tparentComposite.getDisplay().asyncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tdoUpdate();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate void doUpdate() {\n\t\ttransactionManager.updateTransactionInfo(transactionInfo);\n\t\tISourceProviderService sourceProviderService = (ISourceProviderService) getViewSite().getWorkbenchWindow().getService(ISourceProviderService.class);\n\t\tInterceptQueueStateSourceProvider provider = (InterceptQueueStateSourceProvider) sourceProviderService.getSourceProvider(InterceptQueueStateSourceProvider.INTERCEPT_QUEUE_STATE);\n\t\tif (transactionInfo.isPending() == true) {\n\t\t\tprovider.setPending(true);\n\t\t} else {\n\t\t\tprovider.setSent(transactionInfo.getRequestStatus() == TransactionManager.TransactionStatus.STATUS_SENT);\n\t\t}\n\t\ttransactionViewerRequest.notifyUpdate();\n\t\ttransactionViewerResponse.notifyUpdate();\n\t}\n\n\tpublic void forwardTransaction() {\n\t\ttry {\n\t\t\ttransactionViewerRequest.processChanges();\n\t\t\ttransactionViewerResponse.processChanges();\n\t\t\ttransactionManager.forwardTransaction(transactionInfo);\n\t\t} catch (Exception ex) {\n\t\t\tErrorDialog.displayExceptionError(parentComposite.getShell(), ex);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tpublic void dropTransaction() {\n\t\ttry {\n\t\t\ttransactionManager.dropTransaction(transactionInfo);\n\t\t} catch (Exception ex) {\n\t\t\tErrorDialog.displayExceptionError(parentComposite.getShell(), ex);\n\t\t\treturn;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/TransactionInfo.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept;\n\nimport java.net.URISyntaxException;\n\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\n\n/**\n * Provides a modifiable snapshot of a transaction held by the TransactionManager. The information contained here is\n * used to display information in the UI.\n */\npublic class TransactionInfo {\n\tprivate int currentSerial; // Serial of the pending transaction\n\n\tprivate int requestTransactionSerial;\n\tprivate final IHttpRequestBuilder requestBuilder;\n\tprivate boolean requestHasContent;\n\tprivate TransactionManager.TransactionStatus requestStatus;\n\tprivate String requestStatusMessage;\n\n\tprivate int responseTransactionSerial;\n\tprivate final IHttpResponseBuilder responseBuilder;\n\tprivate boolean responseHasContent;\n\tprivate TransactionManager.TransactionStatus responseStatus;\n\tprivate String responseStatusMessage;\n\t\n\tpublic TransactionInfo(IHttpRequestBuilder requestBuilder, IHttpResponseBuilder responseBuilder) {\n\t\tcurrentSerial = -1;\n\t\trequestTransactionSerial = -1;\n\t\tthis.requestBuilder = requestBuilder;\n\t\trequestHasContent = false;\n\t\tsetRequestStatus(TransactionManager.TransactionStatus.STATUS_INACTIVE);\n\t\tresponseTransactionSerial = -1;\n\t\tthis.responseBuilder = responseBuilder;\n\t\tresponseHasContent = false;\n\t\tsetResponseStatus(TransactionManager.TransactionStatus.STATUS_INACTIVE);\n\t}\n\n\tpublic void setCurrentSerial(int serial) {\n\t\tthis.currentSerial = serial;\n\t}\n\n\tpublic int getCurrentSerial() {\n\t\treturn currentSerial;\n\t}\n\t\n\tpublic boolean isPending() {\n\t\treturn (requestStatus == TransactionManager.TransactionStatus.STATUS_PENDING ||\n\t\t\t\tresponseStatus == TransactionManager.TransactionStatus.STATUS_PENDING);\n\t}\n\n\tpublic void setRequestTransactionSerial(int requestTransactionSerial) {\n\t\tthis.requestTransactionSerial = requestTransactionSerial;\n\t}\n\t\n\tpublic int getRequestTransactionSerial() {\n\t\treturn requestTransactionSerial;\n\t}\n\n\tpublic void setFromRequest(HttpRequest request) throws URISyntaxException {\n\t\trequestBuilder.setFromRequest(request);\n\t}\n\n\tpublic IHttpRequestBuilder getRequestBuilder() {\n\t\treturn requestBuilder;\n\t}\n\n\tpublic void setRequestHasContent(boolean requestHasContent) {\n\t\tthis.requestHasContent = requestHasContent;\n\t}\n\t\n\tpublic boolean requestHasContent() {\n\t\treturn requestHasContent;\n\t}\n\n\tpublic void setRequestStatus(TransactionManager.TransactionStatus requestStatus) {\n\t\tthis.requestStatus = requestStatus;\n\t\tswitch (requestStatus) {\n\t\tcase STATUS_INACTIVE:\n\t\t\trequestStatusMessage = \"No request pending\";\n\t\t\tbreak;\n\t\tcase STATUS_PENDING:\n\t\t\trequestStatusMessage = \"Request pending to \" + getRequestHostPart();\n\t\t\tbreak;\n\t\tcase STATUS_SENT:\n\t\t\trequestStatusMessage = \"Request sent, awaiting response\";\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tprivate String getRequestHostPart() {\n\t\tfinal StringBuilder buf = new StringBuilder();\n\t\tbuf.append(requestBuilder.getScheme());\n\t\tbuf.append(\"://\");\n\t\tbuf.append(requestBuilder.getHost());\n\t\tif (requestBuilder.getHostPort() != -1) {\n\t\t\tbuf.append(':');\n\t\t\tbuf.append(Integer.toString(requestBuilder.getHostPort()));\n\t\t}\n\t\treturn buf.toString();\n\t}\n\n\tpublic TransactionManager.TransactionStatus getRequestStatus() {\n\t\treturn requestStatus; \n\t}\n\n\tpublic boolean requestIsPending() {\n\t\treturn (requestStatus == TransactionManager.TransactionStatus.STATUS_PENDING);\n\t}\n\n\tpublic String getRequestStatusMessage() {\n\t\treturn requestStatusMessage;\n\t}\n\t\n\tpublic void setResponseTransactionSerial(int responseTransactionSerial) {\n\t\tthis.responseTransactionSerial = responseTransactionSerial;\n\t}\n\t\n\tpublic int getResponseTransactionSerial() {\n\t\treturn responseTransactionSerial;\n\t}\n\n\tpublic void setFromResponse(HttpResponse response) throws URISyntaxException {\n\t\tresponseBuilder.setFromResponse(response);\n\t}\n\n\tpublic IHttpResponseBuilder getResponseBuilder() {\n\t\treturn responseBuilder;\n\t}\n\n\tpublic void setResponseHasContent(boolean responseHasContent) {\n\t\tthis.responseHasContent = responseHasContent;\n\t}\n\t\n\tpublic boolean responseHasContent() {\n\t\treturn responseHasContent;\n\t}\n\n\tpublic void setResponseStatus(TransactionManager.TransactionStatus responseStatus) {\n\t\tthis.responseStatus = responseStatus;\n\t\tswitch (responseStatus) {\n\t\tcase STATUS_INACTIVE:\n\t\t\tresponseStatusMessage = \"No response pending\";\n\t\t\tbreak;\n\t\tcase STATUS_PENDING:\n\t\t\tresponseStatusMessage = \"Response pending\";\n\t\t\tbreak;\n\t\tcase STATUS_SENT:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tpublic TransactionManager.TransactionStatus getResponseStatus() {\n\t\treturn responseStatus; \n\t}\n\n\tpublic boolean responseIsPending() {\n\t\treturn (responseStatus == TransactionManager.TransactionStatus.STATUS_PENDING);\n\t}\n\n\tpublic String getResponseStatusMessage() {\n\t\treturn responseStatusMessage;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/TransactionManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URISyntaxException;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.apache.http.HttpResponse;\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptorEventHandler;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\nimport com.subgraph.vega.api.http.proxy.IProxyTransactionEventHandler;\n\n/**\n * Manages transactions held by the HTTP proxy interceptor on behalf of InterceptView.\n * \n * The transaction manager employs a serial number to avoid race conditions caused by the delay signaling to the UI\n * thread that a change occurred in the transaction queue. The TransactionInfo class, which the UI uses to display the\n * transaction held by the manager after an event is received, records currentSerial when a transaction is pending. That\n * way, if the transaction queue changes before the next event reaches the UI, the UI can't accidentally forward the\n * wrong transaction. \n */\npublic class TransactionManager {\n\tpublic enum TransactionStatus {\n\t\tSTATUS_INACTIVE,\n\t\tSTATUS_PENDING,\n\t\tSTATUS_SENT,\n\t};\n\t\n\tprivate final Logger logger = Logger.getLogger(\"proxy\");\n\tprivate InterceptView interceptView;\n\tprivate IHttpInterceptor interceptor;\n\tprivate IHttpInterceptorEventHandler interceptorEventHandler;\n\tprivate IProxyTransactionEventHandler transactionEventHandler;\n\tprivate IProxyTransaction currentTransaction;\n\tprivate IProxyTransaction currentRequestTransaction;\n\tprivate int currentSerial; // Serial number of current pending transaction\n\tprivate TransactionStatus requestStatus;\n\tprivate int requestTransactionSerial; // Serial number of last request change\n\tprivate TransactionStatus responseStatus;\n\tprivate int responseTransactionSerial; // Serial number of last response change\n\t\n\tTransactionManager(InterceptView interceptView, IHttpInterceptor interceptor) {\n\t\tthis.interceptView = interceptView;\n\t\tthis.interceptor = interceptor;\n\t\tinterceptorEventHandler = new IHttpInterceptorEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void notifyQueue(IProxyTransaction transaction, int idx) {\n\t\t\t\tif (transaction.hasResponse() == false) {\n\t\t\t\t\thandleTransactionRequest(transaction);\n\t\t\t\t} else {\n\t\t\t\t\thandleTransactionResponse(transaction);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyRemove(int idx) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyEmpty() {\n\t\t\t}\n\t\t};\n\t\ttransactionEventHandler = new IProxyTransactionEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void notifyForward() {\n\t\t\t\thandleTransactionForward();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyComplete(boolean dropped) {\n\t\t\t\thandleTransactionComplete();\n\t\t\t}\n\t\t};\n\t\tcurrentSerial = 0;\n\t\trequestStatus = TransactionStatus.STATUS_INACTIVE;\n\t\trequestTransactionSerial = 0;\n\t\tresponseStatus = TransactionStatus.STATUS_INACTIVE;\n\t\tresponseTransactionSerial = 0;\n\t\tgetNextTransaction();\n\t}\n\t\n\t/**\n\t * Activate the transaction manager to handle interceptor events once elements of the intercept view are initialized.\n\t */\n\tpublic void setManagerActive() {\n\t\tsynchronized(this) {\n\t\t\tinterceptor.addEventHandler(interceptorEventHandler);\n\t\t\tgetNextTransaction();\n\t\t}\n\t}\n\n\t/**\n\t * Set a transaction as the current transaction.\n\t * @param transaction Transaction. \n\t */\n\tpublic void openTransaction(IProxyTransaction transaction) {\n\t\tsynchronized(this) {\n\t\t\tif (currentTransaction != null) {\n\t\t\t\tif (currentTransaction == transaction) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcurrentTransaction.setEventHandler(null);\n\t\t\t}\n\t\t\tsetCurrentTransaction(transaction);\n\t\t\tinterceptView.notifyUpdate();\n\t\t}\n\t}\n\t\n\t/**\n\t * Close this transaction manager prior to the interceptor view being disposed. Unregisters the manager as an event\n\t * handler in the interceptor and the current transaction, if one exists. \n\t */\n\tpublic void close() {\n\t\tsynchronized(this) {\n\t\t\tif (interceptor != null) {\n\t\t\t\tinterceptor.removeEventHandler(interceptorEventHandler);\n\t\t\t\tif (currentTransaction != null) {\n\t\t\t\t\tcurrentTransaction.setEventHandler(null);\n\t\t\t\t\tcurrentTransaction = currentRequestTransaction = null;\n\t\t\t\t\tcurrentSerial++;\n\t\t\t\t\trequestTransactionSerial++;\n\t\t\t\t\tresponseTransactionSerial++;\n\t\t\t\t\trequestStatus = responseStatus = TransactionStatus.STATUS_INACTIVE;\n\t\t\t\t}\n\t\t\t\tinterceptor = null;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Update transaction info with the transaction currently held by the manager.\n\t * \n\t * @param transactionInfo Transaction info.\n\t */\n\tpublic void updateTransactionInfo(TransactionInfo transactionInfo) {\n\t\tsynchronized(this) {\n\t\t\tif (currentTransaction != null) {\n\t\t\t\tif (transactionInfo.getRequestTransactionSerial() != requestTransactionSerial) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttransactionInfo.setFromRequest(currentTransaction.getRequest());\n\t\t\t\t\t} catch (URISyntaxException e) {\n\t\t\t\t\t\tlogger.log(Level.WARNING, \"Error processing request, dropped transaction\", e);\n\t\t\t\t\t\thandleBadUpdate(transactionInfo);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (requestStatus == TransactionStatus.STATUS_PENDING) {\n\t\t\t\t\t\ttransactionInfo.setCurrentSerial(currentSerial);\n\t\t\t\t\t}\n\t\t\t\t\ttransactionInfo.setRequestHasContent(true);\n\t\t\t\t\ttransactionInfo.setRequestStatus(requestStatus);\n\t\t\t\t\ttransactionInfo.setRequestTransactionSerial(requestTransactionSerial);\n\t\t\t\t} else {\n\t\t\t\t\tif (transactionInfo.getRequestStatus() != requestStatus) {\n\t\t\t\t\t\tif (requestStatus == TransactionStatus.STATUS_SENT) {\n\t\t\t\t\t\t\ttransactionInfo.setCurrentSerial(currentSerial);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttransactionInfo.setRequestStatus(requestStatus);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (transactionInfo.getResponseTransactionSerial() != responseTransactionSerial) {\n\t\t\t\t\tif (responseStatus != TransactionStatus.STATUS_INACTIVE) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\ttransactionInfo.setFromResponse(currentTransaction.getResponse().getRawResponse());\n\t\t\t\t\t\t} catch (URISyntaxException e) {\n\t\t\t\t\t\t\tlogger.log(Level.WARNING, \"Error processing response, dropped transaction\", e);\n\t\t\t\t\t\t\thandleBadUpdate(transactionInfo);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (responseStatus == TransactionStatus.STATUS_PENDING) {\n\t\t\t\t\t\t\ttransactionInfo.setCurrentSerial(currentSerial);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttransactionInfo.setResponseHasContent(true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttransactionInfo.getResponseBuilder().clear();\n\t\t\t\t\t\ttransactionInfo.setResponseHasContent(false);\n\t\t\t\t\t}\n\t\t\t\t\ttransactionInfo.setResponseStatus(responseStatus);\n\t\t\t\t\ttransactionInfo.setResponseTransactionSerial(responseTransactionSerial);\n\t\t\t\t} else {\n\t\t\t\t\tif (transactionInfo.getResponseStatus() != responseStatus) {\n\t\t\t\t\t\ttransactionInfo.setResponseStatus(responseStatus);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (transactionInfo.getRequestTransactionSerial() != requestTransactionSerial) {\n\t\t\t\t\ttransactionInfo.getRequestBuilder().clear();\n\t\t\t\t\ttransactionInfo.setRequestHasContent(false);\n\t\t\t\t\ttransactionInfo.setRequestStatus(requestStatus);\n\t\t\t\t\ttransactionInfo.setRequestTransactionSerial(requestTransactionSerial);\n\t\t\t\t}\n\n\t\t\t\tif (transactionInfo.getResponseTransactionSerial() != responseTransactionSerial) {\n\t\t\t\t\ttransactionInfo.getResponseBuilder().clear();\n\t\t\t\t\ttransactionInfo.setResponseHasContent(false);\n\t\t\t\t\ttransactionInfo.setResponseStatus(responseStatus);\n\t\t\t\t\ttransactionInfo.setResponseTransactionSerial(responseTransactionSerial);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Drop a transaction following an error processing it into TransactionInfo and attempt to load the next queued\n\t * transaction.\n\t */\n\tprivate void handleBadUpdate(TransactionInfo transactionInfo) {\n\t\tcurrentTransaction.setEventHandler(null);\n\t\tcurrentTransaction.doDrop();\n\t\tgetNextTransaction();\n\t\tupdateTransactionInfo(transactionInfo);\n\t}\n\t\n\tprivate void handleTransactionRequest(final IProxyTransaction transaction) {\n\t\tsynchronized(this) {\n\t\t\tif(currentTransaction == null) {\n\t\t\t\tcurrentTransaction = transaction;\n\t\t\t\tcurrentTransaction.setEventHandler(transactionEventHandler);\n\t\t\t\trequestTransactionSerial++;\n\t\t\t\tsetRequestPending();\n\t\t\t\tinterceptView.notifyUpdate();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void handleTransactionResponse(final IProxyTransaction transaction) {\n\t\tsynchronized(this) {\n\t\t\tif (currentTransaction == null || currentTransaction == transaction) {\n\t\t\t\tif (currentTransaction == null) {\n\t\t\t\t\tcurrentTransaction = transaction;\n\t\t\t\t\tcurrentTransaction.setEventHandler(transactionEventHandler);\n\t\t\t\t\trequestTransactionSerial++;\n\t\t\t\t}\n\t\t\t\tresponseTransactionSerial++;\n\t\t\t\tsetResponsePending();\n\t\t\t\tinterceptView.notifyUpdate();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void handleTransactionForward() {\n\t\tsynchronized(this) {\n\t\t\tif (currentTransaction.hasResponse()) {\n\t\t\t\tcurrentTransaction.setEventHandler(null);\n\t\t\t\tgetNextTransaction();\n\t\t\t} else {\n\t\t\t\tsetRequestSent();\n\t\t\t}\n\t\t\tinterceptView.notifyUpdate();\n\t\t}\n\t}\n\n\tprivate void handleTransactionComplete() {\n\t\tsynchronized(this) {\n\t\t\tcurrentTransaction.setEventHandler(null);\n\t\t\tgetNextTransaction();\n\t\t\tinterceptView.notifyUpdate();\n\t\t}\n\t}\n\t\n\t/**\n\t * Make the transaction at the head of the interceptor queue the current transaction. Must be invoked within a\n\t * synchronized block.\n\t */\n\tprivate void getNextTransaction() {\n\t\tsetCurrentTransaction(interceptor.transactionQueueGet(0));\n\t}\n\n\tprivate void setCurrentTransaction(IProxyTransaction transaction) {\n\t\tcurrentTransaction = transaction;\t\t\t\n\t\trequestTransactionSerial++;\n\t\tresponseTransactionSerial++;\n\t\tif(currentTransaction != null) {\n\t\t\tcurrentTransaction.setEventHandler(transactionEventHandler);\n\t\t\tif (!currentTransaction.hasResponse()) {\n\t\t\t\tsetRequestPending();\n\t\t\t\tsetResponseInactive();\n\t\t\t} else {\n\t\t\t\tsetResponsePending();\n\t\t\t}\n\t\t} else {\n\t\t\tsetRequestInactive();\n\t\t\tsetResponseInactive();\n\t\t}\n\t}\n\n\tprivate void setRequestPending() {\n\t\tcurrentRequestTransaction = currentTransaction;\n\t\trequestStatus = TransactionStatus.STATUS_PENDING;\n\t\tcurrentSerial++;\n\t}\n\t\n\tprivate void setRequestInactive() {\n\t\tcurrentRequestTransaction = currentTransaction;\n\t\trequestStatus = TransactionStatus.STATUS_INACTIVE;\n\t\tcurrentSerial++;\n\t}\n\n\tprivate void setRequestSent() {\n\t\tcurrentRequestTransaction = currentTransaction;\n\t\trequestStatus = TransactionStatus.STATUS_SENT;\n\t\tcurrentSerial++;\n\t}\n\n\tprivate void setResponseInactive() {\n\t\tresponseStatus = TransactionStatus.STATUS_INACTIVE;\n\t\tcurrentSerial++;\n\t}\n\n\tprivate void setResponsePending() {\n\t\tresponseStatus = TransactionStatus.STATUS_PENDING;\n\t\tcurrentSerial++;\n\t\tif(currentRequestTransaction != currentTransaction) {\n\t\t\tsetRequestSent();\n\t\t}\n\t}\n\n\tpublic void forwardTransaction(TransactionInfo info) throws URISyntaxException, UnsupportedEncodingException {\n\t\tsynchronized(this) {\n\t\t\tif (info.getCurrentSerial() == currentSerial) {\n\t\t\t\tif (requestStatus == TransactionManager.TransactionStatus.STATUS_PENDING) {\n\t\t\t\t\tHttpUriRequest request = info.getRequestBuilder().buildRequest(true);\n\t\t\t\t\tcurrentTransaction.setRequest(request);\n\t\t\t\t\tcurrentTransaction.doForward();\n\t\t\t\t} else if (responseStatus == TransactionManager.TransactionStatus.STATUS_PENDING) {\n\t\t\t\t\tHttpResponse response = info.getResponseBuilder().buildResponse();\n\t\t\t\t\tcurrentTransaction.getResponse().setRawResponse(response);\n\t\t\t\t\tcurrentTransaction.doForward();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void dropTransaction(TransactionInfo info) {\n\t\tsynchronized(this) {\n\t\t\tif (info.getCurrentSerial() == currentSerial) {\n\t\t\t\tcurrentSerial++;\n\t\t\t\tcurrentTransaction.doDrop();\n\t\t\t}\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/TransactionViewer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept;\n\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StackLayout;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Menu;\nimport org.eclipse.swt.widgets.MenuItem;\nimport org.eclipse.swt.widgets.ToolBar;\nimport org.eclipse.swt.widgets.ToolItem;\n\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction.TransactionDirection;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.builder.HeaderEditor;\nimport com.subgraph.vega.ui.http.builder.IHttpBuilderPart;\nimport com.subgraph.vega.ui.http.builder.RequestEditor;\nimport com.subgraph.vega.ui.http.builder.ResponseMessageEditor;\nimport com.subgraph.vega.ui.http.intercept.config.ConfigureInterceptionContent;\nimport com.subgraph.vega.ui.util.dialogs.ConfigDialogCreator;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class TransactionViewer extends Composite {\n\tprivate static final Image IMAGE_CONFIGURE = Activator.getImageDescriptor(\"icons/interception_rules.png\").createImage();\n\tprivate final IModel model;\n\tprivate final TransactionDirection direction;\n\tprivate final TransactionInfo transactionInfo;\n\tprivate Label statusLabel;\n\tprivate ToolItem configureButton;\n\tprivate Composite viewerControl;\n\tprivate StackLayout viewerLayout;\n\tprivate Composite viewerEmpty;\n\tprivate Menu viewerMenu;\n\tprivate boolean isPending;\n\tprivate int lastTransactionSerial;\n\tprivate IHttpBuilderPart builderPartCurr;\n\tprivate Window configDialog;\n\n\tpublic TransactionViewer(Composite parent, IModel model, TransactionInfo transactionInfo, TransactionDirection direction) {\n\t\tsuper(parent, SWT.NONE);\n\n\t\tthis.model = model;\n\t\tthis.direction = direction;\n\t\tthis.transactionInfo = transactionInfo;\n\t\tisPending = false;\n\n\t\tsetLayout(createLayout());\n\n\t\tcreateStatusLabel();\n\t\tcreateToolbar();\n\n\t\tfinal Group viewerGroup = new Group(this, SWT.NONE);\n\t\tviewerGroup.setLayout(new FillLayout());\n\t\tviewerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));\n\n\t\tif (direction == TransactionDirection.DIRECTION_REQUEST) { \n\t\t    lastTransactionSerial = transactionInfo.getRequestTransactionSerial();\n\t\t\tcreateViewersRequest(viewerGroup);\n\t\t\tupdateViewerRequest();\n\t\t} else {\n\t\t    lastTransactionSerial = transactionInfo.getResponseTransactionSerial();\n\t\t\tcreateViewersResponse(viewerGroup);\n\t\t\tupdateViewerResponse();\n\t\t}\n\t}\n\n\tpublic void processChanges() {\n\t\tif (isPending) {\n\t\t\ttry {\n\t\t\t\tbuilderPartCurr.processContents();\n\t\t\t} catch (Exception e) {\n\t\t\t\tErrorDialog.displayExceptionError(getShell(), e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate GridLayout createLayout() {\n\t\tfinal GridLayout layout = new GridLayout(2, false);\n\t\tlayout.marginWidth = 2;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.verticalSpacing = 0;\n\t\tlayout.horizontalSpacing = 2;\n\t\treturn layout;\n\t}\n\t\n\tprivate Label createStatusLabel() {\n\t\tstatusLabel = new Label(this, SWT.NONE);\n\t\tstatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));\n\t\treturn statusLabel;\n\t}\n\n\tprivate ToolBar createToolbar() {\n\t\tfinal ToolBar toolBar = new ToolBar(this, SWT.RIGHT);\n\n\t\tviewerMenu = new Menu(getShell(), SWT.POP_UP);\n\t    final ToolItem item = new ToolItem(toolBar, SWT.DROP_DOWN);\n\t    item.setText(\"View\");\n\t    item.addSelectionListener(new SelectionAdapter() {\n\t    \t@Override\n\t    \tpublic void widgetSelected(SelectionEvent event) {\n\t        \tRectangle rect = item.getBounds();\n\t        \tPoint pt = new Point(rect.x, rect.y + rect.height);\n\t            pt = toolBar.toDisplay(pt);\n\t            viewerMenu.setLocation(pt.x, pt.y);\n\t            viewerMenu.setVisible(true);\n\t    \t}\n\t    });\n\t    \n\t\tconfigureButton = createToolbarButton(toolBar, IMAGE_CONFIGURE, \"Configure interception rules\", createConfigureButtonListener());\n\t\t\n\t\treturn toolBar;\n\t}\n\t\n\tprivate ToolItem createToolbarButton(ToolBar toolBar, Image image, String tooltip, SelectionListener listener) {\n\t\tfinal ToolItem buttonItem = new ToolItem(toolBar, SWT.PUSH);\n\t\tbuttonItem.setImage(image);\n\t\tbuttonItem.setToolTipText(tooltip);\n\t\tbuttonItem.addSelectionListener(listener);\n\t\treturn buttonItem;\n\t}\n\t\n\tprivate SelectionListener createConfigureButtonListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdoConfigure();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void createViewersRequest(final Composite parent) {\n\t\tviewerControl = new Composite(parent, SWT.NONE);\n\t\tviewerLayout = new StackLayout();\n\t\tviewerControl.setLayout(viewerLayout);\n\t\t\n\t\tIHttpRequestBuilder requestBuilder = transactionInfo.getRequestBuilder();\n\t\tfinal SelectionListener listener = createSelectionListenerMenuItem();\n\n\t    viewerEmpty = new Composite(viewerControl, SWT.NONE);\n\t    viewerEmpty.setLayout(new FillLayout());\n\t\t\n\t\tRequestEditor requestEditor = new RequestEditor(viewerControl, requestBuilder);\n\t    MenuItem menuItem = new MenuItem(viewerMenu, SWT.NONE);\n\t    menuItem.setText(\"Request\");\n\t    menuItem.setData(requestEditor);\n\t    menuItem.addSelectionListener(listener);\n\t\tbuilderPartCurr = requestEditor;\n\n\t    HeaderEditor headerEditor = new HeaderEditor(viewerControl, requestBuilder, 0);\n\t    menuItem = new MenuItem(viewerMenu, SWT.NONE);\n\t    menuItem.setText(\"Headers\");\n\t    menuItem.setData(headerEditor);\n\t    menuItem.addSelectionListener(listener);\n\t}\n\n\tprivate void createViewersResponse(final Composite parent) {\n\t\tviewerControl = new Composite(parent, SWT.NONE);\n\t\tviewerLayout = new StackLayout();\n\t\tviewerControl.setLayout(viewerLayout);\n\n\t\tIHttpResponseBuilder responseBuilder = transactionInfo.getResponseBuilder();\n\t\tfinal SelectionListener listener = createSelectionListenerMenuItem();\n\n\t    viewerEmpty = new Composite(viewerControl, SWT.NONE);\n\t    viewerEmpty.setLayout(new FillLayout());\n\n\t\tResponseMessageEditor responseEditor = new ResponseMessageEditor(viewerControl, responseBuilder);\n\t\tresponseEditor.setEditable(false);\n\t    MenuItem menuItem = new MenuItem(viewerMenu, SWT.NONE);\n\t    menuItem.setText(\"Response\");\n\t    menuItem.setData(responseEditor);\n\t    menuItem.addSelectionListener(listener);\n\t\tbuilderPartCurr = responseEditor;\n\n\t    HeaderEditor headerEditor = new HeaderEditor(viewerControl, responseBuilder, 0);\n\t    headerEditor.setEditable(false);\n\t    menuItem = new MenuItem(viewerMenu, SWT.NONE);\n\t    menuItem.setText(\"Headers\");\n\t    menuItem.setData(headerEditor);\n\t    menuItem.addSelectionListener(listener);\n\t}\n\t\n\tprivate SelectionAdapter createSelectionListenerMenuItem() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tfinal MenuItem menuItem = (MenuItem) event.widget;\n\t\t\t\tfinal IHttpBuilderPart builderPart = (IHttpBuilderPart) menuItem.getData();\n\t\t\t\tprocessChanges();\n\t\t\t\tbuilderPartCurr = builderPart;\n\t\t\t\tbuilderPartCurr.setEditable(isPending);\n\t\t\t\tbuilderPartCurr.refresh();\n\t\t\t\tviewerLayout.topControl = builderPartCurr.getControl();\n\t\t\t\tviewerControl.layout();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void doConfigure() {\n\t\tif(configDialog != null && configDialog.getShell() != null) {\n\t\t\tconfigDialog.close();\n\t\t\tconfigDialog = null;\n\t\t\treturn;\n\t\t}\n\t\tconfigDialog = ConfigDialogCreator.createDialog(configureButton, new ConfigureInterceptionContent(model, direction));\n\t\tconfigDialog.open();\n\t}\n\n\tprivate void updateViewerRequest() {\n\t\tfinal TransactionManager.TransactionStatus status = transactionInfo.getRequestStatus();\n\t\tfinal Control topControl;\n\t\tString statusMessage = transactionInfo.getRequestStatusMessage();\n\t\tif (status == TransactionManager.TransactionStatus.STATUS_INACTIVE) {\n\t\t\tisPending = false;\n\t\t\ttopControl = viewerEmpty;\n\t\t} else {\n\t\t\tisPending = (status == TransactionManager.TransactionStatus.STATUS_PENDING);\n\t\t\ttopControl = builderPartCurr.getControl();\n\t\t\tbuilderPartCurr.setEditable(isPending);\n\t\t\tif (lastTransactionSerial != transactionInfo.getRequestTransactionSerial()) {\n\t\t\t\tlastTransactionSerial = transactionInfo.getRequestTransactionSerial();\n\t\t\t\tbuilderPartCurr.refresh();\n\t\t\t}\n\t\t}\n\t\tstatusLabel.setText(statusMessage);\n\t\tif (viewerLayout.topControl != topControl) {\n\t\t\tviewerLayout.topControl = topControl;\n\t\t\tviewerControl.layout();\n\t\t}\n\t\tviewerMenu.setEnabled(isPending);\n\t}\n\t\n\tprivate void updateViewerResponse() {\n\t\tfinal TransactionManager.TransactionStatus status = transactionInfo.getResponseStatus();\n\t\tfinal Control topControl;\n\t\tString statusMessage = transactionInfo.getResponseStatusMessage();\n\t\tif (status == TransactionManager.TransactionStatus.STATUS_INACTIVE) {\n\t\t\tisPending = false;\n\t\t\ttopControl = viewerEmpty;\n\t\t} else {\n\t\t\tisPending = (status == TransactionManager.TransactionStatus.STATUS_PENDING);\n\t\t\ttopControl = builderPartCurr.getControl();\n\t\t\tbuilderPartCurr.setEditable(isPending);\n\t\t\tif (lastTransactionSerial != transactionInfo.getResponseTransactionSerial()) {\n\t\t\t\tlastTransactionSerial = transactionInfo.getResponseTransactionSerial();\n\t\t\t\tbuilderPartCurr.refresh();\n\t\t\t}\n\t\t}\n\t\tstatusLabel.setText(statusMessage);\n\t\tif (viewerLayout.topControl != topControl) {\n\t\t\tviewerLayout.topControl = topControl;\n\t\t\tviewerControl.layout();\n\t\t}\n\t\tviewerMenu.setEnabled(isPending);\n\t}\n\n\t/**\n\t * Notification from InterceptView when transactionInfo has been updated.\n\t */\n\tpublic void notifyUpdate() {\n\t\tif (direction == TransactionDirection.DIRECTION_REQUEST) {\n\t\t\tupdateViewerRequest();\n\t\t} else {\n\t\t\tupdateViewerResponse();\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/config/BreakpointEnabledEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept.config;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.CheckboxCellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.swt.SWT;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\n\npublic class BreakpointEnabledEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\n\tpublic BreakpointEnabledEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn new CheckboxCellEditor(null, SWT.CHECK);// | SWT.READ_ONLY);\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\treturn ((IHttpCondition)element).isEnabled();\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\t((IHttpCondition) element).setEnabled((Boolean) value);\n\t\tviewer.refresh();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/config/BreakpointMatchTypeEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept.config;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.ComboBoxViewerCellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.swt.SWT;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\n\npublic class BreakpointMatchTypeEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\n\tpublic BreakpointMatchTypeEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\tComboBoxViewerCellEditor editor = new ComboBoxViewerCellEditor(viewer.getTable(), SWT.READ_ONLY);\n\t\teditor.setContenProvider(new ArrayContentProvider());\n\t\teditor.setLabelProvider(new LabelProvider() {\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn ((IHttpConditionMatchAction) element).getLabel();\n\t\t\t}\n\t\t});\n\t\tfinal IHttpCondition condition = (IHttpCondition) element;\n\t\tfinal List<IHttpConditionMatchAction> matchActions = condition.getType().getMatchActions();\n\t\teditor.setInput(matchActions);\n\t\tfor(IHttpConditionMatchAction ma: matchActions) {\n\t\t\tif(ma.getLabel().equals(condition.getMatchAction().getLabel()))\n\t\t\t\teditor.getViewer().setSelection(new StructuredSelection(ma));\n\t\t}\n\t\treturn editor;\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\treturn ((IHttpCondition) element).getType();\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\tfinal IHttpCondition condition = (IHttpCondition) element;\n\t\tfinal IHttpConditionMatchAction newMatchAction = (IHttpConditionMatchAction) value;\n\t\tfinal IHttpConditionMatchAction oldMatchAction = condition.getMatchAction();\n\t\tif(newMatchAction.getLabel().equals(oldMatchAction.getLabel()))\n\t\t\treturn;\n\t\t// Input will be quietly rejected if it doesn't make sense  (ie: an integer input to a range match action)\n\t\tnewMatchAction.setArgumentFromString(oldMatchAction.getArgumentAsString());\n\t\tcondition.setMatchAction(newMatchAction);\n\t\tviewer.refresh(true);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/config/BreakpointPatternEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept.config;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TextCellEditor;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\n\npublic class BreakpointPatternEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\n\tpublic BreakpointPatternEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn new TextCellEditor(viewer.getTable());\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\tfinal IHttpCondition condition = (IHttpCondition) element;\n\t\treturn condition.getMatchAction().getArgumentAsString();\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\tif(!(value instanceof String))\n\t\t\treturn;\n\t\tfinal IHttpCondition condition = (IHttpCondition) element;\n\t\tcondition.getMatchAction().setArgumentFromString((String) value);\n\t\tviewer.refresh(true);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/config/BreakpointTypeEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept.config;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\n\npublic class BreakpointTypeEditingSupport extends EditingSupport {\n\t//private final TableViewer viewer;\n\n\tpublic BreakpointTypeEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\t//this.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/intercept/config/ConfigureInterceptionContent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.intercept.config;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.proxy.HttpInterceptorLevel;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction.TransactionDirection;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.conditions.ConditionSetChanged;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.conditions.ConditionInput;\nimport com.subgraph.vega.ui.util.dialogs.IConfigDialogContent;\n\npublic class ConfigureInterceptionContent implements IConfigDialogContent {\n\tprivate static final Image IMAGE_CHECKED = Activator.getImageDescriptor(\"icons/checked.png\").createImage();\n\tprivate static final Image IMAGE_UNCHECKED = Activator.getImageDescriptor(\"icons/unchecked.png\").createImage();\n\tprivate final IModel model;\n\tprivate final TransactionDirection direction;\n\tprivate final IEventHandler conditionSetEventHandler;\n\tprivate ComboViewer comboViewerInterceptorLevel;\n\tprivate TableViewer tableViewerBreakpoints;\n\tprivate ConditionInput conditionInput;\n\tprivate IHttpInterceptor interceptor;\n\tprivate IHttpConditionSet conditionSet;\n\tprivate Composite composite;\n\t\n\tpublic ConfigureInterceptionContent(IModel model, TransactionDirection direction) {\n\t\tthis.model = model;\n\t\tfinal IWorkspace workspace = model.getCurrentWorkspace();\n\t\tfinal IHttpConditionManager conditionManager = (workspace == null) ? (null) : (workspace.getHttpConditionMananger());\n\t\tthis.conditionInput = new ConditionInput(conditionManager);\n\t\tthis.direction = direction;\n\t\tthis.conditionSetEventHandler = createConditionSetEventHandler();\n\t\tthis.conditionSet = model.addConditionSetTracker(getConditionSetName(), conditionSetEventHandler);\n\t}\n\tprivate IEventHandler createConditionSetEventHandler() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof ConditionSetChanged) \n\t\t\t\t\tonConditionSetChanged((ConditionSetChanged) event);\n\t\t\t}\t\t\t\n\t\t};\n\t}\n\t@Override\n\tpublic Composite createContents(Composite parent) {\n\t\tcomposite = new Composite(parent, SWT.NONE);\n\t\tcomposite.setLayout(new GridLayout(1, true));\n\t\tcomposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\tcreateInterceptorOptions(composite).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));\n\t\tcreateBreakpointsEditor(composite).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));\n\t\tinterceptor = Activator.getDefault().getProxyService().getInterceptor();\n\t\tcomboViewerInterceptorLevel.setSelection(new StructuredSelection(interceptor.getInterceptLevel(direction)));\n\t\tsetConditionSetInput();\n\t\treturn composite;\n\t}\n\n\t@Override\n\tpublic String getTitle() {\n\t\treturn \"Interceptor Options\";\n\t}\n\n\t@Override\n\tpublic String getMessage() {\n\t\treturn \"Set up breakpoint for interceptor\";\n\t}\n\n\t@Override\n\tpublic Control getFocusControl() {\n\t\treturn composite;\n\t}\n\n\t@Override\n\tpublic void onClose() {\n\t\tmodel.removeConditionSetTracker(getConditionSetName(), conditionSetEventHandler);\n\t}\n\n\t@Override\n\tpublic void onOk() {\t\n\t}\n\t\n\tprivate String getConditionSetName() {\n\t\tswitch(direction) {\n\t\tcase DIRECTION_REQUEST:\n\t\t\treturn IHttpConditionManager.CONDITION_SET_BREAKPOINTS_REQUEST;\n\t\tcase DIRECTION_RESPONSE:\n\t\t\treturn IHttpConditionManager.CONDITION_SET_BREAKPOINTS_RESPONSE;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate void setConditionSetInput() {\n\t\tif(tableViewerBreakpoints == null || tableViewerBreakpoints.getContentProvider() == null)\n\t\t\treturn;\n\t\tif(conditionSet == null)\n\t\t\ttableViewerBreakpoints.setInput(null);\n\t\telse\n\t\t\ttableViewerBreakpoints.setInput(conditionSet.getAllConditions());\n\t}\n\t\n\tprivate void onConditionSetChanged(ConditionSetChanged event) {\n\t\tconditionSet = event.getConditionSet();\n\t\tsetConditionSetInput();\n\t}\n\n\tprotected Control createDialogArea(Composite parent) {\n\t\t\n\t\tparent.setLayout(new GridLayout(1, true));\n\t\tcreateInterceptorOptions(parent).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));\n\t\tcreateBreakpointsEditor(parent).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));\n\t\tinterceptor = Activator.getDefault().getProxyService().getInterceptor();\n\t\tcomboViewerInterceptorLevel.setSelection(new StructuredSelection(interceptor.getInterceptLevel(direction)));\n\t\tsetConditionSetInput();\n\t\treturn parent;\n\t}\n\n\tvoid dispose() {\n\t\tmodel.removeConditionSetTracker(getConditionSetName(), conditionSetEventHandler);\n\t}\n\n\tpublic TransactionDirection getDirection() {\n\t\treturn direction;\n\t}\n\n\tprivate Composite createInterceptorOptions(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setText(\"Interceptor Options\");\n\t\trootControl.setLayout(new GridLayout(2, false));\n\n\t\tfinal Label label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Intercept for:\");\n\n\t\tcomboViewerInterceptorLevel = new ComboViewer(rootControl, SWT.READ_ONLY);\n\t\tcomboViewerInterceptorLevel.setContentProvider(new ArrayContentProvider());\n\t\tcomboViewerInterceptorLevel.setLabelProvider(new LabelProvider() {\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn ((HttpInterceptorLevel) element).getName();\n\t\t\t}\n\t\t});\n\t\tcomboViewerInterceptorLevel.setInput(HttpInterceptorLevel.values());\n\t\tcomboViewerInterceptorLevel.addSelectionChangedListener(createSelectionChangedListenerComboViewerInterceptorLevel());\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate ISelectionChangedListener createSelectionChangedListenerComboViewerInterceptorLevel() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(final SelectionChangedEvent e) {\n\t\t\t\tHttpInterceptorLevel level = (HttpInterceptorLevel) ((IStructuredSelection) comboViewerInterceptorLevel.getSelection()).getFirstElement();\n\t\t\t\tif (level != null) {\n\t\t\t\t\tinterceptor.setInterceptLevel(direction, level);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\tprivate Composite createBreakpointsEditor(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setText(\"Breakpoints\");\n\t\trootControl.setLayout(new GridLayout(2, false));\n\n\t\tGridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);\n\t\tfinal Composite compTable = createTableBreakpoints(rootControl, gd, 7);\n\t\tcompTable.setLayoutData(gd);\n\t\tfinal Composite compTableButtons = createTableBreakpointsButtons(rootControl);\n\t\tcompTableButtons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\n\t\tfinal Composite compCreate = createCreatorBreakpoints(rootControl);\n\t\tcompCreate.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));\n\t\tfinal Composite compCreateButtons = createCreatorBreakpointsButtons(rootControl);\n\t\tcompCreateButtons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate Composite createTableBreakpoints(Composite parent, GridData gd, int heightInRows) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\ttableViewerBreakpoints = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\tcreateTableBreakpointsColumns(tableViewerBreakpoints, tcl);\n\t\ttableViewerBreakpoints.setContentProvider(new ArrayContentProvider());\n\t\tfinal Table table = tableViewerBreakpoints.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t\tgd.heightHint = table.getItemHeight() * heightInRows;\n\n\t\treturn rootControl;\n\t}\n\n\tprivate void createTableBreakpointsColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"\", \"Type\", \"Matches\", \"Pattern\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnPixelData(16, false, true),\n\t\t\tnew ColumnPixelData(150, true, true),\n\t\t\tnew ColumnPixelData(150, true, true),\n\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t};\n\t\tfinal EditingSupport editorList[] = {\n\t\t\t\tnew BreakpointEnabledEditingSupport(viewer),\n\t\t\t\tnew BreakpointTypeEditingSupport(viewer),\n\t\t\t\tnew BreakpointMatchTypeEditingSupport(viewer),\n\t\t\t\tnew BreakpointPatternEditingSupport(viewer),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t@Override\n\t\t\t\tpublic Image getImage(Object element) {\n\t\t\t\t\tif(((IHttpCondition) element).isEnabled()) {\n\t\t\t\t\t\treturn IMAGE_CHECKED;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn IMAGE_UNCHECKED;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpCondition) element).getType().getName();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\tIHttpCondition condition = (IHttpCondition) element;\n\t\t\t\t\treturn condition.getMatchAction().getLabel();\n\t\t\t\t}\n\t\t\t},\t\t\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\tIHttpCondition condition = (IHttpCondition) element;\n\t\t\t\t\treturn condition.getMatchAction().getArgumentAsString();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\tfor (int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\t\t\t\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setEditingSupport(editorList[i]);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\t\n\t}\n\n\tprivate Composite createTableBreakpointsButtons(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, true));\n\n\t\tButton button = new Button(rootControl, SWT.PUSH);\n\t\tbutton.setText(\"remove\");\n\t\tbutton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tbutton.addSelectionListener(createSelectionListenerButtonRemove());\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate SelectionListener createSelectionListenerButtonRemove() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) tableViewerBreakpoints.getSelection();\n\t\t\t\tfor(Object ob: selection.toList()) {\n\t\t\t\t\tif((ob instanceof IHttpCondition) && (conditionSet != null)) \n\t\t\t\t\t\tconditionSet.removeCondition((IHttpCondition) ob, true);\t\t\t\n\t\t\t\t}\n\t\t\t\ttableViewerBreakpoints.refresh(true);\n\t\t\t}\n\t\t};\n\t}\n\n\t\n\tprivate Composite createCreatorBreakpoints(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(3, false));\n\t\tconditionInput.createConditionTypeCombo(rootControl);\n\t\tconditionInput.createConditionMatchCombo(rootControl);\n\t\tconditionInput.createInputPanel(rootControl);\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createCreatorBreakpointsButtons(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, true));\n\n\t\tButton button = new Button(rootControl, SWT.PUSH);\n\t\tbutton.setText(\"create\");\n\t\tbutton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tbutton.addSelectionListener(createSelectionListenerButtonCreateBreakpoint());\n\n\t\treturn rootControl;\n\t}\n\t\n\t\n\tprivate SelectionListener createSelectionListenerButtonCreateBreakpoint() {\n\t\treturn new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tfinal IHttpCondition breakpoint = conditionInput.createConditionFromData();\n\t\t\t\tif(breakpoint == null)\n\t\t\t\t\treturn;\n\t\t\t\tif(conditionSet != null)\n\t\t\t\t\tconditionSet.appendCondition(breakpoint, true);\n\t\t\t\tconditionInput.reset();\n\t\t\t\ttableViewerBreakpoints.refresh(true);\n\t\t\t}\n\t\t};\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/preferencepage/HttpPreferenceInitializer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.preferencepage;\n\nimport org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\nimport org.eclipse.jface.preference.IPreferenceStore;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.ui.http.Activator;\n\npublic class HttpPreferenceInitializer extends AbstractPreferenceInitializer implements IPreferenceConstants {\n\n\tpublic HttpPreferenceInitializer() {\n\t\tIPreferenceStore store = Activator.getDefault().getPreferenceStore();\n\t\tstore.setDefault(P_USER_AGENT, IHttpRequestEngineFactory.DEFAULT_USER_AGENT);\n\t\tstore.setDefault(P_USER_AGENT_OVERRIDE, false);\n\t\tstore.setDefault(P_DISABLE_BROWSER_CACHE, false);\n\t\tstore.setDefault(P_DISABLE_PROXY_CACHE, false);\n\t\tstore.setDefault(P_PROXY_LISTENERS, \"[127.0.0.1]:8888\");\n\t}\n\n\t@Override\n\tpublic void initializeDefaultPreferences() {\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/preferencepage/HttpPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.preferencepage;\n\nimport org.eclipse.jface.preference.BooleanFieldEditor;\nimport org.eclipse.jface.preference.FieldEditorPreferencePage;\nimport org.eclipse.jface.preference.StringFieldEditor;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\nimport com.subgraph.vega.ui.http.Activator;\n\npublic class HttpPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IPreferenceConstants {\n\n\tpublic HttpPreferencePage() {\n\t\tsuper(GRID);\n\t}\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t\tsetDescription(\"Configuration parameters for the HTTP Proxy\");\n\t}\n\n\t@Override\n\tprotected void createFieldEditors() {\n\t\tfinal StringFieldEditor userAgent = new StringFieldEditor(P_USER_AGENT, \"Default &User-Agent:\", 60, getFieldEditorParent());\n\t\taddField(userAgent);\n\n\t\tfinal BooleanFieldEditor userAgentOverride = new BooleanFieldEditor(P_USER_AGENT_OVERRIDE, \"Override client User-Agent\", getFieldEditorParent());\n\t\taddField(userAgentOverride);\n\n\t\tfinal BooleanFieldEditor cacheBrowserDisable = new BooleanFieldEditor(P_DISABLE_BROWSER_CACHE, \"Prevent browser caching\", getFieldEditorParent());\n\t\taddField(cacheBrowserDisable);\n\n\t\tfinal BooleanFieldEditor cacheProxyDisable = new BooleanFieldEditor(P_DISABLE_PROXY_CACHE, \"Prevent intermediate (proxy) caching\", getFieldEditorParent());\n\t\taddField(cacheProxyDisable);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/preferencepage/IPreferenceConstants.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.preferencepage;\n\npublic interface IPreferenceConstants {\n\tpublic static final String P_PROXY_LISTENERS = \"ProxyListeners\";\n\t\n\tpublic static final String P_USER_AGENT = \"UserAgent\";\n\tpublic static final String P_USER_AGENT_OVERRIDE = \"UserAgentOverride\";\n\n\tpublic static final String P_DISABLE_BROWSER_CACHE = \"DisableBrowserCache\";\n\tpublic static final String P_DISABLE_PROXY_CACHE = \"DisableProxyCache\";\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/preferencepage/ListenerAddressDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.preferencepage;\n\nimport java.net.InetAddress;\nimport java.net.UnknownHostException;\n\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class ListenerAddressDialog extends Dialog {\n\tprivate ProxyListenerPreferencePage page;\n\tprivate Composite parentComposite;\n\tprivate Text ipAddress;\n\tprivate Text port;\n\tprivate int portNum;\n\tprivate InetAddress inetAddress;\n\n\tpublic ListenerAddressDialog(Shell parent, ProxyListenerPreferencePage page) {\n\t\tsuper(parent);\n\t\tthis.page = page;\n\t}\n\n\tprotected void configureShell(Shell shell) {\n\t\tsuper.configureShell(shell);\n\t\tshell.setText(\"Add Listen Address\");\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tparentComposite = (Composite) super.createDialogArea(parent);\n\t\tcreateFields(parentComposite);\t\t\n\t\treturn parentComposite;\n\t}\n\t\n\t@Override\n\tprotected void okPressed() {\n\t\tif (parseInput() == true) {\n\t\t\tsuper.okPressed();\n\t\t}\n\t}\n\n\tprivate Composite createFields(Composite parent) {\n\t\tComposite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, true));\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"IP Address:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tipAddress = new Text(rootControl, SWT.BORDER);\n//\t\tipAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tipAddress.addListener(SWT.Verify, new Listener() {\n\t\t\tpublic void handleEvent(Event e) {\n\t\t\t\tString string = e.text;\n\t\t\t\tchar[] chars = new char[string.length()];\n\t\t\t\tstring.getChars(0, chars.length, chars, 0);\n\t\t\t\tfor (int i = 0; i < chars.length; i++) {\n\t\t\t\t\tif (!('0' <= chars[i] && chars[i] <= '9') && chars[i] != '.') {\n\t\t\t\t\t\te.doit = false;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tlabel = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Port:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tport = new Text(rootControl, SWT.BORDER);\n\t\tport.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tport.addListener(SWT.Verify, new Listener() { // REVISIT: should create a helper method for this\n\t\t\tpublic void handleEvent(Event e) {\n\t\t\t\tString string = e.text;\n\t\t\t\tchar[] chars = new char[string.length()];\n\t\t\t\tstring.getChars(0, chars.length, chars, 0);\n\t\t\t\tfor (int i = 0; i < chars.length; i++) {\n\t\t\t\t\tif (!('0' <= chars[i] && chars[i] <= '9')) {\n\t\t\t\t\t\te.doit = false;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\treturn rootControl;\n\t}\n\t\n\tpublic IHttpProxyListenerConfig getConfig() {\n\t\tfinal IHttpProxyListenerConfig listenerConfig = Activator.getDefault().getProxyService().createListenerConfig();\n\t\tlistenerConfig.setInetAddress(inetAddress);\n\t\tlistenerConfig.setPort(portNum);\n\t\treturn listenerConfig;\n\t}\n\n\tprivate boolean parseInput() {\n\t\ttry {\n\t\t\tinetAddress = InetAddress.getByName(ipAddress.getText());\n\t\t} catch (UnknownHostException e) {\n\t\t\tErrorDialog.displayError(getShell(), \"Invalid IP address\");\n\t        return false;\n\t\t}\n\n\t\ttry {\n\t\t\tportNum = Integer.parseInt(port.getText());\n\t\t} catch (NumberFormatException e) {\n\t\t\tErrorDialog.displayError(getShell(), \"Invalid port: must be between 1 and 65535\");\n\t        return false;\n\t\t}\t\t\n\t\tif (portNum < 1 || portNum > 65535) {\n\t\t\tErrorDialog.displayError(getShell(), \"Invalid port: must be between 1 and 65535\");\n\t        return false;\n\t\t}\n\n\t\tif (page.hasListener(inetAddress, portNum) == true) {\n\t\t\tErrorDialog.displayError(getShell(), \"IP address/port combination is already registered\");\n\t        return false;\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/preferencepage/ListenerTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.preferencepage;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\n\npublic class ListenerTableContentProvider implements IStructuredContentProvider {\n\tprivate List<IHttpProxyListenerConfig> addressList;\n\t\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\taddressList = (List<IHttpProxyListenerConfig>) newInput;\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn addressList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/preferencepage/ProxyListenerPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.preferencepage;\n\nimport java.net.InetAddress;\nimport java.util.ArrayList;\nimport java.util.Iterator;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\nimport org.eclipse.ui.IWorkbench;\n\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListenerConfig;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.util.preferences.VegaPreferencePage;\n\npublic class ProxyListenerPreferencePage extends VegaPreferencePage implements IPreferenceConstants {\n\tprivate static final String SEPARATOR_LISTENER = \";\"; \n\tprivate static final String SEPARATOR_ADDRESS_PORT = \":\";\n\tprivate Composite parentComposite;\n\tprivate TableViewer listenersTableViewer;\n\tprivate Button buttonCreate;\n\tprivate Button buttonRemove;\n\tprivate ArrayList<IHttpProxyListenerConfig> listenerList = new ArrayList<IHttpProxyListenerConfig>();\n\n\tpublic ProxyListenerPreferencePage() {\n\t\tsuper(\"Proxy Listen Address\");\n\t}\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t}\n\n\t@Override\n\tprotected Control createPage(Composite parent) {\n\t\tparentComposite = new SashForm(parent, SWT.VERTICAL);\n\t\tcreateListenAddressGroup(parentComposite);\n\t\tparsePreferencesString(listenerList, getPreferenceStore().getString(IPreferenceConstants.P_PROXY_LISTENERS));\n\t\tlistenersTableViewer.setInput(listenerList);\n\t\treturn parentComposite;\n\t}\n\n\t@Override\n\tprotected void performDefaults() {\n\t\tsuper.performDefaults();\n\t\tparsePreferencesString(listenerList, getPreferenceStore().getDefaultString(IPreferenceConstants.P_PROXY_LISTENERS));\n\t\tlistenersTableViewer.setInput(listenerList);\n\t}\n\n\t@Override\n\tpublic boolean performOk() {\n\t    boolean rv = super.performOk();\n\t    if (rv) {\n\t    \tgetPreferenceStore().setValue(IPreferenceConstants.P_PROXY_LISTENERS, getPreferencesString());\n\t    }\n\t    return rv;\n\t}\n\n\tstatic public void parsePreferencesString(ArrayList<IHttpProxyListenerConfig> listenerList, final String prefListeners) {\n\t\tlistenerList.clear();\n\t\tif (prefListeners != null) {\n\t\t\tfinal String[] listeners = prefListeners.split(SEPARATOR_LISTENER);\n\t\t\tfor (int listenerIdx = 0; listenerIdx < listeners.length; listenerIdx++) {\n\t\t\t\tfinal String[] listenerInfo = listeners[listenerIdx].split(SEPARATOR_ADDRESS_PORT);\n\t\t\t\tIHttpProxyListenerConfig listenerConfig;\n\t\t\t\ttry {\n\t\t\t\t\tlistenerConfig = Activator.getDefault().getProxyService().createListenerConfig();\n\t\t\t\t\tInetAddress inetAddress = InetAddress.getByName(listenerInfo[0].substring(1, listenerInfo[0].length() - 1));\n\t\t\t\t\tlistenerConfig.setInetAddress(inetAddress);\n\t\t\t\t\tlistenerConfig.setPort(Integer.parseInt(listenerInfo[1]));\n\t\t\t\t\tlistenerList.add(listenerConfig);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t// REVISIT: should log this\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate String getPreferencesString() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor (int idx = 0; idx < listenerList.size(); idx++) {\n\t\t\tIHttpProxyListenerConfig listenerConfig = listenerList.get(idx);\n\t\t\tif (idx != 0) {\n\t\t\t\tsb.append(SEPARATOR_LISTENER);\n\t\t\t}\n\t\t\tsb.append(\"[\");\n\t\t\tsb.append(listenerConfig.getInetAddress().getHostAddress());\n\t\t\tsb.append(\"]\");\n\t\t\tsb.append(SEPARATOR_ADDRESS_PORT);\n\t\t\tsb.append(Integer.toString(listenerConfig.getPort()));\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate Composite createListenAddressGroup(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, false));\n\t\trootControl.setText(\"Listen Addresses\");\n\n\t\tfinal Composite compTable = createListenerTable(rootControl);\n\t\tcompTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));\n\t\tfinal Composite compTableButtons = createListenerTableButtons(rootControl);\n\t\tcompTableButtons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createListenerTable(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\tlistenersTableViewer = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\tlistenersTableViewer.setContentProvider(new ListenerTableContentProvider());\n\t\tlistenersTableViewer.addSelectionChangedListener(createSelectionChangedListener());\n\t\tcreateListenerTableColumns(listenersTableViewer, tcl);\n\t\tfinal Table table = listenersTableViewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tboolean sel = event.getSelection().isEmpty(); \n\t\t\t\tbuttonRemove.setGrayed(sel);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void createListenerTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"IP Address\", \"Port\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t\tnew ColumnPixelData(80, true, true),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpProxyListenerConfig) element).getInetAddress().getHostAddress();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn Integer.toString(((IHttpProxyListenerConfig) element).getPort());\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\tfor (int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\t\n\t}\n\n\tprivate Composite createListenerTableButtons(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, true));\n\n\t\tbuttonCreate = new Button(rootControl, SWT.PUSH);\n\t\tbuttonCreate.setText(\"create\");\n\t\tbuttonCreate.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tbuttonCreate.addSelectionListener(createSelectionListenerButtonCreate());\n\n\t\tbuttonRemove = new Button(rootControl, SWT.PUSH);\n\t\tbuttonRemove.setText(\"remove\");\n\t\tbuttonRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tbuttonRemove.setGrayed(true);\n\t\tbuttonRemove.addSelectionListener(createSelectionListenerButtonRemove());\n\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonCreate() {\n\t\tfinal ProxyListenerPreferencePage page = this;\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tfinal ListenerAddressDialog dialog = new ListenerAddressDialog(parentComposite.getShell(), page); \n\t\t\t\tdialog.create();\n\t\t\t\tif (dialog.open() == Window.OK) {\n\t\t\t\t\tlistenerList.add(dialog.getConfig());\n\t\t\t\t\tlistenersTableViewer.refresh();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonRemove() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) listenersTableViewer.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tlistenerList.remove((IHttpProxyListenerConfig) i.next());\n\t\t\t\t}\n\t\t\t\tlistenersTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\t\n\tpublic boolean hasListener(InetAddress inetAddress, int port) {\n\t\tfor (IHttpProxyListenerConfig listener: listenerList) {\n\t\t\tif (listener.getInetAddress().equals(inetAddress) && listener.getPort() == port) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/proxy/ConfigureProxyModulesContent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.proxy;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.CheckboxTreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.ui.util.dialogs.IConfigDialogContent;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryCheckStateProvider;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryContentProvider;\n\npublic class ConfigureProxyModulesContent implements IConfigDialogContent {\n\tprivate final List<IScannerModule> modules;\n\tprivate Composite composite;\n\tprivate CheckboxTreeViewer viewer;\n\t\n\tpublic ConfigureProxyModulesContent(List<IScannerModule> modules) {\n\t\tthis.modules = modules;\n\t}\n\n\t@Override\n\tpublic Composite createContents(Composite parent) {\n\t\tcomposite = new Composite(parent, SWT.NONE);\n\t\tfinal GridLayout layout = new GridLayout();\n\t\tlayout.marginHeight = 10;\n\t\tlayout.verticalSpacing = 20;\n\t\tcomposite.setLayout(layout);\n\t\tcomposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\n\t\tviewer = new CheckboxTreeViewer(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\tfinal ModuleRegistryCheckStateProvider checkStateProvider = new ModuleRegistryCheckStateProvider(viewer);\n\t\tviewer.setContentProvider(new ModuleRegistryContentProvider(checkStateProvider));\n\t\tviewer.setLabelProvider(new ConfigureProxyModulesLabelProvider());\n\t\tviewer.setCheckStateProvider(checkStateProvider);\n\t\t\n\t\tviewer.setInput(modules.toArray(new IScannerModule[0]));\n\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\tgd.heightHint = 300;\n\t\tgd.widthHint = 500;\n\t\tviewer.getTree().setLayoutData(gd);\n\t\t\n\t\tviewer.addCheckStateListener(checkStateProvider);\n\t\tcomposite.layout();\n\t\treturn composite;\n\t}\n\n\t@Override\n\tpublic String getTitle() {\n\t\treturn \"Configure enabled modules for proxy\";\n\t}\n\n\t@Override\n\tpublic String getMessage() {\n\t\treturn \"Select which vulnerability modules to enable in the Proxy. Injection modules only run against in-scope targets when proxy scanning is enabled.\";\n\t}\n\n\t@Override\n\tpublic Control getFocusControl() {\n\t\treturn composite;\n\t}\n\n\t@Override\n\tpublic void onClose() {\t\t\n\t}\n\n\t@Override\n\tpublic void onOk() {\t\t\n\t}\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/proxy/ConfigureProxyModulesLabelProvider.java",
    "content": "package com.subgraph.vega.ui.http.proxy;\n\nimport org.eclipse.jface.viewers.LabelProvider;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\n\npublic class ConfigureProxyModulesLabelProvider extends LabelProvider {\n\t\n\tpublic String getText(Object element) {\n\t\tif (element instanceof IScannerModule) {\n\t\t\treturn ((IScannerModule) element).getModuleName();\n\t\t} else if (element instanceof String) {\n\t\t\treturn getCategoryText((String) element);\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tprivate String getCategoryText(String text) {\n\t\tif(text.toLowerCase().contains(\"injection\")) {\n\t\t\treturn text + \" (When Proxy Scanning is active)\";\n\t\t} else {\n\t\t\treturn text;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/request/view/HttpRequestView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.request.view;\n\nimport org.eclipse.core.commands.Command;\nimport org.eclipse.core.commands.State;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.ISelectionListener;\nimport org.eclipse.ui.ISelectionService;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.commands.ICommandService;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.requestlogviewer.RequestLogViewer;\nimport com.subgraph.vega.ui.http.requestlogviewer.RequestResponseViewer;\n\n/**\n * When multiple instances of this view are opened, the secondary view ID must be set to a unique value. The value is\n * used to differentiate between condition filter sets.\n */\npublic class HttpRequestView extends ViewPart {\n\tpublic final static String ID = \"com.subgraph.vega.views.http\";\n\tpublic final static String ID_PROXY_SECONDARY = \"proxy\";\n\tpublic final static String ID_PROXY = ID + \":\" + ID_PROXY_SECONDARY; /** Compound ID identifying the non-closable base view in the proxy perspective */\n\tprivate RequestLogViewer requestLogViewer;\n\tprivate RequestResponseViewer requestResponseViewer;\n\tprivate IEventHandler workspaceListener;\n\t\n\tpublic HttpRequestView() {\n\t}\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tparent.setLayout(new FillLayout());\n\t\tfinal SashForm form = new SashForm(parent, SWT.VERTICAL);\n\n\t\trequestLogViewer = new RequestLogViewer(form, getViewSite().getSecondaryId(), 0);\n\n\t\trequestResponseViewer = new RequestResponseViewer(form);\n\t\trequestLogViewer.setRequestResponseViewer(requestResponseViewer);\n\n\t\tform.setWeights(new int[] {40, 60});\n\t\tparent.pack();\n\t\t\n\t\tfinal ISelectionService ss = getSite().getWorkbenchWindow().getSelectionService();\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tfinal ISelectionListener listener = new WebEntitySelectionListener(model, getViewSite().getSecondaryId());\n\t\tss.addSelectionListener(listener);\n\t\t\n\t\tworkspaceListener = new IEventHandler() {\n\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceCloseEvent || event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceCloseOrReset();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tmodel.addWorkspaceListener(workspaceListener);\n\t}\n\n\tprivate void handleWorkspaceCloseOrReset() {\n\t\tfinal IHttpProxyService proxyService = Activator.getDefault().getProxyService();\n\t\tresetToggleCommand(\"com.subgraph.vega.commands.proxyScan\", false);\n\t\tresetToggleCommand(\"com.subgraph.vega.commands.proxyPassthrough\", proxyService.isPassthrough());\n\t}\n\t\n\tprivate void resetToggleCommand(String commandId, boolean value) {\n\t\tfinal ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\n\t\tfinal Command command = service.getCommand(commandId);\n\t\tif(command == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal State state = command.getState(\"org.eclipse.ui.commands.toggleState\");\n\t\tif(state != null) {\n\t\t\tstate.setValue(value);\n\t\t}\n\t}\n\t\n\tpublic void focusOnRecord(long requestId) {\n\t\trequestLogViewer.focusOnRecord(requestId);\n\t}\n\n\t@Override\n\tpublic void setFocus() {\n\t\trequestLogViewer.setFocus();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/request/view/WebEntitySelectionListener.java",
    "content": "package com.subgraph.vega.ui.http.request.view;\n\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.ui.ISelectionListener;\nimport org.eclipse.ui.IWorkbenchPart;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\n\npublic class WebEntitySelectionListener implements ISelectionListener {\n\t\n\tprivate final IModel model;\n\tprivate final String instanceId;\n\t\n\tpublic WebEntitySelectionListener(IModel model, String instanceId) {\n\t\tthis.model = model;\n\t\tthis.instanceId = instanceId;\n\t}\n\n\t@Override\n\tpublic void selectionChanged(IWorkbenchPart part, ISelection selection) {\n\t\tif(!(selection instanceof IStructuredSelection)) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IStructuredSelection ss = (IStructuredSelection) selection;\n\t\tfor(Object ob: ss.toArray()) {\n\t\t\tif(ob instanceof IWebEntity) {\n\t\t\t\thandleWebEntitySelected((IWebEntity) ob);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate String getConditionSetId() {\n\t\tif(instanceId == null) {\n\t\t\treturn IHttpConditionManager.CONDITION_SET_FILTER;\n\t\t} else {\n\t\t\treturn IHttpConditionManager.CONDITION_SET_FILTER + \".\" + instanceId;\n\t\t}\n\t}\n\n\tprivate void handleWebEntitySelected(IWebEntity entity) {\n\t\tfinal IHttpConditionSet conditionSet = getConditionSet();\n\t\tif(conditionSet == null) {\n\t\t\treturn;\n\t\t}\n\t\tconditionSet.clearTemporaryConditions(false);\n\t\t\n\t\tif(entity instanceof IWebHost) {\n\t\t\thandleWebHostSelected(conditionSet, (IWebHost) entity);\n\t\t} else if(entity instanceof IWebPath) {\n\t\t\thandleWebPathSelected(conditionSet, (IWebPath) entity);\n\t\t} else if(entity instanceof IWebResponse) {\n\t\t\thandleWebResponseSelected(conditionSet, (IWebResponse) entity);\n\t\t}\n\t\tconditionSet.notifyChanged();\n\t}\n\t\n\tprivate void handleWebHostSelected(IHttpConditionSet conditionSet, IWebHost host) {\n\t\taddHostnameCondition(conditionSet, host.getHostname());\n\t}\n\t\n\tprivate void handleWebPathSelected(IHttpConditionSet conditionSet, IWebPath path) {\n\t\taddHostnameCondition(conditionSet, path.getMountPoint().getWebHost().getHostname());\n\t\taddPathCondition(conditionSet, path.getFullPath());\n\t}\n\t\n\tprivate void handleWebResponseSelected(IHttpConditionSet conditionSet, IWebResponse response) {\n\t\thandleWebPathSelected(conditionSet, response.getPathEntity());\n\t}\n\n\tprivate void addHostnameCondition(IHttpConditionSet conditionSet, String hostname) {\n\t\tfinal IHttpConditionType type = conditionSet.getConditionManager().getConditionTypeByName(\"hostname\");\n\t\tfinal IHttpConditionMatchAction matchAction = type.getMatchActionByName(\"contains\");\n\t\tmatchAction.setArgumentFromString(hostname);\n\t\tfinal IHttpCondition condition = type.createConditionInstance(matchAction);\n\t\tconditionSet.appendTemporaryCondition(condition, false);\n\t}\n\t\n\tprivate void addPathCondition(IHttpConditionSet conditionSet, String path) {\n\t\tfinal IHttpConditionType type = conditionSet.getConditionManager().getConditionTypeByName(\"request path\");\n\t\tfinal IHttpConditionMatchAction matchAction = type.getMatchActionByName(\"starts with\");\n\t\tmatchAction.setArgumentFromString(path);\n\t\tfinal IHttpCondition condition = type.createConditionInstance(matchAction);\n\t\tconditionSet.appendTemporaryCondition(condition, false);\n\t}\n\n\n\tprivate IHttpConditionSet getConditionSet() {\n\t\tfinal IHttpConditionManager manager = getConditionManager();\n\t\tif(manager == null) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal String id = getConditionSetId();\n\t\treturn manager.getConditionSet(id);\n\t}\n\n\tprivate IHttpConditionManager getConditionManager() {\n\t\tfinal IWorkspace workspace = model.getCurrentWorkspace();\n\t\tif(workspace == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn workspace.getHttpConditionMananger();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requesteditviewer/RequestEditView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.requesteditviewer;\n\nimport java.net.URISyntaxException;\n\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.MessageBox;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.analysis.IContentAnalyzer;\nimport com.subgraph.vega.api.analysis.IContentAnalyzerFactory;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.builder.HeaderEditor;\nimport com.subgraph.vega.ui.http.builder.IHttpBuilderPart;\nimport com.subgraph.vega.ui.http.builder.RequestEditor;\nimport com.subgraph.vega.ui.httpeditor.HttpMessageEditor;\n\npublic class RequestEditView extends ViewPart {\n\tpublic final static String VIEW_ID = \"com.subgraph.vega.views.requestEdit\";\n\tprivate IHttpRequestEngine requestEngine;\n\tprivate IHttpRequestBuilder requestBuilder;\n\tprivate IContentAnalyzer contentAnalyzer;\n\tprivate SashForm parentComposite;\n\tprivate IHttpBuilderPart requestBuilderPartCurr;\n\tprivate RequestEditor requestEditor;\n\tprivate HeaderEditor requestHeaderEditor;\n\tprivate TabFolder requestTabFolder;\n\tprivate TabItem requestTabItem;\n\tprivate TabItem requestHeaderTabItem;\n\tprivate TabItem requestTabFolderItem;\n\tprivate HttpMessageEditor responseViewer;\n\n\tpublic RequestEditView() {\n\t\tsuper();\n\t\tfinal IContentAnalyzerFactory contentAnalyzerFactory = Activator.getDefault().getContentAnalyzerFactoryService();\n\t\t// XXX we should be watching for workspace events\n\t\tfinal IWorkspace workspace = Activator.getDefault().getModel().getCurrentWorkspace();\n\t\tif(workspace != null) {\n\t\t\tcontentAnalyzer = contentAnalyzerFactory.createContentAnalyzer(workspace.getScanAlertRepository().getProxyScanInstance());\n\t\t\tcontentAnalyzer.setDefaultAddToRequestLog(true);\n\t\t\tcontentAnalyzer.setAddLinksToModel(true);\n\t\t}\n\t\tIRequestOrigin requestOrigin = workspace.getRequestLog().getRequestOriginRequestEditor();\n\t\tIHttpRequestEngineFactory requestEngineFactory = Activator.getDefault().getHttpRequestEngineFactoryService();\n\t\trequestEngine = requestEngineFactory.createRequestEngine(IHttpRequestEngine.EngineConfigType.CONFIG_PROXY, requestEngineFactory.createConfig(), requestOrigin);\n\t\trequestBuilder = requestEngineFactory.createRequestBuilder();\n\t}\n\t\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tparentComposite = new SashForm(parent, SWT.VERTICAL);\n\n\t\tcreateRequestEditor(parentComposite);\n\t\tcreateResponseViewer(parentComposite);\n\t\t\n\t\tparentComposite.setWeights(new int[] {50, 50});\n\t\tparentComposite.pack();\n\t}\n\n\t@Override\n\tpublic void setFocus() {\n\t\tif (parentComposite != null) {\n\t\t\tparentComposite.setFocus();\n\t\t}\n\t}\n\n\tpublic void setRequest(IRequestLogRecord record) throws URISyntaxException {\n\t\tif (record != null) {\n\t\t\trequestBuilder.setFromRequest(record);\n\t\t} else {\n\t\t\trequestBuilder.clear();\n\t\t}\n\n\t\tif (requestBuilderPartCurr != null) {\n\t\t\trequestBuilderPartCurr.refresh();\n\t\t}\n\t}\n\n\tprivate void displayError(String text) {\n\t\tMessageBox messageDialog = new MessageBox(parentComposite.getShell(), SWT.ICON_WARNING | SWT.OK);\n\t\tmessageDialog.setText(\"Error\");\n\t\tif (text == null) {\n\t\t\ttext = \"Unexpected error occurred\";\n\t\t}\n\t\tmessageDialog.setMessage(text);\n\t\tmessageDialog.open();\n\t}\n\t\n\tvoid displayExceptionError(Exception e) {\n\t\tif (e.getMessage() != null) {\n\t\t\tdisplayError(e.getMessage());\n\t\t} else {\n\t\t\tdisplayError(e.getCause().getMessage());\n\t\t}\n\t}\n\n\tpublic void sendRequest() {\n\t\tif (requestBuilderPartCurr != null) {\n\t\t\ttry {\n\t\t\t\trequestBuilderPartCurr.processContents();\n\t\t\t} catch (Exception e) {\n\t\t\t\tdisplayExceptionError(e);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tHttpUriRequest uriRequest;\n\t\ttry {\n\t\t\turiRequest = requestBuilder.buildRequest(true);\n\t\t} catch (Exception e) {\n\t\t\tdisplayExceptionError(e);\n\t\t\treturn;\n\t\t}\n\n\t\tfinal SendRequestTask sendTask = new SendRequestTask(uriRequest, this, requestEngine);\n\t\tsendTask.start();\n\t}\n\t\n\tvoid processResponse(IHttpResponse response) {\n\t\tdisplayResponse(response);\n\t\tif(contentAnalyzer != null && response != null) {\n\t\t\tcontentAnalyzer.processResponse(response);\n\t\t}\n\t}\n\t\n\tprivate void displayResponse(final IHttpResponse response) {\n\t\tif(parentComposite == null || parentComposite.isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\tparentComposite.getDisplay().syncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(response != null) {\n\t\t\t\t\tresponseViewer.displayHttpResponse(response.getRawResponse());\n\t\t\t\t}\n\t\t\t\tif(requestBuilderPartCurr != null) {\n\t\t\t\t\trequestBuilderPartCurr.refresh();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate Composite createRequestEditor(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new FillLayout());\n\n\t\trequestTabFolder = new TabFolder(rootControl, SWT.TOP);\n\n\t\trequestTabItem = new TabItem(requestTabFolder, SWT.NONE);\n\t\trequestTabItem.setText(\"Request\");\n\t\trequestEditor = new RequestEditor(requestTabFolder, requestBuilder);\n\t\trequestTabItem.setControl(requestEditor);\n\t\trequestTabItem.setData(requestEditor);\n\n\t\trequestHeaderTabItem = new TabItem(requestTabFolder, SWT.NONE);\n\t\trequestHeaderTabItem.setText(\"Headers\");\n\t\trequestHeaderEditor = new HeaderEditor(requestTabFolder, requestBuilder, 0);\n\t\trequestHeaderTabItem.setControl(requestHeaderEditor);\n\t\trequestHeaderTabItem.setData(requestHeaderEditor);\n\n\t\trequestTabFolder.addSelectionListener(createRequestTabFolderSelectionListener());\n\t\trequestTabFolderItem = requestTabFolder.getSelection()[0];\n\t\trequestBuilderPartCurr = (IHttpBuilderPart) requestTabFolderItem.getData();\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createRequestTabFolderSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tTabItem[] selection = requestTabFolder.getSelection();\n\t\t\t\tif (selection != null) {\n\t\t\t\t\tif (requestBuilderPartCurr != null) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\trequestBuilderPartCurr.processContents();\n\t\t\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\t\t\trequestTabFolder.setSelection(requestTabFolderItem);\n\t\t\t\t\t\t\tdisplayExceptionError(ex);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\trequestTabFolderItem = selection[0];\n\t\t\t\t\trequestBuilderPartCurr = (IHttpBuilderPart) requestTabFolderItem.getData();\n\t\t\t\t\trequestBuilderPartCurr.refresh();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate Composite createResponseViewer(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setText(\"Response\");\n\t\trootControl.setLayout(new FillLayout());\n\n\t\tresponseViewer = new HttpMessageEditor(rootControl);\n\t\tresponseViewer.setEditable(false);\n\n\t\treturn rootControl;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requesteditviewer/SendRequestTask.java",
    "content": "package com.subgraph.vega.ui.http.requesteditviewer;\n\nimport org.apache.http.client.methods.HttpUriRequest;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngine;\nimport com.subgraph.vega.api.http.requests.IHttpResponse;\nimport com.subgraph.vega.api.http.requests.RequestEngineException;\n\npublic class SendRequestTask implements Runnable {\n\n\tprivate final HttpUriRequest request;\n\tprivate final RequestEditView view;\n\tprivate final IHttpRequestEngine requestEngine;\n\tprivate final Thread sendingThread;\n\t\n\tSendRequestTask(HttpUriRequest request, RequestEditView view, IHttpRequestEngine requestEngine) {\n\t\tthis.request = request;\n\t\tthis.view = view;\n\t\tthis.requestEngine = requestEngine;\n\t\tthis.sendingThread = new Thread(this);\n\t}\n\t\n\tvoid start() {\n\t\tsendingThread.start();\n\t}\n\t\n\tpublic void run() {\n\t\ttry {\n\t\t\tfinal IHttpResponse response = requestEngine.sendRequest(request).get(true);\n\t\t\tview.processResponse(response);\n\t\t} catch (RequestEngineException e) {\n\t\t\tview.processResponse(null);\n\t\t\tview.displayExceptionError((Exception) e.getCause());\n\t\t\treturn;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestfilters/ConditionCreateDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\n\tpackage com.subgraph.vega.ui.http.requestfilters;\n\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.ui.http.conditions.ConditionInput;\n\npublic class ConditionCreateDialog extends TitleAreaDialog {\n\n\tprivate final ConditionInput conditionInput;\n\tprivate Composite parentComposite;\n\tprivate IHttpCondition newCondition;\n\n\tpublic ConditionCreateDialog(Shell parent, IHttpConditionManager conditionManager) {\n\t\tsuper(parent);\n\t\tconditionInput = new ConditionInput(conditionManager);\n\t}\n\n\t@Override\n\tpublic void create() {\n\t\tsuper.create();\n\t\tsetTitle(\"Create a filter\");\n\t\tsetMessage(\"Create a new filter to filter out information displayed in the Requests table within the Proxy.\");\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tparentComposite = (Composite) super.createDialogArea(parent);\n\t\tcreateFields(parentComposite);\n\t\treturn parentComposite;\n\t}\n\t\n\t@Override\n\tprotected void okPressed() {\n\t\tnewCondition = conditionInput.createConditionFromData();\n\t\tsuper.okPressed();\n\t}\n\t\n\tprivate Composite createFields(Composite parent) {\n\t\tComposite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, true));\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Condition type:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tconditionInput.createConditionTypeCombo(rootControl);\n\t\t\n\t\tlabel = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Match type:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tconditionInput.createConditionMatchCombo(rootControl);\n\n\t\tlabel = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Input:\");\n\t\tconditionInput.createInputPanel(rootControl);\n\t\t\n\t\treturn rootControl;\n\t}\n\t\n\tpublic IHttpCondition getNewCondition() {\n\t\treturn newCondition;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestfilters/ConditionTreeContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.requestfilters;\n\nimport java.util.ArrayList;\nimport java.util.IdentityHashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\n\npublic class ConditionTreeContentProvider implements ITreeContentProvider {\n\tprivate IHttpConditionSet conditionSet;\n\tprivate Map<IHttpConditionType, List<IHttpCondition>> conditionTypeMap = new IdentityHashMap<IHttpConditionType, List<IHttpCondition>>(); \n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tconditionSet = (IHttpConditionSet) newInput;\n\t\tconditionTypeMap.clear();\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\tconditionTypeMap.clear();\n\t\tfor(IHttpCondition c: conditionSet.getAllConditions()) {\n\t\t\tList<IHttpCondition> list = conditionTypeMap.get(c.getType());\n\t\t\tif(list == null) {\n\t\t\t\tlist = new ArrayList<IHttpCondition>();\n\t\t\t\tconditionTypeMap.put(c.getType(), list);\n\t\t\t}\n\t\t\tlist.add(c);\n\t\t}\n\t\treturn conditionTypeMap.keySet().toArray(new IHttpConditionType[0]);\n\t}\n\n\t@Override\n\tpublic Object[] getChildren(Object parentElement) {\n\t\tif(parentElement instanceof IHttpConditionType) {\n\t\t\tfinal List<IHttpCondition> conditions = conditionTypeMap.get(parentElement);\n\t\t\tif(conditions != null)\n\t\t\t\treturn conditions.toArray(new IHttpCondition[0]);\n\t\t}\n\t\treturn null; \n\t}\n\n\t@Override\n\tpublic Object getParent(Object element) {\n\t\tif(element instanceof IHttpCondition) \n\t\t\treturn ((IHttpCondition) element).getType();\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren(Object element) {\n\t\tif (element instanceof IHttpConditionType) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestfilters/ConditionTreeLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.requestfilters;\n\nimport org.eclipse.jface.viewers.LabelProvider;\n\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\n\npublic class ConditionTreeLabelProvider extends LabelProvider {\n\n\t@Override\n\tpublic String getText(Object element) {\n\t\tif (element instanceof IHttpConditionType) {\n\t\t\treturn ((IHttpConditionType)element).getName();\n\t\t} else if(element instanceof IHttpCondition) {\t\t\t\n\t\t\tfinal IHttpCondition c = (IHttpCondition) element;\n\t\t\treturn c.getMatchAction().getLabel() +  \" \" + c.getMatchAction().getArgumentAsString();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestfilters/RequestFilterConfigContent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.requestfilters;\n\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionManager;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.util.dialogs.IConfigDialogContent;\n\npublic class RequestFilterConfigContent implements IConfigDialogContent {\n\tprivate final String conditionSetId;\n\tprivate Composite composite;\n\tprivate TreeViewer treeViewer;\n\tprivate IHttpConditionManager conditionManager;\n\tprivate IHttpConditionSet conditionSet;\n\tprivate boolean conditionSetDirty;\n\n\t/**\n\t * @param instanceId A unique ID to differentiate between condition filter sets.\n\t */\n\tpublic RequestFilterConfigContent(String instanceId) {\n\t\tif (instanceId != null) {\n\t\t\tconditionSetId = IHttpConditionManager.CONDITION_SET_FILTER + \".\" + instanceId;\n\t\t} else {\n\t\t\tconditionSetId = IHttpConditionManager.CONDITION_SET_FILTER;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic String getTitle() {\n\t\treturn \"Configure Request View Filters\";\n\t}\n\n\t@Override\n\tpublic String getMessage() {\n\t\treturn \"Create and remove filters which will control the displayed HTTP request and response records.\";\n\t}\n\n\t@Override\n\tpublic Control getFocusControl() {\n\t\treturn composite;\n\t}\n\n\t@Override\n\tpublic void onClose() {\n\t}\n\t\n\t@Override\n\tpublic void onOk() {\n\t\tif(conditionSetDirty) {\n\t\t\tconditionManager.saveConditionSet(conditionSetId, conditionSet);\n\t\t\tconditionSetDirty = false;\n\t\t}\t\t\n\t}\n\n\t@Override\n\tpublic Composite createContents(Composite parent) {\n\t\tcomposite = new Composite(parent, SWT.NONE);\n\t\tfinal GridLayout layout = new GridLayout();\n\t\tlayout.marginHeight = 10;\n\t\tlayout.verticalSpacing = 20;\n\t\tcomposite.setLayout(layout);\n\t\tcomposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\n\t\tLabel label = new Label(composite, SWT.WRAP);\n\t\tlabel.setText(\"Filter out information displayed in the Requests table within the Proxy.\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\t\n\t\tComposite treePanel = new Composite(composite, SWT.NONE);\n\t\ttreePanel.setLayout(new GridLayout(2, false));\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\ttreePanel.setLayoutData(gd);\n\t\t\n\t\tcreateTreeViewer(treePanel);\n\t\tcreateTreeViewerButtons(treePanel);\n\t\t\n\t\tfinal IWorkspace workspace = Activator.getDefault().getModel().getCurrentWorkspace();\n\t\tif(workspace != null) {\n\t\t\tconditionManager = workspace.getHttpConditionMananger();\n\t\t\tconditionSet = conditionManager.getConditionSetCopy(conditionSetId);\n\n\t\t} else {\n\t\t\tconditionManager = null;\n\t\t\tconditionSet = null;\n\t\t}\n\t\ttreeViewer.setInput(conditionSet);\n\t\treturn composite;\n\t}\n\n\tprivate void createTreeViewer(Composite parent) {\n\t\ttreeViewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\ttreeViewer.setContentProvider(new ConditionTreeContentProvider());\n\t\ttreeViewer.setLabelProvider(new ConditionTreeLabelProvider());\n\t\ttreeViewer.setAutoExpandLevel(2);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);\n\t\tgd.heightHint = 300;\n\t\ttreeViewer.getTree().setLayoutData(gd);\n\t}\n\n\tprivate void createTreeViewerButtons(Composite parent) {\n\t\tButton button = new Button(parent, SWT.PUSH);\n\t\tbutton.setText(\"create\");\n\t\tbutton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));\n\t\tbutton.addSelectionListener(createSelectionListenerButtonCreate());\n\t\tbutton = new Button(parent, SWT.PUSH);\n\t\tbutton.setText(\"remove\");\n\t\tbutton.setLayoutData(new GridData(SWT.TOP, SWT.CENTER, false, false));\n\t\tbutton.addSelectionListener(createSelectionListenerButtonRemove());\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonCreate() {\n\t\treturn new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\topenConditionCreateDialog();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createSelectionListenerButtonRemove() {\n\t\treturn new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();\n\t\t\t\tfor(Object element: selection.toList()) {\n\t\t\t\t\tif(element instanceof IHttpCondition) {\n\t\t\t\t\t\tconditionSet.removeCondition((IHttpCondition) element, false);\n\t\t\t\t\t\tconditionSetDirty = true;\n\t\t\t\t\t} else if (element instanceof IHttpConditionType) {\n\t\t\t\t\t\tIHttpConditionType type = (IHttpConditionType) element;\n\t\t\t\t\t\tfor(IHttpCondition c: conditionSet.getAllConditions()) {\n\t\t\t\t\t\t\tif(c.getType() == type) {\n\t\t\t\t\t\t\t\tconditionSet.removeCondition(c, false);\n\t\t\t\t\t\t\t\tconditionSetDirty = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(conditionSetDirty) {\n\t\t\t\t\t\tconditionSet.notifyChanged();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttreeViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void openConditionCreateDialog() {\n\t\tif(conditionSet == null || conditionManager == null)\n\t\t\treturn;\n\t\t\n\t\tConditionCreateDialog dialog = new ConditionCreateDialog(null, conditionManager);\n\t\tdialog.setBlockOnOpen(true);\n\t\tif (dialog.open() == ConditionCreateDialog.OK) {\n\t\t\tfinal IHttpCondition condition = dialog.getNewCondition();\n\t\t\tif(condition != null) {\n\t\t\t\tconditionSet.appendCondition(condition, true);\n\t\t\t\tconditionSetDirty = true;\n\t\t\t\ttreeViewer.refresh();\n\t\t\t\ttreeViewer.expandToLevel(condition, TreeViewer.ALL_LEVELS);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestlogviewer/FocusOnRecordTask.java",
    "content": "package com.subgraph.vega.ui.http.requestlogviewer;\n\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Table;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.internal.ui.http.requestlogviewer.RequestViewContentProvider;\n\npublic class FocusOnRecordTask implements Runnable {\n\tprivate final IRequestLogRecord record;\n\tprivate final RequestViewContentProvider contentProvider;\n\tprivate final TableViewer tableViewer;\n\n\t\n\tFocusOnRecordTask(IRequestLogRecord record, RequestViewContentProvider contentProvider, TableViewer tableViewer) {\n\t\tthis.record = record;\n\t\tthis.contentProvider = contentProvider;\n\t\tthis.tableViewer = tableViewer;\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\tfinal int row = contentProvider.getRowForRecord(record);\n\t\tif(row == -1) {\n\t\t\treturn;\n\t\t}\n\t\n\t\tfinal Table table = tableViewer.getTable();\n\t\tfinal Display display = table.getDisplay();\n\t\t\n\t\tif(!display.isDisposed()) {\n\t\t\tdisplay.asyncExec(new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tif(table.isDisposed()) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tfinal int top = calculateTopRow(row);\n\t\t\t\t\ttable.setTopIndex(top);\n\t\t\t\t\ttableViewer.setSelection(new StructuredSelection(record), false);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\t\n\tprivate int calculateTopRow(int rowToDisplay) {\n\t\tfinal int rowsVisible = rowsVisible();\n\t\tfinal int rowsAbove = rowsVisible / 2;\n\t\tif(rowsAbove > rowToDisplay) {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\treturn rowToDisplay - rowsAbove;\n\t\t}\n\t}\n\n\tprivate int rowsVisible() {\n\t\tfinal Table table = tableViewer.getTable();\n\t\tfinal int rowHeight = table.getItemHeight();\n\t\tfinal int clientHeight = (table.getClientArea().height - table.getHeaderHeight());\n\t\treturn clientHeight / rowHeight;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestlogviewer/RequestLogViewer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.requestlogviewer;\n\nimport java.net.URISyntaxException;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.UUID;\n\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.MouseEvent;\nimport org.eclipse.swt.events.MouseMoveListener;\nimport org.eclipse.swt.events.MouseTrackListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.RGB;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Menu;\nimport org.eclipse.swt.widgets.MenuItem;\nimport org.eclipse.swt.widgets.MessageBox;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\nimport org.eclipse.swt.widgets.TableItem;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.conditions.IHttpCondition;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionSet;\nimport com.subgraph.vega.api.model.conditions.IHttpConditionType;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionIntegerMatchAction;\nimport com.subgraph.vega.api.model.conditions.match.IHttpConditionMatchAction;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.internal.ui.http.requestlogviewer.HttpViewLabelProvider;\nimport com.subgraph.vega.internal.ui.http.requestlogviewer.RequestViewContentProvider;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.requesteditviewer.RequestEditView;\nimport com.subgraph.vega.ui.tags.taggableeditor.TaggableEditorDialog;\nimport com.subgraph.vega.ui.tagsl.taggablepopup.TaggablePopupDialog;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class RequestLogViewer extends Composite {\n\tpublic final static String POPUP_REQUESTS_TABLE = \"com.subgraph.vega.ui.http.requestlogviewer.popup\";\n\tprivate static final RGB ACTIVE_FILTER_COLOR = new RGB(0xF0, 0xFF, 0xFF);\n\tprivate static final int MAX_OPEN_EDITORS = 3; // Maximum number of editors to allow to open at once before prompting the user\n\tprivate final String instanceId;\n\tprivate final int heightInRows;\n\tprivate TableViewer tableViewer;\n\tprivate Menu tableMenu;\n\tprivate RequestResponseViewer requestResponseViewer;\n\tprivate TaggablePopupDialog taggablePopupDialog;\n\tprivate RequestViewContentProvider contentProvider;\n\n\t/**\n\t * @param parent\n\t * @param instanceId A unique ID to differentiate between condition filter sets.\n\t * @param heightInRows Desired height of table in text rows, or 0 to fill available space. \n\t */\n\tpublic RequestLogViewer(Composite parent, String instanceId, int heightInRows) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.instanceId = instanceId;\n\t\tthis.heightInRows = heightInRows;\n\n\t\tGridLayout layout = new GridLayout(1, false);\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.marginLeft = 0;\n\t\tlayout.marginTop = 0;\n\t\tlayout.marginRight = 0;\n\t\tlayout.marginBottom = 0;\n\t\tsetLayout(layout);\n\t\tGridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);\n\t\tcreateTable(gd).setLayoutData(gd);\n\n\t\ttableViewer.setInput(Activator.getDefault().getModel());\n\t}\n\n\tpublic void setRequestResponseViewer(RequestResponseViewer requestResponseViewer) {\n\t\tthis.requestResponseViewer = requestResponseViewer;\n\t\ttableMenu.setEnabled(this.requestResponseViewer != null && !tableViewer.getSelection().isEmpty());\n\t}\n\n\tpublic void focusOnRecord(long requestId) {\n\t\tfinal Object inputObj = tableViewer.getInput();\n\t\tif(!(inputObj instanceof IModel)) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IModel model = (IModel) inputObj;\n\t\tfinal IWorkspace workspace = model.getCurrentWorkspace();\n\t\tif(workspace == null) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\taddRequestIdConditionRule(requestId);\n\t\t\n\t\tfinal IRequestLog requestLog = workspace.getRequestLog();\n\t\tfinal IRequestLogRecord record = requestLog.lookupRecord(requestId);\n\t\tif(record == null) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal FocusOnRecordTask task = new FocusOnRecordTask(record, contentProvider, tableViewer);\n\t\tnew Thread(task).start();\n\t\t\n\t\tif (requestResponseViewer != null) {\n\t\t\trequestResponseViewer.setDisplayResponse();\n\t\t}\n\t}\t\n\t\n\tprivate IHttpCondition requestIdCondition;\n\t\n\tprivate void addRequestIdConditionRule(long requestId) {\n\t\tif(contentProvider == null || contentProvider.getConditionSet() == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IHttpConditionSet conditionSet = contentProvider.getConditionSet();\n\t\tfinal IHttpConditionType type = conditionSet.getConditionManager().getConditionTypeByName(\"request id\");\n\t\tfinal IHttpConditionMatchAction matchAction = type.getMatchActionByName(\"equals\");\n\n\t\t((IHttpConditionIntegerMatchAction) matchAction).setInteger((int) requestId);\n\t\t\n\t\tif(requestIdCondition != null) {\n\t\t\tconditionSet.removeTemporaryCondition(requestIdCondition, false);\n\t\t}\n\t\trequestIdCondition = type.createConditionInstance(matchAction);\n\t\trequestIdCondition.setSufficient(true);\n\t\tconditionSet.appendTemporaryCondition(requestIdCondition, true);\n\t}\n\n\t\n\t\n\tprivate Composite createTable(GridData gd) {\n\t\tfinal Composite rootControl = new Composite(this, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\ttableViewer = new TableViewer(rootControl, SWT.MULTI| SWT.VIRTUAL | SWT.FULL_SELECTION);\n\t\tcreateColumns(tableViewer, tcl);\n\t\tfinal Color activeFilterColor = new Color(tableViewer.getControl().getDisplay(), ACTIVE_FILTER_COLOR);\n\t\tcontentProvider = new RequestViewContentProvider(instanceId, activeFilterColor);\n\t\ttableViewer.setContentProvider(contentProvider);\n\t\ttableViewer.setLabelProvider(new HttpViewLabelProvider());\n\t\ttableViewer.addSelectionChangedListener(createSelectionChangedListener());\n\t\tfinal Table table = tableViewer.getTable();\n\t\ttable.setMenu(createTableMenu(table));\n\t\ttable.addMouseTrackListener(createTableMouseTrackListener());\n\t\ttable.addMouseMoveListener(createMouseMoveListener());\n\t\tif (heightInRows != 0) {\n\t\t\tgd.heightHint = table.getItemHeight() * heightInRows;\n\t\t}\n\t\t\n\t\treturn rootControl;\n\t}\n\t\n\tprivate void createColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = {\"ID\", \"Host\", \"Method\", \"Request\", \"Status\", \"Length\", \"Time (ms)\", \"Tags\" };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\t\tnew ColumnPixelData(60, true, true),\n\t\t\t\tnew ColumnPixelData(120, true, true),\n\t\t\t\tnew ColumnPixelData(60, true, true),\n\t\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t\t\tnew ColumnPixelData(50, true, true),\n\t\t\t\tnew ColumnPixelData(80, true, true),\n\t\t\t\tnew ColumnPixelData(50, true, true),\n\t\t\t\tnew ColumnPixelData(15, true, true)\n\t\t};\n\n\t\tfor(int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t}\n\t\tfinal Table table = viewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t}\n\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\ttableMenu.setEnabled(requestResponseViewer != null && !event.getSelection().isEmpty());\n\t\t\t\tif (requestResponseViewer != null) { // REVISIT gross\n\t\t\t\t\tIStructuredSelection selection = (IStructuredSelection) event.getSelection();\n\t\t\t\t\tif (selection.getFirstElement() instanceof IRequestLogRecord) {\n\t\t\t\t\t\trequestResponseViewer.setCurrentRecord((IRequestLogRecord) selection.getFirstElement());\n\t\t\t\t\t} else {\n\t\t\t\t\t\trequestResponseViewer.setCurrentRecord(null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate Menu createTableMenu(Table table) {\n\t\ttableMenu = new Menu(table);\n\t\ttableMenu.setEnabled(false);\n\t\t\n\t    MenuItem replayMenuItem = new MenuItem(tableMenu, SWT.CASCADE);\n\t    replayMenuItem.setText(\"Replay Request\");\n\t    replayMenuItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\treplayRequestSelection();\n\t\t\t};\n\t    });\n\n\t    MenuItem tagEditMenuItem = new MenuItem(tableMenu, SWT.CASCADE);\n\t    tagEditMenuItem.setText(\"Edit Tag\");\n\t    tagEditMenuItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\ttagEditSelection();\n\t\t\t};\n\t    });\n\n\t\treturn tableMenu;\n\t}\n\n\tprivate void replayRequestSelection() {\n\t\tIStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();\n\t\tif (selection.size() > MAX_OPEN_EDITORS) {\n\t\t\tMessageBox messageDialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);\n\t\t\tmessageDialog.setText(\"Warning\");\n\t\t\tmessageDialog.setMessage(selection.size() + \" replay editors will be opened. Proceed?\");\n\t\t\tif (messageDialog.open() == SWT.CANCEL) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tint viewMode = IWorkbenchPage.VIEW_ACTIVATE;\n\t\tfor (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {\n\t\t\tIRequestLogRecord record = (IRequestLogRecord) iter.next();\n\t\t\tString secondaryId = UUID.randomUUID().toString();\n\t\t\tRequestEditView view;\n\t\t\ttry {\n\t\t\t\tview = (RequestEditView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RequestEditView.VIEW_ID, secondaryId, viewMode);\n\t\t\t} catch (PartInitException e) {\n\t\t\t\tErrorDialog.displayExceptionError(getShell(), e);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tview.setRequest(record);\n\t\t\t} catch (URISyntaxException e) {\n\t\t\t\tErrorDialog.displayExceptionError(getShell(), e);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tviewMode = IWorkbenchPage.VIEW_VISIBLE;\n\t\t}\n\t}\n\n\tprivate void tagEditSelection() {\n\t\tfinal IRequestLogRecord record = (IRequestLogRecord)((IStructuredSelection) tableViewer.getSelection()).getFirstElement();\n\t\tfinal Dialog dialog = TaggableEditorDialog.createDialog(getShell(), record);\n\t\tif (dialog.open() == Window.OK) {\n\t\t\ttableViewer.refresh();\n\t\t}\n\t}\t\n\t\n\t@SuppressWarnings(\"unchecked\")\n\tpublic List<IRequestLogRecord> getSelectionList() {\n\t\treturn ((IStructuredSelection) tableViewer.getSelection()).toList();\n\t}\n\t\n\tprivate MouseMoveListener createMouseMoveListener() {\n\t\treturn new MouseMoveListener() {\n\t\t\t@Override\n\t\t\tpublic void mouseMove(MouseEvent e) {\n\t\t\t\tif (taggablePopupDialog != null) {\n\t\t\t\t\ttaggablePopupDialog.close();\n\t\t\t\t\ttaggablePopupDialog = null;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate MouseTrackListener createTableMouseTrackListener() {\n\t\treturn new MouseTrackListener() {\n\t\t\t@Override\n\t\t\tpublic void mouseEnter(MouseEvent e) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void mouseExit(MouseEvent e) {\n\t\t\t\tif (taggablePopupDialog != null) {\n\t\t\t\t\ttaggablePopupDialog.close();\n\t\t\t\t\ttaggablePopupDialog = null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void mouseHover(MouseEvent e) {\n\t\t\t\tif (taggablePopupDialog == null) {\n\t\t\t\t\tPoint pt = new Point(e.x, e.y);\n\t\t\t\t\tTable table = tableViewer.getTable();\n\t\t\t\t\tTableItem tableItem = table.getItem(pt);\n\t\t\t\t\tif (tableItem != null) {\n\t\t\t\t\t\tIRequestLogRecord record = (IRequestLogRecord) tableItem.getData();\n\t\t\t\t\t\tif (record.getTagCount() > 0) {\n\t\t\t\t\t\t\tPoint origin = tableViewer.getTable().getDisplay().map(table.getParent(), null, e.x, e.y);\n\t\t\t\t\t\t\ttaggablePopupDialog = new TaggablePopupDialog(table.getShell(), record, origin);\n\t\t\t\t\t\t\ttaggablePopupDialog.open();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/requestlogviewer/RequestResponseViewer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.requestlogviewer;\n\nimport java.util.Collection;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.events.DisposeEvent;\nimport org.eclipse.swt.events.DisposeListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.FormAttachment;\nimport org.eclipse.swt.layout.FormData;\nimport org.eclipse.swt.layout.FormLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Menu;\nimport org.eclipse.swt.widgets.MenuItem;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.swt.widgets.ToolBar;\nimport org.eclipse.swt.widgets.ToolItem;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.httpeditor.HttpMessageEditor;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class RequestResponseViewer extends Composite {\n\tprivate final static String VERTICAL_ICON = \"icons/vertical.png\";\n\tprivate final static String HORIZONTAL_ICON = \"icons/horizontal.png\";\n\tprivate final static String TABBED_ICON = \"icons/tabbed.png\";\n\tprivate final static String UP_ICON = \"icons/up.png\";\n\tprivate final static String DOWN_ICON = \"icons/down.png\";\n\tprivate final static String CONFIG_ICON = \"icons/configure.png\";\n\t\n\tprivate IEventHandler workspaceListener;\n\tprivate final SashForm parentForm;\n\tprivate final ImageCache imageCache;\n\tprivate final Menu optionsMenu;\n\tprivate final Composite toolbarComposite;\n\tprivate ToolItem hideItem;\n\tprivate SashForm sashForm;\n\tprivate TabFolder tabFolder;\n\tprivate Composite rootComposite;\n\tprivate HttpMessageEditor requestViewer;\n\tprivate HttpMessageEditor responseViewer;\n\tprivate IRequestLogRecord currentRecord;\n\t\n\tprivate boolean displayImages = true;\n\tprivate boolean displayImagesAsHex = false;\n\tprivate boolean urlDecodeState = false;\n\tprivate boolean hideState = false;\n\tprivate boolean wordWrapLines = false;\n\t\n\tpublic RequestResponseViewer(SashForm parentForm) {\n\t\tsuper(parentForm, SWT.NONE);\n\t\tsetLayout(new FormLayout());\n\t\tthis.parentForm = parentForm;\n\t\timageCache = new ImageCache(Activator.PLUGIN_ID);\n\t\toptionsMenu = createOptionsMenu(parentForm.getShell());\n\t\ttoolbarComposite = createToolbarComposite(this);\n\n\t\tFormData fd = new FormData();\n\t\tfd.left = new FormAttachment(0);\n\t\tfd.right = new FormAttachment(100);\n\t\tfd.top = new FormAttachment(0);\n\t\ttoolbarComposite.setLayoutData(fd);\n\t\tsetTabbedMode();\n\t\tworkspaceListener = new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceCloseEvent || event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceCloseOrReset();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tActivator.getDefault().getModel().addWorkspaceListener(workspaceListener);\n\n\t\tcreateDisposeListener();\n\t}\n\n\tprivate void createDisposeListener() {\n\t\taddDisposeListener(new DisposeListener() {\n\t\t\t@Override\n\t\t\tpublic void widgetDisposed(DisposeEvent e) {\n\t\t\t\tActivator.getDefault().getModel().removeWorkspaceListener(workspaceListener);\n\t\t\t\tremoveDisposeListener(this);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void handleWorkspaceCloseOrReset() {\n\t\tif (!isDisposed()) {\n\t\t\tclearViewers();\n\t\t}\n\t}\n\n\tprivate Composite createToolbarComposite(Composite parent) {\n\t\tfinal Composite c = new Composite(this, SWT.NONE);\n\t\tfinal GridLayout layout = new GridLayout(2, false);\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.horizontalSpacing = 0;\n\t\tc.setLayout(layout);\n\t\tComposite tb = createLayoutToolBar(c);\n\t\ttb.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\ttb = createConfigureToolBar(c);\n\t\ttb.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));\n\t\treturn c;\n\t}\n\t\t\n\tprivate ToolBar createLayoutToolBar(Composite parent) {\n\t\tToolBar tb = new ToolBar(parent, SWT.NONE);\n\t\tToolItem tabbed = new ToolItem(tb, SWT.RADIO);\n\t\ttabbed.setImage(imageCache.get(TABBED_ICON));\n\t\ttabbed.setToolTipText(\"Tabbed Request/Response layout\");\n\t\ttabbed.setSelection(true);\n\t\ttabbed.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsetTabbedMode();\n\t\t\t}\t\t\t\n\t\t});\n\t\tToolItem horiz = new ToolItem(tb, SWT.RADIO);\n\t\thoriz.setImage(imageCache.get(HORIZONTAL_ICON));\n\t\thoriz.setToolTipText(\"Horizontal Request/Response layout\");\n\t\thoriz.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsetHorizontalSashMode();\n\t\t\t}\t\t\t\n\t\t});\n\t\tToolItem vert = new ToolItem(tb, SWT.RADIO);\n\t\tvert.setImage(imageCache.get(VERTICAL_ICON));\n\t\tvert.setToolTipText(\"Vertical Request/Response layout\");\n\t\tvert.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsetVerticalSashMode();\n\t\t\t}\t\t\t\t\n\t\t});\n\t\ttb.pack();\n\t\treturn tb;\n\t}\n\t\n\tprivate ToolBar createConfigureToolBar(Composite parent) {\n\t\tfinal ToolBar tb = new ToolBar(parent, SWT.NONE);\n\n\t\tfinal ToolItem config = new ToolItem(tb, SWT.DROP_DOWN);\n\t\tconfig.setImage(imageCache.get(CONFIG_ICON));\n\t\tconfig.setToolTipText(\"Options\");\n\t\tconfig.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tfinal Rectangle r = config.getBounds();\n\t\t\t\tfinal Point p = new Point(r.x, r.y + r.height);\n\t\t\t\toptionsMenu.setLocation(tb.getDisplay().map(tb, null, p));\n\t\t\t\toptionsMenu.setVisible(true);\n\t\t\t}\n\t\t});\n\n\t\thideItem = new ToolItem(tb, SWT.PUSH);\n\t\thideItem.setImage(imageCache.get(UP_ICON));\n\t\thideItem.setToolTipText(\"Hide Request Table\");\n\t\thideItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\ttoggleHideState();\n\t\t\t}\t\t\t\t\t\t\n\t\t});\n\n\t\ttb.pack();\n\t\treturn tb;\n\t}\n\t\n\tprivate Menu createOptionsMenu(Shell shell) {\n\t\tfinal Menu menu = new Menu(shell, SWT.POP_UP);\n\t\tfinal MenuItem displayImagesItem = new MenuItem(menu, SWT.CHECK);\n\t\tdisplayImagesItem.setText(\"Display Images\");\n\t\tdisplayImagesItem.setSelection(displayImages);\n\t\t\n\t\tfinal MenuItem imagesAsHexItem = new MenuItem(menu, SWT.CHECK);\n\t\timagesAsHexItem.setText(\"Display Images with Hex Viewer\");\n\t\t\n\t\tfinal MenuItem decodeItem = new MenuItem(menu, SWT.CHECK);\n\t\tdecodeItem.setText(\"Remove URL encoding\");\n\t\t\n\t\tfinal MenuItem wordwrapItem = new MenuItem(menu, SWT.CHECK);\n\t\twordwrapItem.setText(\"Word wrap lines\");\n\t\t\n\t\tdisplayImagesItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tboolean value = displayImagesItem.getSelection();\n\t\t\t\timagesAsHexItem.setEnabled(value);\n\t\t\t\tsetDisplayImageState(value);\n\t\t\t\tdisplayImages = value;\n\t\t\t}\n\t\t});\n\t\t\n\t\timagesAsHexItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tboolean value = imagesAsHexItem.getSelection();\n\t\t\t\tsetDisplayImagesAsHexState(value);\n\t\t\t\tdisplayImagesAsHex = value;\n\t\t\t}\n\t\t});\n\t\t\n\t\tdecodeItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tboolean value = decodeItem.getSelection();\n\t\t\t\tsetUrlDecodeState(value);\n\t\t\t\turlDecodeState  = value;\n\t\t\t}\n\t\t});\n\t\t\n\t\twordwrapItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tboolean value = wordwrapItem.getSelection();\n\t\t\t\tsetWordwrapState(value);\n\t\t\t\twordWrapLines = value;\n\t\t\t}\n\t\t});\n\t\t\n\t\treturn menu;\n\t}\n\t\n\tprivate void setDisplayImageState(boolean value) {\n\t\trequestViewer.setDisplayImages(value);\n\t\tresponseViewer.setDisplayImages(value);\n\t}\n\t\n\tprivate void setDisplayImagesAsHexState(boolean value) {\n\t\trequestViewer.setDisplayImagesAsHex(value);\n\t\tresponseViewer.setDisplayImagesAsHex(value);\n\t}\n\t\n\tprivate void setUrlDecodeState(boolean value) {\n\t\trequestViewer.setDecodeUrlEncoding(value);\n\t\tresponseViewer.setDecodeUrlEncoding(value);\n\t}\n\n\tprivate void setWordwrapState(boolean value) {\n\t\trequestViewer.setWordwrapLines(value);\n\t\tresponseViewer.setWordwrapLines(value);\n\t}\n\n\tprivate void toggleHideState() {\n\t\tif(hideState) {\n\t\t\thideState = false;\n\t\t\thideItem.setImage(imageCache.get(UP_ICON));\n\t\t\thideItem.setToolTipText(\"Hide Request Table\");\n\t\t\tparentForm.setMaximizedControl(null);\n\t\t} else {\n\t\t\thideState = true;\n\t\t\thideItem.setToolTipText(\"Show Request Table\");\n\t\t\thideItem.setImage(imageCache.get(DOWN_ICON));\n\t\t\tparentForm.setMaximizedControl(this);\n\t\t}\t\n\t}\n\t\n\tpublic void setTabbedMode() {\n\t\tsashForm = null;\n\t\trecreateRootComposite();\n\t\n\t\ttabFolder = new TabFolder(rootComposite, SWT.TOP);\n\t\tcreateMessageViewers(tabFolder);\n\n\t\tfinal TabItem requestItem = new TabItem(tabFolder, SWT.NONE);\n\t\trequestItem.setText(\"Request\");\n\t\trequestItem.setControl(requestViewer);\n\t\t\n\t\tfinal TabItem responseItem = new TabItem(tabFolder, SWT.NONE);\n\t\tresponseItem.setText(\"Response\");\n\t\tresponseItem.setControl(responseViewer);\n\n\t\tthis.layout();\n\t\tif(currentRecord != null)\n\t\t\tprocessCurrentTransaction();\n\t\tsetDisplayResponse();\n\t}\n\t\n\tprivate void createMessageViewers(Composite parent) {\n\t\trequestViewer = new HttpMessageEditor(parent);\n\t\trequestViewer.setEditable(false);\n\t\tresponseViewer = new HttpMessageEditor(parent);\n\t\tresponseViewer.setEditable(false);\n\t\tsetDisplayImageState(displayImages);\n\t\tsetDisplayImagesAsHexState(displayImagesAsHex);\n\t\tsetUrlDecodeState(urlDecodeState);\n\t\tsetWordwrapState(wordWrapLines);\n\t}\n\n\tpublic void setDisplayResponse() {\n\t\tif(tabFolder != null)\n\t\t\ttabFolder.setSelection(1);\n\t\t\n\t}\n\tprivate void recreateRootComposite() {\n\t\tif(rootComposite != null)\n\t\t\trootComposite.dispose();\n\t\trootComposite = new Composite(this, SWT.NONE);\n\t\trootComposite.setLayout(new FillLayout());\n\t\t\n\t\tfinal FormData fd = new FormData();\n\t\tfd.left = new FormAttachment(0);\n\t\tfd.right = new FormAttachment(100);\n\t\tfd.top = new FormAttachment(toolbarComposite);\n\t\tfd.bottom = new FormAttachment(100);\n\t\trootComposite.setLayoutData(fd);\t\n\t}\n\n\tpublic void setVerticalSashMode() {\n\t\tconfigureSashMode(SWT.VERTICAL);\n\t}\n\t\n\tpublic void setHorizontalSashMode() {\n\t\tconfigureSashMode(SWT.HORIZONTAL);\n\t}\n\n\tprivate void configureSashMode(int mode) {\n\t\ttabFolder = null;\n\t\tif(sashForm != null) {\n\t\t\tif(sashForm.getOrientation() != mode)\n\t\t\t\tsashForm.setOrientation(mode);\n\t\t\treturn;\n\t\t}\n\t\trecreateRootComposite();\n\t\tsashForm = new SashForm(rootComposite, mode);\n\n\t\tcreateMessageViewers(sashForm);\n\n\t\tsashForm.setWeights(new int[] {50, 50});\n\t\tthis.layout();\n\t\tprocessCurrentTransaction();\n\t}\n\t\n\tpublic void setCurrentRecord(IRequestLogRecord record) {\n\t\tif (currentRecord != record) {\n\t\t\tcurrentRecord = record;\n\t\t\tprocessCurrentTransaction();\n\t\t}\n\t}\n\t\n\tprivate void addResponseHighlights(Collection<IScanAlert> alerts) {\n\t\tfor(IScanAlert a: alerts) {\n\t\t\tresponseViewer.addAlertHighlights(a.getHighlights());\n\t\t}\n\t\tresponseViewer.displayAlertHighlights();\n\t\t\n\t}\n\tprivate void processCurrentTransaction() {\n\t\tif(currentRecord == null) {\n\t\t\tclearViewers();\n\t\t\treturn;\n\t\t}\n\t\trequestViewer.displayHttpRequest(currentRecord.getRequest());\n\t\tresponseViewer.displayHttpResponse(currentRecord.getResponse());\n\t\tIWorkspace workspace = Activator.getDefault().getModel().getCurrentWorkspace();\n\t\tif(workspace != null) {\n\t\t\tfinal Collection<IScanAlert> alerts = workspace.getScanAlertRepository().getAlertsByRequestId(currentRecord.getRequestId());\n\t\t\tif(!alerts.isEmpty()) {\n\t\t\t\taddResponseHighlights(alerts);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void clearViewers() {\n\t\tcurrentRecord = null;\n\t\trequestViewer.clearContent();\n\t\tresponseViewer.clearContent();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/statusview/InterceptQueueTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.statusview;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptor;\nimport com.subgraph.vega.api.http.proxy.IHttpInterceptorEventHandler;\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\n\npublic class InterceptQueueTableContentProvider implements IStructuredContentProvider {\n\tprivate Viewer viewer;\n\tprivate IHttpInterceptor interceptor;\n\tprivate IHttpInterceptorEventHandler eventHandler;\n\n\tpublic InterceptQueueTableContentProvider() {\n\t\teventHandler = new IHttpInterceptorEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void notifyQueue(IProxyTransaction transaction, int idx) {\n\t\t\t\thandleUpdate();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyRemove(int idx) {\n\t\t\t\thandleUpdate();\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyEmpty() {\n\t\t\t\thandleUpdate();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void handleUpdate() {\n\t\tviewer.getControl().getDisplay().asyncExec(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tviewer.refresh();\n\t\t\t}\n\t\t});\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\tif (interceptor != null) {\n\t\t\tinterceptor.removeEventHandler(eventHandler);\n\t\t\tinterceptor = null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tthis.viewer = viewer;\n\t\tif (interceptor != null) {\n\t\t\tinterceptor.removeEventHandler(eventHandler);\n\t\t}\n\n\t\tif (newInput != null) {\n\t\t\tinterceptor = (IHttpInterceptor) newInput;\n\t\t\tinterceptor.addEventHandler(eventHandler);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn interceptor.getTransactions();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/statusview/RequestStatusTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.statusview;\n\nimport java.util.ArrayList;\nimport java.util.Date;\nimport java.util.List;\nimport java.util.Timer;\nimport java.util.TimerTask;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyListener;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyService;\nimport com.subgraph.vega.api.http.proxy.IHttpProxyServiceEventHandler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.http.requests.RequestTaskStartEvent;\nimport com.subgraph.vega.api.http.requests.RequestTaskStopEvent;\n\npublic class RequestStatusTableContentProvider implements IStructuredContentProvider, IEventHandler {\n\tprivate static final long REQUEST_EXPIRY = 15000; // time in milliseconds before a finished request is removed from requestList\n\tprivate final IHttpProxyServiceEventHandler proxyServiceEventHandler;\n\tprivate final Timer refreshTimer;\n\tprivate TimerTask refreshTimerTask;\n\tprivate Viewer viewer;\n\tprivate IHttpProxyService proxyService;\n\tprivate final List<IHttpProxyListener> listenerList;\n\tprivate final List<IHttpRequestTask> requestList;\n\tprivate int requestListExpiryIdx; // index of first completed request task in requestList \n\n\tpublic RequestStatusTableContentProvider() {\n\t\tproxyServiceEventHandler = new IHttpProxyServiceEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void notifyStart(int numListeners) {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyStartListener(IHttpProxyListener listener) {\n\t\t\t\tregisterProxyListener(listener);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyStop() {\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyStopListener(IHttpProxyListener listener) {\n\t\t\t\tunregisterProxyListener(listener, true);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void notifyConfigChange(int numListeners) {\n\t\t\t}\n\t\t};\n\t\trefreshTimer = new Timer();\n\t\tlistenerList = new ArrayList<IHttpProxyListener>();\n\t\trequestList = new ArrayList<IHttpRequestTask>();\n\t\trequestListExpiryIdx = 0;\n\t}\n\t\n\t@Override\n\tpublic void dispose() {\n\t\tfor (IHttpProxyListener listener: listenerList) {\n\t\t\tunregisterProxyListener(listener, false);\n\t\t}\n\t\tsynchronized(this) {\n\t\t\tlistenerList.clear();\n\t\t}\n\t\tif (proxyService != null) {\n\t\t\tproxyService.unregisterEventHandler(proxyServiceEventHandler);\n\t\t\tproxyService = null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tsynchronized(this) {\n\t\t\tthis.viewer = viewer;\n\t\t\tif (proxyService != null) {\n\t\t\t\tproxyService.unregisterEventHandler(proxyServiceEventHandler);\n\t\t\t\tfor (IHttpProxyListener listener: listenerList) {\n\t\t\t\t\tunregisterProxyListener(listener, false);\n\t\t\t\t}\n\t\t\t\tlistenerList.clear();\n\t\t\t\trequestList.clear();\n\t\t\t\trequestListExpiryIdx = 0;\n\t\t\t}\n\n\t\t\tproxyService = (IHttpProxyService) newInput;\n\t\t\tif (proxyService != null) {\n\t\t\t\tproxyService.registerEventHandler(proxyServiceEventHandler);\n\t\t\t\tfor (IHttpProxyListener listener: proxyService.getListeners()) {\n\t\t\t\t\tregisterProxyListener(listener);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\tsynchronized(this) {\n\t\t\treturn requestList.toArray(new Object[0]);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tsynchronized(this) {\n\t\t\tif (event instanceof RequestTaskStartEvent) {\n\t\t\t\trequestList.add(0, ((RequestTaskStartEvent) event).getRequestTask());\n\t\t\t\trequestListExpiryIdx++;\n\t\t\t} else if (event instanceof RequestTaskStopEvent) {\n\t\t\t\tfinal IHttpRequestTask requestTask = (((RequestTaskStopEvent) event).getRequestTask());\n\t\t\t\tfinal int idx = requestList.indexOf(requestTask);\n\t\t\t\tif (idx != -1) {\n\t\t\t\t\trequestListExpiryIdx--;\n\t\t\t\t\trequestList.remove(idx);\n\t\t\t\t\trequestList.add(requestListExpiryIdx, requestTask);\n\t\t\t\t\tif (refreshTimerTask == null) {\n\t\t\t\t\t\trefreshTimerTask = createRefreshTask();\n\t\t\t\t\t\trefreshTimer.schedule(refreshTimerTask, REQUEST_EXPIRY);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (viewer != null) {\n\t\t\t\tviewer.getControl().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tviewer.refresh();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void registerProxyListener(IHttpProxyListener listener) {\n\t\tsynchronized(this) {\n\t\t\tlistenerList.add(listener);\n\t\t}\n\t\tlistener.getRequestEngine().addRequestListener(this);\n\t}\n\n\tprivate void unregisterProxyListener(IHttpProxyListener listener, boolean remove) {\n\t\tlistener.getRequestEngine().removeRequestListener(this);\n\t\tif (remove) {\n\t\t\tsynchronized(this) {\n\t\t\t\tlistenerList.remove(listener);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate TimerTask createRefreshTask() {\n\t\treturn new TimerTask() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsynchronized(RequestStatusTableContentProvider.this) {\n\t\t\t\t\tfinal Date now = new Date();\n\t\t\t\t\tint idx;\n\t\t\t\t\tfor (idx = requestList.size() - 1; idx >= requestListExpiryIdx; idx--) {\n\t\t\t\t\t\tfinal IHttpRequestTask requestTask = requestList.get(idx);\n\t\t\t\t\t\tfinal long diff = now.getTime() - requestTask.getTimeCompleted().getTime();\n\t\t\t\t\t\tif (diff >= REQUEST_EXPIRY) {\n\t\t\t\t\t\t\trequestList.remove(idx);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (idx != requestListExpiryIdx - 1) {\n\t\t\t\t\t\tfinal IHttpRequestTask requestTask = requestList.get(idx);\n\t\t\t\t\t\trefreshTimerTask = createRefreshTask();\n\t\t\t\t\t\trefreshTimer.schedule(refreshTimerTask, requestTask.getTimeCompleted().getTime() + REQUEST_EXPIRY - now.getTime());\n\t\t\t\t\t} else {\n\t\t\t\t\t\trefreshTimerTask = null;\n\t\t\t\t\t}\n\t\t\t\t\tif (viewer != null) {\n\t\t\t\t\t\tviewer.getControl().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\tviewer.refresh();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.http/src/com/subgraph/vega/ui/http/statusview/StatusView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.http.statusview;\n\nimport java.net.URI;\nimport java.util.Iterator;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.DoubleClickEvent;\nimport org.eclipse.jface.viewers.IDoubleClickListener;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Menu;\nimport org.eclipse.swt.widgets.MenuItem;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.http.proxy.IProxyTransaction;\nimport com.subgraph.vega.api.http.requests.IHttpRequestTask;\nimport com.subgraph.vega.api.model.requests.IRequestOrigin;\nimport com.subgraph.vega.api.model.requests.IRequestOriginProxy;\nimport com.subgraph.vega.ui.http.Activator;\nimport com.subgraph.vega.ui.http.intercept.InterceptView;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class StatusView extends ViewPart {\n\tpublic final static String ID = \"com.subgraph.vega.views.proxystatus\";\n\tprivate SashForm parentComposite;\n\tprivate TableViewer interceptQueueTableViewer;\n\tprivate Menu interceptQueueTableMenu;\n\tprivate TableViewer requestStatusTableViewer;\n\tprivate Menu requestStatusTableMenu;\n\n\tpublic StatusView() {\n\t}\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tparentComposite = new SashForm(parent, SWT.VERTICAL);\n\t\tparentComposite.setLayout(new FillLayout());\n\t\tcreateInterceptQueueArea(parentComposite);\n\t\tcreateRequestStatusArea(parentComposite);\n\t\tparentComposite.setWeights(new int[] {75, 25});\n\t\tinterceptQueueTableViewer.setInput(Activator.getDefault().getProxyService().getInterceptor());\n\t\trequestStatusTableViewer.setInput(Activator.getDefault().getProxyService());\n\t}\n\n\t@Override\n\tpublic void setFocus() {\n\t}\n\n\tprivate Composite createInterceptQueueArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"Interceptor Queue\");\n\n\t\tcreateInterceptQueueTable(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\treturn rootControl;\n\t}\n\t\n\tprivate Composite createInterceptQueueTable(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\tinterceptQueueTableViewer = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\tinterceptQueueTableViewer.setContentProvider(new InterceptQueueTableContentProvider());\n\t\tcreateInterceptQueueTableColumns(interceptQueueTableViewer, tcl);\n\t\tfinal Table table = interceptQueueTableViewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t\tinterceptQueueTableViewer.addSelectionChangedListener(createInterceptQueueTableSelectionChangedListener());\n\t\tinterceptQueueTableViewer.addDoubleClickListener(createInterceptQueueTableDoubleClickListener());\n\t\ttable.setMenu(createInterceptQueueTableMenu(table));\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate void createInterceptQueueTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"Type\", \"Host\", \"Method\", \"Request\", \"Listener\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\t\tnew ColumnPixelData(60, true, true),\n\t\t\t\tnew ColumnPixelData(120, true, true),\n\t\t\t\tnew ColumnPixelData(60, true, true),\n\t\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t\t\tnew ColumnPixelData(100, true, true),\n\t\t};\n\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IProxyTransaction) element).hasResponse() == false ? \"Request\" : \"Response\";\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn uriToHostString(((IProxyTransaction) element).getRequest().getURI());\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IProxyTransaction) element).getRequest().getMethod();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn uriToPathString(((IProxyTransaction) element).getRequest().getURI());\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\tfinal IRequestOrigin origin = ((IProxyTransaction) element).getRequestEngine().getRequestOrigin();\n\t\t\t\t\tif (origin instanceof IRequestOriginProxy) {\n\t\t\t\t\t\treturn origin.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tfor(int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\n\t\tfinal Table table = viewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t}\n\n\tprivate ISelectionChangedListener createInterceptQueueTableSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tinterceptQueueTableMenu.setEnabled(!event.getSelection().isEmpty());\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate IDoubleClickListener createInterceptQueueTableDoubleClickListener() {\n\t\treturn new IDoubleClickListener() {\n\t\t\t@Override\n\t\t\tpublic void doubleClick(DoubleClickEvent event) {\n\t\t\t\tfinal Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();\n\t\t\t\tfinal InterceptView view;\n\t\t\t\ttry {\n\t\t\t\t\tview = (InterceptView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(InterceptView.ID);\n\t\t\t\t} catch (PartInitException e) {\n\t\t\t\t\tErrorDialog.displayExceptionError(parentComposite.getShell(), e);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tview.openTransaction((IProxyTransaction) element);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate Menu createInterceptQueueTableMenu(Table table) {\n\t\tinterceptQueueTableMenu = new Menu(table);\n\t\tinterceptQueueTableMenu.setEnabled(false);\n\t\t\n\t    MenuItem forwardMenuItem = new MenuItem(interceptQueueTableMenu, SWT.CASCADE);\n\t    forwardMenuItem.setText(\"Forward Transaction\");\n\t    forwardMenuItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tforwardInterceptQueueSelection();\n\t\t\t};\n\t    });\n\n\t    MenuItem dropMenuItem = new MenuItem(interceptQueueTableMenu, SWT.CASCADE);\n\t    dropMenuItem.setText(\"Drop Transaction\");\n\t    dropMenuItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdropInterceptQueueSelection();\n\t\t\t};\n\t    });\n\n\t\treturn interceptQueueTableMenu;\n\t}\n\n\tprivate void forwardInterceptQueueSelection() {\n\t\tIStructuredSelection selection = (IStructuredSelection) interceptQueueTableViewer.getSelection();\n\t\tfor (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {\n\t\t\tIProxyTransaction transaction = (IProxyTransaction) iter.next();\n\t\t\ttransaction.doForward();\n\t\t}\n\t}\n\n\tprivate void dropInterceptQueueSelection() {\n\t\tIStructuredSelection selection = (IStructuredSelection) interceptQueueTableViewer.getSelection();\n\t\tfor (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {\n\t\t\tIProxyTransaction transaction = (IProxyTransaction) iter.next();\n\t\t\ttransaction.doDrop();\n\t\t}\n\t}\n\t\n\tprivate Composite createRequestStatusArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"Request Status\");\n\n\t\tcreateRequestStatusTable(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createRequestStatusTable(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\trequestStatusTableViewer = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\trequestStatusTableViewer.setContentProvider(new RequestStatusTableContentProvider());\n\t\tcreateRequestStatusTableColumns(requestStatusTableViewer, tcl);\n\t\tfinal Table table = requestStatusTableViewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t\trequestStatusTableViewer.addSelectionChangedListener(createRequestStatusTableSelectionChangedListener());\n\t\ttable.setMenu(createRequestStatusTableMenu(table));\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate String uriToHostString(URI uri) {\n\t\tfinal StringBuilder buf = new StringBuilder();\n\t\tbuf.append(uri.getScheme());\n\t\tbuf.append(\"://\");\n\t\tbuf.append(uri.getHost());\n\t\tif (uri.getPort() != -1) {\n\t\t\tbuf.append(':');\n\t\t\tbuf.append(Integer.toString(uri.getPort()));\n\t\t}\n\t\treturn buf.toString();\n\t}\n\n\tprivate String uriToPathString(URI uri) {\n\t\tif (uri.getRawQuery() != null) {\n\t\t\treturn uri.getRawPath() + \"?\" + uri.getRawQuery();\n\t\t} else {\n\t\t\treturn uri.getRawPath();\n\t\t}\n\t}\n\n\tprivate void createRequestStatusTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"Status\", \"Host\", \"Method\", \"Request\", \"Listener\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnPixelData(45, true, true),\n\t\t\tnew ColumnPixelData(120, true, true),\n\t\t\tnew ColumnPixelData(60, true, true),\n\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t\tnew ColumnPixelData(100, true, true),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn (((IHttpRequestTask) element).getTimeCompleted() == null) ? \"in progress\" : \"complete\"; \n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn uriToHostString(((IHttpRequestTask) element).getRequest().getURI());\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpRequestTask) element).getRequest().getMethod();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn uriToPathString(((IHttpRequestTask) element).getRequest().getURI());\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\tfinal IRequestOrigin origin = ((IHttpRequestTask) element).getRequestEngine().getRequestOrigin();\n\t\t\t\t\tif (origin instanceof IRequestOriginProxy) {\n\t\t\t\t\t\treturn origin.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tfor(int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\n\t\tfinal Table table = viewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t}\n\n\tprivate ISelectionChangedListener createRequestStatusTableSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\trequestStatusTableMenu.setEnabled(!event.getSelection().isEmpty());\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate Menu createRequestStatusTableMenu(Table table) {\n\t\trequestStatusTableMenu = new Menu(table);\n\t\trequestStatusTableMenu.setEnabled(false);\n\t\t\n\t    MenuItem abortMenuItem = new MenuItem(requestStatusTableMenu, SWT.CASCADE);\n\t    abortMenuItem.setText(\"Abort Request\");\n\t    abortMenuItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tabortRequestStatusSelection();\n\t\t\t};\n\t    });\n\n\t\treturn requestStatusTableMenu;\n\t}\n\n\tprivate void abortRequestStatusSelection() {\n\t\tIStructuredSelection selection = (IStructuredSelection) requestStatusTableViewer.getSelection();\n\t\tfor (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {\n\t\t\tIHttpRequestTask requestTask = (IHttpRequestTask) iter.next();\n\t\t\trequestTask.abort();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.httpeditor</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Httpeditor\nBundle-SymbolicName: com.subgraph.vega.ui.httpeditor\nBundle-Version: 1.0.0.qualifier\nBundle-Vendor: SUBGRAPH\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nImport-Package: com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.ui.hexeditor,\n org.apache.commons.codec;version=\"1.4.0\",\n org.apache.commons.codec.binary;version=\"1.4.0\",\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client.methods,\n org.apache.http.entity;version=\"4.0.0\",\n org.apache.http.message;version=\"4.0.0\",\n org.apache.http.params;version=\"4.0.0\",\n org.apache.http.protocol;version=\"4.0.0\",\n org.apache.http.util;version=\"4.0.0\",\n org.eclipse.jface.text,\n org.eclipse.jface.text.presentation,\n org.eclipse.jface.text.reconciler,\n org.eclipse.jface.text.rules,\n org.eclipse.jface.text.source,\n org.eclipse.jface.text.source.projection\nRequire-Bundle: org.eclipse.ui;bundle-version=\"3.6.0\",\n org.eclipse.core.runtime;bundle-version=\"3.6.0\"\nExport-Package: com.subgraph.vega.ui.httpeditor,\n com.subgraph.vega.ui.httpeditor.parser\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/BinaryEntityManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.Position;\nimport org.eclipse.jface.text.source.SourceViewer;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.ImageData;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.ui.hexeditor.HexEditControl;\nimport com.subgraph.vega.ui.httpeditor.annotations.AnnotationPainter;\nimport com.subgraph.vega.ui.httpeditor.annotations.ImageAnnotation;\n\npublic class BinaryEntityManager {\n\t\n\tprivate final AnnotationPainter annotationPainter;\n\tprivate final SourceViewer viewer;\n\tprivate final SashForm sashForm;\n\tprivate final Composite root;\n\tprivate final HexEditControl hexEditor;\n\t\n\tprivate HttpMessageDocument activeDocument;\n\tprivate ImageAnnotation imageAnnotation;\n\t\n\tprivate boolean displayImages = true;\n\tprivate boolean displayImagesAsHex = false;\n\t\n\tBinaryEntityManager(SourceViewer viewer, SashForm sash, Composite root) {\n\t\tthis.viewer = viewer;\n\t\tthis.annotationPainter = new AnnotationPainter(viewer);\n\t\tthis.sashForm = sash;\n\t\tthis.root = root;\n\t\tthis.hexEditor = new HexEditControl(sashForm);\n\t\tsashForm.setMaximizedControl(root);\n\t}\n\t\n\tvoid dispose() {\n\t\tannotationPainter.dispose();\n\t}\n\tvoid clear() {\n\t\tsashForm.setMaximizedControl(root);\n\t\tif(imageAnnotation != null) {\n\t\t\tremoveImageAnnotation();\n\t\t}\n\t\thexEditor.setInput(new byte[0]);\n\t\tactiveDocument = null;\n\t}\n\t\n\tprivate boolean isImageEntity() {\n\t\treturn activeDocument != null && activeDocument.getMessageEntity().isImageEntity();\n\t}\n\t\n\tboolean isContentDirty() {\n\t\treturn hexEditor.isContentDirty();\n\t}\n\t\n\tbyte[] getContent() {\n\t\treturn hexEditor.getContent();\n\t}\n\t\n\tvoid displayImagesAsHex(boolean flag) {\n\t\tdisplayImagesAsHex = flag;\n\t\tdisplayImageForState();\t\t\n\t}\n\t\n\tvoid displayImages(boolean flag) {\n\t\tdisplayImages = flag;\n\t\tdisplayImageForState();\n\t}\n\n\tvoid displayImageForState() {\n\t\tif(!isImageEntity()) {\n\t\t\tsashForm.setMaximizedControl(root);\n\t\t\treturn;\n\t\t}\n\t\tif(displayImages) {\n\t\t\tif(displayImagesAsHex) {\n\t\t\t\tif(imageAnnotation != null) {\n\t\t\t\t\tremoveImageAnnotation();\n\t\t\t\t}\n\t\t\t\tsashForm.setMaximizedControl(null);\n\t\t\t} else {\n\t\t\t\tif(isImageEntity())\n\t\t\t\t\taddImageAnnotation(activeDocument.getDocument(), activeDocument.getMessageEntity().getImageData());\n\t\t\t\tsashForm.setMaximizedControl(root);\n\t\t\t}\n\t\t} else {\n\t\t\tsashForm.setMaximizedControl(root);\n\t\t\tremoveImageAnnotation();\n\t\t}\n\t}\n\t\n\tvoid displayNewDocument(HttpMessageDocument document) {\n\t\t\n\t\tclear();\n\t\tactiveDocument = document;\n\t\tfinal HttpMessageEntity entity = document.getMessageEntity();\n\t\t\n\t\tif(!entity.isBinaryEntity() && !entity.isImageEntity()) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(entity.isImageEntity()) {\n\t\t\thexEditor.setInput(entity.getBinaryData());\n\t\t\tdisplayImageForState();\n\t\t} else {\n\t\t\thexEditor.setInput(entity.getBinaryData());\n\t\t\tsashForm.setMaximizedControl(null);\n\t\t}\n\t\t\n\t}\n\t\n\tprivate void addImageAnnotation(IDocument document, ImageData imageData) {\n\t\tif(imageAnnotation != null) {\n\t\t\tremoveImageAnnotation();\n\t\t}\n\t\tfinal Image image = new Image(sashForm.getDisplay(), imageData);\n\t\timageAnnotation = new ImageAnnotation(image);\n\t\tfinal Position p = padDocumentForImage(document, imageAnnotation.getPaddingString(viewer));\n\t\tannotationPainter.addAnnotation(imageAnnotation, p);\n\t}\n\t\n\tprivate void removeImageAnnotation() {\n\t\tif(imageAnnotation == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal Position position = annotationPainter.getPosition(imageAnnotation);\n\t\tannotationPainter.removeAnnotation(imageAnnotation);\n\t\tactiveDocument.getDocument().removePosition(position);\n\t\ttry {\n\t\t\tactiveDocument.getDocument().replace(position.offset, position.length, \"\");\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new RuntimeException(\"Internal Error: \"+ e.getMessage(), e);\n\t\t}\n\t\t\n\t\timageAnnotation = null;\n\t}\n\t\n\tprivate Position padDocumentForImage(IDocument document, String padding) {\n\t\tfinal Position position = new Position(document.getLength(), padding.length());\n\t\ttry {\n\t\t\tdocument.replace(document.getLength(), 0, padding);\n\t\t\tdocument.addPosition(position);\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new RuntimeException(\"Internal Error: \"+ e.getMessage(), e);\n\t\t}\n\t\treturn position;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/Colors.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.jface.text.source.ISharedTextColors;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.RGB;\nimport org.eclipse.swt.widgets.Display;\n\npublic class Colors implements ISharedTextColors {\n\tprivate static RGB c(int rgb) {\n\t\tint r = (rgb >> 16) & 0xFF;\n\t\tint g = (rgb >> 8) & 0xFF;\n\t\tint b = rgb & 0xFF;\n\t\treturn new RGB(r, g, b);\n\t}\n\tpublic static RGB HIGHLIGHT_SEARCH_MATCH = c(0xFFFF99);\n\tpublic static RGB ALERT_HIGHLIGHT = c(0xFFA0A0);\n\tpublic static RGB NO_SEARCH_RESULT_TEXT_BACKGROUND = c(0xFF7070);\n\t\n\tpublic static RGB HEADER_NAME = c(0x79693E);\n\tpublic static RGB REQUEST_VERB = c(0x3F3415);\n\tpublic static RGB HTTP_VERSION = c(0x4D4122);\n\t\n\tpublic static RGB STRING = c(0x4B4F72);\n\tpublic static RGB INTEGER = c(0x48592C);\n\tpublic static RGB ENCODED_CHAR = c(0x7D4C63);\n\tpublic static RGB DATE = c(0x4271ae);\n\t\n\tpublic static RGB MULTI_LINE_COMMENT = c(0x4B4F92);\n\tpublic static RGB SINGLE_LINE_COMMENT = c(0x8e908c);\n\tpublic static RGB TAG = c(0x8959a8);\n\tpublic static RGB KEYWORD = c(0x8959a8);\n\tpublic static RGB OTHER = c(0x4d4d4c);\n\t\n\tprivate final Map<RGB, Color> colorMap = new HashMap<RGB, Color>();\n\tprivate final Display display;\n\t\n\tpublic Colors(Display display) {\n\t\tthis.display = display;\n\t}\n\t\n\tpublic void dispose() {\n\t\tfor(Color c: colorMap.values())\n\t\t\tc.dispose();\n\t}\n\t\n\tpublic Color get(RGB rgb) {\n\t\tif(!colorMap.containsKey(rgb)) {\n\t\t\tcolorMap.put(rgb, new Color(display, rgb));\n\t\t}\n\t\treturn colorMap.get(rgb);\n\t}\n\n\t@Override\n\tpublic Color getColor(RGB rgb) {\n\t\treturn get(rgb);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/Configuration.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\n\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextAttribute;\nimport org.eclipse.jface.text.presentation.IPresentationReconciler;\nimport org.eclipse.jface.text.presentation.PresentationReconciler;\nimport org.eclipse.jface.text.rules.BufferedRuleBasedScanner;\nimport org.eclipse.jface.text.rules.DefaultDamagerRepairer;\nimport org.eclipse.jface.text.rules.ITokenScanner;\nimport org.eclipse.jface.text.rules.Token;\nimport org.eclipse.jface.text.source.ISourceViewer;\nimport org.eclipse.jface.text.source.SourceViewerConfiguration;\nimport org.eclipse.swt.graphics.RGB;\n\nimport com.subgraph.vega.ui.httpeditor.html.HtmlPartitionScanner;\nimport com.subgraph.vega.ui.httpeditor.html.TagScanner;\nimport com.subgraph.vega.ui.httpeditor.http.HttpHeaderScanner;\nimport com.subgraph.vega.ui.httpeditor.http.RequestLineScanner;\nimport com.subgraph.vega.ui.httpeditor.http.ResponseLineScanner;\nimport com.subgraph.vega.ui.httpeditor.js.JavascriptPartitionScanner;\nimport com.subgraph.vega.ui.httpeditor.js.JavascriptScanner;\n\npublic class Configuration extends SourceViewerConfiguration {\n\n\tprivate final Colors colors;\n\tprivate final IPresentationReconciler reconciler;\n\t\n\tstatic class SingleTokenScanner extends BufferedRuleBasedScanner {\n\t\tpublic SingleTokenScanner(TextAttribute attribute) {\n\t\t\tsetDefaultReturnToken(new Token(attribute));\n\t\t}\n\t}\n\tConfiguration(Colors colors) {\n\t\tthis.colors = colors;\n\t\tthis.reconciler = createReconciler();\n\t}\n\n\tprivate IPresentationReconciler createReconciler() {\n\t\tfinal PresentationReconciler pr = new PresentationReconciler();\n\t\taddDamagerRepairer(pr, HttpMessageDocumentFactory.PARTITION_REQUEST_LINE, new RequestLineScanner(colors));\n\t\taddDamagerRepairer(pr, HttpMessageDocumentFactory.PARTITION_RESPONSE_LINE, new ResponseLineScanner(colors));\n\t\taddDamagerRepairer(pr, HttpMessageDocumentFactory.PARTITION_MESSAGE_HEADER, new HttpHeaderScanner(colors));\n\t\t\n\t\taddDamagerRepairer(pr, JavascriptPartitionScanner.JS_DEFAULT_TYPE, new JavascriptScanner(colors));\n\t\taddDamagerRepairer(pr, Colors.MULTI_LINE_COMMENT, JavascriptPartitionScanner.JS_MULTILINE_COMMENT);\n\n\t\taddDamagerRepairer(pr, HtmlPartitionScanner.HTML_START_TAG, new TagScanner(colors));\n\t\taddDamagerRepairer(pr, HtmlPartitionScanner.HTML_END_TAG, new TagScanner(colors));\n\t\taddDamagerRepairer(pr, Colors.MULTI_LINE_COMMENT, HtmlPartitionScanner.HTML_COMMENT);\n\t\taddDamagerRepairer(pr, Colors.MULTI_LINE_COMMENT, HtmlPartitionScanner.HTML_DOCTYPE);\n\t\t\n\t\taddDamagerRepairer(pr, Colors.OTHER, IDocument.DEFAULT_CONTENT_TYPE);\n\t\treturn pr;\n\t}\n\n\tprivate void addDamagerRepairer(PresentationReconciler pr, String partition, ITokenScanner scanner) {\n\t\tfinal DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);\n\t\tpr.setDamager(dr, partition);\n\t\tpr.setRepairer(dr, partition);\n\t}\n\t\n\tprivate void addDamagerRepairer(PresentationReconciler pr, RGB color, String type) {\n\t\tfinal TextAttribute ta = new TextAttribute(colors.get(color));\n\t\taddDamagerRepairer(pr, type, new SingleTokenScanner(ta));\n\t}\n\n\t@Override\n\tpublic IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {\n\t\treturn reconciler;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/DefaultTextEntityRenderer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.eclipse.jface.text.presentation.PresentationReconciler;\nimport org.eclipse.jface.text.rules.IPredicateRule;\n\npublic class DefaultTextEntityRenderer implements ITextEntityRenderer {\n\n\t@Override\n\tpublic List<String> getPartitionTypes() {\n\t\treturn Collections.emptyList();\n\t}\n\n\t@Override\n\tpublic boolean matchContentType(String contentType) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic void addPartitionScannerRules(List<IPredicateRule> rules) {\n\t}\n\n\t@Override\n\tpublic void configurePresentationReconciler(\n\t\t\tPresentationReconciler reconciler, Colors colors) {\n\t}\n\n\t@Override\n\tpublic String formatText(String input) {\n\t\treturn input;\n\t}\n\n\t@Override\n\tpublic String getLineSplitChars() {\n\t\treturn \" ,\";\n\t}\n\n\t@Override\n\tpublic String getDefaultPartitionType() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/HeaderDecoder.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.BadPositionCategoryException;\nimport org.eclipse.jface.text.DefaultPositionUpdater;\nimport org.eclipse.jface.text.Position;\n\npublic class HeaderDecoder {\n\tprivate final static String DECODED_CHAR_CATEGORY = \"__decoded_char_category\";\n\tprivate final HttpMessageDocument messageDocument;\n\tprivate boolean decodeState = false;\n\t\n\tHeaderDecoder(HttpMessageDocument messageDocument) {\n\t\tthis.messageDocument = messageDocument;\n\t\tthis.messageDocument.getDocument().addPositionCategory(DECODED_CHAR_CATEGORY);\n\t\tthis.messageDocument.getDocument().addPositionUpdater(new DefaultPositionUpdater(DECODED_CHAR_CATEGORY));\n\t}\n\n\tpublic void toggleDecodeState() {\n\t\tdecodeState = !decodeState;\n\t\tif(decodeState) {\n\t\t\tdecodeHeaders();\n\t\t} else {\n\t\t\tundecodeHeaders();\n\t\t}\n\t}\n\t\n\tpublic void decodeHeaders() {\n\t\ttry {\n\t\t\tdecode();\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new RuntimeException(\"Bad location in document decoding header\", e);\n\t\t} catch (BadPositionCategoryException e) {\n\t\t\tthrow new RuntimeException(\"Position category does not exist in HeaderDecoder\", e);\n\t\t}\n\t}\n\t\n\tpublic void undecodeHeaders() {\n\t\ttry {\n\t\t\tencode();\n\t\t} catch (BadPositionCategoryException e) {\n\t\t\tthrow new RuntimeException(\"Bad location in document decoding header\", e);\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new RuntimeException(\"Position category does not exist in HeaderDecoder\", e);\n\t\t}\n\t}\n\t\n\tpublic String getUndecodedHeaderContent() {\n\t\ttry {\n\t\t\tif(!decodeState) {\n\t\t\t\treturn getHeaderSectionText();\n\t\t\t}\n\t\t\treturn getEncodedHeaderSectionText();\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new RuntimeException(\"Bad location getting undecoded header content\");\n\t\t}\n\t}\n\t\n\tprivate String getHeaderSectionText() throws BadLocationException {\n\t\tfinal Position headerSection = messageDocument.getHeaderSection();\n\t\treturn messageDocument.getDocument().get(headerSection.getOffset(), headerSection.getLength());\n\t}\n\t\n\tprivate String getEncodedHeaderSectionText() throws BadLocationException {\n\t\tfinal Position headerSection = messageDocument.getHeaderSection();\n\t\tfinal int start = headerSection.getOffset();\n\t\tfinal int end = start + headerSection.getLength();\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tfor(int i = start; i < end; i++) {\n\t\t\tchar c = getCharAt(i);\n\t\t\tif(messageDocument.getDocument().containsPosition(DECODED_CHAR_CATEGORY, i, 1)) {\n\t\t\t\tsb.append(getEncodedCharacter(c));\n\t\t\t} else {\n\t\t\t\tsb.append(c);\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tprivate void decode() throws BadLocationException, BadPositionCategoryException {\n\t\tfinal Position headerPosition = messageDocument.getHeaderSection();\n\t\tfinal Position remaining = new Position(headerPosition.getOffset(), headerPosition.getLength());\n\t\twhile(remaining.getLength() > 0) {\n\t\t\tchar c = getCharAt(remaining.getOffset());\n\t\t\tconsumeRemaining(remaining, 1);\n\t\t\tif(c == '%') {\n\t\t\t\tprocessPercent(remaining);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void processPercent(Position remaining) throws BadLocationException, BadPositionCategoryException {\n\t\tif(remaining.getLength() <= 0) {\n\t\t\treturn;\n\t\t}\n\t\tfinal char c1 = getCharAt(remaining.getOffset());\n\t\tif(c1 == '%') {\n\t\t\treplaceDecodedChar(remaining.getOffset() - 1, 2, '%');\n\t\t\tremaining.length -= 1;\n\t\t\treturn;\n\t\t}\n\t\tif(!isHex(c1) || remaining.getLength() == 1) {\n\t\t\treturn;\n\t\t}\n\t\tfinal char c2 = getCharAt(remaining.getOffset() + 1);\n\t\tif(!isHex(c2)) {\n\t\t\treturn;\n\t\t}\n\t\tfinal char cc = hexDecode(c1,c2);\n\t\treplaceDecodedChar(remaining.getOffset() - 1, 3, cc);\n\t\tremaining.length -= 2;\n\t}\n\t\n\tprivate void consumeRemaining(Position remaining, int count) {\n\t\tremaining.offset += count;\n\t\tremaining.length -= count;\n\t}\n\t\n\tprivate void replaceDecodedChar(int offset, int length, char c) throws BadLocationException, BadPositionCategoryException {\n\t\tmessageDocument.getDocument().replace(offset, length, String.valueOf(c));\n\t\tmessageDocument.getDocument().addPosition(DECODED_CHAR_CATEGORY, new Position(offset, 1));\n\t}\n\n\tprivate char getCharAt(int offset) throws BadLocationException {\n\t\treturn messageDocument.getDocument().getChar(offset);\n\t}\n\t\n\tprivate final String HEX_DIGITS = \"01234567890abcdef\";\n\n\tprivate boolean isHex(char c) {\n\t\treturn (HEX_DIGITS.indexOf(Character.toLowerCase(c)) != -1);\n\t}\n\n\tprivate char hexDecode(char hi, char low) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(hi);\n\t\tsb.append(low);\n\t\treturn (char) Integer.parseInt(sb.toString(), 16);\n\t}\n\n\tprivate void encode() throws BadPositionCategoryException, BadLocationException {\n\t\tfinal Position[] positions = messageDocument.getDocument().getPositions(DECODED_CHAR_CATEGORY);\n\t\tfor(Position p: positions) {\n\t\t\tchar c = getCharAt(p.getOffset());\n\t\t\tmessageDocument.getDocument().replace(p.getOffset(), p.getLength(), getEncodedCharacter(c));\n\t\t\tmessageDocument.getDocument().removePosition(DECODED_CHAR_CATEGORY, p);\n\t\t}\n\t}\n\t\n\tprivate String getEncodedCharacter(char c) {\n\t\tif(c == '%') {\n\t\t\treturn \"%%\";\n\t\t} else {\n\t\t\treturn \"%\" + hexEncode(c);\n\t\t}\n\t}\n\t\n\tprivate String hexEncode(char c) {\n\t\treturn String.format(\"%02X\", (int)c);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/HttpHeaderTextRenderer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpMessage;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\n\nimport com.subgraph.vega.api.http.requests.IHttpHeaderBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpMessageBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\n\npublic class HttpHeaderTextRenderer {\n\t\n\tpublic String getRequestAsText(HttpRequest request) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\trenderRequestLine(sb, request);\n\t\trenderAllHeaders(sb, request);\n\t\treturn sb.toString();\n\t}\n\n\tpublic String getRequestAsText(IHttpRequestBuilder request) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\trenderRequestLine(sb, request);\n\t\trenderAllHeaders(sb, request);\n\t\treturn sb.toString();\n\t}\n\t\n\tpublic String getResponseAsText(HttpResponse response) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\trenderStatusLine(sb, response);\n\t\trenderAllHeaders(sb, response);\t\t\n\t\treturn sb.toString();\n\t}\n\t\n\tpublic String getResponseAsText(IHttpResponseBuilder builder) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\trenderStatusLine(sb, builder);\n\t\trenderAllHeaders(sb, builder);\t\t\n\t\treturn sb.toString();\n\t}\n\n\tprivate void renderRequestLine(StringBuilder sb, HttpRequest request) {\n\t\tsb.append(request.getRequestLine().toString());\n\t\tsb.append('\\n');\n\t}\n\n\tprivate void renderRequestLine(StringBuilder sb, IHttpRequestBuilder builder) {\n\t\tfinal String requestLine = builder.getRequestLine();\n\t\tif (requestLine != null) {\n\t\t\tsb.append(requestLine);\n\t\t\tsb.append('\\n');\n\t\t}\n\t}\n\t\n\tprivate void renderStatusLine(StringBuilder sb, HttpResponse response) {\n\t\tsb.append(response.getStatusLine().toString());\n\t\tsb.append('\\n');\n\t}\n\t\n\tprivate void renderStatusLine(StringBuilder sb, IHttpResponseBuilder response) {\n\t\tsb.append(response.getStatusLine().toString());\n\t\tsb.append('\\n');\n\t}\n\n\tprivate void renderAllHeaders(StringBuilder sb, HttpMessage message) {\n\t\tfor(Header h: message.getAllHeaders()) { \n\t\t\trenderHeader(sb, h);\n\t\t}\n\t\tsb.append('\\n');\n\t}\n\n\tprivate void renderAllHeaders(StringBuilder sb, IHttpMessageBuilder builder) {\n\t\tfor(IHttpHeaderBuilder h: builder.getHeaders()) { \n\t\t\trenderHeader(sb, h);\n\t\t}\n\t\tsb.append('\\n');\n\t}\n\n\tprivate void renderHeader(StringBuilder sb, Header header) {\n\t\tsb.append(header.getName());\n\t\tsb.append(\": \");\n\t\tsb.append(header.getValue());\n\t\tsb.append(\"\\n\");\n\t}\n\n\tprivate void renderHeader(StringBuilder sb, IHttpHeaderBuilder builder) {\n\t\t// REVISIT: put raw header, if applicable\n\t\tsb.append(builder.getName());\n\t\tsb.append(\": \");\n\t\tsb.append(builder.getValue());\n\t\tsb.append(\"\\n\");\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/HttpMessageDocument.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.BadPositionCategoryException;\nimport org.eclipse.jface.text.DocumentEvent;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.IDocumentListener;\nimport org.eclipse.jface.text.Position;\nimport org.eclipse.jface.text.source.projection.ProjectionAnnotation;\nimport org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;\n\npublic class HttpMessageDocument implements IDocumentListener {\n\t\n\tstatic final String SECTION_POSITION_CATEGORY = \"__section_category\";\n\t\n\tprivate final IDocument document;\n\tprivate final HttpMessageEntity messageEntity;\n\tprivate final Position headerSectionPosition;\n\tprivate final Position bodySectionPosition;\n\tprivate final HeaderDecoder headerDecoder;\n\tprivate boolean isHeaderSectionDirty;\n\tprivate boolean isBodySectionDirty;\n\t\n\tHttpMessageDocument(IDocument document, HttpMessageEntity entity) {\n\t\tthis.document = document;\n\t\tthis.messageEntity = entity;\n\t\tfinal Position[] sections = getSectionPositions();\n\t\tthis.headerSectionPosition = sections[0];\n\t\tthis.bodySectionPosition = sections[1];\n\t\tthis.headerDecoder = new HeaderDecoder(this);\n\t\t\n\t\tdocument.addDocumentListener(this);\n\t}\n\n\tprivate Position[] getSectionPositions() {\n\t\ttry {\n\t\t\tfinal Position[] ps = document.getPositions(SECTION_POSITION_CATEGORY);\n\t\t\tif(ps.length == 0 || ps.length > 2) {\n\t\t\t\tthrow new IllegalStateException();\n\t\t\t} else if(ps.length == 1) {\n\t\t\t\treturn new Position[] { ps[0], null };\n\t\t\t} else {\n\t\t\t\treturn new Position[] { ps[0], ps[1] };\n\t\t\t}\n\t\t} catch (BadPositionCategoryException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t}\n\t\n\tboolean isHeaderSectionDirty() {\n\t\treturn isHeaderSectionDirty;\n\t}\n\t\n\tboolean isBodyEntityDirty() {\n\t\tif(bodySectionPosition != null) {\n\t\t\treturn isBodySectionDirty;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tIDocument getDocument() {\n\t\treturn document;\n\t}\n\t\n\t\n\tHttpMessageEntity getMessageEntity() {\n\t\treturn messageEntity;\n\t}\n\n\tPosition getHeaderSection() {\n\t\treturn headerSectionPosition;\n\t}\n\t\n\tPosition getBodySection() {\n\t\treturn bodySectionPosition;\n\t}\n\t\n\tpublic String getHeaderSectionText() {\n\t\treturn headerDecoder.getUndecodedHeaderContent();\n\t}\n\n\tpublic void setHeaderSectionText(String newText) {\n\t\ttry {\n\t\t\tdocument.replace(headerSectionPosition.getOffset(), headerSectionPosition.getLength(), newText);\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t}\n\n\tpublic String getBodySectionText() {\n\t\treturn getTextByPosition(bodySectionPosition);\n\t}\n\n\tprivate String getTextByPosition(Position p) {\n\t\tif(p == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn document.get(p.getOffset(), p.getLength());\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t}\n\n\tvoid setHeaderDecodeState(boolean state) {\n\t\tif(state) {\n\t\t\theaderDecoder.decodeHeaders();\n\t\t} else {\n\t\t\theaderDecoder.undecodeHeaders();\n\t\t}\n\t}\n\t\n\t\n\tvoid toggleHeaderDecodeState() {\n\t\theaderDecoder.toggleDecodeState();\n\t}\n\n\t@Override\n\tpublic void documentAboutToBeChanged(DocumentEvent event) {\n\t}\n\n\t@Override\n\tpublic void documentChanged(DocumentEvent event) {\n\t\tif(headerSectionPosition.overlapsWith(event.getOffset(), event.getLength())) {\n\t\t\tisHeaderSectionDirty = true;\n\t\t}\n\t\t\n\t\tif(bodySectionPosition != null && bodySectionPosition.overlapsWith(event.getOffset(), event.getLength())) {\n\t\t\tisBodySectionDirty = true;\n\t\t}\n\t}\n\t\n\tpublic void addProjectionAnnotations(ProjectionAnnotationModel model) {\n\t\t\n\t\tif(headerSectionPosition != null) {\n\t\t\tmodel.addAnnotation(new ProjectionAnnotation(), new Position(headerSectionPosition.offset, headerSectionPosition.length));\n\t\t}\n\t\tif(bodySectionPosition != null) {\n\t\t\tmodel.addAnnotation(new ProjectionAnnotation(), new Position(bodySectionPosition.offset, bodySectionPosition.length));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/HttpMessageDocumentFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.BadPositionCategoryException;\nimport org.eclipse.jface.text.DefaultPositionUpdater;\nimport org.eclipse.jface.text.Document;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.IDocumentPartitioner;\nimport org.eclipse.jface.text.Position;\nimport org.eclipse.jface.text.rules.FastPartitioner;\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.RuleBasedPartitionScanner;\nimport org.eclipse.jface.text.rules.Token;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\nimport com.subgraph.vega.ui.httpeditor.html.HtmlTextEntityRenderer;\nimport com.subgraph.vega.ui.httpeditor.http.HeaderPartitionRule;\nimport com.subgraph.vega.ui.httpeditor.http.RequestLinePartitionRule;\nimport com.subgraph.vega.ui.httpeditor.http.ResponseLinePartitionRule;\nimport com.subgraph.vega.ui.httpeditor.js.JavascriptTextEntityRenderer;\n\npublic class HttpMessageDocumentFactory {\n\tprivate final static int MAX_LONG_LINE = 200;\n\tprivate final static int ABSOLUTE_MAX_LONG_LINE = MAX_LONG_LINE + 20;\n\n\tpublic final static String PARTITION_REQUEST_LINE = \"http-request-line\";\n\tpublic final static String PARTITION_RESPONSE_LINE = \"http-response-line\";\n\tpublic final static String PARTITION_MESSAGE_HEADER = \"http-header\";\n\n\tpublic final static String[] PARTITION_TYPES = { \n\t\tPARTITION_REQUEST_LINE, \n\t\tPARTITION_RESPONSE_LINE, \n\t\tPARTITION_MESSAGE_HEADER \n\t};\n\t\n\tpublic final static ITextEntityRenderer[] ENTITY_RENDERERS = {\n\t\tnew HtmlTextEntityRenderer(),\n\t\tnew JavascriptTextEntityRenderer(),\n\t\tnew DefaultTextEntityRenderer()\n\t};\n\n\tprivate final HttpHeaderTextRenderer messageRenderer = new HttpHeaderTextRenderer();\n\t\n\tHttpMessageDocument createForRequest(HttpRequest request) {\n\t\tif(request instanceof HttpEntityEnclosingRequest) {\n\t\t\tfinal HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();\n\t\t\treturn createForText(messageRenderer.getRequestAsText(request), entity);\n\t\t} else {\n\t\t\treturn createForText(messageRenderer.getRequestAsText(request));\n\t\t}\n\t}\n\n\tHttpMessageDocument createForResponse(HttpResponse response) {\n\t\treturn createForText(messageRenderer.getResponseAsText(response), response.getEntity());\n\t}\n\n\tHttpMessageDocument createForRequest(IHttpRequestBuilder builder) {\n\t\treturn createForText(messageRenderer.getRequestAsText(builder), builder.getEntity());\n\t}\n\n\tHttpMessageDocument createForResponse(IHttpResponseBuilder builder) {\n\t\treturn createForText(messageRenderer.getResponseAsText(builder), builder.getEntity());\n\t}\n\t\n\tprivate HttpMessageDocument createForText(String text) {\n\t\treturn createForText(text, null);\n\t}\n\n\tprivate HttpMessageDocument createForText(String text, HttpEntity entity) {\n\t\tfinal HttpMessageEntity messageEntity = HttpMessageEntity.createFromEntity(entity);\n\t\tif(messageEntity.isAsciiEntity()) {\n\t\t\tfinal ITextEntityRenderer renderer = getTextEntityRendererForType(messageEntity.getContentType());\n\t\t\treturn createForHeaderTextWithRenderer(text, messageEntity, renderer);\n\t\t} else {\n\t\t\treturn createForHeaderTextWithRenderer(text, messageEntity, null);\n\t\t}\n\t}\n\t\n\tprivate HttpMessageDocument createForHeaderTextWithRenderer(String text, HttpMessageEntity messageEntity, ITextEntityRenderer renderer) {\n\t\tfinal String bodyText = getBodyText(messageEntity, renderer);\n\n\t\tfinal IDocument document = createDocument(text, bodyText, renderer);\n\t\treturn new HttpMessageDocument(document, messageEntity);\n\t}\n\t\n\tprivate String getBodyText(HttpMessageEntity messageEntity, ITextEntityRenderer renderer) {\n\t\tif(!messageEntity.isAsciiEntity() || renderer == null || messageEntity.getTextData().isEmpty()) {\n\t\t\treturn \"\";\n\t\t}\n\t\tfinal String formattedText = renderer.formatText(messageEntity.getTextData());\n\t\treturn longLineFormatter(formattedText, renderer.getLineSplitChars());\n\t}\n\n\tprivate String longLineFormatter(String input, String splitAt) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tint count = 0;\n\t\tchar c;\n\t\tfor(int i = 0; i < input.length(); i++) {\n\t\t\tcount += 1;\n\t\t\tc = input.charAt(i);\n\t\t\tsb.append(c);\n\t\t\tif(c == '\\n') {\n\t\t\t\tcount = 0;\n\t\t\t}\n\t\t\tif(count > ABSOLUTE_MAX_LONG_LINE || \n\t\t\t\t\t(count > MAX_LONG_LINE && splitAt.indexOf(c) != -1)) {\n\t\t\t\tsb.append(\"\\n\");\n\t\t\t\tcount = 0;\n\t\t\t} \n\t\t}\n\t\treturn sb.toString();\n\t}\n\n\tprivate ITextEntityRenderer getTextEntityRendererForType(String contentType) {\n\t\tfor(ITextEntityRenderer ter: ENTITY_RENDERERS) {\n\t\t\tif(ter.matchContentType(contentType.toLowerCase())) {\n\t\t\t\treturn ter;\n\t\t\t}\n\t\t}\n\t\treturn new DefaultTextEntityRenderer();\n\t}\n\t\n\tprivate IDocument createDocument(String headerText, String bodyText, ITextEntityRenderer renderer) {\n\t\tfinal IDocument document = createEmptyDocument(renderer);\n\t\tdocument.addPositionCategory(HttpMessageDocument.SECTION_POSITION_CATEGORY);\n\t\tdocument.addPositionUpdater(new DefaultPositionUpdater(HttpMessageDocument.SECTION_POSITION_CATEGORY));\n\t\t\n\t\tif(bodyText != null && !bodyText.isEmpty()) {\n\t\t\tdocument.set(headerText + bodyText);\n\t\t\taddSectionPosition(document, 0, headerText.length());\n\t\t\taddSectionPosition(document, headerText.length(), bodyText.length());\n\t\t} else {\n\t\t\tdocument.set(headerText);\n\t\t\taddSectionPosition(document, 0, headerText.length());\n\t\t}\n\t\treturn document;\n\t}\n\t\t\n\tprivate void addSectionPosition(IDocument document, int offset, int length) {\n\t\ttry {\n\t\t\tdocument.addPosition(HttpMessageDocument.SECTION_POSITION_CATEGORY, new Position(offset, length));\n\t\t} catch (BadLocationException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t} catch (BadPositionCategoryException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n\t}\n\t\n\tprivate IDocument createEmptyDocument(ITextEntityRenderer renderer) {\n\t\tfinal Document document = new Document();\n\t\tfinal IDocumentPartitioner partitioner = createPartitioner(renderer);\n\t\tdocument.setDocumentPartitioner(partitioner);\n\t\tpartitioner.connect(document);\n\t\treturn document;\n\t}\n\t\n\tprivate IDocumentPartitioner createPartitioner(ITextEntityRenderer renderer) {\n\t\tfinal RuleBasedPartitionScanner scanner = new RuleBasedPartitionScanner();\n\t\tscanner.setPredicateRules(createRules(renderer));\n\t\tif(renderer != null && renderer.getDefaultPartitionType() != null) {\n\t\t\tscanner.setDefaultReturnToken(new Token(renderer.getDefaultPartitionType()));\n\t\t}\n\t\treturn new FastPartitioner(scanner, getPartitionTypes(renderer));\n\t}\n\t\n\tprivate IPredicateRule[] createRules(ITextEntityRenderer renderer) {\n\t\tfinal List<IPredicateRule> rules = new ArrayList<IPredicateRule>();\n\t\taddHeaderPartitionRules(rules);\n\t\tif(renderer != null) {\n\t\t\trenderer.addPartitionScannerRules(rules);\n\t\t}\n\n\t\treturn rules.toArray(new IPredicateRule[0]);\n\t}\n\n\tprivate void addHeaderPartitionRules(List<IPredicateRule> rules) {\n\t\trules.add(new RequestLinePartitionRule(new Token(PARTITION_REQUEST_LINE)));\n\t\trules.add(new ResponseLinePartitionRule(new Token(PARTITION_RESPONSE_LINE)));\n\t\trules.add(new HeaderPartitionRule(new Token(PARTITION_MESSAGE_HEADER)));\n\t}\n\t\n\tprivate String[] getPartitionTypes(ITextEntityRenderer renderer) {\n\t\tfinal List<String> types = new ArrayList<String>();\n\t\ttypes.addAll(Arrays.asList(PARTITION_TYPES));\n\t\tif(renderer != null) {\n\t\t\ttypes.addAll(renderer.getPartitionTypes());\n\t\t}\n\t\treturn types.toArray(new String[0]);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/HttpMessageEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport java.io.UnsupportedEncodingException;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.entity.StringEntity;\nimport org.eclipse.jface.action.IMenuListener;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.text.Document;\nimport org.eclipse.jface.text.ITextOperationTarget;\nimport org.eclipse.jface.text.TextViewer;\nimport org.eclipse.jface.text.TextViewerUndoManager;\nimport org.eclipse.jface.text.source.AnnotationModel;\nimport org.eclipse.jface.text.source.CompositeRuler;\nimport org.eclipse.jface.text.source.projection.ProjectionSupport;\nimport org.eclipse.jface.text.source.projection.ProjectionViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Menu;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\nimport com.subgraph.vega.api.model.alerts.IScanAlertHighlight;\nimport com.subgraph.vega.ui.httpeditor.highlights.CornerLayout;\nimport com.subgraph.vega.ui.httpeditor.highlights.CornerLayoutData;\nimport com.subgraph.vega.ui.httpeditor.highlights.HighlightBar;\nimport com.subgraph.vega.ui.httpeditor.search.SearchBar;\n\npublic class HttpMessageEditor extends Composite {\n\t\n\tprivate final Colors colors;\n\tprivate final Composite rootComposite;\n\tprivate final SashForm sashForm;\n\tprivate final ProjectionViewer viewer;\n\tprivate final AnnotationModel viewerAnnotationModel;\n\tprivate final ProjectionSupport projectionSupport;\n\n\t\n\tprivate final HttpMessageDocumentFactory messageDocumentFactory;\n\tprivate final HighlightBar highlightBar;\n\n\tprivate final BinaryEntityManager bem;\n\tprivate HttpMessageDocument activeDocument;\n\tprivate boolean urlDecode;\n\t\n\tpublic HttpMessageEditor(Composite parent) {\n\t\tsuper(parent, SWT.NONE);\n\t\t\n\t\tsetBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));\n\t\tsashForm = new SashForm(this, SWT.VERTICAL);\n\t\t\n\t\trootComposite = createRootComposite(sashForm);\n\t\tcolors = new Colors(getDisplay());\n\t\tviewerAnnotationModel = new AnnotationModel();\n\t\tviewer = createSourceViewer(rootComposite, viewerAnnotationModel);\n\t\tviewer.getTextWidget().setWrapIndent(20);\n\t\tviewer.configure(new Configuration(colors));\n\t\tcreateViewerActions(viewer);\n\t\tprojectionSupport = new ProjectionSupport(viewer,new ProjectionAnnotationAccess(), colors);\n\t\tprojectionSupport.install();\n\t\tmessageDocumentFactory = new HttpMessageDocumentFactory();\n\t\t\n\t\tfinal SearchBar sb = new SearchBar(this, viewer, colors);\n\t\tsb.setLayoutData(CornerLayoutData.createTopRight());\n\t\t\n\t\thighlightBar = new HighlightBar(this, viewer, colors);\n\t\thighlightBar.setLayoutData(CornerLayoutData.createBottomRight());\n\n\t\tsetLayout(new CornerLayout(viewer.getTextWidget()));\n\t\tlayout(true);\n\t\trootComposite.layout(true, true);\n\t\tbem = new BinaryEntityManager(viewer, sashForm, rootComposite);\n\t}\n\t\n\tprivate Composite createRootComposite(Composite parent) {\n\t\tfinal Composite c = new Composite(parent, SWT.NONE);\n\t\tfinal GridLayout layout = new GridLayout(2, false);\n\t\tlayout.marginHeight = 0;\n\t\tlayout.marginWidth = 0;\n\t\tlayout.horizontalSpacing = 0;\n\t\tc.setLayout(layout);\n\t\tc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));\n\t\treturn c;\n\t}\n\n\tprivate ProjectionViewer createSourceViewer(Composite parent, AnnotationModel annotationModel) {\n\t\tfinal CompositeRuler ruler = new CompositeRuler();\n\t\tfinal ProjectionViewer sv = new ProjectionViewer(parent, ruler, null, false, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\tfinal TextViewerUndoManager undoManager = new TextViewerUndoManager(8);\n\t\tundoManager.connect(sv);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\tsv.getControl().setLayoutData(gd);\n\t\treturn sv;\n\t}\n\n\tprivate void createViewerActions(TextViewer viewer) {\n\t\tfinal List<TextViewerAction> actions = new ArrayList<TextViewerAction>();\n\t\tfinal MenuManager menuManager = new MenuManager();\n\t\tactions.add(createMenuAction(menuManager, viewer, ITextOperationTarget.CUT, \"Cut\"));\n\t\tactions.add(createMenuAction(menuManager, viewer, ITextOperationTarget.COPY, \"Copy\"));\n\t\tactions.add(createMenuAction(menuManager, viewer, ITextOperationTarget.PASTE, \"Paste\"));\n\t\tactions.add(createMenuAction(menuManager, viewer, ITextOperationTarget.UNDO, \"Undo\"));\n\t\tactions.add(createMenuAction(menuManager, viewer, ITextOperationTarget.REDO, \"Redo\"));\n\t\t\n\t\tmenuManager.addMenuListener(new IMenuListener() {\n\t\t\t@Override\n\t\t\tpublic void menuAboutToShow(IMenuManager manager) {\n\t\t\t\tfor(TextViewerAction a: actions) {\n\t\t\t\t\ta.update();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfinal Menu menu = menuManager.createContextMenu(viewer.getTextWidget());\n\t\tviewer.getTextWidget().setMenu(menu);\n\t}\n\t\n\tprivate TextViewerAction createMenuAction(MenuManager menuManager, TextViewer viewer, int operationCode, String text) {\n\t\tfinal TextViewerAction action = new TextViewerAction(viewer, operationCode);\n\t\taction.setText(text);\n\t\tmenuManager.add(action);\n\t\treturn action;\n\t}\n\t\n\tpublic void dispose() {\n\t\tcolors.dispose();\n\t\tbem.dispose();\n\t\tsuper.dispose();\n\t}\n\t\n\tpublic void addAlertHighlights(Collection<IScanAlertHighlight> highlights) {\n\t\thighlightBar.addAlertHighlights(highlights);\n\t}\n\t\n\tpublic void displayAlertHighlights() {\n\t\thighlightBar.displayHighlights();\n\t}\n\t\n\tpublic void clearContent() {\n\t\tbem.clear();\n\t\tactiveDocument = null;\n\t\thighlightBar.clearHighlights();\n\t\tviewer.unconfigure();\n\t\tviewer.configure(new Configuration(colors));\n\t\tviewer.setDocument(new Document());\n\t}\n\t\n\tpublic String getContent() {\n\t\tif(activeDocument == null)\n\t\t\treturn \"\";\n\t\telse \n\t\t\treturn activeDocument.getHeaderSectionText();\n\t}\n\t\n\tpublic HttpEntity getEntityContent() {\n\t\t\n\t\tif(activeDocument == null || activeDocument.getMessageEntity().isEmptyEntity())\n\t\t\treturn null;\n\t\t\n\t\tif(!isEntityContentDirty()) {\n\t\t\treturn activeDocument.getMessageEntity().getEntity();\n\t\t}\n\t\t\n\t\tif(activeDocument.getMessageEntity().isAsciiEntity()) {\n\t\t\treturn getDirtyAsciiEntityContent();\n\t\t}\n\t\t\n\t\treturn getDirtyBinaryEntityContent();\n\t}\n\t\n\tprivate HttpEntity getDirtyAsciiEntityContent() {\n\t\ttry {\n\t\t\tfinal StringEntity entity = new StringEntity(activeDocument.getBodySectionText());\n\t\t\tentity.setContentType(activeDocument.getMessageEntity().getContentType());\n\t\t\tentity.setContentEncoding(activeDocument.getMessageEntity().getContentEncoding());\n\t\t\treturn entity;\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tthrow new RuntimeException(\"Unsupported encoding creating new ascii entity\", e);\n\t\t}\n\t}\n\n\tprivate HttpEntity getDirtyBinaryEntityContent() {\n\t\tfinal ByteArrayEntity entity = new ByteArrayEntity(bem.getContent());\n\t\tentity.setContentType(activeDocument.getMessageEntity().getContentType());\n\t\tentity.setContentEncoding(activeDocument.getMessageEntity().getContentType());\n\t\treturn entity;\n\t}\n\n\tpublic void setDecodeUrlEncoding(boolean flag) {\n\t\turlDecode = flag;\n\t\tif(activeDocument != null) {\n\t\t\tactiveDocument.setHeaderDecodeState(flag);\n\t\t}\n\t}\n\t\n\t\n\tpublic void setEditable(boolean flag) {\n\t\tviewer.setEditable(flag);\n\t}\n\t\n\tpublic void setDisplayImages(boolean flag) {\n\t\tbem.displayImages(flag);\n\t}\n\t\n\tpublic void setDisplayImagesAsHex(boolean flag) {\n\t\tbem.displayImagesAsHex(flag);\n\t}\n\t\n\tpublic void setWordwrapLines(boolean flag) {\n\t\tviewer.getTextWidget().setWordWrap(flag);\n\t}\n\t\n\tpublic void displayHttpRequest(HttpRequest request) {\n\t\tclearContent();\n\t\tactiveDocument = messageDocumentFactory.createForRequest(request);\n\t\tdisplayNewDocument();\n\t}\n\t\n\tpublic void displayHttpRequest(IHttpRequestBuilder builder) {\n\t\tclearContent();\n\t\tactiveDocument = messageDocumentFactory.createForRequest(builder);\n\t\tdisplayNewDocument();\n\t}\n\t\n\tpublic void displayHttpResponse(HttpResponse response) {\n\t\tclearContent();\n\t\tactiveDocument = messageDocumentFactory.createForResponse(response);\n\t\tdisplayNewDocument();\n\t}\n\n\tpublic void displayHttpResponse(IHttpResponseBuilder builder) {\n\t\tclearContent();\n\t\tactiveDocument = messageDocumentFactory.createForResponse(builder);\n\t\tdisplayNewDocument();\n\t}\n\t\n\tpublic boolean isEntityContentDirty() {\n\t\tif(activeDocument == null || activeDocument.getMessageEntity().isEmptyEntity()) {\n\t\t\treturn false;\n\t\t} else if(activeDocument.getMessageEntity().isAsciiEntity()) {\n\t\t\treturn activeDocument.isBodyEntityDirty();\n\t\t} else {\n\t\t\treturn bem.isContentDirty();\n\t\t}\n\t}\n\t\n\tprivate void displayNewDocument()  {\n\t\tif(activeDocument == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal AnnotationModel model = new AnnotationModel();\n\t\tviewer.disableProjection();\n\t\tfinal boolean wwflag = viewer.getTextWidget().getWordWrap();\n\t\tif(wwflag) viewer.getTextWidget().setWordWrap(false);\n\t\tviewer.setDocument(activeDocument.getDocument(), model);\n\t\tif(wwflag) viewer.getTextWidget().setWordWrap(true);\n\t\tviewer.enableProjection();\n\t\tactiveDocument.addProjectionAnnotations(viewer.getProjectionAnnotationModel());\n\t\tbem.displayNewDocument(activeDocument);\n\t\tactiveDocument.setHeaderDecodeState(urlDecode);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/HttpMessageEntity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.ParseException;\nimport org.apache.http.util.EntityUtils;\nimport org.eclipse.swt.SWTException;\nimport org.eclipse.swt.graphics.ImageData;\n\npublic class HttpMessageEntity {\n\t\n\tstatic HttpMessageEntity createFromEntity(HttpEntity entity) {\n\t\tif(entity == null || entity.getContentLength() == 0) {\n\t\t\treturn createEmptyEntity();\n\t\t}\n\t\ttry {\n\t\t\tfinal String asString = EntityUtils.toString(entity);\n\t\t\tif(isBodyAscii(asString)) {\n\t\t\t\treturn createAsciiEntity(entity, asString);\n\t\t\t} else {\n\t\t\t\treturn createFromBinaryEntity(entity, EntityUtils.toByteArray(entity));\n\t\t\t}\n\t\t} catch (ParseException e) {\n\t\t\treturn createEmptyEntity();\n\t\t} catch (IOException e) {\n\t\t\treturn createEmptyEntity();\n\t\t}\n\t}\n\t\n\tprivate static HttpMessageEntity createFromBinaryEntity(HttpEntity entity, byte[] binaryData) {\n\t\tif(binaryData == null || binaryData.length == 0) {\n\t\t\treturn createEmptyEntity();\n\t\t}\n\t\tfinal ImageData imageData = binaryToImageData(binaryData);\n\t\tif(imageData != null) {\n\t\t\treturn createImageEntity(entity, binaryData, imageData);\n\t\t} else {\n\t\t\treturn createBinaryEntity(entity, binaryData);\n\t\t}\n\t}\n\t\n\tprivate static boolean isBodyAscii(String body) {\n\t\tif(body == null || body.isEmpty())\n\t\t\treturn false;\n\t\t\n\t\tfinal int total = (body.length() > 500) ? (500) : (body.length());\n\t\tint printable = 0;\n\t\tfor(int i = 0; i < total; i++) {\n\t\t\tchar c = body.charAt(i);\n\t\t\tif((c >= 0x20 && c <= 0x7F) || Character.isWhitespace(c))\n\t\t\t\tprintable += 1;\n\t\t}\n\t\treturn ((printable * 100) / total > 90);\n\t}\n\t\n\tprivate static ImageData binaryToImageData(byte[] binaryData) {\n\t\ttry {\n\t\t\treturn new ImageData(new ByteArrayInputStream(binaryData));\n\t\t} catch (SWTException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate static HttpMessageEntity createEmptyEntity() {\n\t\treturn new HttpMessageEntity(EntityType.ENTITY_NONE, null, \"\", new byte[0], null);\n\t}\n\t\n\tprivate static HttpMessageEntity createImageEntity(HttpEntity entity, byte[] imageBytes, ImageData imageData) {\n\t\treturn new HttpMessageEntity(EntityType.ENTITY_IMAGE, entity, \"\", imageBytes, imageData);\n\t}\n\t\n\tprivate static HttpMessageEntity createBinaryEntity(HttpEntity entity, byte[] data) {\n\t\treturn new HttpMessageEntity(EntityType.ENTITY_BINARY, entity, \"\", data, null);\n\t}\n\t\n\tprivate static HttpMessageEntity createAsciiEntity(HttpEntity entity, String text) {\n\t\treturn new HttpMessageEntity(EntityType.ENTITY_ASCII, entity, text, new byte[0], null);\n\t}\n\t\n    enum EntityType { ENTITY_NONE, ENTITY_IMAGE, ENTITY_BINARY, ENTITY_ASCII };\n\n\tprivate final HttpEntity entity;\n\tprivate final EntityType entityType;\n\tprivate final ImageData entityImage;\n\tprivate final String entityText;\n\tprivate final byte[] entityBytes;\n\tprivate final String contentType;\n\tprivate final String contentEncoding;\n\t\t\n\tprivate HttpMessageEntity(EntityType type, HttpEntity entity, String text, byte[] data, ImageData image) {\n\t\tthis.entityType = type;\n\t\tthis.entity = entity;\n\t\tthis.entityText = text;\n\t\tthis.entityBytes = data;\n\t\tthis.entityImage = image;\n\t\tthis.contentType = getContentType(entity);\n\t\tthis.contentEncoding = getContentEncoding(entity);\n\t}\n\n\tpublic String getContentType() {\n\t\treturn contentType;\n\t}\n\n\tpublic String getContentEncoding() {\n\t\treturn contentEncoding;\n\t}\n\n\tprivate String getContentType(HttpEntity entity) {\n\t\tif(entity == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\treturn getHeaderValue(entity.getContentType());\n\t}\n\t\n\t\n\tprivate String getContentEncoding(HttpEntity entity) {\n\t\tif(entity == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\treturn getHeaderValue(entity.getContentEncoding());\n\t}\n\t\n\tpublic HttpEntity getEntity() {\n\t\treturn entity;\n\t}\n\n\tprivate String getHeaderValue(Header header) {\n\t\tif(header == null || header.getValue() == null) {\n\t\t\treturn \"\";\n\t\t}\n\t\treturn header.getValue();\n\t}\n\t\n\tpublic boolean isEmptyEntity() {\n\t\treturn entityType == EntityType.ENTITY_NONE;\n\t}\n\t\n\tpublic boolean isImageEntity() {\n\t\treturn entityType == EntityType.ENTITY_IMAGE;\n\t}\n\t\n\tpublic boolean isBinaryEntity() {\n\t\treturn entityType == EntityType.ENTITY_BINARY;\n\t}\n\t\n\tpublic boolean isAsciiEntity() {\n\t\treturn entityType == EntityType.ENTITY_ASCII;\n\t}\n\t\n\tpublic ImageData getImageData() {\n\t\treturn entityImage;\n\t}\n\t\n\tpublic byte[] getBinaryData() {\n\t\treturn entityBytes;\n\t}\n\t\n\tpublic String getTextData() {\n\t\treturn entityText;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/ITextEntityRenderer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.presentation.PresentationReconciler;\nimport org.eclipse.jface.text.rules.IPredicateRule;\n\npublic interface ITextEntityRenderer {\n\tList<String> getPartitionTypes();\n\tboolean matchContentType(String contentType);\n\tvoid addPartitionScannerRules(List<IPredicateRule> rules);\n\tString getDefaultPartitionType();\n\tvoid configurePresentationReconciler(PresentationReconciler reconciler, Colors colors);\n\tString formatText(String input);\n\tString getLineSplitChars();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/ProjectionAnnotationAccess.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor;\n\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.jface.text.source.IAnnotationAccess;\nimport org.eclipse.jface.text.source.IAnnotationAccessExtension;\nimport org.eclipse.jface.text.source.IAnnotationPresentation;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.widgets.Canvas;\n\npublic class ProjectionAnnotationAccess implements IAnnotationAccess, IAnnotationAccessExtension {\n\n\t@Override\n\tpublic String getTypeLabel(Annotation annotation) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic int getLayer(Annotation annotation) {\n\t\treturn IAnnotationPresentation.DEFAULT_LAYER; \n\t}\n\n\t@Override\n\tpublic void paint(Annotation annotation, GC gc, Canvas canvas,\n\t\t\tRectangle bounds) {\n\t\tif(annotation instanceof IAnnotationPresentation) {\n\t\t\t((IAnnotationPresentation)annotation).paint(gc, canvas, bounds);\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isPaintable(Annotation annotation) {\n\t\treturn (annotation instanceof IAnnotationPresentation);\n\t}\n\n\t@Override\n\tpublic boolean isSubtype(Object annotationType, Object potentialSupertype) {\n\t\tif(annotationType == null || potentialSupertype == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn annotationType.toString().equals(potentialSupertype.toString());\n\t}\n\n\t@Override\n\tpublic Object[] getSupertypes(Object annotationType) {\n\t\treturn new Object[0];\n\t}\n\n\t@Override\n\tpublic Object getType(Annotation annotation) {\n\t\treturn annotation.getType();\n\t}\n\n\t@Override\n\tpublic boolean isMultiLine(Annotation annotation) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean isTemporary(Annotation annotation) {\n\t\treturn !annotation.isPersistent();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/TextViewerAction.java",
    "content": "package com.subgraph.vega.ui.httpeditor;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.jface.text.ITextOperationTarget;\nimport org.eclipse.jface.text.ITextViewer;\n\npublic class TextViewerAction extends Action {\n\tprivate final int operationCode;\n\tprivate final ITextOperationTarget operationTarget;\n\t\n\tTextViewerAction(ITextViewer viewer, int operationCode) {\n\t\tthis.operationCode = operationCode;\n\t\tthis.operationTarget = viewer.getTextOperationTarget();\n\t\t\n\t}\n\t\n\tpublic void run() {\n\t\tif(operationTarget != null) {\n\t\t\toperationTarget.doOperation(operationCode);\n\t\t}\n\t}\n\t\n\tpublic void update() {\n\t\tfinal boolean wasEnabled = isEnabled();\n\t\tfinal boolean isEnabled = (operationTarget != null && operationTarget.canDoOperation(operationCode));\n\t\tsetEnabled(isEnabled);\n\t\tif(wasEnabled != isEnabled) {\n\t\t\tfirePropertyChange(ENABLED, wasEnabled, isEnabled);\n\t\t}\n\t}\n\t\n\tvoid configureAction(String text, String tooltipText, String description) {\n\t\tsetText(text);\n\t\tsetToolTipText(tooltipText);\n\t\tsetDescription(description);\n\t}\n\t\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/annotations/AnnTransaction.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.annotations;\n\nimport java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.eclipse.jface.text.Position;\n\npublic class AnnTransaction\n{\n   private Map<ISelfDrawingAnnotation, Position> toAdd = new HashMap<ISelfDrawingAnnotation, Position>();\n \n   private List<ISelfDrawingAnnotation> toRemove = new LinkedList<ISelfDrawingAnnotation>();\n \n   public void add(ISelfDrawingAnnotation a, Position p) {\n     this.toAdd.put(a, p);\n   }\n \n   public void remove(ISelfDrawingAnnotation a) {\n     this.toRemove.add(a);\n   }\n \n   @SuppressWarnings(\"deprecation\")\n   public void replaceAnnotations(AnnotationPainter painter) {\n     ISelfDrawingAnnotation[] toRemoveArray = \n       new ISelfDrawingAnnotation[this.toRemove.size()];\n \n     for (int i = 0; i < toRemoveArray.length; i++) {\n       toRemoveArray[i] = ((ISelfDrawingAnnotation)this.toRemove.get(i));\n     }\n     painter.replaceAnnotations(toRemoveArray, this.toAdd);\n   }\n }\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/annotations/AnnotationPainter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.annotations;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Iterator;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\n\nimport org.eclipse.jface.text.IPaintPositionManager;\nimport org.eclipse.jface.text.IPainter;\nimport org.eclipse.jface.text.IRegion;\nimport org.eclipse.jface.text.ITextSelection;\nimport org.eclipse.jface.text.Position;\nimport org.eclipse.jface.text.Region;\nimport org.eclipse.jface.text.source.SourceViewer;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.ISelectionProvider;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.swt.events.PaintEvent;\nimport org.eclipse.swt.events.PaintListener;\n\n public class AnnotationPainter\n   implements IPainter, PaintListener, ISelectionProvider\n {\n   private Set<ISelectionChangedListener> listeners = new HashSet<ISelectionChangedListener>();\n   private SourceViewer viewer;\n   private Map<ISelfDrawingAnnotation, Position> anns = new HashMap<ISelfDrawingAnnotation, Position>();\n \n   public AnnotationPainter(SourceViewer v)\n   {\n     this.viewer = v;\n     this.viewer.getTextWidget().addPaintListener(this);\n   }\n \n   public void addSelectionChangedListener(ISelectionChangedListener listener) {\n     this.listeners.add(listener);\n   }\n \n   public void removeSelectionChangedListener(ISelectionChangedListener listener) {\n     this.listeners.remove(listener);\n   }\n \n   private void fireSelectionEvent() {\n     SelectionChangedEvent e = new SelectionChangedEvent(this, getSelection());\n     for (ISelectionChangedListener l : this.listeners)\n       l.selectionChanged(e);\n   }\n \n   public Position getPosition(ISelfDrawingAnnotation annotation)\n   {\n     return (Position)this.anns.get(annotation);\n   }\n \n   /** @deprecated */\n   public void replaceAnnotations(ISelfDrawingAnnotation[] remove, Map<ISelfDrawingAnnotation, Position> add)\n   {\n     List<Position> positions = new ArrayList<Position>();\n \n     if (remove != null) {\n       for (ISelfDrawingAnnotation r : remove) {\n         Position p = (Position)this.anns.remove(r);\n         if (p != null)\n           positions.add(p);\n       }\n     }\n     if (add != null) {\n       this.anns.putAll(add);\n       positions.addAll(add.values());\n     }\n \n     fireAnnotationChangedEvent(positions);\n   }\n \n   public void replaceAnnotations(AnnTransaction trans) {\n     trans.replaceAnnotations(this);\n   }\n \n   public void addAnnotation(ISelfDrawingAnnotation a, Position p)\n   {\n     this.anns.put(a, p);\n     List<Position> positions = new ArrayList<Position>(1);\n     positions.add(p);\n     fireAnnotationChangedEvent(positions);\n   }\n \n   public void removeAnnotation(ISelfDrawingAnnotation ann)\n   {\n     Position position = (Position)this.anns.remove(ann);\n \n     if (position != null) {\n       List<Position> positions = new ArrayList<Position>(1);\n       positions.add(position);\n       fireAnnotationChangedEvent(positions);\n     }\n   }\n \n   public void removeAllAnnotations() {\n     Collection<Position> positions = new ArrayList<Position>(this.anns.values());\n     this.anns.clear();\n     fireAnnotationChangedEvent(positions);\n   }\n \n   private void fireAnnotationChangedEvent(Collection<Position> positions)\n   {\n     if (positions.isEmpty()) {\n       return;\n     }\n     int start = Integer.MAX_VALUE;\n     int end = Integer.MIN_VALUE;\n     \n \n     for (Position p : positions) {\n       if (start > p.getOffset())\n         start = p.offset;\n       int tempEnd = p.getOffset() + p.getLength();\n       if (end < tempEnd) {\n         end = tempEnd;\n       }\n     }\n     start = widgetIndex(start);\n     end = widgetIndex(end);\n     this.viewer.getTextWidget().redrawRange(start, end - start, false);\n   }\n   public void deactivate(boolean redraw) {\n   }\n   public void setPositionManager(IPaintPositionManager manager) {\n   }\n \n   public void paint(int reason) {\n     switch (reason) {\n     case IPainter.SELECTION:\n     case IPainter.TEXT_CHANGE:\n     case IPainter.KEY_STROKE:\n     case IPainter.MOUSE_BUTTON:\n       fireSelectionEvent();\n     case IPainter.KEY_STROKE | IPainter.TEXT_CHANGE:\n     }\n   }\n \n   public void dispose() {\n     refresh();\n \n     this.anns.clear();\n     paint(IPainter.INTERNAL);\n \n     this.viewer.getTextWidget().removePaintListener(this);\n     this.viewer.removePainter(this);\n   }\n \n   public void paintControl(PaintEvent e)\n   {\n     for (Map.Entry<ISelfDrawingAnnotation, Position> entry : this.anns.entrySet()) {\n       ISelfDrawingAnnotation ann = (ISelfDrawingAnnotation)entry.getKey();\n       Position p = (Position)entry.getValue();\n       IRegion r = this.viewer.modelRange2WidgetRange(new Region(p.offset, p.length));\n \n       if (r != null)\n         ann.draw(e.gc, this.viewer.getTextWidget(), \n           r.getOffset(), \n           r.getLength());\n     }\n   }\n \n   private int widgetIndex(int offset) {\n     int index = this.viewer.modelOffset2WidgetOffset(offset);\n     if (index < 0)\n       index = this.viewer.getBottomIndexEndOffset();\n     return index;\n   }\n \n   public ITextSelection getSelection() {\n     return (ITextSelection)this.viewer.getSelection();\n   }\n \n   public void setSelection(ISelection selection) {\n     this.viewer.setSelection(selection);\n   }\n \n   public Iterator<ISelfDrawingAnnotation> getAnnotationIterator()\n   {\n     return this.anns.keySet().iterator();\n   }\n \n   private void refresh() {\n     fireAnnotationChangedEvent(this.anns.values());\n   }\n \n   public void refresh(Collection<ISelfDrawingAnnotation> someAnnotations) {\n     List<Position> positions = new ArrayList<Position>();\n     for (ISelfDrawingAnnotation ann : someAnnotations) {\n       positions.add((Position)this.anns.get(ann));\n     }\n     fireAnnotationChangedEvent(positions);\n   }\n }\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/annotations/EmbedAnnotation.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.annotations;\n\nimport org.eclipse.jface.text.TextViewer;\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.swt.graphics.GC;\n\npublic abstract class EmbedAnnotation extends Annotation {\n\n\tprivate final int height;\n\t\n\tprivate String cachedPaddingString;\n\t\n\tprotected EmbedAnnotation(String type, int height) {\n\t\tsuper(type, false, \"\");\n\t\tthis.height = height;\n\t\t\n\t}\n\n\tprivate String generatePaddingString(TextViewer viewer) {\n\t\tfinal GC gc = new GC(viewer.getTextWidget());\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tgc.setFont(viewer.getTextWidget().getFont());\n\t\twhile(gc.textExtent(sb.toString()).y < height) {\n\t\t\tsb.append('\\n');\n\t\t}\n\t\treturn sb.toString();\n\t}\n\t\n\tpublic String getPaddingString(TextViewer viewer) {\n\t\tif(cachedPaddingString == null) {\n\t\t\tcachedPaddingString = generatePaddingString(viewer);\n\t\t}\n\t\treturn cachedPaddingString;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/annotations/ISelfDrawingAnnotation.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.annotations;\n\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.graphics.GC;\n\npublic abstract interface ISelfDrawingAnnotation\n{\n  public abstract void draw(GC gc, StyledText textControl, int offset, int length);\n}\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/annotations/ImageAnnotation.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.annotations;\n\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\n\n\npublic class ImageAnnotation extends EmbedAnnotation implements ISelfDrawingAnnotation {\n\tpublic final static String TYPE = \"com.subgraph.vega.ui.httpviewer.annotation.image\";\n\tprivate final Image image;\n\t\n\tpublic ImageAnnotation(Image image) {\n\t\tsuper(TYPE, image.getBounds().height);\n\t\tthis.image = image;\n\t}\n\t\n\tpublic Image getImage() {\n\t\treturn image;\n\t}\n\n\t@Override\n\tpublic void draw(GC gc, StyledText textControl, int offset, int length) {\n\t\tif (gc != null) {\n\t\t\tif (image != null) {\n\t\t\t\tPoint left = textControl.getLocationAtOffset(offset);\n\t\t\t\tif (length > 0) {\n\t\t\t\t\tPoint right = textControl.getLocationAtOffset(offset + length);\n\t\t\t\t\tif (left.x > right.x) {\n\t\t\t\t\t\t// hack: sometimes linewrapping text widget gives us the wrong x/y for the first character of a line that\n\t\t\t\t\t\t// has been wrapped.\n\t\t\t\t\t\tleft.x = 0;\n\t\t\t\t\t\tleft.y = right.y;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// fill the background first so that drawing works properly when\n\t\t\t\t// the viewer itself is not redrawing and image contains semi-transparent\n\t\t\t\t// regions\n\t\t\t\tColor foreground = gc.getForeground();\n\t\t\t\tColor background = gc.getBackground();\n\t\t\t\tgc.setForeground(textControl.getBackground());\n\t\t\t\tgc.setBackground(textControl.getBackground());\n\t\t\t\tRectangle bounds = image.getBounds();\n\t\t\t\tgc.fillRectangle(new Rectangle(left.x, left.y, bounds.width, bounds.height));\n\n\t\t\t\t// now draw the image.\n\t\t\t\tgc.setForeground(foreground);\n\t\t\t\tgc.setBackground(background);\n\t\t\t\tgc.drawImage(image, left.x, left.y);\n\t\t\t}\n\t\t} else {\n\t\t\ttextControl.redrawRange(offset, length, true);\n\t\t}\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/CornerLayout.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Layout;\n\npublic class CornerLayout extends Layout {\n\n\tprivate final Composite textControl;\n\t\n\tpublic CornerLayout(StyledText textControl) {\n\t\tthis.textControl = textControl;\n\t}\n\n\t@Override\n\tprotected Point computeSize(Composite composite, int wHint, int hHint,\n\t\t\tboolean flushCache) {\n\t\tfinal Control bgControl = getBackgroundControl(composite);\n\t\tfinal Point sz = bgControl.computeSize(wHint, hHint, flushCache);\n\t\tfinal int width = getSize(sz.x, wHint);\n\t\tfinal int height = getSize(sz.y, hHint);\n\t\treturn new Point(width, height);\n\t}\n\t\n\tprivate int getSize(int sz, int szHint) {\n\t\treturn (szHint == SWT.DEFAULT) ? sz : szHint;\n\t}\n\n\t@Override\n\tprotected void layout(Composite composite, boolean flushCache) {\n\t\tfinal Control bgControl = getBackgroundControl(composite);\n\t\tfinal Rectangle area = composite.getClientArea();\n\t\tbgControl.setBounds(area);\n\t\tfor(Control c: composite.getChildren()) {\n\t\t\tif(c != bgControl) {\n\t\t\t\tplaceControl(composite, c);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void placeControl(Composite composite, Control c) {\n\t\tfinal Object ob = c.getLayoutData();\n\t\tif(!(ob instanceof CornerLayoutData)) {\n\t\t\treturn;\n\t\t}\n\t\tfinal Point pos = calculateControlPosition(composite, c, (CornerLayoutData) ob);\n\t\tc.setLocation(pos);\n\t}\n\t\n\tprivate Point calculateControlPosition(Composite composite, Control c, CornerLayoutData data) {\n\t\tfinal Rectangle area = textControl.getClientArea();\n\t\tfinal int x = getPosition(data.isLeft(), area.width, c.getSize().x);\n\t\tfinal int y = getPosition(data.isTop(), area.height, c.getSize().y);\n\t\treturn c.getDisplay().map(textControl, composite, x, y);\n\t}\n\t\n\tprivate int getPosition(boolean flag, int dimText, int dimControl) {\n\t\tif(flag || (dimText < dimControl)) {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\treturn dimText - dimControl;\n\t\t}\n\t}\n\t\n\t@Override\n\tprotected boolean flushCache(Control control) {\n\t\treturn true;\n\t}\n\n\tprivate Control getBackgroundControl(Composite composite) {\n\t\tcheckZOrder(composite);\n\t\tfinal Control[] children = composite.getChildren();\n\t\tfinal int idx = findBackgroundControlIdx(children);\n\t\treturn children[idx];\n\t}\n\n\tprivate void checkZOrder(Composite composite) {\n\t\tfinal Control[] children = composite.getChildren();\n\t\tfinal int backgroundIdx = findBackgroundControlIdx(children);\n\t\tif(backgroundIdx != children.length - 1) {\n\t\t\tchildren[backgroundIdx].moveBelow(null);\n\t\t}\n\t}\n\t\n\tprivate int findBackgroundControlIdx(Control[] children) {\n\t\tint backgroundIdx = -1;\n\t\tfor(int i = 0; i < children.length; i++) {\n\t\t\tif(!(children[i].getLayoutData() instanceof CornerLayoutData)) {\n\t\t\t\tif(backgroundIdx >= 0) {\n\t\t\t\t\tthrow new IllegalStateException(\"All children of composite managed by CornerLayout must have CornerLayoutData except background control\");\n\t\t\t\t}\n\t\t\t\tbackgroundIdx = i;\n\t\t\t}\n\t\t}\n\t\tif(backgroundIdx < 0) {\n\t\t\tthrow new IllegalStateException(\"Could not find background control\");\n\t\t}\n\t\treturn backgroundIdx;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/CornerLayoutData.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\npublic class CornerLayoutData {\n\t\n\tpublic static CornerLayoutData createTopLeft() {\n\t\treturn new CornerLayoutData(true, true);\n\t}\n\t\n\tpublic static CornerLayoutData createTopRight() {\n\t\treturn new CornerLayoutData(true, false);\n\t}\n\t\n\tpublic static CornerLayoutData createBottomLeft() {\n\t\treturn new CornerLayoutData(false, true);\n\t}\n\t\n\tpublic static CornerLayoutData createBottomRight() {\n\t\treturn new CornerLayoutData(false, false);\n\t}\n\t\n\tprivate final boolean isTop;\n\tprivate final boolean isLeft;\n\t\n\tprivate CornerLayoutData(boolean isTop, boolean isLeft) {\n\t\tthis.isTop = isTop;\n\t\tthis.isLeft = isLeft;\n\t}\n\t\n\tpublic boolean isTop() {\n\t\treturn isTop;\n\t}\n\t\n\tpublic boolean isLeft() {\n\t\treturn isLeft;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/HighlightBar.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\nimport java.util.Collection;\n\nimport org.eclipse.jface.text.source.projection.ProjectionViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Layout;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlertHighlight;\nimport com.subgraph.vega.ui.httpeditor.Colors;\n\npublic class HighlightBar extends Composite implements MatchChangeListener {\n\tprivate final static String ANNOTATION_HIGHLIGHT = \"httpeditor.highlight\";\n\tprivate final MatchHighlighter highlighter;\n\tprivate final Label alertLabel;\n\tprivate final NavigationButtons buttons;\n\t\n\tpublic HighlightBar(Composite parent, ProjectionViewer viewer, Colors colors) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(createLayout());\n\t\tfinal Color c = colors.get(Colors.ALERT_HIGHLIGHT);\n\t\tsetBackground(c);\n\t\thighlighter = new MatchHighlighter(viewer, c, ANNOTATION_HIGHLIGHT, false);\n\t\talertLabel = createAlertLabel(c);\n\t\tbuttons = new NavigationButtons(this, highlighter, this);\n\t\tbuttons.setBackground(c);\n\t\tpack();\n\t\thideHighlightBar();\n\t}\n\n\tprivate Layout createLayout() {\n\t\tfinal GridLayout layout = new GridLayout(2, false);\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\treturn layout;\n\t}\n\n\tprivate Label createAlertLabel(Color color) {\n\t\tfinal Label label = new Label(this, SWT.SHADOW_IN | SWT.CENTER);\n\t\tlabel.setBackground(color);\n\t\tGridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, true);\n\t\tgd.widthHint = 150;\n\t\tlabel.setLayoutData(gd);\n\t\treturn label;\n\t}\n\t\n\tpublic void clearHighlights() {\n\t\thighlighter.clearMatches();\n\t\thideHighlightBar();\n\t\talertLabel.setText(\"\");\n\t}\n\t\n\tpublic void addAlertHighlights(Collection<IScanAlertHighlight> highlights) {\n\t\tfor(IScanAlertHighlight h: highlights) {\n\t\t\thighlighter.searchMatches(h.getMatchString(), h.isRegularExpression(), h.isCaseSensitive());\n\t\t}\n\t}\n\t\n\tpublic void displayHighlights() {\n\t\tif(highlighter.isActive() && highlighter.getMatchCount() != 0) {\n\t\t\thighlighter.displayFirstMatch();\n\t\t\tif(highlighter.getMatchCount() > 1) {\n\t\t\t\tdisplayHighlightBar();\n\t\t\t\tbuttons.enableButtonsForMatchState();\n\t\t\t\tsummarizeMatchState();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void summarizeMatchState() {\n\t\tif(!highlighter.isActive() || highlighter.getMatchCount() <= 1) {\n\t\t\talertLabel.setText(\"\");\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal int current = highlighter.getCurrentIndex() + 1;\n\t\tfinal int count = highlighter.getMatchCount();\n\t\talertLabel.setText(\"\"+ current +\" of \"+ count +\" highlights\");\n\t}\n\n\n\tprivate void displayHighlightBar() {\n\t\tsetVisible(true);\n\t\tpack();\n\t\tgetParent().layout(true);\n\t}\n\t\n\tprivate void hideHighlightBar() {\n\t\tsetVisible(false);\n\t\tgetParent().layout(true);\n\t}\n\n\t@Override\n\tpublic void matchChanged() {\n\t\tsummarizeMatchState();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/MatchChangeListener.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\npublic interface MatchChangeListener {\n\tvoid matchChanged();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/MatchHighlighter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.eclipse.jface.text.BadLocationException;\nimport org.eclipse.jface.text.FindReplaceDocumentAdapter;\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.IRegion;\nimport org.eclipse.jface.text.ITextInputListener;\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.jface.text.source.AnnotationPainter;\nimport org.eclipse.jface.text.source.IAnnotationAccess;\nimport org.eclipse.jface.text.source.SourceViewer;\nimport org.eclipse.jface.text.source.projection.ProjectionViewer;\nimport org.eclipse.swt.graphics.Color;\n\npublic class MatchHighlighter implements ITextInputListener {\n\t\n\tprivate final ProjectionViewer viewer;\n\tprivate final boolean isDisplaySingleMatch;\n\t\n\tprivate final MatchingRegions matchingRegions;\n\tprivate RegionInfo currentRegion;\n\tprivate boolean areAnnotationsAdded;\n\tprivate boolean isActive;\n\t\n\tpublic MatchHighlighter(ProjectionViewer viewer, Color highlightColor, String annotationType, boolean displaySingle) {\n\t\tthis.viewer = viewer;\n\t\tthis.isDisplaySingleMatch = displaySingle;\n\t\tthis.matchingRegions = new MatchingRegions(annotationType);\n\t\tconfigureViewer(viewer, highlightColor, annotationType);\n\t}\n\n\tpublic boolean isActive() {\n\t\treturn isActive;\n\t}\n\t\n\tpublic int getMatchCount() {\n\t\treturn matchingRegions.getMatchCount();\n\t}\n\t\n\tpublic int getCurrentIndex() {\n\t\treturn matchingRegions.getCurrentIndex();\n\t}\n\t\n\tpublic void displayFirstMatch() {\n\t\tif(matchingRegions.getMatchCount() == 0) {\n\t\t\treturn;\n\t\t}\n\t\tmaybeDisplayAllAnnotations();\n\t\tmaybeHideAnnotation();\n\t\tcurrentRegion = matchingRegions.getFirstRegion();\n\t\tmaybeDisplayAnnotation();\n\t\trevealDocumentRegion(currentRegion.getRegion());\n\t}\n\t\n\tpublic void displayNextMatch() {\n\t\tif(!matchingRegions.hasNext()) {\n\t\t\treturn;\n\t\t}\n\t\tmaybeHideAnnotation();\n\t\tcurrentRegion = matchingRegions.getNextRegion();\n\t\tmaybeDisplayAnnotation();\n\t\trevealDocumentRegion(currentRegion.getRegion());\n\t}\n\t\n\tpublic void displayPreviousMatch() {\n\t\tif(!matchingRegions.hasPrevious()) {\n\t\t\treturn;\n\t\t}\n\t\tmaybeHideAnnotation();\n\t\tcurrentRegion = matchingRegions.getPreviousRegion();\n\t\tmaybeDisplayAnnotation();\n\t\trevealDocumentRegion(currentRegion.getRegion());\n\t}\n\t\n\tpublic void clearMatches() {\n\t\tfor(RegionInfo regionInfo: matchingRegions.getAllRegions()) {\n\t\t\tregionInfo.removeHighlight(viewer);\n\t\t}\n\t\tmatchingRegions.reset();\n\t\tcurrentRegion = null;\n\t\tareAnnotationsAdded = false;\n\t\tisActive = false;\n\t}\n\t\n\tpublic void searchMatches(String query, boolean isRegex, boolean isCaseSensitive) {\n\t\tmatchingRegions.addRegions( findAllMatches(query, isRegex, isCaseSensitive) );\n\t\tisActive = true;\n\t}\n\t\n\tpublic boolean hasNextMatch() {\n\t\treturn matchingRegions.hasNext();\n\t}\n\t\n\tpublic boolean hasPreviousMatch() {\n\t\treturn matchingRegions.hasPrevious();\n\t}\n\n\tprivate void maybeDisplayAllAnnotations() {\n\t\tif(!isDisplaySingleMatch && !areAnnotationsAdded) {\n\t\t\tfor(RegionInfo regionInfo: matchingRegions.getAllRegions()) {\n\t\t\t\tregionInfo.displayHighlight(viewer);\n\t\t\t}\n\t\t\tareAnnotationsAdded = true;\n\t\t}\n\t}\n\t\n\tprivate void maybeHideAnnotation() {\n\t\tif(isDisplaySingleMatch && currentRegion != null) {\n\t\t\tcurrentRegion.removeHighlight(viewer);\n\t\t}\n\t}\n\t\n\tprivate void maybeDisplayAnnotation() {\n\t\tif(isDisplaySingleMatch && currentRegion != null) {\n\t\t\tcurrentRegion.displayHighlight(viewer);\n\t\t}\n\t}\n\t\n\tprivate void revealDocumentRegion(IRegion r) {\n\t\tviewer.revealRange(r.getOffset(), r.getLength());\n\t}\n\n\tprivate void configureViewer(SourceViewer viewer, Color highlightColor, String annotationType) {\n\t\tviewer.addTextInputListener(this);\n\t\tattachHighlightPainter(viewer, highlightColor, annotationType);\n\t}\n\t\n\tprivate void attachHighlightPainter(SourceViewer viewer, Color highlightColor, String annotationType) {\n\t\tfinal AnnotationPainter painter = new AnnotationPainter(viewer, createAnnotationAccess());\n\t\tpainter.addHighlightAnnotationType(annotationType);\n\t\tpainter.setAnnotationTypeColor(annotationType, highlightColor);\n\t\tviewer.addPainter(painter);\n\t\tviewer.addTextPresentationListener(painter);\n\t}\n\t\n\tprivate IAnnotationAccess createAnnotationAccess() {\n\t\treturn new IAnnotationAccess() {\n\t\t\t@Override\n\t\t\tpublic boolean isTemporary(Annotation annotation) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic boolean isMultiLine(Annotation annotation) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic Object getType(Annotation annotation) {\n\t\t\t\treturn annotation.getType();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate List<IRegion> findAllMatches(String query, boolean isRegex, boolean caseSensitive) {\n\t\tfinal IDocument document = viewer.getDocument();\n\t\tif(query.isEmpty() || document == null) {\n\t\t\treturn Collections.emptyList();\n\t\t}\n\t\tfinal FindReplaceDocumentAdapter search = new FindReplaceDocumentAdapter(document);\n\t\tfinal ArrayList<IRegion> results = new ArrayList<IRegion>();\n\t\tint offset = 0;\n\t\twhile(true) {\n\t\t\tif(offset >= document.getLength()) {\n\t\t\t\treturn results;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tIRegion match = search.find(offset, query, true, caseSensitive, false, isRegex);\n\t\t\t\tif(match == null) {\n\t\t\t\t\treturn results;\n\t\t\t\t}\n\t\t\t\tresults.add(match);\n\t\t\t\toffset = match.getOffset() + match.getLength();\n\t\t\t} catch (BadLocationException e) {\n\t\t\t\tthrow new RuntimeException(\"Bad location while performing search\");\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic void inputDocumentAboutToBeChanged(IDocument oldInput,\n\t\t\tIDocument newInput) {\n\t\tclearMatches();\n\t}\n\n\t@Override\n\tpublic void inputDocumentChanged(IDocument oldInput, IDocument newInput) {\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/MatchingRegions.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\nimport java.util.SortedSet;\nimport java.util.TreeSet;\n\nimport org.eclipse.jface.text.IRegion;\n\npublic class MatchingRegions {\n\n\tprivate final String annotationType;\n\tprivate final SortedSet<IRegion> regionsMatched;\n\tprivate final List<RegionInfo> regionInfo;\n\tprivate int currentIndex;\n\tprivate boolean isLocked;\n\t\n\tpublic MatchingRegions(String annotationType) {\n\t\tthis.annotationType = annotationType;\n\t\tthis.regionsMatched = new TreeSet<IRegion>(createRegionComparator());\n\t\tthis.regionInfo = new ArrayList<RegionInfo>();\n\t\treset();\n\t}\n\t\n\tprivate Comparator<IRegion> createRegionComparator() {\n\t\treturn new Comparator<IRegion>() {\n\t\t\t@Override\n\t\t\tpublic int compare(IRegion r1, IRegion r2) {\n\t\t\t\tif(r1.getOffset() == r2.getOffset() && r1.getLength() == r2.getLength()) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\t// If offsets are the same, the shorter region is 'lower'\n\t\t\t\tif(r1.getOffset() == r2.getOffset()) {\n\t\t\t\t\tif(r1.getLength() < r2.getLength()) {\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Otherwise the lower region is the one that begins at the lower offset\n\t\t\t\tif(r1.getOffset() < r2.getOffset()) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tpublic void reset() {\n\t\tregionsMatched.clear();\n\t\tregionInfo.clear();\n\t\tcurrentIndex = 0;\n\t\tisLocked = false;\n\t}\n\n\tpublic List<RegionInfo> getAllRegions() {\n\t\tlockRegions();\n\t\treturn Collections.unmodifiableList(regionInfo);\n\t}\n\t\n\tprivate void lockRegions() {\n\t\tif(isLocked) {\n\t\t\treturn;\n\t\t}\n\t\tisLocked = true;\n\t\tfor(IRegion r: regionsMatched) {\n\t\t\tregionInfo.add(new RegionInfo(r, annotationType));\n\t\t}\n\t}\n\n\tpublic void addRegions(List<IRegion> matches) {\n\t\tif(isLocked) {\n\t\t\tthrow new IllegalStateException(\"Cannot add items to locked matching regions\");\n\t\t}\n\t\tregionsMatched.addAll(matches);\n\t}\n\t\n\tpublic int getCurrentIndex() {\n\t\treturn currentIndex;\n\t}\n\t\n\tpublic int getMatchCount() {\n\t\tlockRegions();\n\t\treturn regionInfo.size();\n\t}\n\t\n\tpublic boolean hasPrevious() {\n\t\tlockRegions();\n\t\treturn currentIndex > 0;\n\t}\n\t\n\tpublic boolean hasNext() {\n\t\tlockRegions();\n\t\treturn regionInfo.size() > (currentIndex + 1);\n\t}\n\t\n\tpublic RegionInfo getFirstRegion() {\n\t\tlockRegions();\n\t\tif(regionInfo.isEmpty()) {\n\t\t\tthrow new RuntimeException(\"Trying to get first match on empty set\");\n\t\t}\n\t\tcurrentIndex = 0;\n\t\treturn regionInfo.get(0);\n\t}\n\t\n\tpublic RegionInfo getNextRegion() {\n\t\tlockRegions();\n\t\tif(!hasNext()) {\n\t\t\tthrow new RuntimeException(\"No next region\");\n\t\t}\n\t\tcurrentIndex += 1;\n\t\treturn regionInfo.get(currentIndex);\n\t}\n\t\n\tpublic RegionInfo getPreviousRegion() {\n\t\tlockRegions();\n\t\tif(!hasPrevious()) {\n\t\t\tthrow new RuntimeException(\"No previous highlight\");\n\t\t}\n\t\tcurrentIndex -= 1;\n\t\treturn regionInfo.get(currentIndex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/NavigationButtons.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Listener;\n\npublic class NavigationButtons extends Composite {\n\n\tprivate final MatchHighlighter highlighter;\n\tprivate final MatchChangeListener listener;\n\tprivate final Button nextMatch;\n\tprivate final Button previousMatch;\n\t\n\tpublic NavigationButtons(Composite parent, MatchHighlighter highlighter, MatchChangeListener listener) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new RowLayout(SWT.HORIZONTAL));\n\t\tthis.highlighter = highlighter;\n\t\tthis.listener = listener;\n\t\tthis.nextMatch = createNextMatchButton();\n\t\tthis.previousMatch = createPreviousMatchButton();\n\t\tpack();\n\t}\n\t\n\tprivate Button createNextMatchButton() {\n\t\treturn createArrowButton(SWT.DOWN, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\thandleNextMatch();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate Button createPreviousMatchButton() {\n\t\treturn createArrowButton(SWT.UP, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\thandlePreviousMatch();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate Button createArrowButton(int flags, Listener listener) {\n\t\tfinal Button b = new Button(this, SWT.ARROW | flags);\n\t\tb.addListener(SWT.Selection, listener);\n\t\tb.setEnabled(false);\n\t\treturn b;\n\t}\n\n\tpublic void handleNextMatch() {\n\t\tif(highlighter.isActive() && highlighter.hasNextMatch()) {\n\t\t\thighlighter.displayNextMatch();\n\t\t}\n\t\tenableButtonsForMatchState();\n\t\tlistener.matchChanged();\n\t}\n\n\tpublic void handlePreviousMatch() {\n\t\tif(highlighter.isActive() && highlighter.hasPreviousMatch()) {\n\t\t\thighlighter.displayPreviousMatch();\n\t\t}\n\t\tenableButtonsForMatchState();\n\t\tlistener.matchChanged();\n\t}\n\n\tpublic void enableButtonsForMatchState() {\n\t\tif(nextMatch.isDisposed() || previousMatch.isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(!highlighter.isActive()) {\n\t\t\tnextMatch.setEnabled(false);\n\t\t\tpreviousMatch.setEnabled(false);\n\t\t\treturn;\n\t\t}\n\t\tnextMatch.setEnabled(highlighter.hasNextMatch());\n\t\tpreviousMatch.setEnabled(highlighter.hasPreviousMatch());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/highlights/RegionInfo.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.highlights;\n\nimport org.eclipse.jface.text.IRegion;\nimport org.eclipse.jface.text.Position;\nimport org.eclipse.jface.text.source.Annotation;\nimport org.eclipse.jface.text.source.IAnnotationModel;\nimport org.eclipse.jface.text.source.SourceViewer;\nimport org.eclipse.jface.text.source.projection.ProjectionViewer;\n\npublic class RegionInfo {\n\tprivate final IRegion region;\n\tprivate final Position position;\n\tprivate final Annotation annotation;\n\t\n\tprivate boolean isAnnotationDisplayed;\n\t\n\tRegionInfo(IRegion region, String annotationType) {\n\t\tthis.region = region;\n\t\tthis.position = new Position(region.getOffset(), region.getLength());\n\t\tthis.annotation = new Annotation(annotationType, false, \"\");\n\t}\n\t\n\tIRegion getRegion() {\n\t\treturn region;\n\t}\n\t\n\tvoid removeHighlight(SourceViewer viewer) {\n\t\tif(!isAnnotationDisplayed) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IAnnotationModel model = viewer.getAnnotationModel();\n\t\tif(model != null) {\n\t\t\tmodel.removeAnnotation(annotation);\n\t\t\tisAnnotationDisplayed = false;\n\t\t}\n\t}\n\t\n\tvoid displayHighlight(SourceViewer viewer) {\n\t\tif(isAnnotationDisplayed) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IAnnotationModel model = viewer.getAnnotationModel();\n\t\tif(model != null) {\n\t\t\tif(viewer instanceof ProjectionViewer) {\n\t\t\t\t((ProjectionViewer)viewer).getProjectionAnnotationModel().expandAll(region.getOffset(), region.getLength());\n\t\t\t}\n\t\t\tmodel.addAnnotation(annotation, position);\n\t\t\tisAnnotationDisplayed = true;\n\t\t}\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/html/HtmlPartitionScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.html;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.MultiLineRule;\nimport org.eclipse.jface.text.rules.RuleBasedPartitionScanner;\nimport org.eclipse.jface.text.rules.Token;\n\npublic class HtmlPartitionScanner extends RuleBasedPartitionScanner {\n\tpublic final static String HTML_COMMENT = \"html_comment\";\n\tpublic final static String HTML_DOCTYPE = \"html_doctype\";\n\tpublic final static String HTML_START_TAG = \"html_start_tag\";\n\tpublic final static String HTML_END_TAG = \"html_end_tag\";\n\tpublic final static String[] HTML_TYPES = {\n\t\tHTML_COMMENT, HTML_DOCTYPE, HTML_START_TAG, HTML_END_TAG\n\t};\n\t\n\tpublic HtmlPartitionScanner() {\n\t\tfinal List<IPredicateRule> rules = new ArrayList<IPredicateRule>();\n\t\trules.add(new MultiLineRule(\"<!--\", \"-->\", new Token(HTML_COMMENT)));\n\t\trules.add(new MultiLineRule(\"</\", \">\", new Token(HTML_END_TAG)));\n\t\tIToken startTagToken = new Token(HTML_START_TAG);\n\t\trules.add(new StartTagRule(startTagToken));\n\t\trules.add(new StartTagRule(startTagToken));\n\t\trules.add(new MultiLineRule(\"<!DOCTYPE\", \">\", new Token(HTML_DOCTYPE)));\n\t\tfinal IPredicateRule[] rs = new IPredicateRule[rules.size()];\n\t\trules.toArray(rs);\n\t\tsetPredicateRules(rs);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/html/HtmlTextEntityRenderer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.html;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.TextAttribute;\nimport org.eclipse.jface.text.presentation.PresentationReconciler;\nimport org.eclipse.jface.text.rules.BufferedRuleBasedScanner;\nimport org.eclipse.jface.text.rules.DefaultDamagerRepairer;\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.ITokenScanner;\nimport org.eclipse.jface.text.rules.MultiLineRule;\nimport org.eclipse.jface.text.rules.Token;\nimport org.eclipse.swt.graphics.Color;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\nimport com.subgraph.vega.ui.httpeditor.ITextEntityRenderer;\n\npublic class HtmlTextEntityRenderer implements ITextEntityRenderer {\n\tpublic final static String HTML_COMMENT = \"html_comment\";\n\tpublic final static String HTML_DOCTYPE = \"html_doctype\";\n\tpublic final static String HTML_START_TAG = \"html_start_tag\";\n\tpublic final static String HTML_END_TAG = \"html_end_tag\";\n\t\n\tpublic final static String[] HTML_TYPES = {\n\t\tHTML_COMMENT, HTML_DOCTYPE, HTML_START_TAG, HTML_END_TAG\n\t};\n\n\t@Override\n\tpublic List<String> getPartitionTypes() {\n\t\treturn Arrays.asList(HTML_TYPES);\n\t}\n\n\t@Override\n\tpublic boolean matchContentType(String contentType) {\n\t\treturn contentType.contains(\"html\");\n\t}\n\n\t@Override\n\tpublic void addPartitionScannerRules(List<IPredicateRule> rules) {\n\t\trules.add(new MultiLineRule(\"<!--\", \"-->\", new Token(HTML_COMMENT)));\n\t\trules.add(new MultiLineRule(\"</\", \">\", new Token(HTML_END_TAG)));\n\t\tfinal IToken startTagToken = new Token(HTML_START_TAG);\n\t\trules.add(new StartTagRule(startTagToken));\n\t\trules.add(new StartTagRule(startTagToken));\n\t\trules.add(new MultiLineRule(\"<!DOCTYPE\", \">\", new Token(HTML_DOCTYPE)));\n\t}\n\n\t@Override\n\tpublic void configurePresentationReconciler(\n\t\tPresentationReconciler reconciler, Colors colors) {\n\t\taddDamagerRepairer(reconciler, new TagScanner(colors), HtmlPartitionScanner.HTML_START_TAG);\n\t\taddDamagerRepairer(reconciler, new TagScanner(colors), HtmlPartitionScanner.HTML_END_TAG);\n\t\taddDamagerRepairer(reconciler, colors.get(Colors.MULTI_LINE_COMMENT), HtmlPartitionScanner.HTML_COMMENT);\n\t\taddDamagerRepairer(reconciler, colors.get(Colors.MULTI_LINE_COMMENT), HtmlPartitionScanner.HTML_DOCTYPE);\n\t\taddDamagerRepairer(reconciler, colors.get(Colors.OTHER), IDocument.DEFAULT_CONTENT_TYPE);\n\t}\n\t\t\n\tstatic class SingleTokenScanner extends BufferedRuleBasedScanner {\n\t\tpublic SingleTokenScanner(TextAttribute attribute) {\n\t\t\tsetDefaultReturnToken(new Token(attribute));\n\t\t}\n\t}\n\n\tprivate void addDamagerRepairer(PresentationReconciler pr, Color color, String type) {\n\t\tfinal TextAttribute ta = new TextAttribute(color);\n\t\taddDamagerRepairer(pr, new SingleTokenScanner(ta), type);\n\t}\n\t\n\tprivate void addDamagerRepairer(PresentationReconciler pr, ITokenScanner scanner, String type) {\n\t\tfinal DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);\n\t\tpr.setDamager(dr, type);\n\t\tpr.setRepairer(dr, type);\n\t}\n\n\t@Override\n\tpublic String formatText(String input) {\n\t\treturn input;\n\t}\n\n\t@Override\n\tpublic String getLineSplitChars() {\n\t\treturn \">,\";\n\t}\n\n\t@Override\n\tpublic String getDefaultPartitionType() {\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/html/HtmlWhitespaceDetector.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.html;\n\nimport org.eclipse.jface.text.rules.IWhitespaceDetector;\n\npublic class HtmlWhitespaceDetector implements IWhitespaceDetector {\n\n\t@Override\n\tpublic boolean isWhitespace(char c) {\n\t\treturn c == ' ' || c == '\\t' || c == '\\n' || c == '\\r';\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/html/StartTagRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.html;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.MultiLineRule;\n\npublic class StartTagRule extends MultiLineRule {\n\n\tpublic StartTagRule(IToken token) {\n\t\tthis(token, false);\n\t}\n\n\tprotected StartTagRule(IToken token, boolean endAsWell) {\n\t\tsuper(\"<\", endAsWell ? \"/>\" : \">\", token);\n\t}\n\n\tprotected boolean sequenceDetected(ICharacterScanner scanner,\n\t\t\tchar[] sequence, boolean eofAllowed) {\n\t\tint c = scanner.read();\n\t\tif (sequence[0] == '<') {\n\t\t\tif (c == '?') {\n\t\t\t\t// processing instruction - abort\n\t\t\t\tscanner.unread();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (c == '!') {\n\t\t\t\tscanner.unread();\n\t\t\t\t// comment - abort\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (sequence[0] == '>') {\n\t\t\tscanner.unread();\n\t\t}\n\t\treturn super.sequenceDetected(scanner, sequence, eofAllowed);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/html/TagScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.html;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.IWordDetector;\nimport org.eclipse.jface.text.rules.SingleLineRule;\nimport org.eclipse.jface.text.rules.WhitespaceRule;\nimport org.eclipse.jface.text.rules.WordRule;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\nimport com.subgraph.vega.ui.httpeditor.http.AbstractScanner;\n\npublic class TagScanner extends AbstractScanner {\n\tprivate final static String[] HTML_TAGS = new String[] {\n\t\t\"a\", \"abbr\", \"acronym\", \"address\", \"area\", \"b\", \"base\", \"bdo\", \"big\",\n\t\t\"blockquote\", \"body\", \"br\", \"button\", \"caption\", \"cite\", \"code\", \"col\", \"colgroup\",\n\t\t\"dd\", \"del\", \"dfn\", \"div\", \"dl\", \"dt\", \"em\", \"fieldset\", \"form\", \"frame\", \"frameset\",\n\t\t\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\", \"tr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\", \"kbd\",\n\t\t\"label\", \"legend\", \"li\", \"link\", \"map\",\"meta\", \"noframes\", \"noscript\", \"object\", \"ol\", \"optgroup\",\n\t\t\"option\", \"p\", \"param\", \"pre\", \"q\", \"samp\", \"script\", \"select\", \"small\", \"span\", \"strong\", \"style\",\n\t\t\"sub\", \"sup\", \"table\", \"tbody\", \"td\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"title\", \"tr\", \"tt\",  \n\t\t\"ul\", \"var\"\n\t};\n\tstatic class TagWordDetector implements IWordDetector {\n\t\t@Override\n\t\tpublic boolean isWordStart(char c) {\n\t\t\treturn Character.isLetter(c);\n\t\t}\n\t\t@Override\n\t\tpublic boolean isWordPart(char c) {\n\t\t\treturn Character.isLetter(c);\n\t\t}\t\t\n\t}\n\n\tpublic TagScanner(Colors colors) {\n\t\tsuper(colors);\n\t\tsetDefaultReturnToken(createToken(Colors.TAG));\n\t}\n\n\t@Override\n\tprotected void initializeRules(List<IRule> rules) {\n\n\t\tfinal IToken string = createToken(Colors.STRING);\n\t\t\n\t\trules.add(new SingleLineRule(\"\\\"\", \"\\\"\", string, '\\\\'));\n\t\trules.add(new SingleLineRule(\"\\'\", \"\\'\", string, '\\\\'));\n\t\trules.add(new WhitespaceRule(new HtmlWhitespaceDetector()));\n\t\tfinal WordRule words = new WordRule(new TagWordDetector(), createToken(Colors.OTHER), true);\n\t\tfinal IToken tag = createToken(Colors.KEYWORD);\n\t\tfor(String s: HTML_TAGS) {\n\t\t\twords.addWord(s, tag);\n\t\t}\n\t\trules.add(words);\n\t}\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/AbstractScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.text.TextAttribute;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.RuleBasedScanner;\nimport org.eclipse.jface.text.rules.Token;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.RGB;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\n\npublic abstract class AbstractScanner extends RuleBasedScanner {\n\n\tprivate final Colors colors;\n\t\n\tprotected AbstractScanner(Colors colors) {\n\t\tthis.colors = colors;\n\t\tfinal List<IRule> rules = new ArrayList<IRule>();\n\t\tinitializeRules(rules);\n\t\tfinal IRule[] ruleArray = new IRule[rules.size()];\n\t\trules.toArray(ruleArray);\n\t\tsetRules(ruleArray);\n\t}\n\t\n\tprotected IToken createToken(RGB rgb) {\n\t\tfinal Color c = colors.get(rgb);\n\t\tfinal TextAttribute attribute = new TextAttribute(c);\n\t\treturn new Token(attribute);\n\t}\n\t\n\tabstract protected void initializeRules(List<IRule> rules);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/AbstractStartLinePartitionRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.Token;\n\nabstract class AbstractStartLinePartitionRule implements IPredicateRule {\n\t\n\tprivate final IToken token;\n\t\n\tprivate ICharacterScanner scanner;\n\t\t\n\tAbstractStartLinePartitionRule(IToken token) {\n\t\tthis.token = token;\n\t}\n\n\tprotected int nextChar() {\n\t\treturn scanner.read();\n\t}\n\t\n\tprotected void unread() {\n\t\tscanner.unread();\n\t}\n\t\n\tprotected boolean isFirstColumn() {\n\t\treturn scanner.getColumn() == 0;\n\t}\n\tprotected void unread(int n) {\n\t\tfor(int i = 0; i < n; i++) \n\t\t\tscanner.unread();\n\t}\n\t\n\tprotected boolean detectSingleSpace() {\n\t\tif(nextChar() == ' ')\n\t\t\treturn true;\n\t\tunread();\n\t\treturn false;\n\t}\n\n\tprotected String parseWord() {\n\t\treturn parseUntilSpace(true);\n\t}\n\n\tprotected String parseUntilSpace(boolean allowEOF) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tint c;\n\t\twhile((c = nextChar()) != ICharacterScanner.EOF) {\n\t\t\tif(c == '\\n' || c == '\\r' || c == ' ') {\n\t\t\t\tunread();\n\t\t\t\treturn sb.toString();\n\t\t\t} else {\n\t\t\t\tsb.append((char) c);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(allowEOF) {\n\t\t\treturn sb.toString();\n\t\t} else {\n\t\t\tunread(sb.length());\n\t\t\treturn \"\";\n\t\t}\n\t}\n\t\n\tprotected String parseUntilEOL(boolean allowEOF) {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tint c;\n\t\twhile((c = nextChar()) != ICharacterScanner.EOF) {\n\t\t\tif(c == '\\n') {\n\t\t\t\tunread();\n\t\t\t\treturn sb.toString();\n\t\t\t}\n\t\t\telse if(c == '\\r') {\n\t\t\t\tif(nextChar() == '\\n') {\n\t\t\t\t\tunread(2);\n\t\t\t\t\treturn sb.toString();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsb.append((char) c);\n\t\t\t}\n\t\t}\n\t\tif(allowEOF) {\n\t\t\treturn sb.toString();\n\t\t} else {\n\t\t\tunread(sb.length());\n\t\t\treturn \"\";\n\t\t}\n\t}\n\t\n\t/*\n\t * Matches \"\\n\" or \"\\r\\n\"\n\t */\n\tprotected boolean detectEOL() {\n\t\tfinal int c = nextChar();\n\t\tif(c == '\\n')\n\t\t\treturn true;\n\t\tif(c == '\\r') {\n\t\t\tif(nextChar() == '\\n')\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\tunread();\n\t\t}\n\t\tunread();\n\t\treturn false;\n\t}\n\t\t\n\tprotected abstract boolean doEvaluate();\n\t\t\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner) {\n\t\tif(scanner.getColumn() != 0)\n\t\t\treturn Token.UNDEFINED;\n\t\t\n\t\tthis.scanner = scanner;\n\n\t\tif(doEvaluate()) {\n\t\t\treturn token;\n\t\t} else {\n\t\t\treturn Token.UNDEFINED;\n\t\t}\n\t}\n\n\t@Override\n\tpublic IToken getSuccessToken() {\n\t\treturn token;\n\t}\n\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner, boolean resume) {\n\t\treturn evaluate(scanner);\n\t}\n\t\n\tprotected boolean isHttpVersion(String s) {\n\t\tif(s == null || !s.toUpperCase().startsWith(\"HTTP/\"))\n\t\t\treturn false;\n\t\t\n\t\treturn isVersionDigits(s.substring(5));\n\t}\n\t\n\tprivate boolean isVersionDigits(String s) {\n\t\tfinal String[] digits = s.split(\"\\\\.\");\n\t\tif(digits.length != 2)\n\t\t\treturn false;\n\t\treturn isInteger(digits[0]) && isInteger(digits[1]);\n\t}\n\t\n\tprotected boolean isInteger(String s) {\n\t\tif(s == null || s.isEmpty())\n\t\t\treturn false;\n\t\t\n\t\ttry {\n\t\t\tInteger.parseInt(s);\n\t\t\treturn true;\n\t\t} catch (NumberFormatException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/AbstractSyntaxRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.Token;\n\npublic abstract class AbstractSyntaxRule implements IRule {\n\t\n\tprivate final IToken token;\n\tprotected int readCount;\n\t\n\tprotected AbstractSyntaxRule(IToken token) {\n\t\tthis.token = token;\n\t}\n\t\n\tprotected IToken getSuccessToken() {\n\t\treturn token;\n\t}\n\t\n\tprotected abstract boolean evaluateRule(ICharacterScanner scanner);\n\t\n\tpublic IToken evaluate(ICharacterScanner scanner) {\n\t\treadCount = 0;\n\t\tif(evaluateRule(scanner))\n\t\t\treturn token;\n\t\t\n\t\trewind(scanner);\n\t\treturn Token.UNDEFINED;\n\t}\n\t\n\tprivate void rewind(ICharacterScanner scanner) {\n\t\tfor(int i = 0; i < readCount; i++)\n\t\t\tscanner.unread();\n\t}\n\t\n\tprotected boolean matchSingleChar(ICharacterScanner scanner, char ch) {\n\t\tif(scanner.read() == ch) {\n\t\t\treadCount++;\n\t\t\treturn true;\n\t\t} else {\n\t\t\tscanner.unread();\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tprotected boolean matchDigits(ICharacterScanner scanner) {\n\t\treturn matchAndCountDigits(scanner) > 0;\n\t}\n\t\n\tprotected boolean matchDigits(ICharacterScanner scanner, int count) {\n\t\treturn matchDigits(scanner, count, count);\n\t}\n\t\n\tprotected boolean matchDigits(ICharacterScanner scanner, int min, int max) {\n\t\tfinal int count = matchAndCountDigits(scanner);\n\t\treturn (count <= max && count >= min);\n\t}\n\t\n\tprotected int matchAndCountDigits(ICharacterScanner scanner) {\n\t\tint digitCount = 0;\n\t\twhile(true) {\n\t\t\tint c = scanner.read();\n\t\t\tif(isDigit(c)) {\n\t\t\t\tdigitCount++;\n\t\t\t\treadCount++;\n\t\t\t} else {\n\t\t\t\tscanner.unread();\n\t\t\t\treturn digitCount;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprotected void skipWhitespace(ICharacterScanner scanner) {\n\t\twhile(true) {\n\t\t\tint c = scanner.read();\n\t\t\tif(!isWhitespace(c)) {\n\t\t\t\tscanner.unread();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treadCount++;\n\t\t}\n\t}\n\t\n\t/* match one or more whitespace characters */\n\tprotected boolean matchWhitespace(ICharacterScanner scanner) {\n\t\tfinal int c = scanner.read(); readCount++;\n\t\tif(!isWhitespace(c)) \n\t\t\treturn false;\n\t\t\n\t\twhile(true) {\n\t\t\tif(!isWhitespace(scanner.read())) {\n\t\t\t\tscanner.unread();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treadCount++;\n\t\t}\n\t}\n\t\n\tprotected boolean isDigit(int c) {\n\t\treturn c >= '0' && c <= '9';\n\t}\n\t\n\tprotected boolean isWhitespace(int c) {\n\t\treturn c == ' ' || c == '\\n' || c == '\\r' || c =='\\t';\n\t}\n\t\n\tprotected boolean isUppercase(int c) {\n\t\treturn c >= 'A' && c <= 'Z';\n\t}\n\t\n\tprotected boolean isLowercase(int c) {\n\t\treturn c >= 'a' && c <= 'z';\n\t}\n\t\n\tprotected boolean isHexDigit(int c) {\n\t\treturn isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); \n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/DateRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport java.util.Arrays;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IToken;\n\npublic class DateRule extends AbstractSyntaxRule {\n\tprivate final String[] days = { \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\" };\n\tprivate final String[] months = { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\",\n\t\t\t\"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" };\n\t\n\tpublic DateRule(IToken token) {\n\t\tsuper(token);\n\t}\n\n\t@Override\n\tprotected boolean evaluateRule(ICharacterScanner scanner) {\n\t\t// Date: Tue, 3 Oct 1974 02:16:00 GMT\n\t\treturn \n\t\tmatchDay(scanner) &&\n\t\tmatchSingleChar(scanner, ',') &&\n\t\tmatchWhitespace(scanner)  && \n\t\tmatchDigits(scanner, 1, 2) &&\n\t\tmatchWhitespace(scanner) &&\n\t\tmatchMonth(scanner) &&\n\t\tmatchWhitespace(scanner) &&\n\t\tmatchDigits(scanner, 4)  && \n\t\tmatchWhitespace(scanner) &&\n\t\tmatchDigits(scanner, 2) &&\n\t\tmatchSingleChar(scanner, ':') &&\n\t\tmatchDigits(scanner, 2) &&\n\t\tmatchSingleChar(scanner, ':') &&\n\t\tmatchDigits(scanner, 2) &&\n\t\tmatchWhitespace(scanner) &&\n\t\tmatchGMT(scanner);  \n\t}\n\t\n\tprivate boolean matchDay(ICharacterScanner scanner) {\n\t\treturn matchStringFromList(scanner, days);\n\t}\n\t\n\tprivate boolean matchMonth(ICharacterScanner scanner) {\n\t\treturn matchStringFromList(scanner, months);\n\t}\n\t\n\tprivate boolean matchStringFromList(ICharacterScanner scanner, String[] list) {\n\t\tfinal char[] buffer = readThreeLetters(scanner);\n\t\tif(buffer == null) \n\t\t\treturn false;\n\t\t\n\t\tfor(String s : list) \n\t\t\tif(Arrays.equals(s.toCharArray(), buffer))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\t\n\tprivate boolean matchGMT(ICharacterScanner scanner) {\n\t\tint c = scanner.read(); readCount++;\n\t\tif(c != 'G') return false;\n\t\tc = scanner.read(); readCount++;\n\t\tif(c != 'M') return false;\n\t\tc = scanner.read(); readCount++;\n\t\treturn c == 'T';\n\t}\n\t\n\tprivate char[] readThreeLetters(ICharacterScanner scanner) {\n\t\tfinal char[] buffer = new char[3];\n\t\t\n\t\tint c = scanner.read(); readCount++;\n\t\tif(!isUppercase(c)) \n\t\t\treturn null;\n\t\tbuffer[0] = (char) c;\n\t\t\n\t\tc = scanner.read(); readCount++;\n\t\tif(!isLowercase(c)) \n\t\t\treturn null;\n\t\t\n\t\tbuffer[1] = (char) c;\n\t\t\n\t\tc = scanner.read(); readCount++;\n\t\tif(!isLowercase(c))\n\t\t\treturn null;\n\t\tbuffer[2] = (char) c;\n\t\treturn buffer;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/EncodedCharacterRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IToken;\n\npublic class EncodedCharacterRule extends AbstractSyntaxRule {\n\n\tpublic EncodedCharacterRule(IToken token) {\n\t\tsuper(token);\n\t}\n\n\t@Override\n\tprotected boolean evaluateRule(ICharacterScanner scanner) {\n\t\tif(!matchSingleChar(scanner, '%'))\n\t\t\treturn false;\n\t\tif(!isHexDigit(scanner.read())) {\n\t\t\tscanner.unread();\n\t\t\treturn false;\n\t\t}\n\t\tif(!isHexDigit(scanner.read())) {\n\t\t\tscanner.unread();\n\t\t\tscanner.unread();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/HeaderNameRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.Token;\n\npublic class HeaderNameRule implements IRule {\n\tprivate final static String SEPARATORS = \"()<>@,;:\\\\\\\"/[]?={} \\t\";\n\n\tprivate final IToken token;\n\t\n\tpublic HeaderNameRule(IToken token) {\n\t\tthis.token = token;\n\t}\n\t\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner) {\n\t\tif(scanner.getColumn() != 0)\n\t\t\treturn Token.UNDEFINED;\n\t\tint readCount = 1;\n\t\tint c;\n\t\twhile((c = scanner.read()) != ICharacterScanner.EOF) {\n\t\t\tif(c == ':' && readCount > 1)\n\t\t\t\treturn token;\n\t\t\tif(!isLegalHeaderNameChar(c))\n\t\t\t\tbreak;\n\t\t\treadCount += 1;\n\t\t}\n\t\trewind(scanner, readCount);\n\t\treturn Token.UNDEFINED;\n\t}\n\n\tprivate void rewind(ICharacterScanner scanner, int count) {\n\t\tfor(int i = 0; i < count; i++) \n\t\t\tscanner.unread();\n\t}\n\t\n\tprivate boolean isLegalHeaderNameChar(int c) {\n\t\treturn (c > 31 && SEPARATORS.indexOf(c) == -1);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/HeaderPartitionRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.Token;\n\npublic class HeaderPartitionRule implements IPredicateRule {\n\tprivate final static String SEPARATORS = \"()<>@,;:\\\\\\\"/[]?={} \\t\";\n\t\n\tprivate final IToken token;\n\t\n\tpublic HeaderPartitionRule(IToken token) {\n\t\tthis.token = token;\n\t}\n\t\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner) {\n\t\tif(!parseHeaderName(scanner))\n\t\t\treturn Token.UNDEFINED;\n\t\tint c;\n\t\twhile(true) {\n\t\t\tc = scanner.read();\n\t\t\tif(c == ICharacterScanner.EOF || c == '\\r' || c == '\\n') {\n\t\t\t\tscanner.unread();\n\t\t\t\treturn token;\n\t\t\t}\n\t\t}\t\t\n\t}\n\n\tprivate boolean parseHeaderName(ICharacterScanner scanner) {\n\t\tif(scanner.getColumn() != 0)\n\t\t\treturn false;\n\t\tint readCount = 1;\n\t\tint c;\n\t\t\n\t\twhile((c = scanner.read()) != ICharacterScanner.EOF) {\n\t\t\tif(c == ':' && readCount > 1) {\n\t\t\t\treturn true;\n\t\t\t} \n\t\t\t\n\t\t\tif(!isLegalHeaderNameChar(c))\n\t\t\t\tbreak;\n\t\t\treadCount += 1;\n\t\t}\n\t\tunread(scanner, readCount);\n\t\treturn false;\n\t}\n\t\n\tprivate void unread(ICharacterScanner scanner, int n) {\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tscanner.unread();\n\t}\n\n\tprivate boolean isLegalHeaderNameChar(int c) {\n\t\treturn (c > 31 && SEPARATORS.indexOf(c) == -1);\n\t}\n\n\t@Override\n\tpublic IToken getSuccessToken() {\n\t\treturn token;\n\t}\n\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner, boolean resume) {\n\t\treturn evaluate(scanner);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/HttpHeaderScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.SingleLineRule;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\n\npublic class HttpHeaderScanner extends AbstractScanner {\n\n\tpublic HttpHeaderScanner(Colors colors) {\n\t\tsuper(colors);\n\t}\n\n\t@Override\n\tprotected void initializeRules(List<IRule> rules) {\n\t\trules.add(new HeaderNameRule(createToken(Colors.HEADER_NAME)));\n\t\trules.add(new SingleLineRule(\"\\\"\", \"\\\"\", createToken(Colors.STRING), '\\\\'));\n\t\trules.add(new SingleLineRule(\"'\", \"'\", createToken(Colors.STRING), '\\\\'));\n\t\trules.add(new DateRule(createToken(Colors.DATE)));\n\t\trules.add(new IntegerRule(createToken(Colors.INTEGER)));\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/HttpVersionRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.Token;\n\npublic class HttpVersionRule implements IRule {\n\tprivate final static char[] VERSION_PREFIX = \"HTTP/\".toCharArray();\n\tprivate final IToken token;\n\t\n\tpublic HttpVersionRule(IToken token) {\n\t\tthis.token = token;\n\t}\n\t\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner) {\n\t\tif(!matchPrefix(VERSION_PREFIX, scanner))\n\t\t\treturn Token.UNDEFINED;\n\t\tint readCount = VERSION_PREFIX.length;\n\t\t\n\t\tif(!readDigit(scanner)) {\n\t\t\trewind(scanner, readCount);\n\t\t\treturn Token.UNDEFINED;\n\t\t}\n\t\treadCount++;\n\t\t\n\t\tif(!readDot(scanner)) {\n\t\t\trewind(scanner, readCount);\n\t\t\treturn Token.UNDEFINED;\n\t\t}\n\t\treadCount++;\n\t\t\n\t\tif(!readDigit(scanner)) {\n\t\t\trewind(scanner, readCount);\n\t\t\treturn Token.UNDEFINED;\n\t\t}\n\t\t\n\t\treturn token;\n\t}\n\t\n\tprivate boolean matchPrefix(char[] prefix, ICharacterScanner scanner) {\n\t\tfor(int i = 0; i < prefix.length; i++) {\n\t\t\tint c = scanner.read();\n\t\t\tif((char)c != prefix[i]) {\n\t\t\t\trewind(scanner, i + 1);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate boolean readDigit(ICharacterScanner scanner) {\n\t\tfinal int c = scanner.read();\n\t\tif(c >= '0' && c <= '9')\n\t\t\treturn true;\n\t\tscanner.unread();\n\t\treturn false;\n\t}\n\t\n\tprivate boolean readDot(ICharacterScanner scanner) {\n\t\tfinal int c = scanner.read();\n\t\tif(c == '.')\n\t\t\treturn true;\n\t\tscanner.unread();\n\t\treturn false;\n\t}\n\t\n\t\n\tprivate void rewind(ICharacterScanner scanner, int n) {\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tscanner.unread();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/IntegerRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IToken;\n\npublic class IntegerRule extends AbstractSyntaxRule {\n\n\tpublic IntegerRule(IToken token) {\n\t\tsuper(token);\n\t}\n\t\n\t@Override\n\tprotected boolean evaluateRule(ICharacterScanner scanner) {\n\t\tif(!matchWhitespace(scanner))\n\t\t\treturn false;\n\t\tmatchSingleChar(scanner, '-');\n\t\treturn matchDigits(scanner) && matchWhitespace(scanner);\n\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/RequestLinePartitionRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.IToken;\n\npublic class RequestLinePartitionRule extends AbstractStartLinePartitionRule {\n\n\tpublic RequestLinePartitionRule(IToken token) {\n\t\tsuper(token);\n\t}\n\n\t@Override\n\tprotected boolean doEvaluate() {\n\t\tif(!isFirstColumn()) {\n\t\t\treturn false;\n\t\t}\n\t\tfinal String method = parseWord();\n\t\tint readLength = method.length();\n\t\tif(!isRequestMethod(method)) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(!detectSingleSpace()) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\treadLength += 1;\n\t\t\n\t\tfinal String uri = parseWord();\n\t\treadLength += uri.length();\n\t\tif(!isRequestUri(uri)) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(!detectSingleSpace()) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\treadLength += 1;\n\t\t\n\t\tfinal String version = parseUntilEOL(true);\n\t\treadLength += version.length();\n\t\tif(!isHttpVersion(version)) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(!detectEOL()) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate boolean isRequestMethod(String s) {\n\t\tif(s == null || s.isEmpty())\n\t\t\treturn false;\n\t\tfor(int i = 0; i < s.length(); i++) {\n\t\t\tif(!Character.isLetter(s.charAt(i)))\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate boolean isRequestUri(String s) {\n\t\treturn (s != null && !s.isEmpty());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/RequestLineScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.IRule;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\n\npublic class RequestLineScanner extends AbstractScanner {\n\n\tpublic RequestLineScanner(Colors colors) {\n\t\tsuper(colors);\n\t}\n\n\t@Override\n\tprotected void initializeRules(List<IRule> rules) {\n\t\trules.add(new RequestMethodRule(createToken(Colors.REQUEST_VERB)));\n\t\trules.add(new EncodedCharacterRule(createToken(Colors.ENCODED_CHAR)));\n\t\trules.add(new HttpVersionRule(createToken(Colors.HTTP_VERSION)));\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/RequestMethodRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.ICharacterScanner;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.Token;\n\npublic class RequestMethodRule implements IRule {\n\n\tprivate final IToken token;\n\t\n\tpublic RequestMethodRule(IToken token) {\n\t\tthis.token = token;\n\t}\n\t\n\t@Override\n\tpublic IToken evaluate(ICharacterScanner scanner) {\n\t\tif(scanner.getColumn() > 0)\n\t\t\treturn Token.UNDEFINED;\n\n\t\tint tokenLength = 0;\n\t\twhile(true) {\n\t\t\tint c = scanner.read();\n\t\t\tif(isMethodCharacter(c)) {\n\t\t\t\ttokenLength++;\n\t\t\t} else if(Character.isWhitespace(c) && tokenLength > 0) {\n\t\t\t\tscanner.unread();\n\t\t\t\treturn token;\n\t\t\t} else {\n\t\t\t\tfor(int i = 0; i < tokenLength + 1; i++)\n\t\t\t\t\tscanner.unread();\n\t\t\t\treturn Token.UNDEFINED;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\t\n\tprivate boolean isMethodCharacter(int c) {\n\t\treturn c >= 'A' && c <= 'Z';\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/ResponseLinePartitionRule.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport org.eclipse.jface.text.rules.IToken;\n\npublic class ResponseLinePartitionRule extends AbstractStartLinePartitionRule {\n\n\tpublic ResponseLinePartitionRule(IToken token) {\n\t\tsuper(token);\n\t}\n\n\t@Override\n\tprotected boolean doEvaluate() {\n\t\tif(!isFirstColumn()) {\n\t\t\treturn false;\n\t\t}\n\t\tfinal String version = parseWord();\n\t\tint readLength = version.length();\n\t\tif(!isHttpVersion(version)) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(!detectSingleSpace()) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\treadLength += 1;\n\t\t\n\t\tfinal String status = parseWord();\n\t\treadLength += status.length();\n\t\tif(!isInteger(status)) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(!detectSingleSpace()) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\treadLength += 1;\n\t\t\n\t\tfinal String reason = parseUntilEOL(true);\n\t\treadLength += reason.length();\n\t\tif(!isResponseReason(reason)) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(!detectEOL()) {\n\t\t\tunread(readLength);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\t\t\n\t}\n\t\n\tprivate boolean isResponseReason(String s) {\n\t\treturn (s != null && !s.isEmpty());\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/http/ResponseLineScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.http;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.IRule;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\n\npublic class ResponseLineScanner extends AbstractScanner {\n\n\tpublic ResponseLineScanner(Colors colors) {\n\t\tsuper(colors);\n\t}\n\n\t@Override\n\tprotected void initializeRules(List<IRule> rules) {\n\t\trules.add(new HttpVersionRule(createToken(Colors.HTTP_VERSION)));\n\t\trules.add(new IntegerRule(createToken(Colors.INTEGER)));\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/JavascriptPartitionScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.EndOfLineRule;\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.MultiLineRule;\nimport org.eclipse.jface.text.rules.RuleBasedPartitionScanner;\nimport org.eclipse.jface.text.rules.SingleLineRule;\nimport org.eclipse.jface.text.rules.Token;\n\npublic class JavascriptPartitionScanner extends RuleBasedPartitionScanner {\n\t\n\tpublic final static String JS_DEFAULT_TYPE = \"js_default\";\n\tpublic final static String JS_MULTILINE_COMMENT = \"js_multiline_comment\";\n\tpublic final static String[] JS_PARTITION_TYPES = new String[] { JS_DEFAULT_TYPE, JS_MULTILINE_COMMENT };\n\t\n\tpublic JavascriptPartitionScanner() {\n\t\tsetDefaultReturnToken(new Token(JS_DEFAULT_TYPE));\n\t\tfinal List<IPredicateRule> rules = new ArrayList<IPredicateRule>();\n\t\trules.add(new EndOfLineRule(\"//\", Token.UNDEFINED));\n\t\trules.add(new SingleLineRule(\"\\\"\", \"\\\"\", Token.UNDEFINED, '\\\\'));\n\t\trules.add(new SingleLineRule(\"'\", \"'\", Token.UNDEFINED, '\\\\'));\n\t\trules.add(new MultiLineRule(\"/*\", \"*/\", new Token(JS_MULTILINE_COMMENT)));\n\t\tfinal IPredicateRule[] rs = new IPredicateRule[rules.size()];\n\t\trules.toArray(rs);\n\t\tsetPredicateRules(rs);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/JavascriptScanner.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.rules.EndOfLineRule;\nimport org.eclipse.jface.text.rules.IRule;\nimport org.eclipse.jface.text.rules.IToken;\nimport org.eclipse.jface.text.rules.SingleLineRule;\nimport org.eclipse.jface.text.rules.WhitespaceRule;\nimport org.eclipse.jface.text.rules.WordRule;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\nimport com.subgraph.vega.ui.httpeditor.http.AbstractScanner;\n\npublic class JavascriptScanner extends AbstractScanner {\n\n\tprivate final static String[] KEYWORDS = { \n\t\t\"break\", \"const\", \"continue\", \"delete\", \"do\", \"while\", \"export\", \n\t\t\"function\", \"for\", \"in\", \"if\", \"else\", \"import\", \"in\", \"instanceOf\", \"label\", \n\t\t\"let\", \"new\", \"return\", \"switch\", \"this\", \"throw\", \"try\", \"catch\", \n\t\t\"typeof\", \"var\", \"void\", \"while\", \"with\", \"yield\" };\n\n\tprivate final static String[] CONSTANTS = {\n\t\t\"true\", \"false\", \"null\"\n\t};\n\t\n\tpublic JavascriptScanner(Colors colors) {\n\t\tsuper(colors);\n\t}\n\n\t@Override\n\tprotected void initializeRules(List<IRule> rules) {\n\t\tfinal IToken keyword = createToken(Colors.KEYWORD);\n\t\tfinal IToken constant = createToken(Colors.ENCODED_CHAR);\n\t\tfinal IToken string = createToken(Colors.STRING);\n\t\tfinal IToken comment = createToken(Colors.SINGLE_LINE_COMMENT);\n\t\tfinal IToken other = createToken(Colors.OTHER);\n\t\t\n\t\trules.add(new EndOfLineRule(\"//\", comment));\n\t\trules.add(new SingleLineRule(\"\\\"\", \"\\\"\", string, '\\\\'));\n\t\trules.add(new SingleLineRule(\"'\", \"'\", string, '\\\\'));\n\t\t\n\t\trules.add(new WhitespaceRule(new JavascriptWhitespaceDetector()));\n\t\tWordRule wordRule = new WordRule(new JavascriptWordDetector(), other);\n\t\t\n\t\twordRule.addWord(\"function\", keyword);\n\t\tfor(String s : KEYWORDS)\n\t\t\twordRule.addWord(s, keyword);\n\t\tfor(String s: CONSTANTS) \n\t\t\twordRule.addWord(s, constant);\n\t\t\n\t\trules.add(wordRule);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/JavascriptTextEntityRenderer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.eclipse.jface.text.TextAttribute;\nimport org.eclipse.jface.text.presentation.PresentationReconciler;\nimport org.eclipse.jface.text.rules.BufferedRuleBasedScanner;\nimport org.eclipse.jface.text.rules.DefaultDamagerRepairer;\nimport org.eclipse.jface.text.rules.EndOfLineRule;\nimport org.eclipse.jface.text.rules.IPredicateRule;\nimport org.eclipse.jface.text.rules.MultiLineRule;\nimport org.eclipse.jface.text.rules.SingleLineRule;\nimport org.eclipse.jface.text.rules.Token;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\nimport com.subgraph.vega.ui.httpeditor.ITextEntityRenderer;\nimport com.subgraph.vega.ui.httpeditor.js.formatter.JavascriptFormatter;\n\npublic class JavascriptTextEntityRenderer implements ITextEntityRenderer {\n\tpublic final static String JS_DEFAULT_TYPE = \"js_default\";\n\tpublic final static String JS_MULTILINE_COMMENT = \"js_multiline_comment\";\n\tpublic final static String[] JS_PARTITION_TYPES = new String[] { JS_DEFAULT_TYPE, JS_MULTILINE_COMMENT };\n\t\n\tprivate final JavascriptFormatter formatter = new JavascriptFormatter();\n\t\n\t@Override\n\tpublic List<String> getPartitionTypes() {\n\t\treturn Arrays.asList(JS_PARTITION_TYPES);\n\t}\n\n\t@Override\n\tpublic boolean matchContentType(String contentType) {\n\t\treturn contentType.contains(\"javascript\") || contentType.contains(\"json\");\n\t}\n\n\t@Override\n\tpublic void addPartitionScannerRules(List<IPredicateRule> rules) {\n\t\trules.add(new EndOfLineRule(\"//\", Token.UNDEFINED));\n\t\trules.add(new SingleLineRule(\"\\\"\", \"\\\"\", Token.UNDEFINED, '\\\\'));\n\t\trules.add(new SingleLineRule(\"'\", \"'\", Token.UNDEFINED, '\\\\'));\n\t\trules.add(new MultiLineRule(\"/*\", \"*/\", new Token(JS_MULTILINE_COMMENT)));\n\t}\n\n\tstatic class SingleTokenScanner extends BufferedRuleBasedScanner {\n\t\tpublic SingleTokenScanner(TextAttribute attribute) {\n\t\t\tsetDefaultReturnToken(new Token(attribute));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void configurePresentationReconciler(\n\t\tPresentationReconciler reconciler, Colors colors) {\n\t\tDefaultDamagerRepairer dr = new DefaultDamagerRepairer(new JavascriptScanner(colors));\n\t\treconciler.setDamager(dr, JS_DEFAULT_TYPE);\n\t\treconciler.setRepairer(dr, JS_DEFAULT_TYPE);\n\t\tdr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(colors.get(Colors.MULTI_LINE_COMMENT))));\n\t\treconciler.setDamager(dr, JavascriptPartitionScanner.JS_MULTILINE_COMMENT);\n\t\treconciler.setRepairer(dr, JavascriptPartitionScanner.JS_MULTILINE_COMMENT);\n\t}\n\n\t@Override\n\tpublic String formatText(String input) {\n\t\treturn formatter.format(input);\n\t}\n\n\t@Override\n\tpublic String getLineSplitChars() {\n\t\treturn \" ;\";\n\t}\n\n\t@Override\n\tpublic String getDefaultPartitionType() {\n\t\treturn JS_DEFAULT_TYPE;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/JavascriptWhitespaceDetector.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js;\n\nimport org.eclipse.jface.text.rules.IWhitespaceDetector;\n\npublic class JavascriptWhitespaceDetector implements IWhitespaceDetector {\n\t@Override\n\tpublic boolean isWhitespace(char c) {\n\t\treturn Character.isWhitespace(c);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/JavascriptWordDetector.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js;\n\nimport org.eclipse.jface.text.rules.IWordDetector;\n\npublic class JavascriptWordDetector implements IWordDetector {\n\n\t@Override\n\tpublic boolean isWordStart(char c) {\n\t\treturn Character.isJavaIdentifierStart(c);\n\t}\n\n\t@Override\n\tpublic boolean isWordPart(char c) {\n\t\treturn Character.isJavaIdentifierPart(c);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/formatter/FormatterState.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js.formatter;\n\npublic class FormatterState {\n\tenum Mode { \n\t\tARRAY_EXPR (true, true), \n\t\tARRAY_INDENTED_EXPR (true, true), \n\t\tPAREN_EXPR (false, true), \n\t\tDO_BLOCK (false, false), \n\t\tBLOCK (false, false), \n\t\tOBJECT (false, false);\n\t\tfinal boolean isArray;\n\t\tfinal boolean isExpression;\n\t\tMode(boolean array, boolean expression) {\n\t\t\tthis.isArray = array;\n\t\t\tthis.isExpression = expression;\n\t\t}\n\t};\n\tint indentationLevel;\n\tint indentationBaseline;\n\tboolean eatNextSpace;\n\tboolean ifLine;\n\tboolean varLine;\n\tboolean varLineTainted;\n\tboolean varLineReindented;\n\tboolean inCase;\n\tboolean inHtmlComment;\n\tint ternaryDepth;\n\t\n\t\n\tMode mode;\n\tMode previousMode;\n\t\n\tFormatterState(Mode mode) {\n\t\tthis(null, mode, null);\n\t}\n\n\tFormatterState(JavascriptFormatterConfig config, Mode mode, FormatterState previousState) {\n\t\tthis.mode = mode;\n\t\tvarLine = false;\n\t\tvarLineTainted = false;\n\t\tvarLineReindented = false;\n\t\tifLine = false;\n\t\tinCase = false;\n\t\teatNextSpace = false;\n\t\tindentationBaseline = -1;\n\t\tternaryDepth = 0;\n\t\t\n\t\tif(previousState != null) {\n\t\t\tpreviousMode = previousState.mode;\n\t\t\tindentationLevel = previousState.indentationLevel;\n\t\t\tif(previousState.varLine && previousState.varLineReindented)\n\t\t\t\tindentationLevel += 1;\n\t\t} else {\n\t\t\tpreviousMode = Mode.BLOCK;\n\t\t\tindentationLevel = (config == null) ? 0 : config.indentLevel;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/formatter/JavascriptFormatter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js.formatter;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.ui.httpeditor.js.formatter.FormatterState.Mode;\nimport com.subgraph.vega.ui.httpeditor.js.formatter.JavascriptFormatterConfig.BraceStyle;\n\n/*\n * Adapted from http://jsbeautifier.org/\n */\npublic class JavascriptFormatter {\n\tprivate final static String[] PUNCTUATION = { \"++\", \"--\", \"+=\", \"-=\", \"*=\", \"/=\", \"%=\", \"===\", \"==\", \"!==\", \"!=\", \">>>=\", \">>>\", \">>=\", \"<<=\", \">=\", \"<=\", \">>\", \"<<\",\n\t\t\">\", \"<\", \"&&\", \"&=\", \"||\", \"!=\", \"|\", \"!!\", \"!\", \",\", \"::\", \"^=\", \"^\", \":\", \"=\", \"+\", \"-\", \"*\", \"/\", \"%\", \"&\"};\n\tprivate final static String[] LINE_STARTERS = { \"continue\", \"try\", \"throw\", \"return\", \"var\", \"if\", \"switch\", \"case\", \"default\", \"for\", \"while\", \"break\", \"function\" };\n\t\n\tprivate final static int PREFIX_NONE = 0;\n\tprivate final static int PREFIX_NEWLINE = 1;\n\tprivate final static int PREFIX_SPACE = 2;\n\t\n\tprivate final static int CHAR_EOF = -1;\n\t\n\tprivate enum TokenType { TK_START_EXPR, TK_END_EXPR, TK_START_BLOCK, TK_END_BLOCK, TK_WORD,\n\t\tTK_SEMICOLON, TK_STRING, TK_EQUALS, TK_OPERATOR, TK_BLOCK_COMMENT, TK_INLINE_COMMENT, \n\t\tTK_COMMENT, TK_EOF, TK_UNKNOWN\n\t}\n\tstatic class Token {\n\t\tfinal TokenType type;\n\t\tfinal String text;\n\t\tToken(TokenType type, int c) {\n\t\t\tthis.type = type;\n\t\t\tthis.text = String.valueOf((char)c);\n\t\t}\n\t\tToken(TokenType type, String text) {\n\t\t\tthis.type = type;\n\t\t\tthis.text = text;\n\t\t}\n\t}\n\t\n\tprivate StringBuilder output;\n\t\n\tprivate String lastWord = \"\";\n\tprivate String secondLastText = \"\";\n\tprivate String lastText = \"\";\n\tprivate TokenType lastTokenType = TokenType.TK_START_EXPR;\n\tprivate String input;\n\tprivate int pos;\n\tprivate int newlineCount = 0;\n\tprivate boolean wantedNewline;\n\tprivate boolean justAddedNewline;\n\tprivate boolean doBlockJustClosed;\n\tprivate String indentString; \n\tprivate FormatterState state = new FormatterState(Mode.BLOCK);\n\tprivate List<FormatterState> stateStack = new ArrayList<FormatterState>();\n\tprivate JavascriptFormatterConfig config = new JavascriptFormatterConfig();\n\tpublic String format(String input) {\n\t\toutput = new StringBuilder();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor(int i = 0; i < config.indentCount; i++) {\n\t\t\tsb.append(' ');\n\t\t}\n\t\tindentString = sb.toString();\n\t\treset(input);\n\t\tToken token = nextToken();\n\t\twhile(token.type != TokenType.TK_EOF) {\n\t\t\tswitch(token.type) {\n\t\t\tcase TK_START_EXPR:\n\t\t\t\thandleStartExpr(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_END_EXPR:\n\t\t\t\thandleEndExpr(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_START_BLOCK:\n\t\t\t\thandleStartBlock(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_END_BLOCK:\n\t\t\t\thandleEndBlock(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_WORD:\n\t\t\t\thandleWord(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_SEMICOLON:\n\t\t\t\thandleSemicolon(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_STRING:\n\t\t\t\thandleString(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_EQUALS:\n\t\t\t\thandleEquals(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_OPERATOR:\n\t\t\t\thandleOperator(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_BLOCK_COMMENT:\n\t\t\t\thandleBlockComment(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_INLINE_COMMENT:\n\t\t\t\thandleInlineComment(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_COMMENT:\n\t\t\t\thandleComment(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_UNKNOWN:\n\t\t\t\thandleUnknown(token.text);\n\t\t\t\tbreak;\n\t\t\tcase TK_EOF:\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpushToken(token);\n\t\t\ttoken = nextToken();\n\t\t}\n\t\t\n\t\treturn output.toString();\n\t}\n\t\n\tprivate void pushToken(Token token) {\n\t\tsecondLastText = lastText;\n\t\tlastText = token.text;\n\t\tlastTokenType = token.type;\n\t}\n\tprivate void reset(String input) {\n\t\tpos = 0;\n\t\tthis.input = input;\n\t}\n\t\n\tprivate Token nextToken() {\n\t\tnewlineCount = 0;\n\t\tif(pos >= input.length())\n\t\t\treturn new Token(TokenType.TK_EOF, \"\");\n\t\twantedNewline = false;\n\t\tint c = input.charAt(pos);\n\t\tpos += 1;\n\t\t\n\t\tboolean keepWhitespace = (config.keepArrayIndentation && state.mode.isArray);\n\t\tif(keepWhitespace) {\n\t\t\tint whitespaceCount = 0;\n\t\t\twhile(Character.isWhitespace(c)) {\n\t\t\t\tif(c == '\\n') {\n\t\t\t\t\ttrimOutput();\n\t\t\t\t\toutput.append(\"\\n\");\n\t\t\t\t\tjustAddedNewline = true;\n\t\t\t\t\twhitespaceCount = 0;\n\t\t\t\t} else if(c == '\\t') {\n\t\t\t\t\twhitespaceCount += 4;\n\t\t\t\t} else if(c == '\\r') {\n\t\t\t\t\t// do nothing\n\t\t\t\t} else {\n\t\t\t\t\twhitespaceCount += 1;\n\t\t\t\t}\n\t\t\t\tif(pos >= input.length()) {\n\t\t\t\t\treturn new Token(TokenType.TK_EOF, \"\");\n\t\t\t\t}\n\t\t\t\tc = input.charAt(pos);\n\t\t\t\tpos += 1;\n\t\t\t}\n\t\t\tif(state.indentationBaseline == -1) {\n\t\t\t\tstate.indentationBaseline = whitespaceCount;\n\t\t\t}\n\t\t\tif(justAddedNewline) {\n\t\t\t\tfor(int i = 0; i < state.indentationLevel + 1; i++) {\n\t\t\t\t\toutput.append(indentString);\n\t\t\t\t}\n\t\t\t\tif(state.indentationBaseline != -1) {\n\t\t\t\t\tfor(int i = 0; i < whitespaceCount - state.indentationBaseline; i++) {\n\t\t\t\t\t\toutput.append(' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile(Character.isWhitespace(c)) {\n\t\t\t\tif(c == '\\n') {\n\t\t\t\t\tif(config.maxPreserveNewline == 0 || config.maxPreserveNewline > newlineCount)\n\t\t\t\t\t\tnewlineCount += 1;\n\t\t\t\t}\n\t\t\t\tif(pos >= input.length())\n\t\t\t\t\treturn new Token(TokenType.TK_EOF, \"\");\n\t\t\t\tc = input.charAt(pos);\n\t\t\t\tpos += 1;\n\t\t\t}\n\t\t\t\n\t\t\tif(config.preserveNewlines && newlineCount > 1) {\n\t\t\t\tfor(int i = 0; i < newlineCount; i++) {\n\t\t\t\t\tprintNewline(i == 0);\n\t\t\t\t\tjustAddedNewline = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\twantedNewline = newlineCount > 0;\n\t\t}\n\t\n\t\tif(Character.isJavaIdentifierStart(c)) {\n\t\t\tStringBuilder text = new StringBuilder();\n\t\t\ttext.append((char)c);\n\n\t\t\tif(pos < input.length()) {\n\t\t\t\twhile(Character.isJavaIdentifierPart(input.charAt(pos))) {\n\t\t\t\t\ttext.append(input.charAt(pos));\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif(pos == input.length())\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!atEnd() && text.toString().matches(\"^[0-9]+[Ee]$\") && (peek() == '-' || peek() == '+')) {\n\t\t\t\tint sign = next();\n\t\t\t\tToken t = nextToken();\n\t\t\t\ttext.append((char) sign);\n\t\t\t\ttext.append(t.text);\n\t\t\t\treturn new Token(TokenType.TK_WORD, text.toString());\n\t\t\t}\n\n\t\t\tif(text.toString().equals(\"in\")) {\n\t\t\t\treturn new Token(TokenType.TK_WORD, text.toString());\n\t\t\t}\n\t\t\t\n\t\t\tif(wantedNewline && notLastToken(TokenType.TK_OPERATOR, TokenType.TK_EQUALS)\n\t\t\t\t\t&& !state.ifLine && (config.preserveNewlines || !\"var\".equals(lastText))) {\n\t\t\t\tprintNewline();\n\t\t\t}\n\t\t\treturn new Token(TokenType.TK_WORD, text.toString());\t\t\t\t\n\t\t}\n\t\t\n\t\tswitch(c) {\n\t\tcase '(':\n\t\tcase '[':\n\t\t\treturn new Token(TokenType.TK_START_EXPR, c);\n\t\tcase ')':\n\t\tcase ']':\n\t\t\treturn new Token(TokenType.TK_END_EXPR, c);\n\t\tcase '{':\n\t\t\treturn new Token(TokenType.TK_START_BLOCK, c);\n\t\tcase '}':\n\t\t\treturn new Token(TokenType.TK_END_BLOCK, c);\n\t\tcase ';':\n\t\t\treturn new Token(TokenType.TK_SEMICOLON, c);\n\t\tcase '/':\n\t\t\tToken t =  maybeCommentToken();\n\t\t\tif(t != null)\n\t\t\t\treturn t;\n\t\t\n\t\t}\n\n\t\tboolean isRegex = \n\t\t\tc == '/' \n\t\t\t&& ((lastTokenType == TokenType.TK_WORD && (\"return\".equals(lastText) || \"do\".equals(lastText))\n\t\t\t\t\t|| (lastTokenType == TokenType.TK_COMMENT || lastTokenType == TokenType.TK_START_EXPR \n\t\t\t\t\t\t|| lastTokenType == TokenType.TK_START_BLOCK || lastTokenType == TokenType.TK_END_BLOCK ||\n\t\t\t\t\t\tlastTokenType == TokenType.TK_OPERATOR || lastTokenType == TokenType.TK_EQUALS || lastTokenType == TokenType.TK_EOF ||\n\t\t\t\t\t\tlastTokenType == TokenType.TK_SEMICOLON)));\n\t\tif(c == '\"' || c == '\\'' || isRegex) {\n\t\t\tint sep = c;\n\t\t\tboolean esc = false;\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append((char) c);\n\t\t\tif(pos < input.length()) {\n\t\t\t\tif(sep == '/') {\n\t\t\t\t\tboolean inCharClass = false;\n\t\t\t\t\twhile(esc || inCharClass || input.charAt(pos) != sep) {\n\t\t\t\t\t\tsb.append(input.charAt(pos));\n\t\t\t\t\t\tif(!esc) {\n\t\t\t\t\t\t\tesc = input.charAt(pos) == '\\\\';\n\t\t\t\t\t\t\tif(input.charAt(pos) == '[') {\n\t\t\t\t\t\t\t\tinCharClass = true;\n\t\t\t\t\t\t\t} else if(input.charAt(pos) == ']') {\n\t\t\t\t\t\t\t\tinCharClass = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tesc = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos += 1;\n\t\t\t\t\t\tif(pos >= input.length()) {\n\t\t\t\t\t\t\treturn new Token(TokenType.TK_STRING, sb.toString());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twhile(esc || input.charAt(pos) != sep) {\n\t\t\t\t\t\tsb.append(input.charAt(pos));\n\t\t\t\t\t\tif(!esc) {\n\t\t\t\t\t\t\tesc = input.charAt(pos) == '\\\\';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tesc = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos += 1;\n\t\t\t\t\t\tif(pos >= input.length()) {\n\t\t\t\t\t\t\treturn new Token(TokenType.TK_STRING, sb.toString());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tpos += 1;\n\t\t\tsb.append((char) sep);\n\t\t\t\n\t\t\tif(sep == '/') {\n\t\t\t\twhile(pos < input.length() && Character.isJavaIdentifierPart(input.charAt(pos))) {\n\t\t\t\t\tsb.append(input.charAt(pos));\n\t\t\t\t\tpos += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new Token(TokenType.TK_STRING, sb.toString());\n\t\t}\n\t\t\n\t\tif(c == '#') {\n\t\t\tif(output.length() == 0 && peek() == '!') {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tsb.append((char) c);\n\t\t\t\twhile(!atEnd() && c != '\\n') {\n\t\t\t\t\tc = next();\n\t\t\t\t\tsb.append((char) c);\n\t\t\t\t}\n\t\t\t\toutput.append(sb.toString().trim());\n\t\t\t\toutput.append('\\n');\n\t\t\t\tprintNewline();\n\t\t\t\treturn nextToken();\n\t\t\t}\n\t\t\t\n\t\t\tif(!atEnd() && Character.isDigit(peek())) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tsb.append('#');\n\t\t\t\tdo {\n\t\t\t\t\tc = next();\n\t\t\t\t\tsb.append((char) c);\n\t\t\t\t} while(pos < input.length() && c != '#' && c != '=');\n\t\t\t\tif(c == '#') {\n\t\t\t\t\t//\n\t\t\t\t} else if(peek() == '[' && input.charAt(pos + 1) == ']') {\n\t\t\t\t\tsb.append(\"[]\");\n\t\t\t\t\tpos += 2;\n\t\t\t\t} else if(peek() == '{' && input.charAt(pos + 1) == '}') {\n\t\t\t\t\tsb.append(\"{}\");\n\t\t\t\t\tpos += 2;\n\t\t\t\t}\n\t\t\t\treturn new Token(TokenType.TK_WORD, sb.toString());\n\t\t\t}\n\t\t}\n\t\tif(c == '<' && peekStr(3).equals(\"!--\")) {\n\t\t\tpos += 3;\n\t\t\tstate.inHtmlComment = true;\n\t\t\treturn new Token(TokenType.TK_COMMENT, \"<!--\");\n\t\t}\n\t\tif(c == '-' && state.inHtmlComment && peekStr(2).equals(\"->\")) {\n\t\t\tstate.inHtmlComment = false;\n\t\t\tpos += 2;\n\t\t\tif(wantedNewline)\n\t\t\t\tprintNewline();\n\t\t\treturn new Token(TokenType.TK_COMMENT, \"-->\");\n\t\t}\n\t\t\n\t\tfor(String p: PUNCTUATION) {\n\t\t\tint plen = p.length();\n\t\t\tif(c == p.charAt(0)) {\n\t\t\t\tif(plen == 1 || p.substring(1).equals(peekStr(plen - 1))) {\n\t\t\t\t\tpos += plen - 1;\n\t\t\t\t\tif(c == '=')\n\t\t\t\t\t\treturn new Token(TokenType.TK_EQUALS, p);\n\t\t\t\t\telse\n\t\t\t\t\t\treturn new Token(TokenType.TK_OPERATOR, p);\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\treturn new Token(TokenType.TK_UNKNOWN, c);\n\t}\n\t\n\tprivate boolean atEnd() {\n\t\treturn pos >= input.length();\n\t}\n\t\n\tprivate int next() {\n\t\tif(atEnd())\n\t\t\treturn CHAR_EOF;\n\t\t\n\t\tpos += 1;\n\t\treturn input.charAt(pos - 1);\n\t}\n\t\n\tprivate String peekStr(int length) {\n\t\tif(pos + length > input.length()) {\n\t\t\treturn \"\";\n\t\t}\n\t\treturn input.substring(pos, pos + length);\n\t}\n\tprivate int peek() {\n\t\tif(atEnd()) \n\t\t\treturn CHAR_EOF;\n\t\treturn input.charAt(pos);\n\t}\n\t\n\tprivate Token maybeCommentToken() {\n\t\tif(peek() != '*' && peek() != '/')\n\t\t\treturn null;\n\t\t\n\t\tTokenType type = TokenType.TK_INLINE_COMMENT;\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint cc = next();\n\t\tsb.append('/');\n\t\t\n\t\tif(cc == '*') {\n\t\t\twhile(!(cc == '*' && peek() == '/') && (cc != CHAR_EOF)) {\n\t\t\t\tsb.append((char) cc);\n\t\t\t\tif(cc == '\\n' || cc == '\\r')\n\t\t\t\t\ttype = TokenType.TK_BLOCK_COMMENT;\n\t\t\t\tcc = next();\n\t\t\t}\n\t\t\tif(cc == '*') {\n\t\t\t\tnext();\n\t\t\t\tsb.append(\"*/\");\n\t\t\t}\n\t\t\treturn new Token(type, sb.toString());\n\t\t} else {\n\t\t\twhile(cc != '\\n' && cc != '\\r' && cc != CHAR_EOF) {\n\t\t\t\tsb.append((char) cc);\n\t\t\t\tcc = next();\n\t\t\t}\n\t\t\treturn new Token(TokenType.TK_COMMENT, sb.toString());\n\t\t}\n\t}\n\n\tprivate void handleStartExpr(String text) {\n\t\tif(text.equals(\"[\")) {\n\t\t\tif(lastTokenType == TokenType.TK_WORD || \")\".equals(lastText)) {\n\t\t\t\tfor(String ls: LINE_STARTERS) {\n\t\t\t\t\tif(ls.equals(text))\n\t\t\t\t\t\tprintSingleSpace();\n\t\t\t\t\tsetMode(Mode.PAREN_EXPR);\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(state.mode == Mode.ARRAY_EXPR || state.mode == Mode.ARRAY_INDENTED_EXPR) {\n\t\t\t\tif(\"]\".equals(secondLastText) && \",\".equals(lastText)) {\n\t\t\t\t\tif(state.mode == Mode.ARRAY_EXPR) {\n\t\t\t\t\t\tstate.mode = Mode.ARRAY_INDENTED_EXPR;\n\t\t\t\t\t\tif(!config.keepArrayIndentation) {\n\t\t\t\t\t\t\tindent();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\tsetMode(Mode.ARRAY_EXPR);\n\t\t\t\t\tif(!config.keepArrayIndentation) {\n\t\t\t\t\t\tprintNewline();\n\t\t\t\t\t}\n\t\t\t\t} else if (\"[\".equals(lastText)) {\n\t\t\t\t\tif(state.mode == Mode.ARRAY_EXPR) {\n\t\t\t\t\t\tstate.mode = Mode.ARRAY_INDENTED_EXPR;\n\t\t\t\t\t\tif(!config.keepArrayIndentation) {\n\t\t\t\t\t\t\tindent();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsetMode(Mode.ARRAY_EXPR);\n\t\t\t\t\tif(!config.keepArrayIndentation) {\n\t\t\t\t\t\tprintNewline();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tsetMode(Mode.ARRAY_EXPR);\n\t\t\t\t}\n\t\t\t\n\t\t\t} else {\n\t\t\t\tsetMode(Mode.ARRAY_EXPR);\n\t\t\t}\n\t\t} else {\n\t\t\tsetMode(Mode.ARRAY_EXPR);\n\t\t}\n\t\tif(\";\".equals(lastText) || lastTokenType == TokenType.TK_START_BLOCK) {\n\t\t\tprintNewline();\n\t\t} else if(lastTokenType == TokenType.TK_END_EXPR || lastTokenType == TokenType.TK_START_EXPR || lastTokenType == TokenType.TK_END_BLOCK || \".\".equals(lastText)) {\n\t\t\t// do nothing\n\t\t} else if(lastTokenType != TokenType.TK_WORD && lastTokenType != TokenType.TK_OPERATOR) {\n\t\t\tprintSingleSpace();\n\t\t} else if(\"function\".equals(lastWord) || \"typeof\".equals(lastWord)) {\n\t\t\tprintSingleSpace();\n\t\t} else if(\"catch\".equals(lastText)){\n\t\t\tprintSingleSpace();\n\t\t} else {\n\t\t\tfor(String ls: LINE_STARTERS) {\n\t\t\t\tif(ls.equals(lastText))\n\t\t\t\t\tprintSingleSpace();\n\t\t\t}\n\t\t}\n\t\tprintToken(text);\n\t}\n\t\n\tprivate void handleEndExpr(String text) {\n\t\tif(\"]\".equals(text)) {\n\t\t\tif(config.keepArrayIndentation) {\n\t\t\t\tif(\"}\".equals(lastText)) {\n\t\t\t\t\tremoveIndent();\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\trestoreMode();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif(state.mode == Mode.ARRAY_INDENTED_EXPR) {\n\t\t\t\t\tif(\"]\".equals(lastText)) {\n\t\t\t\t\t\trestoreMode();\n\t\t\t\t\t\tprintNewline();\n\t\t\t\t\t\tprintToken(text);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} \n\t\trestoreMode();\n\t\tprintToken(text);\n\t}\n\t\n\tprivate void handleStartBlock(String text) {\n\t\tif(isLastWord(\"do\")) {\n\t\t\tsetMode(Mode.DO_BLOCK);\n\t\t} else {\n\t\t\tsetMode(Mode.BLOCK);\n\t\t}\n\t\t\n\t\tif(config.braceStyle == BraceStyle.EXPAND) {\n\t\t\tif(notLastToken(TokenType.TK_OPERATOR)) {\n\t\t\t\tif(isLastText(\"return\", \"=\")) {\n\t\t\t\t\tprintSingleSpace();\n\t\t\t\t} else {\n\t\t\t\t\tprintNewline(true);\n\t\t\t\t}\n\t\t\t}\n\t\t\tprintToken(text);\n\t\t\tindent();\n\t\t} else {\n\t\t\tif(notLastToken(TokenType.TK_OPERATOR, TokenType.TK_START_EXPR)) {\n\t\t\t\tif(isLastToken(TokenType.TK_START_BLOCK)) {\n\t\t\t\t\tprintNewline();\n\t\t\t\t} else {\n\t\t\t\t\tprintSingleSpace();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif(state.previousMode.isArray && isLastText(\",\")) {\n\t\t\t\t\tif(isSecondLastText(\"}\")) {\n\t\t\t\t\t\tprintSingleSpace();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tprintNewline();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tindent();\n\t\t\tprintToken(text);\t\t\t\n\t\t}\n\t}\n\t\n\tprivate void handleEndBlock(String text) {\n\t\trestoreMode();\n\t\tif(config.braceStyle == BraceStyle.EXPAND) {\n\t\t\tif(notLastText(\"{\")) {\n\t\t\t\tprintNewline();\n\t\t\t}\n\t\t\tprintToken(text);\n\t\t} else {\n\t\t\tif(isLastToken(TokenType.TK_START_BLOCK)) {\n\t\t\t\tif(justAddedNewline) {\n\t\t\t\t\tremoveIndent();\n\t\t\t\t} else {\n\t\t\t\t\ttrimOutput();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif(state.mode.isArray && config.keepArrayIndentation) {\n\t\t\t\t\tconfig.keepArrayIndentation = false;\n\t\t\t\t\tprintNewline();\n\t\t\t\t\tconfig.keepArrayIndentation = true;\n\t\t\t\t} else {\n\t\t\t\t\tprintNewline();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\tprintToken(text);\n\t\t}\n\t}\n\t\n\tprivate void handleWord(String text) {\n\t\tif(doBlockJustClosed) {\n\t\t\tprintSingleSpace();\n\t\t\tprintToken(text);\n\t\t\tprintSingleSpace();\n\t\t\tdoBlockJustClosed = false;\n\t\t\treturn;\n\t\t}\n\t\tif(\"function\".equals(text)) {\n\t\t\tif(state.varLine) {\n\t\t\t\tstate.varLineReindented = true;\n\t\t\t}\n\t\t\tif((justAddedNewline || isLastText(\";\")) && notLastText(\"{\")) {\n\t\t\t\tnewlineCount = (justAddedNewline) ? (newlineCount) : 0;\n\t\t\t\tif(!config.preserveNewlines) {\n\t\t\t\t\tnewlineCount = 1;\n\t\t\t\t}\n\t\t\t\tfor(int i = 0; i < (2 - newlineCount); i++) {\n\t\t\t\t\tprintNewline(false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(\"case\".equals(text) || \"default\".equals(text)) {\n\t\t\tif(isLastText(\":\")) {\n\t\t\t\tremoveIndent();\n\t\t\t} else {\n\t\t\t\tstate.indentationLevel -= 1;\n\t\t\t\tprintNewline();\n\t\t\t\tstate.indentationLevel += 1;\n\t\t\t}\n\t\t\tprintToken(text);\n\t\t\tstate.inCase = true;\n\t\t\treturn;\n\t\t}\n\t\tint prefix = PREFIX_NONE;\n\t\tString ltext = text.toLowerCase();\n\t\tif(isLastToken(TokenType.TK_END_BLOCK)) {\n\t\t\tif(!(\"else\".equals(ltext) || \"catch\".equals(ltext) || \"finally\".equals(ltext))) {\n\t\t\t\tprefix = PREFIX_NEWLINE;\n\t\t\t} else {\n\t\t\t\tif(config.braceStyle == BraceStyle.EXPAND || config.braceStyle == BraceStyle.END_EXPAND) {\n\t\t\t\t\tprefix = PREFIX_NEWLINE;\n\t\t\t\t} else {\n\t\t\t\t\tprefix = PREFIX_SPACE;\n\t\t\t\t\tprintSingleSpace();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isLastToken(TokenType.TK_SEMICOLON) && (state.mode == Mode.BLOCK || state.mode == Mode.DO_BLOCK)) {\n\t\t\tprefix = PREFIX_NEWLINE;\n\t\t} else if(isLastToken(TokenType.TK_SEMICOLON) && state.mode.isExpression) {\n\t\t\tprefix = PREFIX_SPACE;\n\t\t} else if(isLastToken(TokenType.TK_STRING)) {\n\t\t\tprefix = PREFIX_NEWLINE;\n\t\t} else if(isLastToken(TokenType.TK_WORD)) {\n\t\t\tif(isLastText(\"else\")) {\n\t\t\t\ttrimOutput(true);\n\t\t\t}\n\t\t\tprefix = PREFIX_SPACE;\n\t\t} else if(isLastToken(TokenType.TK_START_BLOCK)) {\n\t\t\tprefix = PREFIX_NEWLINE;\n\t\t} else if(isLastToken(TokenType.TK_END_EXPR)) {\n\t\t\tprintSingleSpace();\n\t\t\tprefix = PREFIX_NEWLINE;\n\t\t}\n\t\t\n\t\tif(containsString(LINE_STARTERS, text) && notLastText(\")\")) {\n\t\t\tif(isLastText(\"else\")) {\n\t\t\t\tprefix = PREFIX_SPACE;\n\t\t\t} else {\n\t\t\t\tprefix = PREFIX_NEWLINE;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(state.ifLine && isLastToken(TokenType.TK_END_EXPR)) {\n\t\t\tstate.ifLine = false;\n\t\t}\n\t\t\n\t\tif(containsString(new String[] { \"else\", \"catch\", \"finally\"}, ltext)) {\n\t\t\tif(notLastToken(TokenType.TK_END_BLOCK) || config.braceStyle == BraceStyle.EXPAND || config.braceStyle == BraceStyle.END_EXPAND) {\n\t\t\t\tprintNewline();\n\t\t\t} else {\n\t\t\t\ttrimOutput(true);\n\t\t\t\tprintSingleSpace();\n\t\t\t}\n\t\t} else if(prefix == PREFIX_NEWLINE) {\n\t\t\tif((isLastToken(TokenType.TK_START_EXPR) || isLastText(\"=\", \",\")) && \"function\".equals(text)) {\n\t\t\t\t// do nothing\n\t\t\t} else if (\"function\".equals(text) && isLastText(\"new\")) {\n\t\t\t\tprintSingleSpace();\n\t\t\t} else if(isLastText(\"return\", \"throw\")) {\n\t\t\t\tprintSingleSpace();\n\t\t\t} else if(notLastToken(TokenType.TK_END_EXPR)) {\n\t\t\t\tif((notLastToken(TokenType.TK_START_EXPR) || !\"var\".equals(text)) && notLastText(\":\")) {\n\t\t\t\t\tif(\"if\".equals(text) && isLastWord(\"else\") && notLastText(\"{\")) {\n\t\t\t\t\t\tprintSingleSpace();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.varLine = false;\n\t\t\t\t\t\tstate.varLineReindented = false;\n\t\t\t\t\t\tprintNewline();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t} else if(containsString(LINE_STARTERS, text) && notLastText(\")\")) {\n\t\t\t\tstate.varLine = false;\n\t\t\t\tstate.varLineReindented = false;\n\t\t\t\tprintNewline();\n\t\t\t}\n\t\t\t\n\t\t} else if(state.mode.isArray && isLastText(\",\") && isSecondLastText(\")\")) {\n\t\t\tprintNewline();\n\t\t} else if(prefix == PREFIX_SPACE) {\n\t\t\tprintSingleSpace();\n\t\t}\n\t\t\n\t\tprintToken(text);\n\t\tlastWord = text;\n\t\t\n\t\tif(\"var\".equals(text)) {\n\t\t\tstate.varLine = true;\n\t\t\tstate.varLineReindented = false;\n\t\t\tstate.varLineTainted = false;\n\t\t} else if(\"if\".equals(text)) {\n\t\t\tstate.ifLine = true;\n\t\t} else if(\"else\".equals(text)) {\n\t\t\tstate.ifLine = false;\n\t\t}\n\t}\n\t\n\tprivate void handleSemicolon(String text) {\n\t\tprintToken(text);\n\t\tstate.varLine = false;\n\t\tstate.varLineReindented = false;\n\t\tif(state.mode == Mode.OBJECT) {\n\t\t\tstate.mode = Mode.BLOCK;\n\t\t}\n\t}\n\t\n\tprivate void handleString(String text) {\n\t\tif(isLastToken(TokenType.TK_START_BLOCK, TokenType.TK_END_BLOCK, TokenType.TK_SEMICOLON)) {\n\t\t\tprintNewline();\n\t\t} else if(isLastToken(TokenType.TK_WORD)) {\n\t\t\tprintSingleSpace();\n\t\t}\n\t\tprintToken(text);\n\t}\n\t\n\tprivate void handleEquals(String text) {\n\t\tif(state.varLine) {\n\t\t\tstate.varLineTainted = true;\n\t\t}\n\t\tprintSingleSpace();\n\t\tprintToken(text);\n\t\tprintSingleSpace();\n\t}\n\t\n\tprivate void handleOperator(String text) {\n\t\tboolean spaceBefore = true;\n\t\tboolean spaceAfter = true;\n\t\tif(state.varLine && \",\".equals(text) && state.mode.isExpression) {\n\t\t\tstate.varLineTainted = false;\n\t\t}\n\t\tif(state.varLine) {\n\t\t\tif(\",\".equals(text)) {\n\t\t\t\tif(state.varLineTainted) {\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\tstate.varLineReindented = true;\n\t\t\t\t\tstate.varLineTainted = false;\n\t\t\t\t\tprintNewline();\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\tstate.varLineTainted = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(isLastText(\"return\", \"throw\")) {\n\t\t\tprintSingleSpace();\n\t\t\tprintToken(text);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(\":\".equals(text) && state.inCase) {\n\t\t\tprintToken(text);\n\t\t\tprintNewline();\n\t\t\tstate.inCase = false;\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(\"::\".equals(text)) {\n\t\t\tprintToken(text);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(\",\".equals(text)) {\n\t\t\tif(state.varLine) {\n\t\t\t\tif(state.varLineTainted) {\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\tprintNewline();\n\t\t\t\t\tstate.varLineTainted = false;\n\t\t\t\t} else {\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\tprintSingleSpace();\n\t\t\t\t}\n\t\t\t} else if(isLastToken(TokenType.TK_END_BLOCK) && state.mode != Mode.PAREN_EXPR) {\n\t\t\t\tprintToken(text);\n\t\t\t\tif(state.mode == Mode.OBJECT && isLastText(\"}\")) {\n\t\t\t\t\tprintNewline();\n\t\t\t\t} else {\n\t\t\t\t\tprintSingleSpace();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif(state.mode == Mode.OBJECT) {\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\tprintNewline();\n\t\t\t\t} else {\n\t\t\t\t\tprintToken(text);\n\t\t\t\t\tprintSingleSpace();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t} else if (containsString(new String[] {\"--\", \"++\", \"!\"}, text)\n\t\t\t\t|| ( containsString(new String[] { \"-\", \"+\" }, text) \n\t\t\t\t\t\t&& isLastToken(TokenType.TK_START_BLOCK, TokenType.TK_START_EXPR, TokenType.TK_EQUALS, TokenType.TK_OPERATOR) \n\t\t\t\t\t\t|| isLastText(LINE_STARTERS))) {\n\t\t\tspaceBefore = false;\n\t\t\tspaceAfter = false;\n\t\t\tif(isLastText(\";\") && state.mode.isExpression) {\n\t\t\t\tspaceBefore = true;\n\t\t\t}\n\t\t\tif(isLastToken(TokenType.TK_WORD) && isLastText(LINE_STARTERS)) {\n\t\t\t\tspaceBefore = true;\n\t\t\t}\n\t\t\tif(state.mode == Mode.BLOCK && isLastText(\"{\", \";\")) {\n\t\t\t\tprintNewline();\n\t\t\t}\n\t\t} else if(\".\".equals(text)) {\n\t\t\tspaceBefore = false;\n\t\t} else if(\":\".equals(text)) {\n\t\t\tif(state.ternaryDepth == 0) {\n\t\t\t\tstate.mode = Mode.OBJECT;\n\t\t\t\tspaceBefore = false;\n\t\t\t} else {\n\t\t\t\tstate.ternaryDepth -= 1;\n\t\t\t}\n\t\t} else if(\"?\".equals(text)) {\n\t\t\tstate.ternaryDepth += 1;\n\t\t}\n\t\tif(spaceBefore) {\n\t\t\tprintSingleSpace();\n\t\t}\n\t\tprintToken(text);\n\t\tif(spaceAfter) {\n\t\t\tprintSingleSpace();\n\t\t}\n\t\t\n\t}\n\t\n\tprivate void handleBlockComment(String text) {\n\t\tfinal String[] lines = text.split(\"\\\\r?\\\\n\");\n\t\tif(text.matches(\"^/\\\\*\\\\*\")) {\n\t\t\tfor(int i = 0; i < lines.length; i++) {\n\t\t\t\tprintNewline();\n\t\t\t\tif(i > 0)\n\t\t\t\t\toutput.append(\" \");\n\t\t\t\toutput.append(lines[i].trim());\n\t\t\t}\n\t\t} else {\n\t\t\tif(lines.length > 1) {\n\t\t\t\tprintNewline();\n\t\t\t\ttrimOutput();\n\t\t\t} else {\n\t\t\t\tprintSingleSpace();\n\t\t\t}\n\t\t\tfor(int i = 0; i < lines.length; i++) {\n\t\t\t\toutput.append(lines[i]);\n\t\t\t\toutput.append(\"\\n\");\n\t\t\t}\n\t\t}\n\t\tprintNewline();\n\t}\n\t\n\tprivate void handleInlineComment(String text) {\n\t\tprintSingleSpace();\n\t\tprintToken(text);\n\t\tif(state.mode.isExpression) {\n\t\t\tprintSingleSpace();\n\t\t} else {\n\t\t\tprintNewline();\n\t\t}\n\t\t\n\t}\n\t\n\tprivate void handleComment(String text) {\n\t\tif(wantedNewline) {\n\t\t\tprintNewline();\n\t\t} else {\n\t\t\tprintSingleSpace();\n\t\t}\n\t\tprintToken(text);\n\t\tprintNewline();\n\t}\n\t\n\tprivate void handleUnknown(String text) {\n\t\tif(isLastText(\"return\", \"throw\")) {\n\t\t\tprintSingleSpace();\n\t\t}\n\t\tprintToken(text);\n\t}\n\t\n\tprivate void trimOutput() {\n\t\ttrimOutput(false);\n\t}\n\t\n\tprivate void trimOutput(boolean eatNewlines) {\n\t\twhile(endsWith(' ') || endsWithIndent() || (eatNewlines && (endsWith('\\n') || endsWith('\\r')))) {\n\t\t\tdropLast();\n\t\t}\n\t}\n\t\n\tprivate void printNewline() {\n\t\tprintNewline(true);\n\t}\n\tprivate void printNewline(boolean ignoreRepeated) {\n\t\tstate.eatNextSpace = false;\n\t\tif(config.keepArrayIndentation && state.mode.isArray) {\n\t\t\treturn;\n\t\t}\n\t\ttrimOutput();\n\t\tif(outputEmpty())\n\t\t\treturn;\n\t\tif(lastOutputChar() != '\\n' || !ignoreRepeated) {\n\t\t\tjustAddedNewline = true;\n\t\t\toutput.append(\"\\n\");\n\t\t}\n\t\tfor(int i = 0; i < state.indentationLevel; i++) {\n\t\t\toutput.append(indentString);\n\t\t}\n\t\tif(state.varLine && state.varLineReindented) {\n\t\t\tif(config.indentChar == ' ') {\n\t\t\t\toutput.append(\"    \");\n\t\t\t} else {\n\t\t\t\toutput.append(indentString);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n\tprivate void printSingleSpace() {\n\t\tif(state.eatNextSpace) {\n\t\t\tstate.eatNextSpace = false;\n\t\t\treturn;\n\t\t}\n\t\tchar last = ' ';\n\t\tif(output.length() > 0) {\n\t\t\tlast = output.charAt(output.length() - 1);\n\t\t}\n\t\tif(last != ' ' && last != '\\n' && !(indentString.length() == 1 && indentString.charAt(0) == last)) {\n\t\t\toutput.append(' ');\n\t\t}\n\t}\n\t\n\tprivate void printToken(String text) {\n\t\tjustAddedNewline = false;\n\t\tstate.eatNextSpace = false;\n\t\toutput.append(text);\n\t}\n\t\n\tprivate void indent() {\n\t\tstate.indentationLevel += 1;\n\t}\n\t\n\tprivate void removeIndent() {\n\t\tif(output.length() > 0 && matchIndentString(lastOutputChar())) {\n\t\t\tdropLast();\n\t\t}\n\t}\n\t\n\tprivate void setMode(FormatterState.Mode mode) {\n\t\tif(state != null) {\n\t\t\tstateStack.add(state);\n\t\t}\n\t\tstate = new FormatterState(config, mode, state);\n\t}\n\t\n\tprivate void restoreMode() {\n\t\tdoBlockJustClosed = (state.mode == Mode.DO_BLOCK);\n\t\tif(stateStack.size() > 0) {\n\t\t\tstate = stateStack.remove(stateStack.size() - 1);\n\t\t} \n\t}\n\t\n\tprivate boolean endsWith(char c) {\n\t\tif(outputEmpty())\n\t\t\treturn false;\n\t\treturn lastOutputChar() == c;\n\t}\n\tprivate boolean endsWithIndent() {\n\t\tif(outputEmpty())\n\t\t\treturn false;\n\t\treturn matchIndentString(lastOutputChar());\n\t}\n\n\tprivate boolean matchIndentString(char c) {\n\t\treturn indentString.length() == 1 && indentString.charAt(0) == c;\n\t}\n\t\n\tprivate char lastOutputChar() {\n\t\treturn output.charAt(output.length() - 1);\n\t}\n\t\n\tprivate boolean outputEmpty() {\n\t\treturn output.length() == 0;\n\t}\n\t\n\tprivate void dropLast() {\n\t\tif(!outputEmpty()) {\n\t\t\toutput.deleteCharAt(output.length() - 1);\n\t\t}\t\t\n\t}\n\n\tprivate boolean containsString(String[] haystack, String needle) {\n\t\tfor(String s: haystack)\n\t\t\tif(s.equals(needle))\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\tprivate boolean notLastToken(TokenType ... types) {\n\t\tfor(TokenType tt: types) {\n\t\t\tif(lastTokenType == tt)\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate boolean isLastToken(TokenType ...types) {\n\t\tfor(TokenType tt: types) {\n\t\t\tif(lastTokenType == tt)\n\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate boolean isLastText(String ... strings) {\n\t\tfor(String s: strings) {\n\t\t\tif(s.equals(lastText)) \n\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate boolean notLastText(String ...strings) {\n\t\tfor(String s: strings) {\n\t\t\tif(s.equals(lastText))\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\tprivate boolean isSecondLastText(String text) {\n\t\treturn text.equals(secondLastText);\n\t}\n\t\n\tprivate boolean isLastWord(String text) {\n\t\treturn text.equals(lastWord);\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/js/formatter/JavascriptFormatterConfig.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.js.formatter;\n\npublic class JavascriptFormatterConfig {\n\tenum BraceStyle { COLLAPSE, EXPAND, END_EXPAND };\n\tBraceStyle braceStyle = BraceStyle.COLLAPSE;\n\tboolean preserveNewlines;\n\tboolean keepArrayIndentation;\n\tint indentCount = 4;\n\tint indentLevel = 0; // initial indentation\n\tint maxPreserveNewline;\n\tboolean bracesOnOwnLine;\n\tchar indentChar;\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/parser/HttpRequestParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.parser;\n\nimport java.io.UnsupportedEncodingException;\nimport java.net.URISyntaxException;\n\nimport org.apache.http.ParseException;\nimport org.apache.http.ProtocolVersion;\nimport org.apache.http.entity.StringEntity;\nimport org.apache.http.message.BasicLineParser;\nimport org.apache.http.message.LineParser;\nimport org.apache.http.message.ParserCursor;\nimport org.apache.http.util.CharArrayBuffer;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\n\n/**\n * Parser to parse user-entered requests into an IHttpRequestBuilder.\n */\npublic class HttpRequestParser extends ParserBase {\n\tprivate final IHttpRequestBuilder builder;\n\tprivate final boolean parseInlineEntities;\n\n\tpublic HttpRequestParser(final IHttpRequestBuilder builder, boolean parseInlineEntities) {\n\t\tthis.builder = builder;\n\t\tthis.parseInlineEntities = parseInlineEntities;\n\t}\n\n\tpublic HttpRequestParser(final IHttpRequestBuilder builder) {\n\t\tthis(builder, true);\n\t}\n\t\n//\tpublic HttpRequestParser(IHttpRequestEngine requestEngine) {\n//\t\tthis(requestEngine.createRequestBuilder(), true);\n//\t}\n\n\t/**\n\t * Parse a manually-entered HTTP request into the IHttpRequestBuilder.\n\t * \n\t * @param content Manually-entered HTTP request.\n\t */\n\tpublic void parseRequest(final String content) throws URISyntaxException, UnsupportedEncodingException {\n\t\tfinal CharArrayBuffer buf = new CharArrayBuffer(0);\n\t\tbuf.append(content);\n\t\tfinal ParserCursor bufCursor = new ParserCursor(0, buf.length()); \n\t\tfinal LineParser parser = new BasicLineParser();\n\n\t\tstripLeadingWhitspace(buf, bufCursor);\n\t\tif (parseRequestLine(parser, builder, buf, bufCursor) < 0) {\n\t\t\treturn;\n\t\t}\n\t\tbuilder.clearHeaders();\n\t\tparseHeaders(parser, builder, buf, bufCursor);\n\t\tif (!bufCursor.atEnd() && parseInlineEntities) {\n\t\t\tStringEntity entity = new StringEntity(buf.substring(bufCursor.getPos(), bufCursor.getUpperBound()));\n\t\t\tbuilder.setEntity(entity);\n\t\t}\n\t}\n\n\tpublic IHttpRequestBuilder getRequestBuilder() {\n\t\treturn builder;\n\t}\n\n\t/**\n\t * Read and parse the request line.\n\t * \n\t * @param parser HC LineParser.\n\t * @param builder HTTP request builder.\n\t * @param buf\n\t * @param bufCursor\n\t * @return\n\t * @throws URISyntaxException\n\t */\n\tprivate int parseRequestLine(final LineParser parser, final IHttpRequestBuilder builder, final CharArrayBuffer buf, final ParserCursor bufCursor) throws URISyntaxException {\n\t\tfinal CharArrayBuffer lnBuf = new CharArrayBuffer(0);\n\t\tif (readLine(buf, bufCursor, lnBuf) < 1) {\n\t\t\t// no data! \n\t\t\treturn -1;\n\t\t}\n\t\tfinal ParserCursor lnCursor = new ParserCursor(0, lnBuf.length());\n\n\t\tString method, uri;\n\t\tProtocolVersion version;\n\t\tif ((method = nextWord(lnBuf, lnCursor)) != null) {\n\t\t\tif ((uri = nextWord(lnBuf, lnCursor)) != null) {\n\t\t\t\ttry {\n\t\t\t\t\tversion = parser.parseProtocolVersion(lnBuf, lnCursor);\n\t\t\t\t} catch (ParseException e) {\n\t\t\t\t\t// treat the unparseable version as HTTP/1.1\n\t\t\t\t\tversion = new ProtocolVersion(\"HTTP\", 1, 1); \n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\turi = \"\";\n\t\t\t\tversion = null;//new ProtocolVersion(\"HTTP\", 0, 9);\n\t\t\t}\n\t\t} else {\n\t\t\tmethod = lnBuf.toString();\n\t\t\turi = \"\";\n\t\t\tversion = null;//new ProtocolVersion(\"HTTP\", 0, 9);\n\t\t}\n\n\t\tbuilder.setMethod(method);\n\t\tbuilder.setPath(uri);\n\t\tbuilder.setProtocolVersion(version);\n\t\t\n\t\treturn 0;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/parser/HttpResponseParser.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.parser;\n\nimport java.io.UnsupportedEncodingException;\n\nimport org.apache.http.StatusLine;\nimport org.apache.http.entity.StringEntity;\nimport org.apache.http.message.BasicLineParser;\nimport org.apache.http.message.LineParser;\nimport org.apache.http.message.ParserCursor;\nimport org.apache.http.util.CharArrayBuffer;\n\nimport com.subgraph.vega.api.http.requests.IHttpResponseBuilder;\n\n/**\n * Parser to parse user-entered responsesinto an IHttpResponseBuilder.\n */\npublic class HttpResponseParser extends ParserBase {\n\tfinal private IHttpResponseBuilder builder;\n\tprivate final boolean parseInlineEntities;\n\n\tpublic HttpResponseParser(final IHttpResponseBuilder builder, boolean parseInlineEntities) {\n\t\tthis.builder = builder;\n\t\tthis.parseInlineEntities = parseInlineEntities;\n\t}\n\n\t/**\n\t * Parse a HTTP response in a string.\n\t * \n\t * @param content HTTP response string.\n\t * @return HttpResponse, or null if the given HTTP response was empty. \n\t * @throws UnsupportedEncodingException\n\t */\n\tpublic void parseResponse(final String content) throws UnsupportedEncodingException {\n\t\tfinal CharArrayBuffer buf = new CharArrayBuffer(0);\n\t\tbuf.append(content);\n\t\tfinal ParserCursor bufCursor = new ParserCursor(0, buf.length()); \n\t\tfinal LineParser parser = new BasicLineParser();\n\n\t\tif (parseStatusLine(parser, builder, buf, bufCursor) < 0) {\n\t\t\treturn;\n\t\t}\n\t\tbuilder.clearHeaders();\n\t\tparseHeaders(parser, builder, buf, bufCursor);\n\t\tif (!bufCursor.atEnd() && parseInlineEntities) {\n\t\t\tStringEntity entity = new StringEntity(buf.substring(bufCursor.getPos(), bufCursor.getUpperBound()));\n\t\t\tbuilder.setEntity(entity);\n\t\t}\n\t}\n\t\n\tpublic IHttpResponseBuilder getResponseBuilder() {\n\t\treturn builder;\n\t}\n\n\t/**\n\t * Read and parse the response line.\n\t * \n\t * @param parser HC LineParser.\n\t * @param builder HTTP response builder.\n\t * @param buf\n\t * @param bufCursor\n\t * @return\n\t */\n\tprivate int parseStatusLine(final LineParser parser, final IHttpResponseBuilder builder, final CharArrayBuffer buf, final ParserCursor bufCursor) {\n\t\tfinal CharArrayBuffer lnBuf = new CharArrayBuffer(0);\n\t\tif (readLine(buf, bufCursor, lnBuf) < 1) {\n\t\t\t// no data!\n\t\t\treturn -1;\n\t\t}\n\t\tfinal ParserCursor lnCursor = new ParserCursor(0, lnBuf.length());\n\n\t    final StatusLine statusLine = parser.parseStatusLine(lnBuf, lnCursor);\n\t    builder.setFromStatusLine(statusLine);\n\t\t\n\t\treturn 0;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/parser/ParserBase.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.parser;\n\nimport org.apache.http.Header;\nimport org.apache.http.ParseException;\nimport org.apache.http.message.LineParser;\nimport org.apache.http.message.ParserCursor;\nimport org.apache.http.protocol.HTTP;\nimport org.apache.http.util.CharArrayBuffer;\n\nimport com.subgraph.vega.api.http.requests.IHttpMessageBuilder;\n\npublic abstract class ParserBase {\n\n\t/**\n\t * Strip leading whitespace from a buffer. Lines with 0 or more SP or HT characters ending with LF or CRLF are\n\t * removed. \n\t * @param buf Buffer.\n\t * @param bufCursor Parser cursor for buf.\n\t */\n\tprotected void stripLeadingWhitspace(final CharArrayBuffer buf, final ParserCursor bufCursor) {\n\t\tfinal int idxTo = bufCursor.getUpperBound();\n\t\tint idxPos = bufCursor.getPos();\n\t\tint idxLast = idxPos;\n\t\twhile (idxPos < idxTo) {\n\t\t\tchar ch = buf.charAt(idxPos);\n\t\t\tif (ch == HTTP.CR) {\n\t\t\t\tif (idxTo + 1 < idxPos && buf.charAt(idxPos) == HTTP.LF) {\n\t\t\t\t\tidxPos += 2;\n\t\t\t\t\tidxLast = idxPos;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (ch == HTTP.LF) {\n\t\t\t\tidxPos++;\n\t\t\t\tidxLast = idxPos;\n\t\t\t} else {\n\t\t\t\tif (ch == HTTP.SP || ch == HTTP.HT) {\n\t\t\t\t\tidxPos++;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbufCursor.updatePos(idxLast);\t\t\n\t}\n\t\n\t/**\n\t * Get the next line of characters from a CharArrayBuffer into another CharArrayBuffer. Treats LF and CRLF as valid\n\t * line delimiters. Treats the entire buffer as a line if no line delimiters are found.\n\t * \n\t * @param src Source buffer to read line from.\n\t * @param srcCursor Parser cursor for src. Adjusted to discard line delimiters.\n\t * @param dst Destination buffer for characters from line. \n\t * @return Number of characters in line minus line delimiters, or < 0 if none found.\n\t */\n\tprotected int readLine(final CharArrayBuffer src, final ParserCursor srcCursor, final CharArrayBuffer dst) {\n\t\tif (srcCursor.atEnd()) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tint idxPos = srcCursor.getPos();\n\t\tint idxLf = src.indexOf(HTTP.LF, idxPos, srcCursor.getUpperBound());\n\t\tint idxEnd;\n\n\t\tif (idxLf >= 0) {\n\t\t\tif (idxLf != 0 && src.charAt(idxLf - 1) == HTTP.CR) {\n\t\t\t\tidxEnd = idxLf - 1;\n\t\t\t} else {\n\t\t\t\tidxEnd = idxLf;\n\t\t\t}\n\t\t} else {\n\t\t\tidxEnd = srcCursor.getUpperBound();\n\t\t\tidxLf = idxEnd - 1;\n\t\t}\n\n\t\tdst.append(src, idxPos, idxEnd - idxPos);\n\t\tsrcCursor.updatePos(idxLf + 1);\n\t\treturn idxEnd - idxPos;\n\t}\n\n\t/**\n\t * Get the next header line of characters from a CharArrayBuffer into another CharArrayBuffer. Treats LF and CRLF as\n\t * valid line delimiters. Treats the entire buffer as a line if no line delimiters are found. Supports folded header\n\t * field values as per the HTTP/1.1 specification.\n\t *    \n\t * @param src Source buffer to read line from.\n\t * @param srcCursor Parser cursor for src. Adjusted to discard line delimiters.\n\t * @param dst Destination buffer for characters from line. \n\t * @return Number of characters in line minus line delimiters, or < 0 if none found.\n\t */\n\tprotected int readLineHeader(final CharArrayBuffer src, final ParserCursor srcCursor, final CharArrayBuffer dst) {\n\t\tif (srcCursor.atEnd()) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tint idxPos = srcCursor.getPos();\n\t\tint chCnt = 0;\n\t\tint idxLf, idxEnd;\n\n\t\tdo {\t\t\n\t\t\tidxLf = src.indexOf(HTTP.LF, idxPos, srcCursor.getUpperBound());\n\n\t\t\tif (idxLf > 0) {\n\t\t\t\tif (idxLf != srcCursor.getPos() && src.charAt(idxLf - 1) == HTTP.CR) {\n\t\t\t\t\tidxEnd = idxLf - 1;\n\t\t\t\t} else {\n\t\t\t\t\tidxEnd = idxLf;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tidxEnd = srcCursor.getUpperBound();\n\t\t\t\tidxLf = idxEnd - 1;\n\t\t\t}\n\n\t\t\tif (chCnt != 0) {\n\t\t\t\twhile (idxPos < idxEnd && (src.charAt(idxPos) == HTTP.HT || src.charAt(idxPos) == HTTP.SP)) {\n\t\t\t\t\tidxPos++;\n\t\t\t\t}\n\t\t\t\tif (idxPos != idxEnd) {\n\t\t\t\t\tdst.append(' ');\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tdst.append(src, idxPos, idxEnd - idxPos);\n\t\t\tchCnt += idxEnd - idxPos;\n\t\t\tidxPos = idxLf + 1;\n\t\t\tsrcCursor.updatePos(idxPos);\n\t\t} while (idxPos < srcCursor.getUpperBound() && (src.charAt(idxPos) == HTTP.HT || src.charAt(idxPos) == HTTP.SP));\n\n\t\treturn chCnt;\n\t}\n\n\t/**\n\t * Get the next word from a buffer containing a line.\n\t * \n\t * @param lnBuf Buffer containing line.\n\t * @param lnCursor Parser cursor for lnBuf. Adjusted to one character after the word.\n\t * @return Next word, or null if none is found.\n\t */\n\tprotected String nextWord(final CharArrayBuffer lnBuf, final ParserCursor lnCursor) {\n\t\tskipSpHt(lnBuf, lnCursor);\n\t\tint idxPos = lnCursor.getPos();\n        int idxLineEnd = lnBuf.indexOf(' ', idxPos, lnCursor.getUpperBound());\n        if (idxLineEnd < 0) {\n        \tif (idxPos == lnCursor.getUpperBound()) {\n        \t\treturn null;\n        \t}\n        \tidxLineEnd = lnCursor.getUpperBound();\n        }\n\t\tlnCursor.updatePos(idxLineEnd);\n\t\treturn lnBuf.substringTrimmed(idxPos, idxLineEnd);\t\t\n\t}\n\t\n\t/**\n\t * Skip SP and HT characters in a line.   \n\t * \n\t * @param lnBuf Buffer containing line.\n\t * @param lnCursor Parser cursor for lnBuf. Adjusted to one character after and SP and HT.\n\t */\n\tprotected void skipSpHt(final CharArrayBuffer lnBuf, final ParserCursor lnCursor) {\n\t\tint idxTo = lnCursor.getUpperBound();\n\t\tint idxPos = lnCursor.getPos();\n\t\twhile (idxPos < idxTo && (lnBuf.charAt(idxPos) == HTTP.SP || lnBuf.charAt(idxPos) == HTTP.HT)) {\n\t\t\tidxPos++;\n\t\t}\n        lnCursor.updatePos(idxPos);\n\t}\n\n\t/**\n\t * Parse HTTP headers and add them to a IHttpMessageBuilder until a non-header line is encountered.\n\t * \n\t * @param parser HC line parser.\n\t * @param builder IHttpMessageBuilder to add parsed headers to.\n\t * @param buf Buffer containing header data.\n\t * @param bufCursor Parser cursor for buf. Adjusted to one character past the end of headers and optional CRLF line.\n\t */\n\tprotected void parseHeaders(final LineParser parser, final IHttpMessageBuilder builder, final CharArrayBuffer buf, final ParserCursor bufCursor) {\n\t\tfinal CharArrayBuffer lnBuf = new CharArrayBuffer(0);\n\t\twhile (true) {\n\t\t\tlnBuf.clear();\n\t\t\tint idxPos = bufCursor.getPos();\n\t\t\tif (readLineHeader(buf, bufCursor, lnBuf) > 0) {\n\t\t\t\ttry {\n\t\t\t\t\t// REVISIT don't want an extra step\n\t\t\t\t\tHeader header = parser.parseHeader(lnBuf);\n\t\t\t\t\tbuilder.addHeader(header.getName(), header.getValue());\n\t\t\t\t} catch (ParseException e) {\n\t\t\t\t\t// for now we'll move the cursor back so the line gets treated as the start of the body\n\t\t\t\t\tbufCursor.updatePos(idxPos);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/search/SearchBar.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.search;\n\nimport org.eclipse.jface.text.IDocument;\nimport org.eclipse.jface.text.ITextInputListener;\nimport org.eclipse.jface.text.source.SourceViewer;\nimport org.eclipse.jface.text.source.projection.ProjectionViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StyledText;\nimport org.eclipse.swt.custom.VerifyKeyListener;\nimport org.eclipse.swt.events.KeyEvent;\nimport org.eclipse.swt.events.KeyListener;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.VerifyEvent;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.layout.RowData;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.ui.httpeditor.Colors;\nimport com.subgraph.vega.ui.httpeditor.highlights.MatchChangeListener;\nimport com.subgraph.vega.ui.httpeditor.highlights.MatchHighlighter;\nimport com.subgraph.vega.ui.httpeditor.highlights.NavigationButtons;\n\npublic class SearchBar extends Composite implements ModifyListener, KeyListener, VerifyKeyListener, ITextInputListener, MatchChangeListener {\n\t\n\tprivate static final int KEY_ESC = 27;\n\tprivate static final int KEY_F = 102;\n\t\n\tprivate final static String ANNOTATION_MATCH = \"httpeditor.search_match\";\n\t\n\tprivate final StyledText textControl;\n\tprivate final MatchHighlighter highlighter;\n\tprivate final Color noResultBackground;\n\tprivate final Text searchText;\n\tprivate final Color searchTextBackground;\n\tprivate final NavigationButtons buttons;\n\t\n\tpublic SearchBar(Composite parent, ProjectionViewer viewer, Colors colors) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new RowLayout(SWT.HORIZONTAL));\n\t\tconfigureViewer(viewer);\n\t\tthis.textControl = viewer.getTextWidget();\n\t\tthis.highlighter = new MatchHighlighter(viewer, colors.get(Colors.HIGHLIGHT_SEARCH_MATCH), ANNOTATION_MATCH, true);\n\t\tthis.noResultBackground = colors.get(Colors.NO_SEARCH_RESULT_TEXT_BACKGROUND);\n\t\tsearchText = createSearchText();\n\t\tsearchTextBackground = searchText.getBackground();\n\t\tbuttons = new NavigationButtons(this, highlighter, this);\n\t\tpack();\n\t\thideSearchBar();\n\t}\n\n\n\tprivate void configureViewer(SourceViewer viewer) {\n\t\tviewer.addTextInputListener(this);\n\t\tviewer.prependVerifyKeyListener(this);\n\t}\n\n\tprivate Text createSearchText() {\n\t\tfinal Text t = new Text(this, SWT.SINGLE | SWT.BORDER);\n\t\tt.setLayoutData(new RowData(150, SWT.DEFAULT));\n\t\tt.addModifyListener(this);\n\t\tt.addKeyListener(this);\n\t\tt.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t\thandleKeyEnter();\n\t\t\t}\n\t\t});\n\t\treturn t;\n\t}\n\n\tprivate void handleKeyEnter() {\n\t\tif(searchText.getText().isEmpty()) {\n\t\t\treturn;\n\t\t} else if (!highlighter.isActive()) {\n\t\t\tperformSearch(searchText.getText());\n\t\t} else if (highlighter.hasNextMatch()) {\n\t\t\tbuttons.handleNextMatch();\n\t\t} else if (highlighter.getMatchCount() > 1) {\n\t\t\thandleFirstMatch();\n\t\t}\n\t}\n\t\n\tprivate void handleFirstMatch() {\n\t\tif(highlighter.isActive() && highlighter.getMatchCount() != 0) {\n\t\t\thighlighter.displayFirstMatch();\n\t\t}\n\t\tbuttons.enableButtonsForMatchState();\n\t\tsummarizeSearchResult();\n\t}\n\n\t@Override\n\tpublic void modifyText(ModifyEvent e) {\n\t\tif(searchText.getText().isEmpty()) {\n\t\t\thighlighter.clearMatches();\n\t\t\tbuttons.enableButtonsForMatchState();\n\t\t\tsummarizeSearchResult();\n\t\t\treturn;\n\t\t}\n\t\tperformSearch(searchText.getText());\n\t}\n\t\n\tprivate void performSearch(String query) {\n\t\thighlighter.clearMatches();\n\t\thighlighter.searchMatches(query, false, false);\n\t\thandleFirstMatch();\n\t}\n\n\tprivate void summarizeSearchResult() {\n\t\tif(!highlighter.isActive()) {\n\t\t\tclearResultSummary();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(highlighter.getMatchCount() == 0) {\n\t\t\tsearchText.setToolTipText(\"No results found.\");\n\t\t\tsearchText.setBackground(noResultBackground);\n\t\t\treturn;\n\t\t}\n\n\t\tsearchText.setBackground(searchTextBackground);\n\t\tsearchText.setToolTipText(\"(\"+ (highlighter.getCurrentIndex() + 1) + \" of \" +\n\t\t\t\thighlighter.getMatchCount() + \") results\");\n\t}\n\t\n\tprivate void clearResultSummary() {\n\t\tif(!searchText.isDisposed()) {\n\t\t\tsearchText.setToolTipText(null);\n\t\t\tsearchText.setBackground(searchTextBackground);\n\t\t}\n\t}\n\n\tprivate void clearCurrentSearch() {\n\t\thighlighter.clearMatches();\n\t\tclearResultSummary();\n\t\tbuttons.enableButtonsForMatchState();\n\t}\n\n\t@Override\n\tpublic void inputDocumentAboutToBeChanged(IDocument oldInput,\n\t\t\tIDocument newInput) {\n\t\tclearCurrentSearch();\n\t}\n\n\t@Override\n\tpublic void inputDocumentChanged(IDocument oldInput, IDocument newInput) {\n\t}\n\n\tprivate boolean isEventCtrlF(KeyEvent ev) {\n\t\treturn ((ev.stateMask & SWT.MOD1) != 0) && ev.keyCode == KEY_F;\n\t}\n\t\n\tprivate boolean isEventEscape(KeyEvent ev) {\n\t\treturn ev.keyCode == KEY_ESC;\n\t}\n\t\n\tprivate void toggleSearchBar() {\n\t\tif(isVisible()) {\n\t\t\thideSearchBar();\n\t\t\ttextControl.setFocus();\n\t\t} else {\n\t\t\tdisplaySearchBar();\n\t\t}\n\t}\n\n\tprivate void hideSearchBar() {\n\t\tclearCurrentSearch();\n\t\tsetVisible(false);\n\t\tgetParent().layout(true);\n\t}\n\t\n\tprivate void displaySearchBar() {\n\t\tsetVisible(true);\n\t\tpack();\n\t\tgetParent().layout(true);\n\t\tsetFocus();\n\t}\n\t\n\t@Override\n\tpublic void verifyKey(VerifyEvent event) {\n\t\tif(isEventCtrlF(event)) {\n\t\t\ttoggleSearchBar();\n\t\t}\n\t\tif(isEventEscape(event)) {\n\t\t\thideSearchBar();\n\t\t\ttextControl.setFocus();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void keyPressed(KeyEvent e) {\n\t\tif(isEventCtrlF(e) || isEventEscape(e)) {\n\t\t\thideSearchBar();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void keyReleased(KeyEvent e) {\n\t}\n\n\n\t@Override\n\tpublic void matchChanged() {\n\t\tsummarizeSearchResult();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.httpeditor/src/com/subgraph/vega/ui/httpeditor/search/SearchResult.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.httpeditor.search;\n\nimport java.util.List;\n\nimport org.eclipse.jface.text.IRegion;\n\nclass SearchResult {\n\t\n\tfinal private List<IRegion> matches;\n\t\n\tprivate int currentIndex;\n\t\n\t\n\tSearchResult(List<IRegion> matches) {\n\t\tthis.matches = matches;\n\t\tthis.currentIndex = 0;\n\t}\n\t\n\tint getCurrentIndex() {\n\t\treturn currentIndex;\n\t}\n\t\n\tint getResultCount() {\n\t\treturn matches.size();\n\t}\n\t\n\tboolean hasPrevious() {\n\t\treturn currentIndex > 0;\n\t}\n\t\n\tboolean hasNext() {\n\t\treturn matches.size() > (currentIndex + 1);\n\t}\n\t\n\tIRegion getFirstMatch() {\n\t\tif(matches.isEmpty()) {\n\t\t\tthrow new RuntimeException(\"Trying to get first match on empty search result\");\n\t\t}\n\t\tcurrentIndex = 0;\n\t\treturn matches.get(0);\n\t}\n\t\n\tIRegion getNextMatch() {\n\t\tif(!hasNext()) {\n\t\t\tthrow new RuntimeException(\"Next search match does not exist\");\n\t\t}\n\t\tcurrentIndex += 1;\n\t\treturn matches.get(currentIndex);\n\t}\n\t\n\tIRegion getPreviousMatch() {\n\t\tif(!hasPrevious()) {\n\t\t\tthrow new RuntimeException(\"Previous search match does not exist\");\n\t\t}\n\t\tcurrentIndex -= 1;\n\t\treturn matches.get(currentIndex);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.identity</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Identity\nBundle-SymbolicName: com.subgraph.vega.ui.identity;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.identity.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nImport-Package: com.subgraph.vega.api.events,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.identity,\n com.subgraph.vega.api.model.macros,\n com.subgraph.vega.ui.macros.macrodialog,\n com.subgraph.vega.ui.util.images\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <view\n            allowMultiple=\"false\"\n            class=\"com.subgraph.vega.ui.identity.identitiesview.IdentitiesView\"\n            icon=\"icons/identities.png\"\n            id=\"com.subgraph.vega.views.identity.identities\"\n            name=\"Identities\"\n            restorable=\"true\">\n      </view>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:com.subgraph.vega.views.identity.identities\">\n         <command\n               commandId=\"com.subgraph.vega.commands.createIdentity\"\n               icon=\"icons/create_identity.png\"\n               label=\"Create Identity\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <command\n            description=\"Create an Identity\"\n            id=\"com.subgraph.vega.commands.createIdentity\"\n            name=\"Create Identity\">\n      </command>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"com.subgraph.vega.ui.identity.commands.CreateIdentity\"\n            commandId=\"com.subgraph.vega.commands.createIdentity\">\n      </handler>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/Activator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.model.IModel;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.identity\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/commands/CreateIdentity.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.ui.identity.Activator;\nimport com.subgraph.vega.ui.identity.identitywizard.IdentityWizard;\nimport com.subgraph.vega.ui.identity.identitywizard.IdentityWizardDialog;\n\npublic class CreateIdentity extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkspace workspace = Activator.getDefault().getModel().getCurrentWorkspace();\n\t\tif (workspace != null) {\t\t\t\n\t\t\tIIdentityModel identityModel = workspace.getIdentityModel();\n\t\t\tIdentityWizard wizard = new IdentityWizard();\n\t\t\tIdentityWizardDialog dialog = new IdentityWizardDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), wizard);\n\t\t\tif (dialog.open() == IDialogConstants.OK_ID) {\n\t\t\t\tIIdentity identity = wizard.getIdentity();\n\t\t\t\tidentityModel.store(identity);\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitiesview/AuthMethodComboViewer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitiesview;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\n\npublic class AuthMethodComboViewer extends ComboViewer {\n\tpublic enum AuthMethodSelection {\n\t\tAUTH_METHOD_BASIC(\"basic http authentication\", IAuthMethod.AuthMethodType.AUTH_METHOD_RFC2617),\n\t\tAUTH_METHOD_DIGEST(\"digest http authentication\", IAuthMethod.AuthMethodType.AUTH_METHOD_RFC2617),\n\t\tAUTH_METHOD_NTLM(\"NTLM\", IAuthMethod.AuthMethodType.AUTH_METHOD_NTLM),\n\t\tAUTH_METHOD_HTTP_MACRO(\"macro\", IAuthMethod.AuthMethodType.AUTH_METHOD_HTTP_MACRO);\n\t\t\n\t\tprivate String name;\n\t\tprivate IAuthMethod.AuthMethodType authMethodType;\n\n\t\tprivate AuthMethodSelection(String name, IAuthMethod.AuthMethodType authMethodType) {\n\t\t\tthis.name = name;\n\t\t\tthis.authMethodType = authMethodType;\n\t\t}\n\t\t\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\t\t\n\t\tpublic IAuthMethod.AuthMethodType getAuthMethodType() {\n\t\t\treturn authMethodType;\n\t\t}\n\t}\n\n\tpublic AuthMethodComboViewer(Composite parent) {\n\t\tsuper(parent, SWT.READ_ONLY);\n\t\tsetContentProvider(new ArrayContentProvider());\n\t\tsetLabelProvider(createLabelProvider());\n\t\tfinal AuthMethodSelection[] values = AuthMethodSelection.values();\n\t\tsetInput(values);\n\t\tsetSelection(new StructuredSelection(values[0]));\n\t\t\n\t}\n\n\tprivate ILabelProvider createLabelProvider() {\n\t\treturn new LabelProvider() {\n\t\t\t@Override\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn ((AuthMethodSelection)element).getName();\n\t\t\t}\n\t\t};\n\t}\n\n\tpublic AuthMethodSelection getAuthMethodSelection() {\n\t\treturn (AuthMethodSelection)((IStructuredSelection) getSelection()).getFirstElement();\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitiesview/IdentitiesView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitiesview;\n\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.ui.identity.Activator;\nimport com.subgraph.vega.ui.identity.identityview.tree.IdentitiesViewerContentProvider;\nimport com.subgraph.vega.ui.identity.identityview.tree.IdentitiesViewerLabelProvider;\n\npublic class IdentitiesView extends ViewPart {\n\tpublic static final String ID = \"com.subgraph.vega.views.identity.identities\";\n\tprivate IIdentityModel identityModel;\n\tprivate Composite parentComposite;\n\tprivate TreeViewer identitiesViewer;\n\n\tpublic IdentitiesView() {\n\t\tIWorkspace currentWorkspace = Activator.getDefault().getModel().addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tidentityModel = currentWorkspace.getIdentityModel();\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tidentityModel = event.getWorkspace().getIdentityModel();\n\t\tidentitiesViewer.setInput(identityModel);\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tidentityModel = null;\n\t\tidentitiesViewer.setInput(identityModel);\n\t}\n\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tidentityModel = event.getWorkspace().getIdentityModel();\n\t\tidentitiesViewer.setInput(identityModel);\n\t}\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tparentComposite = new Composite(parent, SWT.NONE);\n\t\tparentComposite.setLayout(new FillLayout());\n\t\tcreateTreeViewer(parentComposite);\n\t\tidentitiesViewer.setInput(identityModel);\n\t}\n\n\t@Override\n\tpublic void setFocus() {\n\t\tparentComposite.setFocus();\n\t}\n\n\tprivate void createTreeViewer(Composite parent) {\n\t\tidentitiesViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\tidentitiesViewer.setContentProvider(new IdentitiesViewerContentProvider());\n\t\tidentitiesViewer.setLabelProvider(new IdentitiesViewerLabelProvider());\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/AuthMethodHttpMacroTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodHttpMacro;\n\npublic class AuthMethodHttpMacroTreeNode implements IIdentityTreeNode {\n\tprivate final IAuthMethodHttpMacro authMethod;\n\tprivate final List<IIdentityTreeNode> childrenList = new ArrayList<IIdentityTreeNode>();\n\n\tpublic AuthMethodHttpMacroTreeNode(IAuthMethod authMethod) {\n\t\tthis.authMethod = (IAuthMethodHttpMacro) authMethod;\n\t\tchildrenList.add(new StringTreeNode(\"Macro: \" + this.authMethod.getMacro().getName()));\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn \"HTTP Macro Authentication\";\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn childrenList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/AuthMethodNtlmTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodNtlm;\n\npublic class AuthMethodNtlmTreeNode implements IIdentityTreeNode {\n\tprivate final IAuthMethodNtlm authMethod;\n\tprivate final List<IIdentityTreeNode> childrenList = new ArrayList<IIdentityTreeNode>();\n\n\tpublic AuthMethodNtlmTreeNode(IAuthMethod authMethod) {\n\t\tthis.authMethod = (IAuthMethodNtlm) authMethod;\n\t\tchildrenList.add(new StringTreeNode(\"Username: \" + this.authMethod.getUsername()));\n\t\tchildrenList.add(new StringTreeNode(\"Password: \" + this.authMethod.getPassword()));\n\t\tchildrenList.add(new StringTreeNode(\"Workstation: \" + this.authMethod.getWorkstation()));\n\t\tchildrenList.add(new StringTreeNode(\"Domain: \" + this.authMethod.getDomain()));\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn \"NTLMv1/NTLMv2/NTLM2 Authentication\";\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn childrenList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/AuthMethodRfc2617TreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodRfc2617;\n\npublic class AuthMethodRfc2617TreeNode implements IIdentityTreeNode {\n\tprivate IAuthMethodRfc2617 authMethod;\n\tprivate final List<IIdentityTreeNode> childrenList = new ArrayList<IIdentityTreeNode>();\n\n\tpublic AuthMethodRfc2617TreeNode(IAuthMethod authMethod) {\n\t\tthis.authMethod = (IAuthMethodRfc2617) authMethod;\n\t\tchildrenList.add(new StringTreeNode(\"Username: \" + this.authMethod.getUsername()));\n\t\tchildrenList.add(new StringTreeNode(\"Password: \" + this.authMethod.getPassword()));\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\tStringBuffer buf = new StringBuffer();\n\t\tif (authMethod.getAuthScheme() == IAuthMethodRfc2617.AuthScheme.AUTH_SCHEME_BASIC) {\n\t\t\tbuf.append(\"Basic\");\n\t\t} else {\n\t\t\tbuf.append(\"Digest\");\n\t\t}\n\t\tbuf.append(\" Authentication\");\n\t\treturn buf.toString();\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn childrenList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/AuthenticationTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IIdentity;\n\npublic class AuthenticationTreeNode implements IIdentityTreeNode {\n\tprivate static final String IMAGE_PATH = \"icons/authentication.png\";\n\tprivate final IIdentity identity;\n\tprivate IAuthMethod authMethod;\n\tprivate List<IIdentityTreeNode> childrenList;\n\n\tpublic AuthenticationTreeNode(IIdentity identity) {\n\t\tthis.identity = identity;\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn \"Authentication\";\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn IMAGE_PATH;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\tIAuthMethod authMethodUpdt = identity.getAuthMethod();\n\t\tif (authMethodUpdt != authMethod) {\n\t\t\tif (childrenList == null) {\n\t\t\t\tchildrenList = new ArrayList<IIdentityTreeNode>();\n\t\t\t} else {\n\t\t\t\tchildrenList.clear();\n\t\t\t}\n\n\t\t\tauthMethod = authMethodUpdt;\n\t\t\tswitch (authMethod.getType()) {\n\t\t\tcase AUTH_METHOD_RFC2617:\n\t\t\t\tchildrenList.add(new AuthMethodRfc2617TreeNode(authMethod));\n\t\t\t\tbreak;\n\t\t\tcase AUTH_METHOD_NTLM:\n\t\t\t\tchildrenList.add(new AuthMethodNtlmTreeNode(authMethod));\n\t\t\t\tbreak;\n\t\t\tcase AUTH_METHOD_HTTP_MACRO:\n\t\t\t\tchildrenList.add(new AuthMethodHttpMacroTreeNode(authMethod));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn (childrenList != null && childrenList.size() != 0);\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn childrenList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/DictionaryTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport com.subgraph.vega.api.model.identity.IIdentity;\n\npublic class DictionaryTreeNode implements IIdentityTreeNode {\n\tprivate static final String IMAGE_PATH = \"icons/dictionary.png\";\n\tprivate final IIdentity identity;\n\n\tpublic DictionaryTreeNode(IIdentity identity) {\n\t\tthis.identity = identity;\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn \"Dictionary\";\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn IMAGE_PATH;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\t// TODO Auto-generated method stub\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\t// TODO Auto-generated method stub\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/IIdentityTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\npublic interface IIdentityTreeNode {\n\tString getText();\n\tString getImagePath();\n\tboolean hasChildren();\n \tObject[] getChildren();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/IdentitiesViewerContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.api.model.identity.NewIdentityEvent;\n\npublic class IdentitiesViewerContentProvider implements ITreeContentProvider, IEventHandler {\n\tprivate IIdentityModel identityModel;\n\tprivate Viewer viewer;\n\tprivate List<IIdentityTreeNode> childrenList = new ArrayList<IIdentityTreeNode>();\n\n\t@Override\n\tpublic void dispose() {\n\t\tif (identityModel != null) {\n\t\t\tidentityModel.removeChangeListener(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tthis.viewer = viewer;\n\t\tif (identityModel != newInput) {\n\t\t\tif (identityModel != null) {\n\t\t\t\tidentityModel.removeChangeListener(this);\n\t\t\t\tchildrenList.clear();\n\t\t\t}\n\n\t\t\tidentityModel = (IIdentityModel) newInput;\n\t\t\tchildrenList.clear();\n\t\t\tif (identityModel != null) {\n\t\t\t\tidentityModel.addChangeListener(this);\n\t\t\t\tfor (IIdentity identity: identityModel.getAllIdentities()) {\n\t\t\t\t\tchildrenList.add(new IdentityTreeNode(identity));\n\t\t\t\t}\n\t\t\t} \n\t\t}\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn childrenList.toArray();\n\t}\n\n\t@Override\n\tpublic Object[] getChildren(Object parentElement) {\n\t\treturn ((IIdentityTreeNode) parentElement).getChildren();\n\t}\n\n\t@Override\n\tpublic Object getParent(Object element) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren(Object element) {\n\t\treturn ((IIdentityTreeNode) element).hasChildren();\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif (event instanceof NewIdentityEvent) {\n\t\t\tchildrenList.add(new IdentityTreeNode(((NewIdentityEvent) event).getIdentity()));\n\t\t\tviewer.refresh();\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/IdentitiesViewerLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Image;\n\nimport com.subgraph.vega.ui.identity.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class IdentitiesViewerLabelProvider extends LabelProvider {\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\n\t@Override\n\tpublic String getText(Object element) {\n\t\treturn ((IIdentityTreeNode) element).getText();\n\t}\n\n\t@Override\n\tpublic Image getImage(Object element) {\n\t\tfinal String imagePath = ((IIdentityTreeNode) element).getImagePath();\n\t\tif (imagePath != null) {\n\t\t\treturn imageCache.get(imagePath);\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/IdentityTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.identity.IIdentity;\n\npublic class IdentityTreeNode implements IIdentityTreeNode {\n\tprivate static final String IMAGE_PATH = \"icons/identity.png\";\n\tprivate final IIdentity identity;\n\tprivate final List<IIdentityTreeNode> childrenList = new ArrayList<IIdentityTreeNode>();\n\n\tpublic IdentityTreeNode(IIdentity identity) {\n\t\tthis.identity = identity;\n\t\tchildrenList.add(new DictionaryTreeNode(identity));\n\t\tchildrenList.add(new AuthenticationTreeNode(identity));\n\t\tchildrenList.add(new ScanExclusionsTreeNode(identity));\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn identity.getName();\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn IMAGE_PATH;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn (childrenList.size() > 0);\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn childrenList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/ScanExclusionsTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identityview.tree;\n\nimport com.subgraph.vega.api.model.identity.IIdentity;\n\npublic class ScanExclusionsTreeNode implements IIdentityTreeNode {\n\tprivate static final String IMAGE_PATH = \"icons/scan_exclusions.png\";\n\tprivate final IIdentity identity;\n\n\tpublic ScanExclusionsTreeNode(IIdentity identity) {\n\t\tthis.identity = identity;\n\t}\n\n\t@Override\n\tpublic String getText() {\n\t\treturn \"Scan Exclusions\";\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn IMAGE_PATH;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identityview/tree/StringTreeNode.java",
    "content": "package com.subgraph.vega.ui.identity.identityview.tree;\n\npublic class StringTreeNode implements IIdentityTreeNode {\n\tprivate final String text;\n\n\tpublic StringTreeNode(String text) {\n\t\tthis.text = text;\n\t}\n\t\n\t@Override\n\tpublic String getText() {\n\t\treturn text;\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/AuthMethodControlHttpMacro.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.ui.identity.Activator;\nimport com.subgraph.vega.ui.macros.macrodialog.MacroDialog;\n\npublic class AuthMethodControlHttpMacro extends Composite implements IAuthMethodControl {\n\tprivate final WizardPage page;\n\tprivate IAuthMethodHttpMacro authMethod;\n\tprivate TableViewer macrosTableViewer;\n\n\tAuthMethodControlHttpMacro(Composite parent, WizardPage page) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new GridLayout(1, false));\n\t\tthis.page = page;\n\t\tauthMethod = Activator.getDefault().getModel().getCurrentWorkspace().getIdentityModel().createAuthMethodHttpMacro();\n\t\tcreateControls();\n\t}\n\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic IAuthMethod getAuthMethod() {\n\t\tIHttpMacro macro = (IHttpMacro)((IStructuredSelection) macrosTableViewer.getSelection()).getFirstElement();\n\t\tauthMethod.setMacro(macro);\n\t\treturn authMethod;\n\t}\n\n\tprivate void createControls() {\n\t\tLabel label = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Select a macro below, or create one\");\n\t\tcreateMacrosTable(this).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tcreateMacrosTableButtons(this).setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));\n\n\t\tmacrosTableViewer.setInput(Activator.getDefault().getModel().getCurrentWorkspace().getHttpMacroModel());\n\t}\n\n\tprivate Composite createMacrosTable(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\tmacrosTableViewer = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\tmacrosTableViewer.setContentProvider(new MacrosTableContentProvider());\n\t\tmacrosTableViewer.addSelectionChangedListener(createMacrosTableSelectionChangedListener());\n\t\tcreateMacrosTableColumns(macrosTableViewer, tcl);\n\t\tfinal Table table = macrosTableViewer.getTable();\n\t\ttable.setHeaderVisible(false);\n\t\ttable.setLinesVisible(true);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate ISelectionChangedListener createMacrosTableSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tpage.setPageComplete(!event.getSelection().isEmpty());\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void createMacrosTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnWeightData(1),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpMacro) element).getName();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tfor (int i = 0; i < layoutData.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\t\n\t}\n\n\tprivate Control createMacrosTableButtons(Composite parent) {\n\t\tButton button = new Button(parent, SWT.PUSH);\n\t\tbutton.setText(\"Create macro\");\n\t\tbutton.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tMacroDialog dialog = MacroDialog.createDialog(getShell());\n\t\t\t\tif (dialog.open() == Window.OK) {\n\t\t\t\t\tmacrosTableViewer.refresh();\n\t\t\t\t\tmacrosTableViewer.setSelection(new StructuredSelection(dialog.getMacro()), true);\n\t\t\t\t}\n\t\t\t}\n\t\t});\t\t\n\t\treturn button;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/AuthMethodControlNtlm.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodNtlm;\nimport com.subgraph.vega.ui.identity.Activator;\n\npublic class AuthMethodControlNtlm extends Composite implements IAuthMethodControl {\n\tprivate final WizardPage page;\n\tprivate IAuthMethodNtlm authMethod;\n\tprivate Text usernameText;\n\tprivate Text passwordText;\n\tprivate Text workstationText;\n\tprivate Text domainText;\n\t\n\tpublic AuthMethodControlNtlm(Composite parent, WizardPage page) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new GridLayout(2, false));\n\t\tthis.page = page;\n\t\tauthMethod = Activator.getDefault().getModel().getCurrentWorkspace().getIdentityModel().createAuthMethodNtlm();\n\t\tcreateControls();\n\t}\n\t\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic IAuthMethod getAuthMethod() {\n\t\tauthMethod.setUsername(usernameText.getText());\n\t\tauthMethod.setPassword(passwordText.getText());\n\t\tauthMethod.setWorkstation(workstationText.getText());\n\t\tauthMethod.setDomain(domainText.getText());\n\t\treturn authMethod;\n\t}\n\n\tprivate void createControls() {\n\t\tLabel label = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Username:\");\n\t\tusernameText = new Text(this, SWT.BORDER);\n\t\tusernameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tusernameText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tpage.setPageComplete(!usernameText.getText().trim().isEmpty());\n\t\t\t}\n\t\t});\n\n\t\tlabel = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Password:\");\n\t\tpasswordText = new Text(this, SWT.BORDER);\n\t\tpasswordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\n\t\tlabel = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Workstation:\");\n\t\tworkstationText = new Text(this, SWT.BORDER);\n\t\tworkstationText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\n\t\tlabel = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Domain:\");\n\t\tdomainText = new Text(this, SWT.BORDER);\n\t\tdomainText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/AuthMethodControlRfc2617.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodRfc2617;\nimport com.subgraph.vega.ui.identity.Activator;\n\npublic class AuthMethodControlRfc2617 extends Composite implements IAuthMethodControl {\n\tprivate final WizardPage page;\n\tprivate IAuthMethodRfc2617 authMethod;\n\tprivate Text usernameText;\n\tprivate Text passwordText;\n\t\n\tpublic AuthMethodControlRfc2617(Composite parent, WizardPage page, IAuthMethodRfc2617.AuthScheme authScheme) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new GridLayout(2, false));\n\t\tthis.page = page;\n\t\tauthMethod = Activator.getDefault().getModel().getCurrentWorkspace().getIdentityModel().createAuthMethodRfc2617();\n\t\tauthMethod.setAuthScheme(authScheme);\n\t\tcreateControls();\n\t}\n\t\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic IAuthMethod getAuthMethod() {\n\t\tauthMethod.setUsername(usernameText.getText());\n\t\tauthMethod.setPassword(passwordText.getText());\n\t\treturn authMethod;\n\t}\n\n\tprivate void createControls() {\n\t\tLabel label = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Username:\");\n\t\tusernameText = new Text(this, SWT.BORDER);\n\t\tusernameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tusernameText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tpage.setPageComplete(!usernameText.getText().trim().isEmpty());\n\t\t\t}\n\t\t});\n\n\t\tlabel = new Label(this, SWT.NONE);\n\t\tlabel.setText(\"Password:\");\n\t\tpasswordText = new Text(this, SWT.BORDER);\n\t\tpasswordText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/IAuthMethodControl.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.swt.widgets.Control;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\n\npublic interface IAuthMethodControl {\n\tControl getControl();\n\tIAuthMethod getAuthMethod();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/IIdentityWizardPage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\npublic interface IIdentityWizardPage {\n\t/**\n\t * Notification that the page was selected.\n\t */\n\tpublic void pageSelected();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/IdentityWizard.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.wizard.Wizard;\n\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.identity.IIdentityModel;\nimport com.subgraph.vega.ui.identity.Activator;\n\npublic class IdentityWizard extends Wizard {\n\tprivate final IdentityWizardPage1 page1;\n\tprivate final IdentityWizardPage2 page2;\n\tprivate IIdentity identity;\n\n\tpublic IdentityWizard() {\n\t\tpage1 = new IdentityWizardPage1();\n\t\tpage2 = new IdentityWizardPage2(page1);\n\t}\n\n\t@Override\n\tpublic void addPages() {\n\t\taddPage(page1);\n\t\taddPage(page2);\n\t}\n\n\t@Override\n\tpublic boolean performFinish() {\n\t\tfinal IIdentityModel identityModel = Activator.getDefault().getModel().getCurrentWorkspace().getIdentityModel();\n\t\tidentity = identityModel.createIdentity();\n\t\tidentity.setName(page1.getName());\n\t\tidentity.setAuthMethod(page2.getAuthMethod());\n\t\treturn true;\n\t}\n\n\tpublic IIdentity getIdentity() {\n\t\treturn identity;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/IdentityWizardDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.dialogs.IPageChangedListener;\nimport org.eclipse.jface.dialogs.PageChangedEvent;\nimport org.eclipse.jface.wizard.IWizard;\nimport org.eclipse.jface.wizard.WizardDialog;\nimport org.eclipse.swt.widgets.Shell;\n\npublic class IdentityWizardDialog extends WizardDialog {\n\t\n\tpublic IdentityWizardDialog(Shell parentShell, IWizard newWizard) {\n\t\tsuper(parentShell, newWizard);\n\t\taddPageChangedListener(createPageChangedListener());\n\t}\n\n\tprivate IPageChangedListener createPageChangedListener() {\n\t\treturn new IPageChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void pageChanged(PageChangedEvent event) {\n\t\t\t\tObject page = event.getSelectedPage();\n\t\t\t\tif (page instanceof IIdentityWizardPage) {\n\t\t\t\t\t((IIdentityWizardPage)page).pageSelected();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/IdentityWizardPage1.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.ui.identity.identitiesview.AuthMethodComboViewer;\nimport com.subgraph.vega.ui.identity.identitiesview.AuthMethodComboViewer.AuthMethodSelection;\n\npublic class IdentityWizardPage1 extends WizardPage implements IIdentityWizardPage {\n\tprivate Composite parentComposite;\n\tprivate Text identityNameText;\n\tprivate AuthMethodComboViewer authMethodComboViewer;\n\n\tprotected IdentityWizardPage1() {\n\t\tsuper(\"Create an identity\");\n\t\tsetTitle(\"Create an identity\");\n\t\tsetDescription(\"Specify basic information about the identity\");\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\tparentComposite = new Composite(parent, SWT.NULL);\n\t\tparentComposite.setLayout(new GridLayout(1, false));\n\n\t\tLabel label = new Label(parentComposite, SWT.NONE);\n\t\tlabel.setText(\"Input an identity name:\");\n\n\t\tidentityNameText = new Text(parentComposite, SWT.SINGLE | SWT.BORDER);\n\t\tidentityNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tidentityNameText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tsetPageComplete(!identityNameText.getText().trim().isEmpty());\n\t\t\t}\n\t\t});\n\t\t\n\t\tlabel = new Label(parentComposite, SWT.NONE);\n\t\tlabel.setText(\"Authentication type:\");\n\n\t\tauthMethodComboViewer = new AuthMethodComboViewer(parentComposite); \n\t\t\n\t\tsetControl(parentComposite);\n\t\tsetPageComplete(false);\n\t}\n\n\t@Override\n\tpublic void pageSelected() {\n\t}\n\n\tpublic String getName() {\n\t\treturn identityNameText.getText();\n\t}\n\t\n\tpublic AuthMethodSelection getAuthMethodSelection() {\n\t\treturn authMethodComboViewer.getAuthMethodSelection(); \n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/IdentityWizardPage2.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StackLayout;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.model.identity.IAuthMethod;\nimport com.subgraph.vega.api.model.identity.IAuthMethodRfc2617;\nimport com.subgraph.vega.ui.identity.identitiesview.AuthMethodComboViewer;\n\npublic class IdentityWizardPage2 extends WizardPage implements IIdentityWizardPage {\n\tprivate final IdentityWizardPage1 page1;\n\tprivate Composite parentComposite;\n\tprivate StackLayout stackLayout;\n\tprivate AuthMethodComboViewer.AuthMethodSelection authMethodSelCurr;\n\tprivate IAuthMethodControl authMethodControl;\n\n\tprotected IdentityWizardPage2(IdentityWizardPage1 page1) {\n\t\tsuper(\"Create an identity\");\n\t\tsetTitle(\"Create an identity\");\n\t\tsetDescription(\"Specify scheme-specific authentication information\");\n\t\tthis.page1 = page1;\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\tparentComposite = new Composite(parent, SWT.NULL);\n\t\tstackLayout = new StackLayout();\n\t\tparentComposite.setLayout(stackLayout);\n\t\tsetControl(parentComposite);\n\t\tsetPageComplete(false);\t\t\n\t}\n\n\t@Override\n\tpublic void pageSelected() {\n\t\tif (authMethodSelCurr != page1.getAuthMethodSelection()) {\n\t\t\tauthMethodSelCurr = page1.getAuthMethodSelection();\n\t\t\tauthMethodControl = instAuthMethodControl(authMethodSelCurr);\n\t\t\tstackLayout.topControl = authMethodControl.getControl();\n\t\t\tstackLayout.topControl.setFocus();\n\t\t\tparentComposite.layout();\n\t\t}\n\t}\n\n\tprivate IAuthMethodControl instAuthMethodControl(AuthMethodComboViewer.AuthMethodSelection authMethodSel) {\n\t\tIAuthMethodControl control = null;\n\t\tswitch (authMethodSelCurr) {\n\t\tcase AUTH_METHOD_BASIC:\n\t\t\tcontrol = new AuthMethodControlRfc2617(parentComposite, this, IAuthMethodRfc2617.AuthScheme.AUTH_SCHEME_BASIC);\n\t\t\tbreak;\n\t\tcase AUTH_METHOD_DIGEST:\n\t\t\tcontrol = new AuthMethodControlRfc2617(parentComposite, this, IAuthMethodRfc2617.AuthScheme.AUTH_SCHEME_DIGEST);\n\t\t\tbreak;\n\t\tcase AUTH_METHOD_NTLM:\n\t\t\tcontrol = new AuthMethodControlNtlm(parentComposite, this);\n\t\t\tbreak;\n\t\tcase AUTH_METHOD_HTTP_MACRO:\n\t\t\tcontrol = new AuthMethodControlHttpMacro(parentComposite, this);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn null;\n\t\t}\n\t\treturn control;\n\t}\n\n\tpublic IAuthMethod getAuthMethod() {\n\t\treturn authMethodControl.getAuthMethod();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.identity/src/com/subgraph/vega/ui/identity/identitywizard/MacrosTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.identity.identitywizard;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\n\npublic class MacrosTableContentProvider implements IStructuredContentProvider {\n\tprivate IHttpMacroModel macroModel;\n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tmacroModel = (IHttpMacroModel) newInput;\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn macroModel.getAllMacros().toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.macros</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Macros\nBundle-SymbolicName: com.subgraph.vega.ui.macros;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.macros.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nImport-Package: com.subgraph.vega.api.events,\n com.subgraph.vega.api.http.requests,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.macros,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.variables,\n com.subgraph.vega.ui.http.builder,\n com.subgraph.vega.ui.http.requestlogviewer,\n com.subgraph.vega.ui.util.dialogs,\n com.subgraph.vega.ui.util.images,\n org.apache.http;version=\"4.1.0\"\nExport-Package: com.subgraph.vega.ui.macros.macrodialog\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <view\n            allowMultiple=\"false\"\n            class=\"com.subgraph.vega.ui.macros.macrosview.MacrosView\"\n            icon=\"icons/macros.png\"\n            id=\"com.subgraph.vega.views.macros.macros\"\n            name=\"Macros\"\n            restorable=\"true\">\n      </view>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <command\n            description=\"Create a Macro\"\n            id=\"com.subgraph.vega.commands.createMacro\"\n            name=\"Create Macro\">\n      </command>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"com.subgraph.vega.ui.macros.commands.CreateMacro\"\n            commandId=\"com.subgraph.vega.commands.createMacro\">\n      </handler>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:com.subgraph.vega.views.macros.macros\">\n         <command\n               commandId=\"com.subgraph.vega.commands.createMacro\"\n               icon=\"icons/create_macro.png\"\n               label=\"Create Macro\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/internal/ui/macros/macrodialog/MacroItemEditor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.macros.macrodialog;\n\nimport java.util.Iterator;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItem;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam;\nimport com.subgraph.vega.ui.http.builder.BuilderParseException;\nimport com.subgraph.vega.ui.http.builder.IHttpBuilderPart;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class MacroItemEditor extends Composite implements IHttpBuilderPart {\n\tprivate IHttpRequestBuilder requestBuilder;\n\tprivate IHttpMacroItem macroItem;\n\tprivate Button useCookiesButton;\n\tprivate Button keepCookiesButton;\n\tprivate TableViewer paramsTableViewer;\n\tprivate boolean paramsTableHasSelection;\n\tprivate Button createButton;\n\tprivate Button removeButton;\n\tprivate Button moveUpButton;\n\tprivate Button moveDownButton;\n\n\tpublic MacroItemEditor(Composite parent, IHttpRequestBuilder requestBuilder) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.requestBuilder = requestBuilder;\n\t\tsetLayout(new GridLayout(1, false));\n\n\t\tcreateConfigGroup(this).setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));\n\t\tcreateParamsGroup(this).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t}\n\n\t@Override\n\tpublic Control getControl() {\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic void setEditable(boolean editable) {\n\t\tuseCookiesButton.setEnabled(editable);\n\t\tkeepCookiesButton.setEnabled(editable);\n\t\tcreateButton.setEnabled(editable);\n\t\tremoveButton.setEnabled(editable && paramsTableHasSelection);\n\t\tmoveUpButton.setEnabled(editable && paramsTableHasSelection);\n\t\tmoveDownButton.setEnabled(editable && paramsTableHasSelection);\n\t}\n\n\t@Override\n\tpublic void refresh() {\n\t\ttry {\n\t\t\tif (macroItem != null) {\n\t\t\t\tmacroItem.updateFromRequestBuilder(requestBuilder);\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tErrorDialog.displayError(getShell(), \"An unexpected error occurred while processing the request\");\n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tif (macroItem != null) {\n\t\t\tuseCookiesButton.setSelection(macroItem.getUseCookies());\n\t\t\tkeepCookiesButton.setSelection(macroItem.getKeepCookies());\n\t\t} else {\n\t\t\tuseCookiesButton.setSelection(false);\n\t\t\tkeepCookiesButton.setSelection(false);\n\t\t}\n\t\tparamsTableViewer.setInput(macroItem);\n\t}\n\n\t@Override\n\tpublic void processContents() throws BuilderParseException {\n\t\tif (macroItem != null) {\n\t\t\ttry {\n\t\t\t\tmacroItem.setRequestBuilder(requestBuilder, null);\n\t\t\t} catch (Exception e) {\n\t\t\t\tErrorDialog.displayError(getShell(), \"An unexpected error occurred while processing the request\");\n\t\t\t\te.printStackTrace();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmacroItem.setUseCookies(useCookiesButton.getSelection());\n\t\t\tmacroItem.setKeepCookies(keepCookiesButton.getSelection());\n\t\t}\n\t}\n\n\tpublic void setMacroItem(IHttpMacroItem macroItem) {\n\t\tthis.macroItem = macroItem;\n\t}\n\t\n\tprivate Composite createConfigGroup(Composite parent) {\n\t\tGroup rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, false));\n\t\trootControl.setText(\"Configuration\");\n\n\t\tuseCookiesButton = new Button(rootControl, SWT.CHECK);\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Use cookies in the request that were already set\");\n\n\t\tkeepCookiesButton = new Button(rootControl, SWT.CHECK);\n\t\tlabel = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Keep cookies from the response\");\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createParamsGroup(Composite parent) {\n\t\tGroup rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, false));\n\t\trootControl.setText(\"Request Parameters\");\n\n\t\tGridData gd = new GridData(GridData.FILL_BOTH);\n\t\tcreateParamsTable(rootControl, gd, 8).setLayoutData(gd);\n\t\tcreateParamsButtons(rootControl).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createParamsTable(Composite parent, GridData gd, int heightInRows) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\tparamsTableViewer = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\tparamsTableViewer.setContentProvider(new MacroItemParamsTableContentProvider());\n\t\tparamsTableViewer.addSelectionChangedListener(createParamsTableSelectionChangedListener());\n\t\tcreateParamsTableColumns(paramsTableViewer, tcl);\n\t\tfinal Table table = paramsTableViewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t\tgd.heightHint = table.getItemHeight() * heightInRows;\n\n\t\treturn rootControl;\n\t}\n\n\tprivate ISelectionChangedListener createParamsTableSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tparamsTableHasSelection = !event.getSelection().isEmpty(); \n\t\t\t\tremoveButton.setEnabled(paramsTableHasSelection);\n\t\t\t\tmoveUpButton.setEnabled(paramsTableHasSelection);\n\t\t\t\tmoveDownButton.setEnabled(paramsTableHasSelection);\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void createParamsTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"Name\", \"Source\", \"Value\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnPixelData(70, true, true),\n\t\t\tnew ColumnPixelData(140, true, true),\n\t\t\tnew ColumnWeightData(100, 100, true),\n\t\t};\n\t\tfinal EditingSupport editorList[] = {\n\t\t\tnull,\n\t\t\tnew MacroItemParamValueSourceEditingSupport(viewer),\n\t\t\tnew MacroItemParamValueEditingSupport(viewer),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpMacroItemParam) element).getName();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpMacroItemParam) element).getValueSource().getDescription();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpMacroItemParam) element).getValue();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tfor (int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setEditingSupport(editorList[i]);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\t\n\t}\n\t\n\tprivate Composite createParamsButtons(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, true));\n\n\t\tcreateButton = new Button(rootControl, SWT.PUSH);\n\t\tcreateButton.setText(\"create\");\n\t\tcreateButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tcreateButton.addSelectionListener(createCreateButtonSelectionListener());\n\t\tremoveButton = new Button(rootControl, SWT.PUSH);\n\t\tremoveButton.setText(\"remove\");\n\t\tremoveButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tremoveButton.addSelectionListener(createRemoveButtonSelectionListener());\n\t\tmoveUpButton = new Button(rootControl, SWT.PUSH);\n\t\tmoveUpButton.setText(\"move up\");\n\t\tmoveUpButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tmoveUpButton.addSelectionListener(createMoveUpButtonSelectionListener());\n\t\tmoveDownButton = new Button(rootControl, SWT.PUSH);\n\t\tmoveDownButton.setText(\"move down\");\n\t\tmoveDownButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tmoveDownButton.addSelectionListener(createMoveDownButtonSelectionListener());\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createCreateButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate SelectionListener createRemoveButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) paramsTableViewer.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tmacroItem.removeParam((IHttpMacroItemParam) i.next());\n\t\t\t\t}\n\t\t\t\tparamsTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createMoveUpButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) paramsTableViewer.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tint idx = macroItem.indexOfParam((IHttpMacroItemParam) i.next());\n\t\t\t\t\tif (idx != 0) {\n\t\t\t\t\t\tmacroItem.swapParams(idx - 1, idx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tparamsTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createMoveDownButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) paramsTableViewer.getSelection();\n\t\t\t\tint idx[] = new int[selection.size()];\n\t\t\t\tint offset = 1;\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext(); offset++) {\n\t\t\t\t\tidx[idx.length - offset] = macroItem.indexOfParam((IHttpMacroItemParam) i.next());\n\t\t\t\t}\n\n\t\t\t\tif (idx[0] + 1 != macroItem.paramsSize()) {\n\t\t\t\t\tfor (int i = 0; i < idx.length; i++) {\n\t\t\t\t\t\tmacroItem.swapParams(idx[i], idx[i] + 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tparamsTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/internal/ui/macros/macrodialog/MacroItemParamValueEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.macros.macrodialog;\n\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TextCellEditor;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam;\n\npublic class MacroItemParamValueEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\n\tpublic MacroItemParamValueEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\treturn new TextCellEditor(viewer.getTable());\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\treturn ((IHttpMacroItemParam) element).getValue();\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\t((IHttpMacroItemParam) element).setValue((String) value);\n\t\tviewer.refresh();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/internal/ui/macros/macrodialog/MacroItemParamValueSourceEditingSupport.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.macros.macrodialog;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.CellEditor;\nimport org.eclipse.jface.viewers.ComboBoxViewerCellEditor;\nimport org.eclipse.jface.viewers.EditingSupport;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.swt.SWT;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacroItemParam;\n\npublic class MacroItemParamValueSourceEditingSupport extends EditingSupport {\n\tprivate final TableViewer viewer;\n\t\n\tpublic MacroItemParamValueSourceEditingSupport(TableViewer viewer) {\n\t\tsuper(viewer);\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tprotected CellEditor getCellEditor(Object element) {\n\t\tComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor(viewer.getTable(), SWT.READ_ONLY);\n\t\tcellEditor.setLabelProvider(new LabelProvider() {\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn ((IHttpMacroItemParam.ValueSource) element).getDescription();\n\t\t\t}\n\t\t});\n\t\tcellEditor.setContentProvider(new ArrayContentProvider());\n\t\tcellEditor.setInput(IHttpMacroItemParam.ValueSource.values());\n\t\treturn cellEditor;\n\t}\n\n\t@Override\n\tprotected boolean canEdit(Object element) {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Object getValue(Object element) {\n\t\tif (element instanceof IHttpMacroItemParam) {\n\t\t\treturn ((IHttpMacroItemParam) element).getValueSource().getDescription();\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tprotected void setValue(Object element, Object value) {\n\t\tif (element instanceof IHttpMacroItemParam && value instanceof IHttpMacroItemParam.ValueSource) {\n\t\t\tfinal IHttpMacroItemParam macroItemParam = (IHttpMacroItemParam) element;\n\t\t\tfinal IHttpMacroItemParam.ValueSource newValue = (IHttpMacroItemParam.ValueSource) value;\n\t\t\tif (macroItemParam.getValueSource().getDescription().equals(newValue.getDescription())) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmacroItemParam.setValueSource(newValue);\n\t\t\tviewer.refresh(true);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/internal/ui/macros/macrodialog/MacroItemParamsTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.macros.macrodialog;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacroItem;\n\npublic class MacroItemParamsTableContentProvider implements IStructuredContentProvider {\n\tprivate IHttpMacroItem macroItem;\n\t\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tmacroItem = (IHttpMacroItem) newInput;\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn macroItem.getParams().toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/internal/ui/macros/macrodialog/MacroItemSelectionDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.macros.macrodialog;\n\nimport java.util.List;\nimport java.util.UUID;\n\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.SashForm;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.ui.http.requestlogviewer.RequestLogViewer;\nimport com.subgraph.vega.ui.http.requestlogviewer.RequestResponseViewer;\n\npublic class MacroItemSelectionDialog extends TitleAreaDialog {\n\tprivate RequestLogViewer logViewer;\n\tprivate RequestResponseViewer requestResponseViewer;\n\tprivate List<IRequestLogRecord> selectionList;\n\n\tpublic MacroItemSelectionDialog(Shell parentShell) {\n\t\tsuper(parentShell);\n\t}\n\n\t@Override\n\tprotected boolean isResizable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected void okPressed() {\n\t\tselectionList = logViewer.getSelectionList();\n\t\tsuper.okPressed();\n\t}\n\n\t@Override\n\tpublic void create() {\n\t\tsuper.create();\n\t\tsetTitle(\"Macro Item Selector\");\n\t\tsetMessage(\"Select one or more requests below to be added to the macro\");\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tfinal Composite dialogArea = (Composite) super.createDialogArea(parent);\n\t\tfinal SashForm form = new SashForm(dialogArea, SWT.VERTICAL);\n\t\tform.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\tlogViewer = new RequestLogViewer(form, UUID.randomUUID().toString(), 12);\n\t\trequestResponseViewer = new RequestResponseViewer(form);\n\t\tlogViewer.setRequestResponseViewer(requestResponseViewer);\n\n\t\tform.setWeights(new int[] {40, 60});\n\n\t\treturn dialogArea;\n\t}\n\n\tpublic List<IRequestLogRecord> getSelectionList() {\n\t\treturn selectionList;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/internal/ui/macros/macrodialog/MacroItemTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.macros.macrodialog;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\n\npublic class MacroItemTableContentProvider implements IStructuredContentProvider {\n\tprivate IHttpMacro macro;\n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tmacro = (IHttpMacro) newInput;\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn macro.getMacroItems().toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/Activator.java",
    "content": "package com.subgraph.vega.ui.macros;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.model.IModel;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.macros\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\tprivate ServiceTracker<IHttpRequestEngineFactory, IHttpRequestEngineFactory> httpRequestEngineFactoryServiceTracker;\n\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t\t\n\t\thttpRequestEngineFactoryServiceTracker = new ServiceTracker<IHttpRequestEngineFactory, IHttpRequestEngineFactory>(context, IHttpRequestEngineFactory.class.getName(), null);\n\t\thttpRequestEngineFactoryServiceTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\n\tpublic IHttpRequestEngineFactory getHttpRequestEngineFactoryService() {\n\t\treturn httpRequestEngineFactoryServiceTracker.getService();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/commands/CreateMacro.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.macros.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.macros.macrodialog.MacroDialog;\n\npublic class CreateMacro extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tMacroDialog dialog = MacroDialog.createDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell());\n\t\tdialog.open();\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/macrodialog/MacroDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.macros.macrodialog;\n\nimport java.io.IOException;\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.Iterator;\nimport java.util.List;\n\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.graphics.FontMetrics;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.http.requests.IHttpRequestBuilder;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacroItem;\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.internal.ui.macros.macrodialog.MacroItemEditor;\nimport com.subgraph.vega.internal.ui.macros.macrodialog.MacroItemSelectionDialog;\nimport com.subgraph.vega.internal.ui.macros.macrodialog.MacroItemTableContentProvider;\nimport com.subgraph.vega.ui.http.builder.HeaderEditor;\nimport com.subgraph.vega.ui.http.builder.IHttpBuilderPart;\nimport com.subgraph.vega.ui.http.builder.RequestEditor;\nimport com.subgraph.vega.ui.macros.Activator;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic class MacroDialog extends TitleAreaDialog {\n\tprivate IHttpMacroModel macroModel;\n\tprivate IHttpMacro macro;\n\tprivate IHttpRequestBuilder requestBuilder;\n\tprivate Composite parentComposite;\n\tprivate Text macroNameText;\n\tprivate TableViewer macroItemTableViewer;\n\tprivate Button addItemButton;\n\tprivate Button moveUpButton;\n\tprivate Button moveDownButton;\n\tprivate Button removeButton;\n\tprivate TabFolder macroItemTabFolder;\n\tprivate TabItem macroItemTabFolderItem;\n\tprivate MacroItemEditor macroItemEditor;\n\tprivate IHttpBuilderPart requestBuilderPartCurr;\n\tprivate boolean requestIsEditable;\n\t\n\tpublic static MacroDialog createDialog(Shell parentShell) {\n\t\treturn createDialog(parentShell, null);\n\t}\n\n\tstatic public MacroDialog createDialog(Shell parentShell, IHttpMacro macro) {\n\t\tfinal MacroDialog dialog = new MacroDialog(parentShell, macro);\n\t\tdialog.create();\n\t\tdialog.getShell().addListener(SWT.Traverse, new Listener() {\n        \tpublic void handleEvent(Event e) {\n        \t\tif (e.detail == SWT.TRAVERSE_ESCAPE) {\n        \t\t\te.doit = false;\n        \t\t}\n        \t}\n        });\n\t\treturn dialog;\n\t}\n\t\n\tprivate MacroDialog(Shell parentShell, IHttpMacro macro) {\n\t\tsuper(parentShell);\n\t\tIWorkspace currentWorkspace = Activator.getDefault().getModel().addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tmacroModel = currentWorkspace.getHttpMacroModel();\n\t\tif (macro != null) {\n\t\t\tthis.macro = macro;\n\t\t} else {\n\t\t\tthis.macro = macroModel.createMacro();\n\t\t}\n\t\trequestBuilder = Activator.getDefault().getHttpRequestEngineFactoryService().createRequestBuilder();\n\t}\n\t\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tmacroModel = event.getWorkspace().getHttpMacroModel();\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tmacroModel = null;\n\t}\n\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tmacroModel = event.getWorkspace().getHttpMacroModel();\n\t}\n\n\tpublic IHttpMacro getMacro() {\n\t\treturn macro;\n\t}\n\n\t@Override\n\tprotected boolean isResizable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected void okPressed() {\n\t\tfinal String macroName = macroNameText.getText().trim();\n\t\tif (macroName.isEmpty()) {\n\t\t\tsetErrorMessage(\"The macro name cannot be empty\");\n\t\t\treturn;\n\t\t}\n\t\tfinal IHttpMacro macroStored = macroModel.getMacroByName(macroName); \n\t\tif (macroStored != null && macroStored != macro) {\n\t\t\tsetErrorMessage(\"A macro by that name already exists\");\n\t\t\treturn;\n\t\t}\n\n\t\tsetErrorMessage(null);\t\t\n\t\tmacro.setName(macroName);\n\t\tmacroModel.store(macro);\n\t\tsuper.okPressed();\n\t}\n\t\n\t@Override\n\tpublic void create() {\n\t\tsuper.create();\n\t\tsetTitle(\"Macro Editor\");\n\t\tsetMessage(\"Select items for the macro, then modify their characteristics\");\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tfinal Composite dialogArea = (Composite) super.createDialogArea(parent);\n\t\tparentComposite = new Composite(dialogArea, SWT.NONE);\n\t\tparentComposite.setLayout(new GridLayout(1, false));\n\t\tparentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\tcreateMacroArea(parentComposite).setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));\n\t    createItemsArea(parentComposite).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t    createItemEditor(parentComposite).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t    macroItemTableViewer.setInput(macro);\n\t    \n\t\treturn dialogArea;\n\t}\n\n\tprivate Composite createMacroArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, false));\n\t\trootControl.setText(\"Macro\");\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Macro Name:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));\n\n\t\tmacroNameText = new Text(rootControl, SWT.BORDER | SWT.SINGLE);\n\t\tmacroNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));;\n\t\tfinal FontMetrics macroNameTextFm = new GC(macroNameText).getFontMetrics();\n\t\tGridData requestPortGd = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);\n\t\trequestPortGd.widthHint = macroNameTextFm.getAverageCharWidth() * 50;\n\t\tmacroNameText.setLayoutData(requestPortGd);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createItemsArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, false));\n\t\trootControl.setText(\"Macro Items\");\n\n\t\tGridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);\n\t\tcreateItemsTable(rootControl, gd, 8).setLayoutData(gd);\n\n\t\tcreateItemsButtons(rootControl).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createItemsTable(Composite parent, GridData gd, int heightInRows) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\tfinal TableColumnLayout tcl = new TableColumnLayout();\n\t\trootControl.setLayout(tcl);\n\n\t\tmacroItemTableViewer = new TableViewer(rootControl, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);\n\t\tmacroItemTableViewer.setContentProvider(new MacroItemTableContentProvider());\n\t\tmacroItemTableViewer.addSelectionChangedListener(createMacroItemTableSelectionChangedListener());\n\t\tcreateItemsTableColumns(macroItemTableViewer, tcl);\n\t\tfinal Table table = macroItemTableViewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t\tgd.heightHint = table.getItemHeight() * heightInRows;\n\n\t\treturn rootControl;\n\t}\n\n\tprivate ISelectionChangedListener createMacroItemTableSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tboolean hasSelection = !event.getSelection().isEmpty();\n\t\t\t\tmoveUpButton.setEnabled(hasSelection);\n\t\t\t\tmoveDownButton.setEnabled(hasSelection);\n\t\t\t\tremoveButton.setEnabled(hasSelection);\n\t\t\t\tif (hasSelection == true) {\n\t\t\t\t\tfinal IHttpMacroItem macroItem = (IHttpMacroItem)((IStructuredSelection) event.getSelection()).getFirstElement();\n\t\t\t\t\tsetMacroItemSelected(macroItem);\n\t\t\t\t} else {\n\t\t\t\t\tsetMacroItemSelected(null);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate void createItemsTableColumns(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal String[] titles = { \"Host\", \"Method\", \"Request\", \"Status\", };\n\t\tfinal ColumnLayoutData[] layoutData = {\n\t\t\tnew ColumnPixelData(120, true, true),\n\t\t\tnew ColumnPixelData(60, true, true),\n\t\t\tnew ColumnWeightData(100, 500, true),\n\t\t\tnew ColumnPixelData(50, true, true),\n\t\t};\n\t\tfinal ColumnLabelProvider providerList[] = {\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpMacroItem) element).getRequestLogRecord().getHttpHost().toURI();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn ((IHttpMacroItem) element).getRequestLogRecord().getRequest().getRequestLine().getMethod();\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\tURI uri;\n\t\t\t\t\ttry {\n\t\t\t\t\t\turi = new URI(((IHttpMacroItem) element).getRequestLogRecord().getRequest().getRequestLine().getUri());\n\t\t\t\t\t} catch (URISyntaxException e) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tif (uri.getRawQuery() != null) {\n\t\t\t\t\t\treturn uri.getRawPath() + \"?\" + uri.getRawQuery();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn uri.getRawPath();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tnew ColumnLabelProvider() {\n\t\t\t\t@Override\n\t\t\t\tpublic String getText(Object element) {\n\t\t\t\t\treturn Integer.valueOf(((IHttpMacroItem) element).getRequestLogRecord().getResponse().getStatusLine().getStatusCode()).toString();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tfor(int i = 0; i < titles.length; i++) {\n\t\t\tfinal TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);\n\t\t\tfinal TableColumn c = column.getColumn();\n\t\t\tlayout.setColumnData(c, layoutData[i]);\n\t\t\tc.setText(titles[i]);\n\t\t\tc.setMoveable(true);\n\t\t\tcolumn.setLabelProvider(providerList[i]);\n\t\t}\n\t\tfinal Table table = viewer.getTable();\n\t\ttable.setHeaderVisible(true);\n\t\ttable.setLinesVisible(true);\n\t}\n\n\tprivate Composite createItemsButtons(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, true));\n\n\t\taddItemButton = new Button(rootControl, SWT.PUSH);\n\t\taddItemButton.setText(\"add item\");\n\t\taddItemButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\taddItemButton.addSelectionListener(createAddItemButtonSelectionListener());\n\n\t\tmoveUpButton = new Button(rootControl, SWT.PUSH);\n\t\tmoveUpButton.setText(\"move up\");\n\t\tmoveUpButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tmoveUpButton.setEnabled(false);\n\t\tmoveUpButton.addSelectionListener(createMoveUpButtonSelectionListener());\n\n\t\tmoveDownButton = new Button(rootControl, SWT.PUSH);\n\t\tmoveDownButton.setText(\"move down\");\n\t\tmoveDownButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tmoveDownButton.setEnabled(false);\n\t\tmoveDownButton.addSelectionListener(createMoveDownButtonSelectionListener());\n\n\t\tremoveButton = new Button(rootControl, SWT.PUSH);\n\t\tremoveButton.setText(\"remove\");\n\t\tremoveButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\n\t\tremoveButton.setEnabled(false);\n\t\tremoveButton.addSelectionListener(createRemoveButtonSelectionListener());\n\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createAddItemButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tMacroItemSelectionDialog dialog = new MacroItemSelectionDialog(parentComposite.getShell());\n\t\t\t\tif (dialog.open() == IDialogConstants.OK_ID) {\n\t\t\t\t\tList<IRequestLogRecord> selectionList = dialog.getSelectionList();\n\t\t\t\t\tfor (Iterator<IRequestLogRecord> iter = selectionList.iterator(); iter.hasNext();) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tmacro.createMacroItem(iter.next());\n\t\t\t\t\t\t} catch (URISyntaxException ex) {\n\t\t\t\t\t\t\tErrorDialog.displayError(getShell(), \"An unexpected error occurred while processing the URI\");\n\t\t\t\t\t\t\tex.printStackTrace();\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t} catch (IOException ex) {\n\t\t\t\t\t\t\tErrorDialog.displayError(getShell(), null);\n\t\t\t\t\t\t\tex.printStackTrace();\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmacroItemTableViewer.refresh();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createMoveUpButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) macroItemTableViewer.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tint idx = macro.indexOfMacroItem((IHttpMacroItem) i.next());\n\t\t\t\t\tif (idx != 0) {\n\t\t\t\t\t\tmacro.swapMacroItems(idx - 1, idx);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmacroItemTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createMoveDownButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) macroItemTableViewer.getSelection();\n\t\t\t\tint idx[] = new int[selection.size()];\n\t\t\t\tint offset = 1;\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext(); offset++) {\n\t\t\t\t\tidx[idx.length - offset] = macro.indexOfMacroItem((IHttpMacroItem) i.next());\n\t\t\t\t}\n\n\t\t\t\tif (idx[0] + 1 != macro.macroItemsSize()) {\n\t\t\t\t\tfor (int i = 0; i < idx.length; i++) {\n\t\t\t\t\t\tmacro.swapMacroItems(idx[i], idx[i] + 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmacroItemTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createRemoveButtonSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tIStructuredSelection selection = (IStructuredSelection) macroItemTableViewer.getSelection();\n\t\t\t\tfor (Iterator<?> i = selection.iterator(); i.hasNext();) {\n\t\t\t\t\tmacro.removeMacroItem((IHttpMacroItem) i.next());\n\t\t\t\t}\n\t\t\t\tmacroItemTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate Composite createItemEditor(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new FillLayout());\n\t\t\n\t\tmacroItemTabFolder = new TabFolder(rootControl, SWT.TOP);\n\n\t\tTabItem macroParamsTabItem = new TabItem(macroItemTabFolder, SWT.NONE);\n\t\tmacroParamsTabItem.setText(\"Params\");\n\t\tmacroItemEditor = new MacroItemEditor(macroItemTabFolder, requestBuilder);\n\t\tmacroParamsTabItem.setControl(macroItemEditor);\n\t\tmacroParamsTabItem.setData(macroItemEditor);\n\n\t\tTabItem requestTabItem = new TabItem(macroItemTabFolder, SWT.NONE);\n\t\trequestTabItem.setText(\"Request\");\n\t\tRequestEditor requestEditor = new RequestEditor(macroItemTabFolder, requestBuilder);\n\t\trequestTabItem.setControl(requestEditor);\n\t\trequestTabItem.setData(requestEditor);\n\n\t\tTabItem requestHeaderTabItem = new TabItem(macroItemTabFolder, SWT.NONE);\n\t\trequestHeaderTabItem.setText(\"Headers\");\n\t\tHeaderEditor requestHeaderEditor = new HeaderEditor(macroItemTabFolder, requestBuilder, 0);\n\t\trequestHeaderTabItem.setControl(requestHeaderEditor);\n\t\trequestHeaderTabItem.setData(requestHeaderEditor);\n\t\t\n\t\tmacroItemTabFolder.addSelectionListener(createRequestTabFolderSelectionListener());\n\t\tmacroItemTabFolderItem = macroItemTabFolder.getSelection()[0];\n\t\trequestBuilderPartCurr = (IHttpBuilderPart) macroItemTabFolderItem.getData();\n\t\trequestIsEditable = false;\n\t\trequestBuilderPartCurr.setEditable(requestIsEditable);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createRequestTabFolderSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tTabItem[] selection = macroItemTabFolder.getSelection();\n\t\t\t\tif (selection != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\trequestBuilderPartCurr.processContents();\n\t\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\t\tmacroItemTabFolder.setSelection(macroItemTabFolderItem);\n\t\t\t\t\t\tErrorDialog.displayError(getShell(), \"An unexpected error occurred processing the request\");\n\t\t\t\t\t\tex.printStackTrace();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tmacroItemTabFolderItem = selection[0];\n\t\t\t\trequestBuilderPartCurr = (IHttpBuilderPart) macroItemTabFolderItem.getData();\n\t\t\t\trequestBuilderPartCurr.setEditable(requestIsEditable);\n\t\t\t\trequestBuilderPartCurr.refresh();\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void setMacroItemSelected(IHttpMacroItem macroItem) {\n\t\tif (macroItem != null) {\n\t\t\ttry {\n\t\t\t\tmacroItem.setRequestBuilder(requestBuilder, null);\n\t\t\t} catch (Exception e) {\n\t\t\t\tErrorDialog.displayError(getShell(), \"An unexpected error occurred while processing the request\");\n\t\t\t\te.printStackTrace();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trequestIsEditable = true;\n\t\t} else {\n\t\t\trequestBuilder.clear();\n\t\t\trequestIsEditable = false;\n\t\t}\n\t\tmacroItemEditor.setMacroItem(macroItem);\n\t\trequestBuilderPartCurr.setEditable(requestIsEditable);\n\t\trequestBuilderPartCurr.refresh();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/macrosview/MacrosView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.macros.macrosview;\n\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\nimport com.subgraph.vega.ui.macros.Activator;\nimport com.subgraph.vega.ui.macros.macrosview.tree.MacroViewerContentProvider;\nimport com.subgraph.vega.ui.macros.macrosview.tree.MacroViewerLabelProvider;\n\npublic class MacrosView extends ViewPart {\n\tpublic static final String ID = \"com.subgraph.vega.views.macros.macros\";\n\tprivate IHttpMacroModel macroModel;\n\tprivate Composite parentComposite;\n\tprivate TreeViewer macroViewer;\n\n\tpublic MacrosView() {\n\t\tIWorkspace currentWorkspace = Activator.getDefault().getModel().addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tmacroModel = currentWorkspace.getHttpMacroModel();\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tmacroModel = event.getWorkspace().getHttpMacroModel();\n\t\tmacroViewer.setInput(macroModel);\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tmacroModel = null;\n\t\tmacroViewer.setInput(macroModel);\n\t}\n\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tmacroModel = event.getWorkspace().getHttpMacroModel();\n\t\tmacroViewer.setInput(macroModel);\n\t}\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tparentComposite = new Composite(parent, SWT.NONE);\n\t\tparentComposite.setLayout(new FillLayout());\n\t\tcreateTreeViewer(parentComposite);\n\t\tmacroViewer.setInput(macroModel);\n\t}\n\n\t@Override\n\tpublic void setFocus() {\n\t\tparentComposite.setFocus();\n\t}\n\n\tprivate void createTreeViewer(Composite parent) {\n\t\tmacroViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\tmacroViewer.setContentProvider(new MacroViewerContentProvider());\n\t\tmacroViewer.setLabelProvider(new MacroViewerLabelProvider());\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/macrosview/tree/IMacroTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.macros.macrosview.tree;\n\npublic interface IMacroTreeNode {\n\tString getText();\n\tString getImagePath();\n\tboolean hasChildren();\n \tObject[] getChildren();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/macrosview/tree/MacroTreeNode.java",
    "content": "package com.subgraph.vega.ui.macros.macrosview.tree;\n\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\n\npublic class MacroTreeNode implements IMacroTreeNode {\n\tprivate static final String IMAGE_PATH = \"icons/macro.png\";\n\tprivate final IHttpMacro macro;\n\n\tpublic MacroTreeNode(IHttpMacro macro) {\n\t\tthis.macro = macro;\n\t}\n\t\n\t@Override\n\tpublic String getText() {\n\t\treturn macro.getName();\n\t}\n\n\t@Override\n\tpublic String getImagePath() {\n\t\treturn IMAGE_PATH;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/macrosview/tree/MacroViewerContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.macros.macrosview.tree;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.macros.IHttpMacro;\nimport com.subgraph.vega.api.model.macros.IHttpMacroModel;\nimport com.subgraph.vega.api.model.macros.NewMacroEvent;\n\npublic class MacroViewerContentProvider implements ITreeContentProvider, IEventHandler {\n\tprivate IHttpMacroModel macroModel;\n\tprivate Viewer viewer;\n\tprivate final List<IMacroTreeNode> childrenList = new ArrayList<IMacroTreeNode>();\n\n\t@Override\n\tpublic void dispose() {\n\t\tif (macroModel != null) {\n\t\t\tmacroModel.removeChangeListener(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tthis.viewer = viewer;\n\t\tif (newInput != oldInput) {\n\t\t\tif (macroModel != null) {\n\t\t\t\tmacroModel.removeChangeListener(this);\n\t\t\t\tchildrenList.clear();\n\t\t\t}\n\n\t\t\tmacroModel = (IHttpMacroModel) newInput;\n\t\t\tif (macroModel != null) {\n\t\t\t\tmacroModel.addChangeListener(this);\n\t\t\t\tfor (IHttpMacro macro: macroModel.getAllMacros()) {\n\t\t\t\t\tchildrenList.add(new MacroTreeNode(macro));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn childrenList.toArray();\n\t}\n\n\t@Override\n\tpublic Object[] getChildren(Object parentElement) {\n\t\treturn ((IMacroTreeNode) parentElement).getChildren();\n\t}\n\n\t@Override\n\tpublic Object getParent(Object element) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren(Object element) {\n\t\treturn ((IMacroTreeNode) element).hasChildren();\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif (event instanceof NewMacroEvent) {\n\t\t\tchildrenList.add(new MacroTreeNode(((NewMacroEvent) event).getMacro()));\n\t\t\tviewer.refresh();\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.macros/src/com/subgraph/vega/ui/macros/macrosview/tree/MacroViewerLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.macros.macrosview.tree;\n\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Image;\n\nimport com.subgraph.vega.ui.macros.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class MacroViewerLabelProvider extends LabelProvider {\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\n\t@Override\n\tpublic String getText(Object element) {\n\t\treturn ((IMacroTreeNode) element).getText();\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\t\n\t@Override\n\tpublic Image getImage(Object element) {\n\t\tfinal String imagePath = ((IMacroTreeNode) element).getImagePath();\n\t\tif (imagePath != null) {\n\t\t\treturn imageCache.get(imagePath);\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry exported=\"true\" kind=\"lib\" path=\"lib/freemarker-gae-2.3.20.jar\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.scanner</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Scanner\nBundle-SymbolicName: com.subgraph.vega.ui.scanner;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.scanner.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime,\n com.subgraph.vega.api\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nImport-Package: com.subgraph.vega.api.events,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.model.identity,\n com.subgraph.vega.api.model.requests,\n com.subgraph.vega.api.model.variables,\n com.subgraph.vega.api.paths,\n com.subgraph.vega.api.scanner,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.api.xml,\n com.subgraph.vega.export,\n com.subgraph.vega.ui.http.request.view,\n com.subgraph.vega.ui.util.dialogs,\n com.subgraph.vega.ui.util.export,\n com.subgraph.vega.ui.util.images,\n com.subgraph.vega.ui.util.modules,\n org.apache.http;version=\"4.0.0\",\n org.apache.http.client.methods;version=\"4.1.1\",\n org.apache.http.client.utils,\n org.apache.http.cookie,\n org.apache.http.impl.cookie,\n org.eclipse.ui.forms,\n org.eclipse.ui.forms.widgets\nBundle-ClassPath: .,\n lib/freemarker-gae-2.3.20.jar\nExport-Package: com.subgraph.vega.ui.scanner,\n com.subgraph.vega.ui.scanner.info\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/,\\\n               lib/freemarker-gae-2.3.20.jar\n\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"menu:org.eclipse.ui.main.menu?before=window\">\n         <menu\n               id=\"scanMenu\"\n               label=\"Scan\">\n            <command\n                  commandId=\"com.subgraph.vega.ui.scanner.startnewscan\"\n                  label=\"Start New Scan\"\n                  style=\"push\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.scanner\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.ui.scanner.editscope\"\n                  label=\"Edit Target Scope\"\n                  style=\"push\">\n            </command>\n         </menu>\n      </menuContribution>\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:org.eclipse.ui.main.toolbar\">\n         <toolbar\n               id=\"com.subgraph.vega.toolbars.main\">\n            <command\n                  commandId=\"com.subgraph.vega.ui.scanner.startnewscan\"\n                  icon=\"icons/wand.png\"\n                  label=\"Start New Scan\"\n                  style=\"push\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.scanner\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.ui.scanner.stopscan\"\n                  icon=\"icons/stop_16x16.png\"\n                  label=\"Stop Scanner\"\n                  style=\"push\">\n               <visibleWhen\n                     checkEnabled=\"false\">\n                  <with\n                        variable=\"activeWorkbenchWindow.activePerspective\">\n                     <equals\n                           value=\"com.subgraph.vega.perspectives.scanner\">\n                     </equals>\n                  </with>\n               </visibleWhen>\n            </command>\n            <command\n                  commandId=\"com.subgraph.vega.ui.scanner.editscope\"\n                  icon=\"icons/scope.png\"\n                  label=\"Edit Target Scope\"\n                  style=\"push\">\n            </command>\n         </toolbar>\n      </menuContribution>\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:com.subgraph.vega.views.alert\">\n         <command\n               commandId=\"com.subgraph.vega.ui.scanner.pausescan\"\n               icon=\"icons/scan_pause.png\"\n               label=\"Pause Scan\"\n               style=\"push\">\n            <visibleWhen\n                  checkEnabled=\"false\">\n               <with\n                     variable=\"activeWorkbenchWindow.activePerspective\">\n                  <equals\n                        value=\"com.subgraph.vega.perspectives.scanner\">\n                  </equals>\n               </with>\n            </visibleWhen>\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.ui.scanner.unpausescan\"\n               icon=\"icons/scan_unpause.png\"\n               label=\"Unpause Scan\"\n               style=\"push\">\n            <visibleWhen\n                  checkEnabled=\"false\">\n               <with\n                     variable=\"activeWorkbenchWindow.activePerspective\">\n                  <equals\n                        value=\"com.subgraph.vega.perspectives.scanner\">\n                  </equals>\n               </with>\n            </visibleWhen>\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.commands.alertScopeFilter\"\n               icon=\"icons/scope.png\"\n               label=\"Filter by Current Scope\"\n               style=\"toggle\">\n            <visibleWhen\n                  checkEnabled=\"false\">\n               <with\n                     variable=\"activeWorkbenchWindow.activePerspective\">\n                  <equals\n                        value=\"com.subgraph.vega.perspectives.proxy\">\n                  </equals>\n               </with>\n            </visibleWhen>\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.ui.scanner.expandallalerts\"\n               icon=\"icons/expandall.png\"\n               label=\"Expand All\"\n               style=\"push\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.ui.scanner.collapseallalerts\"\n               icon=\"icons/collapseall.png\"\n               label=\"Collapse All\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <command\n            id=\"com.subgraph.vega.ui.scanner.startnewscan\"\n            name=\"Start New Scan\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.scanner.stopscan\"\n            name=\"Stop Scanner\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.scanner.expandallalerts\"\n            name=\"Expand All Scan Alerts\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.scanner.collapseallalerts\"\n            name=\"Collapse All Scan Alerts\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.scanner.editscope\"\n            name=\"Edit Scope\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.scanner.pausescan\"\n            name=\"Pause Scan\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.scanner.unpausescan\"\n            name=\"Unpause Scan\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.commands.alertScopeFilter\"\n            name=\"Filter by Current Scope\">\n      </command>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <category\n            id=\"com.subgraph.vega.views.category.scanner\"\n            name=\"Scanner\">\n      </category>\n      <view\n            category=\"com.subgraph.vega.views.category.scanner\"\n            class=\"com.subgraph.vega.ui.scanner.info.ScanInfoView\"\n            icon=\"icons/info_view.png\"\n            id=\"com.subgraph.vega.views.scaninfo\"\n            name=\"Scan Info\"\n            restorable=\"true\">\n      </view>\n      <view\n            category=\"com.subgraph.vega.views.category.scanner\"\n            class=\"com.subgraph.vega.ui.scanner.alerts.ScanAlertView\"\n            icon=\"icons/alert_view.png\"\n            id=\"com.subgraph.vega.views.alert\"\n            name=\"Scan Alerts\"\n            restorable=\"true\">\n      </view>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectives\">\n      <perspective\n            class=\"com.subgraph.vega.ui.scanner.ScannerPerspectiveFactory\"\n            icon=\"icons/scanner.png\"\n            id=\"com.subgraph.vega.perspectives.scanner\"\n            name=\"Scanner\">\n      </perspective>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.StopScannerHandler\"\n            commandId=\"com.subgraph.vega.ui.scanner.stopscan\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.scanSelectionState\">\n               <equals\n                     value=\"active\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.StartNewScanHandler\"\n            commandId=\"com.subgraph.vega.ui.scanner.startnewscan\">\n         <enabledWhen>\n            <and>\n               <with\n                     variable=\"vega.scanSelectionState\">\n                  <equals\n                        value=\"idle\">\n                  </equals>\n               </with>\n               <with\n                     variable=\"activeWorkbenchWindow.activePerspective\">\n                  <equals\n                        value=\"com.subgraph.vega.perspectives.scanner\">\n                  </equals>\n               </with>\n            </and>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.ExpandAllAlerts\"\n            commandId=\"com.subgraph.vega.ui.scanner.expandallalerts\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.CollapseAllAlerts\"\n            commandId=\"com.subgraph.vega.ui.scanner.collapseallalerts\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.EditScopeHandler\"\n            commandId=\"com.subgraph.vega.ui.scanner.editscope\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.PauseScanHandler\"\n            commandId=\"com.subgraph.vega.ui.scanner.pausescan\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.pauseState\">\n               <equals\n                     value=\"pauseable\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.UnpauseScanHandler\"\n            commandId=\"com.subgraph.vega.ui.scanner.unpausescan\">\n         <enabledWhen>\n            <with\n                  variable=\"vega.pauseState\">\n               <equals\n                     value=\"paused\">\n               </equals>\n            </with>\n         </enabledWhen>\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.scanner.commands.AlertScopeFilterHandler\"\n            commandId=\"com.subgraph.vega.commands.alertScopeFilter\">\n      </handler>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.services\">\n      <sourceProvider\n            provider=\"com.subgraph.vega.ui.scanner.commands.ScannerStateSourceProvider\">\n         <variable\n               name=\"vega.scannerState\"\n               priorityLevel=\"workbench\">\n         </variable>\n      </sourceProvider>\n      <sourceProvider\n            provider=\"com.subgraph.vega.ui.scanner.commands.PauseStateSourceProvider\">\n         <variable\n               name=\"vega.pauseState\"\n               priorityLevel=\"workbench\">\n         </variable>\n      </sourceProvider>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.perspectiveExtensions\">\n      <perspectiveExtension\n            targetID=\"com.subgraph.vega.perspectives.scanner\">\n         <view\n               closeable=\"false\"\n               id=\"com.subgraph.vega.views.http:scanner\"\n               minimized=\"false\"\n               ratio=\"0.6\"\n               relationship=\"fast\">\n         </view>\n      </perspectiveExtension>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.runtime.preferences\">\n      <initializer\n            class=\"com.subgraph.vega.ui.scanner.preferences.ScannerDebugPreferenceInitializer\">\n      </initializer>\n      <initializer\n            class=\"com.subgraph.vega.ui.scanner.preferences.ScannerOptionsPreferenceInitializer\">\n      </initializer>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.preferencePages\">\n      <page\n            category=\"com.subgraph.vega.preferences.scanoptions\"\n            class=\"com.subgraph.vega.ui.scanner.preferences.ScannerDebugPreferencePage\"\n            id=\"com.subgraph.vega.preferences.scandebug\"\n            name=\"Debug\">\n      </page>\n      <page\n            class=\"com.subgraph.vega.ui.scanner.preferences.ScannerOptionsPreferencePage\"\n            id=\"com.subgraph.vega.preferences.scanoptions\"\n            name=\"Scanner\">\n      </page>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.bindings\">\n      <key\n            commandId=\"com.subgraph.vega.ui.scanner.startnewscan\"\n            contextId=\"org.eclipse.ui.contexts.window\"\n            schemeId=\"vega.scheme\"\n            sequence=\"M1+N\">\n      </key>\n      <key\n            commandId=\"com.subgraph.vega.ui.scanner.editscope\"\n            contextId=\"org.eclipse.ui.contexts.window\"\n            schemeId=\"vega.scheme\"\n            sequence=\"M1+E\">\n      </key>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/Activator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.api.scanner.IScanner;\nimport com.subgraph.vega.api.xml.IXmlRepository;\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.scanner\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IScanner, IScanner> scannerTracker;\n\tprivate ServiceTracker<IPathFinder, IPathFinder> pathFinderTracker;\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\tprivate ServiceTracker<IXmlRepository, IXmlRepository> xmlRepositoryTracker;\n\tprivate ServiceTracker<IScannerModuleRegistry, IScannerModuleRegistry> moduleRegistryTracker;\n\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\n\t\tscannerTracker = new ServiceTracker<IScanner, IScanner>(context, IScanner.class.getName(), null);\n\t\tscannerTracker.open();\n\n\t\tpathFinderTracker = new ServiceTracker<IPathFinder, IPathFinder>(context, IPathFinder.class.getName(), null);\n\t\tpathFinderTracker.open();\n\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\n\t\txmlRepositoryTracker = new ServiceTracker<IXmlRepository, IXmlRepository>(context, IXmlRepository.class.getName(), null);\n\t\txmlRepositoryTracker.open();\n\n\t\tmoduleRegistryTracker = new ServiceTracker<IScannerModuleRegistry, IScannerModuleRegistry>(context, IScannerModuleRegistry.class.getName(), null);\n\t\tmoduleRegistryTracker.open();\n\t\t\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\t\n\tpublic IScanner getScanner() {\n\t\treturn scannerTracker.getService();\n\t}\n\t\n\tpublic IPathFinder getPathFinder() {\n\t\treturn pathFinderTracker.getService();\n\t}\n\t\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\t\n\tpublic IXmlRepository getXmlRepository() {\n\t\treturn xmlRepositoryTracker.getService();\n\t}\n\t\n\tpublic IScannerModuleRegistry getIScannerModuleRegistry() {\n\t\treturn moduleRegistryTracker.getService();\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/ScanExecutor.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner;\n\nimport java.net.HttpCookie;\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.Calendar;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport org.apache.http.cookie.Cookie;\nimport org.apache.http.impl.cookie.BasicClientCookie;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.preference.IPreferenceStore;\nimport org.eclipse.jface.wizard.WizardDialog;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.IScanner;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.ui.scanner.preferences.IPreferenceConstants;\nimport com.subgraph.vega.ui.scanner.wizards.NewScanWizard;\nimport com.subgraph.vega.ui.scanner.wizards.NewWizardDialog;\n\npublic class ScanExecutor {\n\t\n\tpublic String runScan(Shell shell, String target) {\n\t\tfinal IScanner scanner = Activator.getDefault().getScanner();\n\t\tfinal IScan scan = scanner.createScan();\n\t\tfinal Collection<IIdentity> identities = Activator.getDefault().getModel().getCurrentWorkspace().getIdentityModel().getAllIdentities();\n\n\t\tNewScanWizard wizard = new NewScanWizard(target, identities, scan.getModuleList(), scan.getConfig().getDefaultExcludedParameterNames());\n\t\tWizardDialog dialog = new NewWizardDialog(shell, wizard);\n\t\tif(dialog.open() == IDialogConstants.OK_ID) {\n\t\t\treturn maybeLaunchScanFromWizard(shell, wizard, scanner, scan);\n\t\t} else {\n\t\t\t// REVISIT: delete the scan so the ID can be used in the future?\n\t\t\tscan.stopScan(); // stop to unlock workspace\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate String maybeLaunchScanFromWizard(Shell shell, NewScanWizard wizard, IScanner scanner, IScan scan) {\n\n\t\tfinal ITargetScope scanTargetScope = wizard.getScanTargetScope();\n\t\tif(scanTargetScope == null) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfinal IScannerConfig config = scan.getConfig();\n\t\tconfig.setScanTargetScope(scanTargetScope);\n\t\tconfig.setUserAgent(IPreferenceConstants.P_USER_AGENT);\n\t\tconfig.setCookieList(getCookieListForScope(wizard.getCookieStringList(), scanTargetScope));\n\t\tconfig.setScanIdentity(wizard.getScanIdentity());\n\t\tconfig.setExcludedParameterNames(wizard.getExcludedParameterNames());\n\t\tfinal IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();\n\t\tconfig.setLogAllRequests(preferences.getBoolean(IPreferenceConstants.P_LOG_ALL_REQUESTS));\n\t\tconfig.setDisplayDebugOutput(preferences.getBoolean(IPreferenceConstants.P_DISPLAY_DEBUG_OUTPUT));\n\t\tconfig.setMaxRequestsPerSecond(preferences.getInt(IPreferenceConstants.P_MAX_REQUESTS_PER_SECOND));\n\t\tconfig.setMaxDescendants(preferences.getInt(IPreferenceConstants.P_MAX_SCAN_DESCENDANTS));\n\t\tconfig.setMaxChildren(preferences.getInt(IPreferenceConstants.P_MAX_SCAN_CHILDREN));\n\t\tconfig.setMaxDepth(preferences.getInt(IPreferenceConstants.P_MAX_SCAN_DEPTH));\n\t\tconfig.setMaxDuplicatePaths(preferences.getInt(IPreferenceConstants.P_MAX_SCAN_DUPLICATE_PATHS));\n\t\tconfig.setMaxResponseKilobytes(preferences.getInt(IPreferenceConstants.P_MAX_RESPONSE_LENGTH));\n\n\t\tfinal Thread probeThread = new Thread(new ScanProbeTask(shell, scan));\n\t\tprobeThread.start();\n\n\t\treturn wizard.getTargetField();\n\t}\n\n\tprivate List<Cookie> getCookieListForScope(List<String> cookieStringList, ITargetScope scope) {\n\t\tfinal List<Cookie> cookies = new ArrayList<Cookie>();\n\t\tfor(URI uri: scope.getScopeURIs()) {\n\t\t\tcookies.addAll(getCookieList(cookieStringList, uri));\n\t\t}\n\t\treturn cookies;\n\t}\n\t\n\t// gross hack\n\tprivate List<Cookie> getCookieList(List<String> cookieStringList, URI uri) {\n\t\tif (cookieStringList.size() != 0) {\n\t\t\tArrayList<Cookie> cookieList = new ArrayList<Cookie>(cookieStringList.size());\n\t\t\tfor (String cookieString: cookieStringList) {\n\t\t\t\tList<HttpCookie> parseList = HttpCookie.parse(cookieString);\n\t\t\t\tfor (HttpCookie cookie: parseList) {\n\t\t\t\t\tBasicClientCookie cp = new BasicClientCookie(cookie.getName(), cookie.getValue());\n\t\t\t\t\tcp.setComment(cookie.getComment());\n\t\t\t\t\tif (cookie.getDomain() != null) {\n\t\t\t\t\t\tcp.setDomain(cookie.getDomain());\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// just set it to the target host for now - may need something slightly less specific\n\t\t\t\t\t\tcp.setDomain(uri.getHost());\n\t\t\t\t\t}\n\t\t\t\t\tlong maxAge = cookie.getMaxAge();\n\t\t\t\t\tif (maxAge > 0) {\n\t\t\t\t\t\tCalendar calendar = Calendar.getInstance();\n\t\t\t\t\t\tcalendar.add(Calendar.SECOND, (int) maxAge);\n\t\t\t\t\t\tcp.setExpiryDate(calendar.getTime());\n\t\t\t\t\t}\n\t\t\t\t\tcp.setPath(cookie.getPath());\n\t\t\t\t\tcp.setSecure(cookie.getSecure());\n\t\t\t\t\tcp.setVersion(cookie.getVersion());\n\t\t\t\t\tcookieList.add(cp);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn cookieList;\n\t\t}\n\t\treturn Collections.emptyList();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/ScanProbeTask.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner;\n\nimport java.net.URI;\n\nimport org.eclipse.jface.dialogs.MessageDialog;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.api.scanner.IScanProbeResult;\nimport com.subgraph.vega.api.scanner.IScanProbeResult.ProbeResultType;\n\npublic class ScanProbeTask implements Runnable {\n\n\tprivate final Shell shell;\n\tprivate final IScan scan;\n\tprivate volatile boolean cancelScan;\n\t\n\t\n\tScanProbeTask(Shell shell, IScan scan) {\n\t\tthis.shell = shell;\n\t\tthis.scan = scan;\n\t}\n\n\t@Override\n\tpublic void run() {\n\t\tfinal ITargetScope scanScope = scan.getConfig().getScanTargetScope();\n\t\tfor(URI uri: scanScope.getScopeURIs()) {\n\t\t\tif(cancelScan) {\n\t\t\t\tscan.stopScan();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprocessTargetURI(uri);\n\t\t}\n\t\tif(cancelScan) {\n\t\t\tscan.stopScan();\n\t\t} else {\n\t\t\tscan.startScan();\n\t\t}\n\t}\n\n\tprivate void processTargetURI(final URI uri) {\n\t\tfinal IScanProbeResult probeResult = scan.probeTargetUri(uri);\n\t\tshell.getDisplay().syncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(!processProbeResult(uri, probeResult)) {\n\t\t\t\t\tcancelScan = true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate boolean processProbeResult(URI uri, IScanProbeResult probeResult) {\n\t\tif(probeResult.getProbeResultType() == ProbeResultType.PROBE_CONNECT_FAILED) {\n\t\t\tMessageDialog.openError(shell, \"Failed to connect to target\", probeResult.getFailureMessage());\n\t\t\treturn false;\n\t\t} else if(probeResult.getProbeResultType() == ProbeResultType.PROBE_REDIRECT) {\n\t\t\tfinal URI redirectURI = probeResult.getRedirectTarget();\n\t\t\tif(!isTrivialRedirect(uri, redirectURI)) {\n\t\t\t\tString message = \"Target address \"+ uri + \" redirects to address \"+ redirectURI + \"\\n\\n\"+\n\t\t\t\t\t\t\"Would you like to add \"+ redirectURI +\" to the scope?\";\n\t\t\t\tboolean doit = MessageDialog.openQuestion(shell, \"Follow Redirect?\", message);\n\t\t\t\tif(!doit) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tscan.getConfig().getScanTargetScope().addScopeURI(redirectURI);\n\t\t\t\n\t\t\treturn true;\n\t\t} else if(probeResult.getProbeResultType() == ProbeResultType.PROBE_REDIRECT_FAILED) {\n\t\t\tMessageDialog.openError(shell, \"Redirect failure\", probeResult.getFailureMessage());\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tprivate boolean isTrivialRedirect(URI original, URI redirect) {\n\t\tfinal String originalStr = original.toString();\n\t\t/* Do we ask the user or not? I will assume yes for now\n\t\t * if (original.getHost().equals(redirect.getHost()) && (original.getPort()  == redirect.getPort())) {\n\t\t\treturn true;\n\t\t}\n\t\t*/\n\t\tif(originalStr.endsWith(\"/\")) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (redirect.toString().equals(originalStr + \"/\"));\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/ScannerPerspectiveFactory.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner;\n\nimport org.eclipse.ui.IFolderLayout;\nimport org.eclipse.ui.IPageLayout;\nimport org.eclipse.ui.IPerspectiveFactory;\n\nimport com.subgraph.vega.ui.scanner.alerts.ScanAlertView;\nimport com.subgraph.vega.ui.scanner.info.ScanInfoView;\n\npublic class ScannerPerspectiveFactory implements IPerspectiveFactory {\n\tprivate final static String SCAN_INFO_FOLDER = \"scanInfo\";\n\tprivate final static String MGMT_FOLDER = \"connection\";\n\tprivate final static String WEBSITE_VIEW = \"com.subgraph.vega.views.website\";\n\tpublic final static String HTTP_VIEW_SECONDARY_ID = \"scanner\"; /** Secondary ID for the scanner's com.subgraph.vega.views.http */\n\n\t@Override\n\tpublic void createInitialLayout(IPageLayout layout) {\n\t\tfinal IFolderLayout scanFolder = layout.createFolder(SCAN_INFO_FOLDER, IPageLayout.TOP, 0, layout.getEditorArea());\n\t\tscanFolder.addView(ScanInfoView.ID);\n\t\tlayout.getViewLayout(ScanInfoView.ID).setCloseable(false);\n\t\tscanFolder.addPlaceholder(\"*:*\");\n\n\t\tlayout.addStandaloneView(WEBSITE_VIEW, true, IPageLayout.LEFT, 0.25f, ScanInfoView.ID);\n\t\tlayout.getViewLayout(WEBSITE_VIEW).setCloseable(false);\n\t\tlayout.addStandaloneView(ScanAlertView.ID, true, IPageLayout.BOTTOM, 0.40f, WEBSITE_VIEW);\n\t\tlayout.getViewLayout(ScanAlertView.ID).setCloseable(false);\n\n\t\tfinal IFolderLayout mgmtFolder = layout.createFolder(MGMT_FOLDER, IPageLayout.BOTTOM, 0.75f, SCAN_INFO_FOLDER);\n\t\tmgmtFolder.addView(\"com.subgraph.vega.views.identity.identities\");\n\t\t\n\t\tlayout.setEditorAreaVisible(false);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/AlertTreeContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Timer;\nimport java.util.TimerTask;\nimport java.util.TreeMap;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.ActiveScanInstanceEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.NewScanAlertEvent;\nimport com.subgraph.vega.api.model.alerts.RemoveScanAlertsEvent;\nimport com.subgraph.vega.api.model.alerts.RemoveScanInstanceEvent;\nimport com.subgraph.vega.api.model.alerts.ScanStatusChangeEvent;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertScanNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertTree;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class AlertTreeContentProvider implements ITreeContentProvider, IEventHandler {\n\tprivate static final long BLINK_INTERVAL = 1000; // interval in milliseconds for active scan icon blink \n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\tprivate final Timer blinkTimer = new Timer();\n\tprivate final Map<Long, Integer> lastStatusMap = new TreeMap<Long, Integer>(); /** Map of active scan statuses, keyed by scan ID */\n\tprivate AlertTree tree;\n\tprivate TreeViewer viewer; // guarded by this\n\tprivate IWorkspace workspace;\n\tprivate IScanInstance proxyInstance;\n\tprivate List<AlertScanNode> activeList = new ArrayList<AlertScanNode>(); // guarded by this\n\tprivate boolean activeBlinkState; // guarded by this\n\n\t@Override\n\tpublic void dispose() {\t\t\n\t\timageCache.dispose();\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tsynchronized(this) {\n\t\t\tthis.viewer = (TreeViewer) viewer;\n\t\t\tif(newInput instanceof IWorkspace)\n\t\t\t\tsetNewModelAndViewer((IWorkspace) newInput);\n\t\t\telse\n\t\t\t\tsetNullModel();\t\t\n\t\t}\n\t}\n\n\tprivate void setNullModel() {\n\t\ttree = null;\n\t\tworkspace = null;\n\t\tlastStatusMap.clear();\n\t\tactiveList.clear();\n\t}\n\t\n\tprivate void setNewModelAndViewer(IWorkspace newWorkspace) {\n\t\tif(newWorkspace != workspace) {\n\t\t\tif(workspace != null) {\n\t\t\t\tworkspace.getScanAlertRepository().removeActiveScanInstanceListener(this);\n\t\t\t}\n\t\t\tif(proxyInstance != null) {\n\t\t\t\tproxyInstance.removeScanEventListener(this);\n\t\t\t}\n\n\t\t\tlastStatusMap.clear();\n\t\t\tactiveList.clear();\n\t\t\tworkspace = newWorkspace;\n\t\t\tif(newWorkspace == null) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\ttree = new AlertTree(workspace);\n\t\t\tfor(IScanInstance scan: workspace.getScanAlertRepository().getAllScanInstances()) {\n\t\t\t\tif (scan.getScanStatus() != IScanInstance.SCAN_CONFIG) {\n\t\t\t\t\ttree.addScan(scan);\n\t\t\t\t\tfor(IScanAlert alert: scan.getAllAlerts()) {\n\t\t\t\t\t\ttree.addAlert(alert);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (IScanInstance scanInstance: workspace.getScanAlertRepository().addActiveScanInstanceListener(this)) {\n\t\t\t\taddActiveScan(scanInstance);\n\t\t\t}\n\t\t\tproxyInstance = workspace.getScanAlertRepository().getProxyScanInstance();\n\t\t\tlastStatusMap.put(proxyInstance.getScanId(), -1);\n\t\t\tproxyInstance.addScanEventListenerAndPopulate(this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\tif(tree != null) {\n\t\t\treturn tree.getChildren();\n\t\t} else {\n\t\t\treturn new Object[0];\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object[] getChildren(Object parentElement) {\n\t\tif(parentElement instanceof IAlertTreeNode) {\n\t\t\treturn ((IAlertTreeNode) parentElement).getChildren();\n\t\t} else {\n\t\t\treturn new Object[0];\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object getParent(Object element) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren(Object element) {\n\t\tif(element instanceof IAlertTreeNode) {\n\t\t\treturn ((IAlertTreeNode) element).hasChildren();\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic void removeAlert(IScanAlert alert) {\n\t\tif(tree != null) {\n\t\t\ttree.removeAlert(alert);\n\t\t\trefreshViewer();\n\t\t}\n\t}\n\tprivate void handleNewScanAlert(NewScanAlertEvent event) {\n\t\tif(tree != null) {\n\t\t\ttree.addAlert(event.getAlert());\n\t\t\trefreshViewer();\n\t\t}\n\t}\n\t\n\tprivate void handleRemoveScanAlerts(RemoveScanAlertsEvent event) {\n\t\tif(tree != null) {\n\t\t\ttree.removeAlerts(event.getRemovedEvents());\n\t\t\trefreshViewer();\n\t\t}\n\t}\n\t\n\tprivate void handleActiveScanInstance(final ActiveScanInstanceEvent event) {\n\t\tsynchronized(this) {\n\t\t\tif (viewer != null) {\n\t\t\t\tviewer.getControl().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tif (tree != null && event.getScanInstance() != null) {\n\t\t\t\t\t\t\taddActiveScan(event.getScanInstance());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void handleRemoveScanInstance(RemoveScanInstanceEvent event) {\n\t\tif(tree != null && !event.getScanInstance().isActive()) {\n\t\t\ttree.removeScan(event.getScanInstance());\n\t\t\trefreshViewer();\n\t\t\tfinal AlertScanNode scanNode = chooseScanNode();\n\t\t\tif(scanNode != null) {\n\t\t\t\tviewer.setSelection(new StructuredSelection(scanNode));\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate AlertScanNode chooseScanNode() {\n\t\tif(tree == null) {\n\t\t\treturn null;\n\t\t}\n\t\tList<AlertScanNode> scanNodes = tree.getScanNodes();\n\t\tif(scanNodes.size() == 0) {\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tfor(AlertScanNode node: scanNodes) {\n\t\t\tif(node.getScanInstance().isActive()) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\treturn scanNodes.get(0);\n\t}\n\t\n\tprivate void addActiveScan(IScanInstance scan) {\n\t\tif(scan != null) {\n\t\t\tlastStatusMap.put(scan.getScanId(), -1);\n\t\t\tscan.addScanEventListenerAndPopulate(this);\n\t\t\tAlertScanNode scanNode = tree.addScan(scan);\n\t\t\tviewer.refresh();\n\t\t\tviewer.setSelection(new StructuredSelection(scanNode));\n\t\t}\n\t}\n\n\tprivate void handleScanStatusChange(ScanStatusChangeEvent event) {\n\t\tfinal int lastStatus = lastStatusMap.get(event.getScanInstance().getScanId());\n\t\tfinal int status = event.getStatus();\n\t\tif (lastStatus != status) {\n\t\t\tfinal long scanId = event.getScanInstance().getScanId();  \n\t\t\tlastStatusMap.put(scanId, status);\n\t\t\tif (scanId != IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\t\tif (event.getScanInstance().isActive() == true) {\n\t\t\t\t\tfinal AlertScanNode scanNode = tree.getScanNode(event.getScanInstance().getScanId());\n\t\t\t\t\tsynchronized(this) {\n\t\t\t\t\t\tif (!activeList.contains(scanNode)) {\n\t\t\t\t\t\t\tactiveList.add(scanNode);\n\t\t\t\t\t\t\tif (activeList.size() == 1) {\n\t\t\t\t\t\t\t\tblinkTimer.scheduleAtFixedRate(createBlinkTask(), 0, BLINK_INTERVAL);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (event.getScanInstance().isComplete() == true) {\n\t\t\t\t\tsynchronized(this) {\n\t\t\t\t\t\tactiveList.remove(tree.getScanNode(scanId));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trefreshViewer();\n\t\t}\n\t}\n\n\tprivate void refreshViewer() {\n\t\tsynchronized(this) {\n\t\t\tif (viewer != null && !viewer.getControl().isDisposed()) {\n\t\t\t\tviewer.getControl().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tviewer.refresh();\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif(event instanceof NewScanAlertEvent) {\n\t\t\thandleNewScanAlert((NewScanAlertEvent) event);\n\t\t} else if(event instanceof RemoveScanAlertsEvent) {\n\t\t\thandleRemoveScanAlerts((RemoveScanAlertsEvent) event);\n\t\t} else if(event instanceof ActiveScanInstanceEvent) {\n\t\t\thandleActiveScanInstance((ActiveScanInstanceEvent) event);\n\t\t} else if(event instanceof RemoveScanInstanceEvent) { \n\t\t\thandleRemoveScanInstance((RemoveScanInstanceEvent) event);\n\t\t} else if(event instanceof ScanStatusChangeEvent) {\n\t\t\thandleScanStatusChange((ScanStatusChangeEvent) event);\n\t\t}\n\t}\n\t\n\tprivate TimerTask createBlinkTask() {\n\t\treturn new TimerTask() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsynchronized(AlertTreeContentProvider.this) {\n\t\t\t\t\tif (activeList.size() != 0) {\n\t\t\t\t\t\tactiveBlinkState = !activeBlinkState;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tactiveBlinkState = false;\n\t\t\t\t\t\tcancel();\n\t\t\t\t\t}\n\t\t\t\t\tupdateScanNodes();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\t/**\n\t * Must be invoked within a synchronized block.\n\t */\n\tprivate void updateScanNodes() {\n\t\tif(viewer != null && !viewer.getControl().isDisposed()) {\n\t\t\tviewer.getControl().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tfor (AlertScanNode node: activeList) {\n\t\t\t\t\t\tviewer.update(node, null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tpublic boolean isBlinkStateActive() {\n\t\tsynchronized(this) {\n\t\t\treturn activeBlinkState;\n\t\t}\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/AlertTreeLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts;\n\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Image;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertScanNode;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class AlertTreeLabelProvider extends LabelProvider {\n\tprivate final static String ALERT_ITEM = \"icons/alert_item.png\";\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\tprivate final AlertTreeContentProvider contentProvider;\n\n\tpublic AlertTreeLabelProvider(AlertTreeContentProvider contentProvider) {\n\t\tsuper();\n\t\tthis.contentProvider = contentProvider;\n\t}\n\t\n\t@Override\n\tpublic void dispose() {\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\n\t@Override\n\tpublic String getText(Object element) {\n\t\tif(element instanceof IAlertTreeNode) {\n\t\t\tfinal IAlertTreeNode node = (IAlertTreeNode) element;\n\t\t\tfinal int childCount = node.getAlertCount();\n\t\t\tif(childCount <= 1) {\n\t\t\t\treturn node.getLabel();\n\t\t\t} else {\n\t\t\t\treturn node.getLabel() + \" (\"+ childCount +\")\";\n\t\t\t}\n\t\t} else if(element instanceof IScanAlert) {\n\t\t\treturn ((IScanAlert)element).getResource();\n\t\t} else {\n\t\t\treturn \"???\";\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic Image getImage(Object element) {\n\t\tif(element instanceof AlertScanNode) {\n\t\t\tfinal AlertScanNode node = (AlertScanNode) element;\n\t\t\tif (node.getScanInstance().isActive()) {\n\t\t\t\tfinal boolean activeBlinkState = contentProvider.isBlinkStateActive();\n\t\t\t\tif(activeBlinkState) {\n\t\t\t\t\treturn imageCache.get(node.getImage());\n\t\t\t\t} else {\n\t\t\t\t\treturn imageCache.getDisabled(node.getImage());\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn imageCache.get(node.getImage());\n\t\t\t}\n\t\t} else if(element instanceof IAlertTreeNode) {\n\t\t\tfinal String imageKey = ((IAlertTreeNode) element).getImage();\n\t\t\tif(imageKey != null) {\n\t\t\t\treturn imageCache.get(imageKey);\n\t\t\t}\n\t\t} else if(element instanceof IScanAlert) {\n\t\t\treturn imageCache.get(ALERT_ITEM);\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/CurrentScopeFilter.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerFilter;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.util.UriTools;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertHostNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertScanNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertSeverityNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertTitleNode;\n\npublic class CurrentScopeFilter extends ViewerFilter {\n\n\tprivate final IWorkspace workspace;\n\tprivate final ITargetScope currentScope;\n\t\n\tpublic CurrentScopeFilter(IWorkspace workspace, ITargetScope currentScope) {\n\t\tthis.workspace = workspace;\n\t\tthis.currentScope = currentScope;\n\t}\n\t\n\t@Override\n\tpublic boolean select(Viewer viewer, Object parentElement, Object element) {\n\t\treturn selectElement(element);\n\t}\n\t\n\tprivate boolean selectElement(Object element) {\n\t\tif(element instanceof AlertScanNode) {\n\t\t\treturn selectAlertScanNode((AlertScanNode) element);\n\t\t} else if(element instanceof AlertHostNode) {\n\t\t\treturn selectAlertHostNode((AlertHostNode) element);\n\t\t} else if(element instanceof AlertSeverityNode) {\n\t\t\treturn selectAlertSeverityNode((AlertSeverityNode) element);\n\t\t} else if(element instanceof AlertTitleNode) {\n\t\t\treturn selectAlertTitleNode((AlertTitleNode) element);\n\t\t} else if(element instanceof IScanAlert) {\n\t\t\treturn selectScanAlert((IScanAlert) element);\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tprivate boolean selectAlertScanNode(AlertScanNode node) {\n\t\tfor(IAlertTreeNode n: node.getChildren()) {\n\t\t\tif(selectElement(n)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate boolean selectAlertHostNode(AlertHostNode node) {\n\t\tfor(IAlertTreeNode n: node.getChildren()) {\n\t\t\tif(selectElement(n)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate boolean selectAlertSeverityNode(AlertSeverityNode node) {\n\t\tfor(IAlertTreeNode n: node.getChildren()) {\n\t\t\tif(selectElement(n)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\t\n\t}\n\t\n\tprivate boolean selectAlertTitleNode(AlertTitleNode node) {\n\t\tif(node.hasChildren()) {\n\t\t\tfor(Object ob: node.getChildren()) {\n\t\t\t\tif(selectElement(ob)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\treturn selectScanAlert(node.getFirstAlert());\n\t}\n\t\n\tprivate boolean selectScanAlert(IScanAlert alert) {\n\t\tfinal IRequestLogRecord record = alertToRecord(alert);\n\t\tif(record == null) {\n\t\t\treturn false;\n\t\t}\n\t\tfinal HttpHost host = record.getHttpHost();\n\t\tfinal String uriPath = recordToUriPath(record);\n\t\tif(host == null || uriPath == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn currentScope.filter(host, uriPath);\n\t}\n\n\tprivate IRequestLogRecord alertToRecord(IScanAlert alert) {\n\t\tif(alert == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn workspace.getRequestLog().lookupRecord(alert.getRequestId());\n\t}\n\n\tprivate String recordToUriPath(IRequestLogRecord record) {\n\t\tfinal HttpRequest request = record.getRequest();\n\t\tif(request == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn UriTools.removeUnicodeEscapes(request.getRequestLine().getUri());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/IAlertTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts;\n\nimport java.util.Collection;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\npublic interface IAlertTreeNode {\n\tString getKey();\n\tvoid remove();\n\tvoid addAlert(IScanAlert alert);\n\tvoid removeAlert(IScanAlert alert);\n\tboolean hasChildren();\n\tCollection<IScanAlert> getAlerts();\n\tint getAlertCount();\n\tObject[] getChildren();\n\tString getLabel();\n\tString getImage();\n\tIScanInstance getScanInstance();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/PerspectiveTracker.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport org.eclipse.jface.viewers.StructuredViewer;\nimport org.eclipse.ui.IPerspectiveDescriptor;\nimport org.eclipse.ui.IPerspectiveListener;\nimport org.eclipse.ui.IWorkbenchPage;\n\npublic class PerspectiveTracker implements IPerspectiveListener {\n\tprivate final StructuredViewer viewer;\n\tprivate final ProxyPerspectiveFilter proxyPerspectiveFilter;\n\tpublic PerspectiveTracker(IWorkbenchPage page, StructuredViewer viewer) {\n\t\tthis.viewer = viewer;\n\t\tthis.proxyPerspectiveFilter = new ProxyPerspectiveFilter();\n\t\tif(page.getPerspective() != null) {\n\t\t\tperspectiveActivated(page, page.getPerspective());\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void perspectiveActivated(IWorkbenchPage page,\n\t\t\tIPerspectiveDescriptor perspective) {\n\t\tif(perspective.getId().equals(\"com.subgraph.vega.perspectives.proxy\")) {\n\t\t\tviewer.addFilter(proxyPerspectiveFilter);\n\t\t} else {\n\t\t\tviewer.removeFilter(proxyPerspectiveFilter);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void perspectiveChanged(IWorkbenchPage page,\n\t\t\tIPerspectiveDescriptor perspective, String changeId) {\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/ProxyPerspectiveFilter.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerFilter;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\n\npublic class ProxyPerspectiveFilter extends ViewerFilter {\n\t@Override\n\tpublic boolean select(Viewer viewer, Object parentElement, Object element) {\n\t\tif(element instanceof IAlertTreeNode) {\n\t\t\tfinal IAlertTreeNode node = (IAlertTreeNode) element;\n\t\t\treturn node.getScanInstance().getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID;\n\t\t} else if(element instanceof IScanAlert) {\n\t\t\tfinal IScanAlert alert = (IScanAlert) element;\n\t\t\treturn alert.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID;\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/ScanAlertSorter.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport java.util.Date;\n\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerSorter;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertScanNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertSeverityNode;\n\npublic class ScanAlertSorter extends ViewerSorter {\n\n\t@Override\n\tpublic int compare(Viewer viewer, Object e1, Object e2) {\n\t\tfinal int cat1 = category(e1);\n\t\tfinal int cat2 = category(e2);\n\t\tif (cat1 != cat2) {\n\t\t\treturn cat1 - cat2;\n\t\t}\n\n\t\tif ((e1 instanceof AlertScanNode) && (e2 instanceof AlertScanNode)) {\n\t\t\treturn compareAlertNodes((AlertScanNode) e1, (AlertScanNode) e2);\n\t\t} else if ((e1 instanceof AlertSeverityNode)\n\t\t\t\t&& (e2 instanceof AlertSeverityNode)) {\n\t\t\tfinal AlertSeverityNode asn1 = (AlertSeverityNode) e1;\n\t\t\tfinal AlertSeverityNode asn2 = (AlertSeverityNode) e2;\n\t\t\treturn asn2.getSeverityIndex() - asn1.getSeverityIndex();\n\n\t\t} else {\n\t\t\treturn super.compare(viewer, e1, e2);\n\t\t}\n\t}\n\n\t@Override\n\tpublic int category(Object element) {\n\t\tif (element instanceof AlertScanNode) {\n\t\t\treturn (((AlertScanNode) element).getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) ? (0)\n\t\t\t\t\t: (1);\n\t\t}\n\t\treturn 0;\n\t}\n\n\tprivate int compareAlertNodes(AlertScanNode n1, AlertScanNode n2) {\n\t\tif ((n1.getScanInstance() == null) || (n2.getScanInstance() == null)) {\n\t\t\treturn (int) (n1.getScanId() - n2.getScanId());\n\t\t} else {\n\t\t\tfinal Date d1 = n1.getScanInstance().getStartTime();\n\t\t\tfinal Date d2 = n2.getScanInstance().getStartTime();\n\t\t\tif (d1 == null || d2 == null) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn (d1.getTime() < d2.getTime()) ? (1) : (-1);\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/ScanAlertView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts;\n\nimport java.util.Collection;\nimport java.util.Timer;\nimport java.util.TimerTask;\nimport java.util.logging.Logger;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.jface.action.IMenuListener;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.viewers.DoubleClickEvent;\nimport org.eclipse.jface.viewers.IDoubleClickListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.jface.wizard.WizardDialog;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Menu;\nimport org.eclipse.swt.widgets.TreeItem;\nimport org.eclipse.ui.IPartListener2;\nimport org.eclipse.ui.IWorkbenchPartReference;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.internal.dialogs.ExportWizard;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.NewScanAlertEvent;\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.export.AlertExporter;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertHostNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertScanNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertSeverityNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertTitleNode;\nimport com.subgraph.vega.ui.util.export.AlertExportWizard;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class ScanAlertView extends ViewPart implements IDoubleClickListener, IEventHandler {\n\tpublic final static String ID = \"com.subgraph.vega.views.alert\";\n\tprivate final static String ALERT_VIEW_ICON = \"icons/alert_view.png\";\n\tprivate final Logger logger = Logger.getLogger(\"scan-alert-view\");\n\t\n\tprivate final Timer blinkTimer = new Timer();\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\t\n\t\n\tprivate IWorkspace currentWorkspace;\n\tprivate ScopeTracker scopeTracker;\n\tprivate IPartListener2 partListener;\n\tprivate TreeViewer viewer;\n\tprivate TimerTask blinkTask;\n\tprivate boolean isViewVisible;\n\tprivate boolean ignoreEvents;\n\t\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tviewer = new TreeViewer(parent);\n\t\tfinal AlertTreeContentProvider contentProvider = new AlertTreeContentProvider();\n\t\tviewer.setContentProvider(contentProvider);\n\t\tviewer.setLabelProvider(new AlertTreeLabelProvider(contentProvider));\n\t\tviewer.addDoubleClickListener(this);\n\t\tviewer.setSorter(new ScanAlertSorter());\n\t\t\t\t\n\t\tgetSite().setSelectionProvider(viewer);\n\t\tviewer.addSelectionChangedListener(new SelectionTracker(getSite().getPage()));\n\t\tcreateContextMenu(viewer);\n\t\t\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tif(model == null) {\n\t\t\tlogger.warning(\"Failed to obtain reference to model\");\n\t\t\treturn;\n\t\t}\n\t\tscopeTracker = new ScopeTracker(viewer);\n\t\tWorkspaceTracker.create(model, this, scopeTracker);\n\t\tgetSite().getWorkbenchWindow().addPerspectiveListener(new PerspectiveTracker(getSite().getPage(), viewer));\n\t\tpartListener = createPartListener();\n\t\tgetSite().getPage().addPartListener(partListener);\n\t}\n\t\n\t\tprivate IPartListener2 createPartListener() {\n\t\treturn new IPartListener2() {\n\t\t\t@Override\n\t\t\tpublic void partVisible(IWorkbenchPartReference partRef) {\n\t\t\t\tif(ID.equals(partRef.getId())) {\n\t\t\t\t\tisViewVisible = true;\n\t\t\t\t\tstopNotifier();\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void partHidden(IWorkbenchPartReference partRef) {\n\t\t\t\tif(ID.equals(partRef.getId())) {\n\t\t\t\t\tisViewVisible = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t@Override public void partOpened(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partInputChanged(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partDeactivated(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partClosed(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partBroughtToTop(IWorkbenchPartReference partRef) {}\n\t\t\t@Override public void partActivated(IWorkbenchPartReference partRef) {}\n\t\t};\n\t}\n\t@Override\n\tpublic void dispose() {\n\t\tgetSite().getPage().removePartListener(partListener);\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\n\tpublic void expandAll() {\n\t\tif (viewer != null) {\n\t\t\tviewer.expandAll();\n\t\t}\n\t}\n\n\tpublic void collapseAll() {\n\t\tif (viewer != null) {\n\t\t\tviewer.collapseAll();\n\t\t}\n\t}\n\t\n\tprivate void selectFirstScan() {\n\t\tif(viewer.getTree().getItemCount() > 0) {\n\t\t\tfinal TreeItem item = viewer.getTree().getItem(0);\n\t\t\tviewer.setSelection(new StructuredSelection(item.getData()));\n\t\t} \n\t}\n\n\tpublic void workspaceChanged(IWorkspace workspace) {\n\t\tif(currentWorkspace != null) {\n\t\t\tcurrentWorkspace.getScanAlertRepository().getProxyScanInstance().removeScanEventListener(this);\n\t\t}\n\t\tcurrentWorkspace = workspace;\n\t\tviewer.setInput(workspace);\n\t\tif(workspace != null) {\n\t\t\tselectFirstScan();\n\t\t\tignoreEvents = true;\n\t\t\tworkspace.getScanAlertRepository().getProxyScanInstance().addScanEventListenerAndPopulate(this);\n\t\t\tignoreEvents = false;\n\t\t}\t\n\t}\n\t\n\tpublic void startNotifier() {\n\t\tif(blinkTask == null) {\n\t\t\tblinkTask = createBlinkTask();\n\t\t\tblinkTimer.scheduleAtFixedRate(blinkTask, 0, 500);\n\t\t}\n\t}\n\n\tpublic void stopNotifier() {\n\t\tif(blinkTask != null) {\n\t\t\tblinkTask.cancel();\n\t\t\tsetLabelImage(imageCache.get(ALERT_VIEW_ICON));\n\t\t\tblinkTask = null;\n\t\t}\n\t}\n\t\n\tprivate TimerTask createBlinkTask() {\n\t\treturn new TimerTask() {\n\t\t\tprivate boolean state;\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tstate = !state;\n\t\t\t\tif(state) {\n\t\t\t\t\tsetLabelImage(imageCache.getDisabled(ALERT_VIEW_ICON));\n\t\t\t\t} else {\n\t\t\t\t\tsetLabelImage(imageCache.get(ALERT_VIEW_ICON));\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate void setLabelImage(final Image image) {\n\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsetTitleImage(image);\n\t\t\t}\n\t\t});\n\t}\n\t\n\t@Override\n\tpublic void setFocus() {\n\t\tviewer.getTree().setFocus();\n\t\tstopNotifier();\n\t}\n\n\t@Override\n\tpublic void doubleClick(DoubleClickEvent event) {\n\t\tfinal IStructuredSelection selection = (IStructuredSelection) event.getSelection();\n\t\tfinal Object element = selection.getFirstElement();\n\t\tif(viewer.isExpandable(element)) {\n\t\t\tviewer.setExpandedState(element, !viewer.getExpandedState(element));\n\t\t}\n\t}\n\n\tpublic IScan getSelection() {\n\t\tfinal IScanInstance scanInstance = getScanInstanceForSelection((IStructuredSelection) viewer.getSelection());\n\t\tif(scanInstance == null) {\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn scanInstance.getScan();\n\t\t}\n\t}\n\n\tprivate IScanInstance getScanInstanceForSelection(IStructuredSelection selection) {\n\t\tif(selection == null || selection.isEmpty()) {\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tfinal Object element = selection.getFirstElement();\n\t\t\n\t\tif(element instanceof IScanAlert) {\n\t\t\treturn ((IScanAlert)element).getScanInstance();\n\t\t} else if(element instanceof IAlertTreeNode) {\n\t\t\treturn ((IAlertTreeNode)element).getScanInstance();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic void setTitleImage(Image image) {\n\t\tif(image != null && !image.isDisposed()) {\n\t\t\tsuper.setTitleImage(image);\n\t\t}\n\t}\n\t\n\tpublic void setFilterByScope(boolean enabled) {\n\t\tscopeTracker.setFilterByScopeEnabled(enabled);\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif(event instanceof NewScanAlertEvent) {\n\t\t\tif(!isViewVisible && !ignoreEvents) {\n\t\t\t\tstartNotifier();\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void createContextMenu(TreeViewer viewer) {\n\t\tfinal MenuManager menuManager = new MenuManager();\n\t\tmenuManager.setRemoveAllWhenShown(true);\n\t\tmenuManager.addMenuListener(new IMenuListener() {\n\t\t\t@Override\n\t\t\tpublic void menuAboutToShow(IMenuManager manager) {\n\t\t\t\tfillContextMenu(manager);\n\t\t\t}\n\t\t});\n\t\tfinal Menu menu = menuManager.createContextMenu(viewer.getControl());\n\t\tviewer.getControl().setMenu(menu);\n\t}\n\t\n\tprivate void fillContextMenu(IMenuManager manager) {\n\t\tfinal IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();\n\t\tif(selection == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal Object ob = selection.getFirstElement();\n\t\tif(ob instanceof IScanAlert) {\n\t\t\tcreateContextMenuForScanAlert(manager, (IScanAlert) ob);\n\t\t} else if (ob instanceof AlertScanNode) {\n\t\t\tcreateContextMenuForScanNode(manager, (AlertScanNode) ob);\n\t\t} else if (ob instanceof IAlertTreeNode) {\n\t\t\tcreateContextMenuForAlertTreeNode(manager, (IAlertTreeNode) ob);\n\t\t}\n\t}\n\t\n\tprivate void createContextMenuForScanAlert(IMenuManager manager, final IScanAlert alert) {\n\t\tfinal Action action = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\talert.getScanInstance().removeAlert(alert);\n\t\t\t}\n\t\t};\n\t\taction.setText(\"Remove alert\");\n\t\tmanager.add(action);\n\t\t\n\t}\n\t\n\tprivate void createContextMenuForScanNode(IMenuManager manager, final AlertScanNode node) {\n\t\tif(node.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID || node.getScanInstance().isActive()) {\n\t\t\treturn;\n\t\t}\n\n\t\tfinal Action action = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tcurrentWorkspace.getScanAlertRepository().removeScanInstance(node.getScanInstance());\n\t\t\t}\n\t\t};\n\t\taction.setText(\"Remove Scan\");\n\t\tmanager.add(action);\n\t\t\n\t\tfinal Action exportAction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t//\tAlertExporter exporter = new AlertExporter(currentWorkspace);\n\t\t\t\t//exporter.exportbyScanInstance(node.getScanInstance());\t\t\t\n\t\t\t\tWizardDialog wizardDialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),\n\t\t\t\t      new AlertExportWizard(node.getScanInstance()));\t\t\t\t\n\t\t\t\twizardDialog.open();\n\t\t\t\t\n\t\t\t  }\n\t\t\t\t\n\t\t\t\t  \n\t\t\t\n\t\t};\n\t\texportAction.setText(\"Export Scan Results\");\n\t\tmanager.add(exportAction);\n\t}\n\t\n\tprivate void createContextMenuForAlertTreeNode(IMenuManager manager, final IAlertTreeNode node) {\n\t\tfinal Collection<IScanAlert> alerts = node.getAlerts();\n\t\tfinal Action action = new Action() {\n\t\t\t@Override \n\t\t\tpublic void run() {\n\t\t\t\tnode.getScanInstance().removeAlerts(alerts);\n\t\t\t}\n\t\t};\n\t\taction.setText(getAlertTreeNodeString(node) + getAlertCountString(alerts.size()));\n\t\tmanager.add(action);\n\t\t\n\t}\n\n\tprivate String getAlertCountString(int n) {\n\t\tif(n == 1) {\n\t\t\treturn \"1 alert\";\n\t\t} else {\n\t\t\treturn Integer.toString(n) + \" alerts\";\n\t\t}\n\t}\n\t\n\tprivate String getAlertTreeNodeString(IAlertTreeNode node) {\n\t\tif(node instanceof AlertTitleNode) {\n\t\t\treturn \"Remove \";\n\t\t} else if (node instanceof AlertSeverityNode) {\n\t\t\treturn \"Remove severity node with \";\n\t\t} else if (node instanceof AlertHostNode) {\n\t\t\treturn \"Remove host node with \";\n\t\t} else {\n\t\t\treturn \"Remove \";\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/ScopeTracker.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport org.eclipse.jface.viewers.StructuredViewer;\nimport org.eclipse.jface.viewers.ViewerFilter;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.scope.ActiveScopeChangedEvent;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\n\npublic class ScopeTracker {\n\t\n\tprivate final StructuredViewer viewer;\n\tprivate final IEventHandler scopeChangeListener;\n\t\n\tprivate IWorkspace currentWorkspace;\n\tprivate ViewerFilter activeScopeFilter;\n\tprivate boolean filterEnabled;\n\t\n\tScopeTracker(StructuredViewer viewer) {\n\t\tthis.viewer = viewer;\n\t\tthis.scopeChangeListener = createScopeChangeListener();\n\t}\n\t\n\tprivate IEventHandler createScopeChangeListener() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof ActiveScopeChangedEvent) {\n\t\t\t\t\tchangeActiveScope(((ActiveScopeChangedEvent)event).getActiveScope());\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate void changeActiveScope(ITargetScope activeScope) {\n\t\tif(currentWorkspace == null) {\n\t\t\treturn;\n\t\t}\n\t\tif(activeScopeFilter != null) {\n\t\t\tviewer.removeFilter(activeScopeFilter);\n\t\t\tactiveScopeFilter = null;\n\t\t}\n\t\tif(filterEnabled) {\n\t\t\tactiveScopeFilter = new CurrentScopeFilter(currentWorkspace, activeScope);\n\t\t\tviewer.addFilter(activeScopeFilter);\n\t\t}\n\t}\n\t\n\tpublic void workspaceChanged(IWorkspace workspace) {\n\t\tif(currentWorkspace != null) {\n\t\t\tcurrentWorkspace.getTargetScopeManager().removeActiveScopeChangeListener(scopeChangeListener);\n\t\t}\n\t\tcurrentWorkspace = workspace;\n\t\tif(workspace != null) {\n\t\t\tfinal ITargetScope activeScope = workspace.getTargetScopeManager().addActiveScopeChangeListener(scopeChangeListener);\n\t\t\tchangeActiveScope(activeScope);\n\t\t}\n\t}\n\t\n\tpublic void setFilterByScopeEnabled(boolean value) {\n\t\tfilterEnabled = value;\n\t\tfinal ITargetScope activeScope = currentWorkspace.getTargetScopeManager().getActiveScope();\n\t\tchangeActiveScope(activeScope);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/SelectionTracker.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.services.ISourceProviderService;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.ScanPauseStateChangedEvent;\nimport com.subgraph.vega.api.model.alerts.ScanStatusChangeEvent;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertTitleNode;\nimport com.subgraph.vega.ui.scanner.commands.PauseStateSourceProvider;\nimport com.subgraph.vega.ui.scanner.commands.ScannerStateSourceProvider;\nimport com.subgraph.vega.ui.scanner.info.ScanInfoView;\n\npublic class SelectionTracker implements ISelectionChangedListener {\n\tprivate final Logger logger = Logger.getLogger(\"scan-alert-view\");\n\tprivate final IWorkbenchPage page;\n\tprivate final IEventHandler scanEventHandler;\n\t\n\tprivate IScanInstance selectedScanInstance;\n\t\n\tpublic SelectionTracker(IWorkbenchPage page) {\n\t\tthis.page = page;\n\t\tthis.scanEventHandler = createScanEventHandler();\n\t}\n\t\n\tprivate IEventHandler createScanEventHandler() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif( (event instanceof ScanPauseStateChangedEvent) \n\t\t\t\t\t\t|| (event instanceof ScanStatusChangeEvent)) {\n\t\t\t\t\tupdateSourceProviders(selectedScanInstance);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t@Override\n\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\thandleSelection((IStructuredSelection) event.getSelection());\n\t}\n\t\n\tprivate void handleSelection(IStructuredSelection selection) {\n\t\tfinal Object item = selection.getFirstElement();\n\t\tif(item instanceof IAlertTreeNode) {\n\t\t\tsetSelectedScanInstance( ((IAlertTreeNode) item).getScanInstance() );\n\t\t\tif(item instanceof AlertTitleNode) {\n\t\t\t\tactivateInfoView();\n\t\t\t}\n\t\t} else if(item instanceof IScanAlert) {\n\t\t\tsetSelectedScanInstance( ((IScanAlert)item).getScanInstance() );\n\t\t\tactivateInfoView();\n\t\t} else {\n\t\t\tsetSelectedScanInstance(null);\n\t\t}\n\t}\n\n\tprivate void activateInfoView() {\n\t\ttry {\n\t\t\tpage.showView(ScanInfoView.ID, null, IWorkbenchPage.VIEW_VISIBLE);\n\t\t} catch (PartInitException e) {\n\t\t\tlogger.log(Level.WARNING, \"Failed to open Scan Info view\", e);\n\t\t}\n\t}\n\n\tprivate void setSelectedScanInstance(IScanInstance scanInstance) {\n\t\tif(selectedScanInstance != null) {\n\t\t\tselectedScanInstance.removeScanEventListener(scanEventHandler);\n\t\t} \n\t\tselectedScanInstance = scanInstance;\n\t\tif(selectedScanInstance != null) {\n\t\t\tselectedScanInstance.addScanEventListenerAndPopulate(scanEventHandler);\n\t\t} \n\t\tupdateSourceProviders(scanInstance);\n\n\t\t\n\t}\n\tprivate void updateSourceProviders(IScanInstance scanInstance) {\n\t\tfinal ISourceProviderService sps = (ISourceProviderService) PlatformUI.getWorkbench().getService(ISourceProviderService.class);\n\t\tupdatePauseStateSourceProvider((PauseStateSourceProvider) sps.getSourceProvider(PauseStateSourceProvider.PAUSE_STATE), scanInstance);\n\t\tupdateScannerStateSourceProvider((ScannerStateSourceProvider) sps.getSourceProvider(ScannerStateSourceProvider.SCAN_SELECTION_STATE), scanInstance);\n\t}\n\t\n\tprivate void updatePauseStateSourceProvider(PauseStateSourceProvider provider, IScanInstance scanInstance) {\n\t\tif(provider != null) {\n\t\t\tprovider.setSelectedScan(scanInstance);\n\t\t}\n\t}\n\t\n\tprivate void updateScannerStateSourceProvider(ScannerStateSourceProvider provider, IScanInstance scanInstance) {\n\t\tif(provider != null) {\n\t\t\tif(scanInstance != null) {\n\t\t\t\tprovider.setScanSelectionIsActive(scanInstance.isActive());\n\t\t\t} else {\n\t\t\t\tprovider.setScanSelectionIsActive(false);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/WorkspaceTracker.java",
    "content": "package com.subgraph.vega.ui.scanner.alerts;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\n\npublic class WorkspaceTracker implements IEventHandler {\n\t\n\tstatic WorkspaceTracker create(IModel model, ScanAlertView alertView, ScopeTracker scopeTracker) {\n\t\tfinal WorkspaceTracker tracker = new WorkspaceTracker(alertView, scopeTracker);\n\t\tfinal IWorkspace workspace = model.addWorkspaceListener(tracker);\n\t\ttracker.setCurrentWorkspace(workspace);\n\t\treturn tracker;\n\t}\n\t\n\tprivate final ScanAlertView alertView;\n\tprivate final ScopeTracker scopeTracker;\n\t\n\tprivate WorkspaceTracker(ScanAlertView alertView, ScopeTracker scopeTracker) {\n\t\tthis.alertView = alertView;\n\t\tthis.scopeTracker = scopeTracker;\n\t}\n\t\n\tprivate void setCurrentWorkspace(IWorkspace workspace) {\n\t\talertView.workspaceChanged(workspace);\n\t\tscopeTracker.workspaceChanged(workspace);\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif(event instanceof WorkspaceOpenEvent) {\n\t\t\tsetCurrentWorkspace(((WorkspaceOpenEvent)event).getWorkspace());\n\t\t} else if(event instanceof WorkspaceCloseEvent) {\n\t\t\tsetCurrentWorkspace(null);\n\t\t} else if(event instanceof WorkspaceResetEvent) {\n\t\t\tsetCurrentWorkspace(null);\n\t\t\tsetCurrentWorkspace( ((WorkspaceResetEvent)event).getWorkspace());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/tree/AbstractAlertTreeNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts.tree;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.ui.scanner.alerts.IAlertTreeNode;\n\nabstract class AbstractAlertTreeNode implements IAlertTreeNode {\n\tprotected final AbstractAlertTreeNode parentNode;\n\tprotected final Map<String, IAlertTreeNode> nodeMap = new HashMap<String, IAlertTreeNode>();\n\n\tprotected AbstractAlertTreeNode(AbstractAlertTreeNode parentNode) {\n\t\tthis.parentNode = parentNode;\n\t}\n\n\t@Override\n\tpublic void addAlert(IScanAlert alert) {\n\t\tfinal IAlertTreeNode node = getNodeForAlert(alert);\n\t\tif(node != null) {\n\t\t\tnode.addAlert(alert);\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void removeAlert(IScanAlert alert) {\n\t\tfinal String key = createKeyForAlert(alert);\n\t\tfor(IAlertTreeNode node: getChildren()) {\n\t\t\tif(node.getKey().equals(key)) {\n\t\t\t\tnode.removeAlert(alert);\n\t\t\t}\n\t\t\tif(node.getAlertCount() == 0) {\n\t\t\t\tremoveNode(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic void remove() {\n\t\tfor(IAlertTreeNode node: getChildren()) {\n\t\t\tnode.remove();\n\t\t}\n\t\tparentNode.removeNode(getKey());\n\t}\n\t\n\t@Override\n\tpublic Collection<IScanAlert> getAlerts() {\n\t\tfinal List<IScanAlert> alerts = new ArrayList<IScanAlert>();\n\t\tfor(IAlertTreeNode node: getChildren()) {\n\t\t\talerts.addAll(node.getAlerts());\n\t\t}\n\t\treturn Collections.unmodifiableList(alerts);\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn nodeMap.size() > 0;\n\t}\n\t\n\t@Override\n\tpublic int getAlertCount() {\n\t\tint n = 0;\n\t\tfor(IAlertTreeNode node: nodeMap.values()) {\n\t\t\tn += node.getAlertCount();\n\t\t}\n\t\treturn n;\n\t}\n\t\n\t\n\t@Override\n\tpublic synchronized IAlertTreeNode[] getChildren() {\n\t\treturn nodeMap.values().toArray(new IAlertTreeNode[0]);\n\t}\n\n\tpublic synchronized void removeNode(String key) {\n\t\tnodeMap.remove(key);\n\t}\n\n\t@Override\n\tpublic String getImage() {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic IScanInstance getScanInstance() {\n\t\tif (parentNode != null) {\n\t\t\treturn parentNode.getScanInstance();\n\t\t}\n\t\treturn null;\n\t}\n\n\n\tprotected synchronized IAlertTreeNode getNodeForAlert(IScanAlert alert) {\n\t\tfinal String key = createKeyForAlert(alert);\n\t\tif(key == null) {\n\t\t\treturn null;\n\t\t}\n\t\tif(!nodeMap.containsKey(key)) {\n\t\t\tnodeMap.put(key, createNodeForAlert(alert));\n\t\t}\n\t\treturn nodeMap.get(key);\n\t}\n\n\tabstract protected IAlertTreeNode createNodeForAlert(IScanAlert alert);\n\tabstract protected String createKeyForAlert(IScanAlert alert);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/tree/AlertHostNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts.tree;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\n\npublic class AlertHostNode extends AbstractAlertTreeNode {\n\tprivate final static String HOSTNAME_IMAGE = \"icons/hostname.png\";\n\tprivate final String hostname;\n\n\tAlertHostNode(AbstractAlertTreeNode parentNode, String hostname) {\n\t\tsuper(parentNode);\n\t\tthis.hostname = hostname;\n\t}\n\n\tpublic String getKey() {\n\t\treturn hostname;\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn hostname;\n\t}\n\n\t@Override\n\tpublic String getImage() {\n\t\treturn HOSTNAME_IMAGE;\n\t}\n\n\t@Override\n\tprotected AbstractAlertTreeNode createNodeForAlert(IScanAlert alert) {\n\t\treturn new AlertSeverityNode(this, alert.getSeverity());\n\t}\n\n\t@Override\n\tprotected String createKeyForAlert(IScanAlert alert) {\n\t\treturn alert.getSeverity().toString();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/tree/AlertScanNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts.tree;\n\nimport java.text.SimpleDateFormat;\n\nimport org.apache.http.HttpHost;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\n\npublic class AlertScanNode extends AbstractAlertTreeNode {\n\tprivate final static String SCAN_IMAGE = \"icons/scanner.png\";\n\tprivate final static String PROXY_IMAGE = \"icons/proxy.png\";\n\tprivate final static String NO_HOSTNAME = \"No Hostname\";\n\tprivate final SimpleDateFormat dateFormat = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");\n\tprivate final IWorkspace workspace;\n\tprivate final long scanId;\n\tprivate IScanInstance scanInstance;\n\t\n\tAlertScanNode(AbstractAlertTreeNode parentNode, long scanId, IWorkspace workspace) {\n\t\tsuper(parentNode);\n\t\tthis.workspace = workspace;\n\t\tthis.scanId = scanId;\n\t}\n\n\tvoid setScanInstance(IScanInstance scanInstance) {\n\t\tthis.scanInstance = scanInstance;\n\t}\n\n\t@Override\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\tif(scanId == -1) {\n\t\t\treturn \"Proxy\";\n\t\t} else if(scanInstance == null) {\n\t\t\treturn \"Scan [id: #\"+ Long.toString(scanId) +\"]  \";\n\t\t} else {\n\t\t\treturn renderScanInstance();\n\t\t}\n\t}\n\n\tprivate String renderScanInstance() {\n\t\tfinal StringBuilder sb = new StringBuilder();\n\t\tif (scanInstance.getStartTime() != null) {\n\t\t\tsb.append(dateFormat.format(scanInstance.getStartTime()));\n\t\t}\n\n\t\tif(scanInstance.isScanPaused()) {\n\t\t\tsb.append(\" [Scan Paused] \");\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tsb.append(\" [\");\n\t\tswitch(scanInstance.getScanStatus()) {\n\t\t\n\t\tcase IScanInstance.SCAN_PROBING:\n\t\t\tsb.append(\"Probing Server\");\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_STARTING:\n\t\t\tsb.append(\"Starting\");\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_AUDITING:\n\t\t\tsb.append(\"Auditing\");\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_CANCELLED:\n\t\t\tsb.append(\"Cancelled\");\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_COMPLETED:\n\t\t\tsb.append(\"Completed\");\n\t\t\tbreak;\n\t\t}\n\t\tsb.append(\"] \");\n\t\treturn sb.toString();\n\t}\n\n\t@Override\n\tprotected AbstractAlertTreeNode createNodeForAlert(IScanAlert alert) {\n\t\treturn new AlertHostNode(this, createKeyForAlert(alert));\n\t}\n\n\t@Override\n\tpublic String getImage() {\n\t\tif(scanId == -1) {\n\t\t\treturn PROXY_IMAGE;\n\t\t} else {\n\t\t\treturn SCAN_IMAGE;\n\t\t}\n\t}\n\n\t@Override\n\tprotected String createKeyForAlert(IScanAlert alert) {\n\t\tif(!alert.hasAssociatedRequest()) {\n\t\t\tif (alert.getDiscretionaryHostname() != null) {\n\t\t\t\treturn alert.getDiscretionaryHostname();\n\t\t\t}\n\t\t\treturn NO_HOSTNAME;\n\t\t}\n\t\tfinal IRequestLogRecord record = workspace.getRequestLog().lookupRecord(alert.getRequestId());\n\t\tif(record == null) {\n\t\t\treturn NO_HOSTNAME;\n\t\t}\n\t\tfinal HttpHost host = record.getHttpHost();\n\t\tif(host == null) {\n\t\t\treturn NO_HOSTNAME;\n\t\t}\n\t\treturn host.toString();\n\t}\n\n\tpublic long getScanId() {\n\t\treturn scanId;\n\t}\n\t\n\tpublic String getKey() {\n\t\treturn Long.toString(scanId);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/tree/AlertSeverityNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts.tree;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlert.Severity;\nimport com.subgraph.vega.ui.scanner.alerts.IAlertTreeNode;\n\npublic class AlertSeverityNode extends AbstractAlertTreeNode {\n\tprivate final static String ALERT_LOW = \"icons/alert_low.png\";\n\tprivate final static String ALERT_MEDIUM = \"icons/alert_medium.png\";\n\tprivate final static String ALERT_HIGH = \"icons/alert_high.png\";\n\tprivate final static String ALERT_INFO = \"icons/alert_info.png\";\n\t\n\tprivate final Severity severity;\n\t\t\n\tAlertSeverityNode(AbstractAlertTreeNode parentNode, Severity severity) {\n\t\tsuper(parentNode);\n\t\tthis.severity = severity;\n\t}\n\n\tpublic Severity getSeverity() {\n\t\treturn severity;\n\t}\n\t\n\tpublic String getKey() {\n\t\treturn severity.toString();\n\t}\n\n\tpublic int getSeverityIndex() {\n\t\tswitch(severity) {\n\t\tcase HIGH:\n\t\t\treturn 5;\n\t\tcase MEDIUM:\n\t\t\treturn 4;\n\t\tcase LOW:\n\t\t\treturn 3;\n\t\tcase INFO:\n\t\t\treturn 2;\n\t\tdefault:\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\tswitch(severity) {\n\t\tcase HIGH:\n\t\t\treturn \"High\";\n\t\tcase MEDIUM:\n\t\t\treturn \"Medium\";\n\t\tcase LOW:\n\t\t\treturn \"Low\";\n\t\tcase INFO:\n\t\t\treturn \"Info\";\n\t\tcase UNKNOWN:\n\t\t\treturn \"Unknown\";\n\t\t}\n\t\treturn \"\";\n\t}\n\t\n\t@Override\n\tpublic String getImage() {\n\t\tswitch(severity) {\n\t\tcase HIGH:\n\t\t\treturn ALERT_HIGH;\n\t\tcase MEDIUM:\n\t\t\treturn ALERT_MEDIUM;\n\t\tcase LOW:\n\t\t\treturn ALERT_LOW;\n\t\tcase INFO:\n\t\t\treturn ALERT_INFO;\n\t\tcase UNKNOWN:\n\t\t\treturn null;\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tprotected IAlertTreeNode createNodeForAlert(IScanAlert alert) {\n\t\treturn new AlertTitleNode(this, alert.getTitle());\n\t}\n\n\t@Override\n\tprotected String createKeyForAlert(IScanAlert alert) {\n\t\treturn alert.getTitle();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/tree/AlertTitleNode.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts.tree;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.ui.scanner.alerts.IAlertTreeNode;\n\npublic class AlertTitleNode implements IAlertTreeNode {\n\tprivate final static String ALERT_ITEM = \"icons/alert_item.png\";\n\tprivate final AlertSeverityNode parentNode;\n\tprivate final String title;\n\tprivate final List<IScanAlert> alerts;\n\t\n\tAlertTitleNode(AlertSeverityNode parentNode, String title) {\n\t\tthis.parentNode = parentNode;\n\t\tthis.title = title;\n\t\tthis.alerts = new ArrayList<IScanAlert>();\n\t}\n\t\n\t@Override\n\tpublic String getLabel() {\n\t\tif(alerts.size() == 1) {\n\t\t\treturn title + \" (\" + alerts.get(0).getResource() + \")\";\n\t\t}\n\t\treturn title;\n\t}\n\t\n\t@Override\n\tpublic String getKey() {\n\t\treturn title;\n\t}\n\t\n\t@Override\n\tpublic void remove() {\n\t\talerts.clear();\n\t\tparentNode.removeNode(getKey());\n\t}\n\n\t@Override\n\tpublic void addAlert(IScanAlert alert) {\n\t\talerts.add(alert);\t\t\n\t}\n\n\t@Override\n\tpublic void removeAlert(IScanAlert alert) {\n\t\talerts.remove(alert);\n\t}\n\n\t@Override\n\tpublic Collection<IScanAlert> getAlerts() {\n\t\treturn Collections.unmodifiableList(new ArrayList<IScanAlert>(alerts));\n\t}\n\n\t@Override\n\tpublic boolean hasChildren() {\n\t\treturn alerts.size() > 1;\n\t}\n\n\t@Override\n\tpublic int getAlertCount() {\n\t\treturn alerts.size();\n\t}\n\n\t@Override\n\tpublic Object[] getChildren() {\n\t\tif(alerts.size() > 1) {\n\t\t\treturn alerts.toArray();\n\t\t} else {\n\t\t\treturn new Object[0];\n\t\t}\n\t}\n\n\tpublic IScanAlert getFirstAlert() {\n\t\tif(alerts.isEmpty()) {\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn alerts.get(0);\n\t\t}\n\t}\n\t@Override\n\tpublic String getImage() {\n\t\treturn ALERT_ITEM;\n\t}\n\n\t@Override\n\tpublic IScanInstance getScanInstance() {\n\t\treturn parentNode.getScanInstance();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/alerts/tree/AlertTree.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.alerts.tree;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.ui.scanner.alerts.IAlertTreeNode;\n\npublic class AlertTree extends AbstractAlertTreeNode {\n\n\tprivate final IWorkspace workspace;\n\t\n\tpublic AlertTree(IWorkspace workspace) {\n\t\tsuper(null);\n\t\tthis.workspace = workspace;\n\t}\n\t\n\tpublic synchronized AlertScanNode addScan(IScanInstance scan) {\n\t\tif(scan.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\tif(scan.getAllAlerts().size() == 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tfinal AlertScanNode scanNode = getScanNode(scan.getScanId());\n\t\tif(scanNode.getScanInstance() == null) {\n\t\t\tscanNode.setScanInstance(scan);\n\t\t}\n\t\treturn scanNode;\n\t}\n\t\n\tpublic String getKey() {\n\t\treturn \"\";\n\t}\n\n\tpublic synchronized AlertScanNode getScanNode(long scanId) {\n\t\tfinal String key = Long.toString(scanId);\n\t\tAlertScanNode node = (AlertScanNode) nodeMap.get(key);\n\t\tif (node == null) {\n\t\t\tnode = new AlertScanNode(this, scanId, workspace);\n\t\t\tif(scanId == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\t\tnode.setScanInstance(workspace.getScanAlertRepository().getProxyScanInstance());\n\t\t\t}\n\t\t\tnodeMap.put(key, node);\n\t\t}\n\t\treturn node;\n\t}\n\n\t@Override\n\tpublic String getLabel() {\n\t\treturn \"[root]\";\n\t}\n\n\t@Override\n\tprotected AbstractAlertTreeNode createNodeForAlert(IScanAlert alert) {\n\t\treturn getScanNode(alert.getScanId());\n\t}\n\n\t@Override\n\tprotected String createKeyForAlert(IScanAlert alert) {\n\t\treturn Long.toString(alert.getScanId());\n\t}\n\t\n\tpublic void removeAlerts(Collection<IScanAlert> alerts) {\n\t\tfor(IScanAlert alert: alerts) {\n\t\t\tremoveAlert(alert);\n\t\t}\n\t}\n\t\n\tpublic synchronized void removeScan(IScanInstance scanInstance) {\n\t\tfinal String key = Long.toString(scanInstance.getScanId());\n\t\tfinal AlertScanNode node = (AlertScanNode) nodeMap.remove(key);\n\t\tif(node != null) {\n\t\t\tnode.remove();\n\t\t}\n\t}\n\t\n\tpublic synchronized List<AlertScanNode> getScanNodes() {\n\t\tfinal List<AlertScanNode> scanNodes = new ArrayList<AlertScanNode>();\n\t\tfor(IAlertTreeNode node: nodeMap.values()) {\n\t\t\tscanNodes.add((AlertScanNode) node);\n\t\t}\n\t\treturn scanNodes;\n\t}\n\t\n\tpublic synchronized void removeNode(String key) {\n\t\tfinal AlertScanNode scanNode = (AlertScanNode) nodeMap.get(key);\n\t\tif(scanNode != null && scanNode.getScanInstance().isActive()) {\n\t\t\treturn;\n\t\t}\n\t\tnodeMap.remove(key);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/AbstractScanHandler.java",
    "content": "package com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.api.scanner.IScan;\nimport com.subgraph.vega.ui.scanner.alerts.ScanAlertView;\nimport com.subgraph.vega.ui.util.dialogs.ErrorDialog;\n\npublic abstract class AbstractScanHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal ScanAlertView scanAlertView = getScanAlertView(event);\n\t\tif(scanAlertView == null) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal IScan scan = scanAlertView.getSelection();\n\t\tif(scan != null) {\n\t\t\trunCommand(event, scan);\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate ScanAlertView getScanAlertView(ExecutionEvent event) {\n\t\ttry {\n\t\t\treturn (ScanAlertView) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(ScanAlertView.ID);\n\t\t} catch (PartInitException e) {\n\t\t\tfinal Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();\n\t\t\tErrorDialog.displayExceptionError(shell, e);\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tabstract protected void runCommand(ExecutionEvent event, IScan selectedScan);\n\t\t\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/AlertScopeFilterHandler.java",
    "content": "package com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.ToolItem;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.scanner.alerts.ScanAlertView;\n\npublic class AlertScopeFilterHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(event.getTrigger() instanceof Event) {\n\t\t\tfinal Event e = (Event) event.getTrigger();\n\t\t\tif(e.widget instanceof ToolItem) {\n\t\t\t\tfinal ToolItem item = (ToolItem) e.widget;\n\t\t\t\tif(activePart instanceof ScanAlertView) {\n\t\t\t\t((ScanAlertView) activePart).setFilterByScope(item.getSelection());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/CollapseAllAlerts.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.scanner.alerts.ScanAlertView;\n\npublic class CollapseAllAlerts extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif (activePart instanceof ScanAlertView) {\n\t\t\t((ScanAlertView) activePart).collapseAll();\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/ConfigureScanHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.handlers.HandlerUtil;\nimport com.subgraph.vega.ui.scanner.dialogs.ScanConfigDialog;\n\npublic class ConfigureScanHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tScanConfigDialog dialog = new ScanConfigDialog(HandlerUtil.getActiveWorkbenchWindow(event).getShell());\n\t\tdialog.create();\n\t\tdialog.open();\n\t\treturn null;\n\t}\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/EditScopeHandler.java",
    "content": "package com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.scanner.scope.EditScopeDialog;\n\npublic class EditScopeHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tEditScopeDialog dialog = new EditScopeDialog(\n\t\t\t\tHandlerUtil.getActiveWorkbenchWindow(event).getShell());\n\t\tdialog.create();\n\t\tdialog.open();\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/ExpandAllAlerts.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.scanner.alerts.ScanAlertView;\n\npublic class ExpandAllAlerts extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif (activePart instanceof ScanAlertView) {\n\t\t\t((ScanAlertView) activePart).expandAll();\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/PauseScanHandler.java",
    "content": "package com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.ExecutionEvent;\n\nimport com.subgraph.vega.api.scanner.IScan;\n\npublic class PauseScanHandler extends AbstractScanHandler {\n\t@Override\n\tprotected void runCommand(ExecutionEvent event, IScan selectedScan) {\n\t\tselectedScan.pauseScan();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/PauseStateSourceProvider.java",
    "content": "package com.subgraph.vega.ui.scanner.commands;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.ui.AbstractSourceProvider;\nimport org.eclipse.ui.ISources;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\npublic class PauseStateSourceProvider extends AbstractSourceProvider {\n\tpublic final static String PAUSE_STATE = \"vega.pauseState\";\n\t\n\tprivate final static String PAUSE_PAUSEABLE = \"pauseable\";\n\tprivate final static String PAUSE_PAUSED = \"paused\";\n\tprivate final static String PAUSE_NOTPAUSEABLE = \"not_pauseable\";\n\t\n\tboolean isPauseable = false;\n\tboolean isPaused = false;\n\t\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic Map<?,?> getCurrentState() {\n\t\tfinal Map<String,String> stateMap = new HashMap<String,String>(1);\n\t\tstateMap.put(PAUSE_STATE, getCurrentPauseState());\n\t\treturn stateMap;\n\t}\n\n\t@Override\n\tpublic String[] getProvidedSourceNames() {\n\t\treturn new String[] { PAUSE_STATE };\n\t}\n\t\n\tprivate String getCurrentPauseState() {\n\t\tif(!isPauseable) {\n\t\t\treturn PAUSE_NOTPAUSEABLE;\n\t\t} else if(isPaused) {\n\t\t\treturn PAUSE_PAUSED;\n\t\t} else {\n\t\t\treturn PAUSE_PAUSEABLE;\n\t\t}\n\t}\n\n\tpublic void setSelectedScan(IScanInstance scanInstance) {\n\t\tif(scanInstance == null || scanInstance.getScan() == null \n\t\t\t\t|| scanInstance.getScanStatus() != IScanInstance.SCAN_AUDITING\n\t\t\t\t|| scanInstance.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID) {\n\t\t\tisPauseable = false;\n\t\t\tisPaused = false;\n\t\t\tfireSourceChanged(ISources.WORKBENCH, PAUSE_STATE, getCurrentState());\n\t\t\treturn;\n\t\t}\n\t\tisPauseable = true;\n\t\tisPaused = scanInstance.getScan().isPausedScan();\n\t\tfireSourceChanged(ISources.WORKBENCH, PAUSE_STATE, getCurrentPauseState());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/ScannerStateSourceProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.commands;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.ui.AbstractSourceProvider;\nimport org.eclipse.ui.ISources;\n\npublic class ScannerStateSourceProvider extends AbstractSourceProvider {\n\tpublic final static String SCAN_SELECTION_STATE = \"vega.scanSelectionState\"; \n\tpublic final static String SCAN_ACTIVE = \"active\";\n\tpublic final static String SCAN_IDLE = \"idle\";\n\tprivate boolean isScanActive = false;\n\t\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tsynchronized public Map<?,?> getCurrentState() {\n\t\tMap<String, String> stateMap = new HashMap<String, String>(1);\n\t\tstateMap.put(SCAN_SELECTION_STATE, getCurrentScanSelectionState());\n\t\treturn stateMap;\n\t}\n\n\tpublic synchronized void setScanSelectionIsActive(boolean isActive) {\n\t\tif (isScanActive != isActive) {\n\t\t\tisScanActive = isActive;\n\t\t\tfireSourceChanged(ISources.WORKBENCH, SCAN_SELECTION_STATE, getCurrentScanSelectionState());\n\t\t}\n\t}\n\n\tprivate String getCurrentScanSelectionState() {\n\t\tif (isScanActive) {\n\t\t\treturn SCAN_ACTIVE;\n\t\t} else {\n\t\t\treturn SCAN_IDLE;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String[] getProvidedSourceNames() {\n\t\treturn new String[] { SCAN_SELECTION_STATE, };\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/StartNewScanHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.commands;\n\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.scanner.ScanExecutor;\n\npublic class StartNewScanHandler extends AbstractHandler {\n\tprivate String lastTargetValue = null;\n\tprivate final ScanExecutor scanExecutor = new ScanExecutor();\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tlastTargetValue = scanExecutor.runScan(HandlerUtil.getActiveShell(event), lastTargetValue);\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/StopScannerHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.ExecutionEvent;\n\nimport com.subgraph.vega.api.scanner.IScan;\n\npublic class StopScannerHandler extends AbstractScanHandler {\n\t@Override\n\tprotected void runCommand(ExecutionEvent event, IScan selectedScan) {\n\t\tselectedScan.stopScan();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/commands/UnpauseScanHandler.java",
    "content": "package com.subgraph.vega.ui.scanner.commands;\n\nimport org.eclipse.core.commands.ExecutionEvent;\n\nimport com.subgraph.vega.api.scanner.IScan;\n\npublic class UnpauseScanHandler extends AbstractScanHandler {\n\n\t@Override\n\tprotected void runCommand(ExecutionEvent event, IScan selectedScan) {\n\t\tselectedScan.unpauseScan();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/AlertItemRow.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\n\n/**\n * This class renders a single row containing the title of an alert type and the number\n * of times this alert appears in the current scan model.\n */\npublic class AlertItemRow extends Composite {\n\n\tprivate final Label countLabel;\n\tprivate int count;\n\t\n\tpublic AlertItemRow(Composite parent, String title) {\n\t\tsuper(parent, SWT.NONE);\n\t\tGridLayout layout = new GridLayout(2, false);\n\t\tlayout.marginHeight = 0;\n\t\tsetLayout(layout);\n\t\tsetBackground(parent.getBackground());\n\t\tfinal Label label = new Label(this, SWT.WRAP);\n\t\tlabel.setText(title);\n\t\tlabel.setBackground(parent.getBackground());\n\t\tGridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);\n\t\tgd.widthHint = 300;\n\t\tlabel.setLayoutData(gd);\n\t\t\n\t\tcountLabel = new Label(this, SWT.NONE);\n\t\tcountLabel.setText(\"0\");\n\t\tcountLabel.setBackground(parent.getBackground());\n\t\t\n\t\tcountLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\t\t\n\t}\n\t\n\tvoid incrementCount() {\n\t\tcount += 1;\n\t\tif(!countLabel.isDisposed()) {\n\t\t\tcountLabel.setText(Integer.toString(count));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/AlertPane.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlert.Severity;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class AlertPane extends Composite {\n\tprivate final static String ALERT_HIGH = \"icons/alert_high.png\";\n\tprivate final static String ALERT_MEDIUM = \"icons/alert_medium.png\";\n\tprivate final static String ALERT_LOW = \"icons/alert_low.png\";\n\tprivate final static String ALERT_INFO = \"icons/alert_info.png\";\n\t\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\t\t\n\tprivate final Map<Severity, AlertSeverityCell> alertSeverityCells = new HashMap<Severity, AlertSeverityCell>();\n\tprivate Composite rootComposite;\n\t\n\tAlertPane(Composite parent) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new FillLayout());\n\t\tsetBackground(parent.getBackground());\n\t\treset();\n\t}\n\t\n\t@Override\n\tpublic void dispose() {\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\n\tprivate void addSeverityCells(Color background) {\n\t\tfor(Severity s: Severity.values()) {\n\t\t\tif(s.equals(Severity.UNKNOWN))\n\t\t\t\tcontinue;\n\t\t\tfinal AlertSeverityCell cell = createCellForSeverity(s, background);\n\t\t\tif(cell != null)\n\t\t\t\talertSeverityCells.put(s, cell);\n\t\t}\n\t}\n\t\n\tprivate AlertSeverityCell createCellForSeverity(Severity s, Color background) {\n\t\tfinal String severityImageKey = getImageKeyForSeverity(s);\n\t\tfinal String severityLabel = getLabelForSeverity(s);\n\t\tif(severityImageKey == null || severityLabel == null)\n\t\t\treturn null;\n\t\tfinal Image severityImage = imageCache.get(severityImageKey);\n\t\tfinal Image severityDisabledImage = imageCache.getDisabled(severityImageKey);\n\t\tif(severityImage == null || severityDisabledImage == null)\n\t\t\treturn null;\n\t\tfinal AlertSeverityCell cell = new AlertSeverityCell(rootComposite, background, severityImage, severityDisabledImage, severityLabel);\n\t\tcell.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tcell.setBackground(background);\n\t\treturn cell;\n\t}\n\t\n\tprivate String getImageKeyForSeverity(Severity s) {\n\t\tswitch(s) {\n\t\tcase HIGH:\n\t\t\treturn ALERT_HIGH;\n\t\tcase MEDIUM:\n\t\t\treturn ALERT_MEDIUM;\n\t\tcase LOW:\n\t\t\treturn ALERT_LOW;\n\t\tcase INFO:\n\t\t\treturn ALERT_INFO;\n\t\tcase UNKNOWN:\n\t\t\treturn null;\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate String getLabelForSeverity(Severity s) {\n\t\tswitch(s) {\n\t\tcase HIGH:\n\t\t\treturn \"High\";\n\t\tcase MEDIUM:\n\t\t\treturn \"Medium\";\n\t\tcase LOW:\n\t\t\treturn \"Low\";\n\t\tcase INFO:\n\t\t\treturn \"Info\";\n\t\tcase UNKNOWN:\n\t\t\treturn \"Unknown\";\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tvoid reset() {\n\t\tif(rootComposite != null) {\n\t\t\trootComposite.dispose();\n\t\t}\n\t\trootComposite = new Composite(this, SWT.NULL);\n\t\trootComposite.setBackground(getBackground());\n\t\trootComposite.setLayout(new GridLayout());\n\t\taddSeverityCells(getParent().getBackground());\n\t\tlayout();\n\t}\n\n\tvoid addAlert(final IScanAlert alert) {\n\t\tfinal AlertSeverityCell cell = alertSeverityCells.get(alert.getSeverity());\n\t\tif(cell == null)\n\t\t\treturn;\n\t\tgetDisplay().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tcell.addAlert(alert);\n\t\t\t}\n\t\t});\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/AlertSeverityCell.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\n\n/**\n * Renders all the information for a particular alert severity including the\n * AlertItemRows corresponding to each alert type.  There are one of these\n * for each alert severity.\n */\npublic class AlertSeverityCell extends Composite {\n\n\tprivate final Label imageLabel;\n\tprivate final Label labelLabel;\n\tprivate final Label countLabel;\n\tprivate final Image image;\n\tprivate int totalCount = 0;\n\t\n\tprivate Map<String, AlertItemRow> alertTitleToItem = new HashMap<String, AlertItemRow>();\n\t\t\n\tAlertSeverityCell(Composite parent, Color background, Image image, Image disabled, String label) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.image = image;\n\n\t\tGridLayout layout = new GridLayout(3, false);\n\t\tlayout.verticalSpacing = 2;\n\t\tsetLayout(layout);\n\t\timageLabel = new Label(this, SWT.NONE);\n\t\timageLabel.setImage(disabled);\n\t\timageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));\n\t\timageLabel.setBackground(background);\n\t\t\n\t\tlabelLabel = new Label(this, SWT.NONE);\n\t\tlabelLabel.setText(label);\n\t\tlabelLabel.setFont(JFaceResources.getBannerFont());\n\t\tsetLabelForegroundGrey(labelLabel);\n\n\t\tGridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\tlabelLabel.setLayoutData(gd);\n\t\tlabelLabel.setBackground(background);\n\t\t\n\t\tcountLabel = new Label(this, SWT.LEFT);\n\t\tgd = new GridData(SWT.FILL, SWT.CENTER, false, false);\n\t\tgd.widthHint = 85;\n\t\tcountLabel.setLayoutData(gd);\n\t\tcountLabel.setText(\"(None found)\");\n\t\tcountLabel.setBackground(background);\n\t\tsetLabelForegroundGrey(countLabel);\n\t\t\t\t\n\t\tfinal Composite spacer = new Composite(this, SWT.NONE);\n\t\tspacer.setBackground(background);\n\t\tgd = new GridData(SWT.FILL, SWT.FILL, true, false);\n\t\tgd.heightHint = 5;\n\t\tgd.horizontalSpan = 3;\n\t\tspacer.setLayoutData(gd);\n\t}\n\n\tprivate void setLabelForegroundGrey(Label label) {\n\t\tif(!label.isDisposed()) {\n\t\t\tlabel.setData(\"saved-foreground\", label.getForeground());\n\t\t\tlabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));\n\t\t}\n\t}\n\t\n\tprivate void restoreLabelForeground(Label label) {\n\t\tfinal Object ob = label.getData(\"saved-foreground\");\n\t\tif(ob instanceof Color) {\n\t\t\tif(!label.isDisposed()) {\n\t\t\t\tlabel.setForeground((Color)ob);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tvoid addAlert(IScanAlert alert) {\n\t\tif(isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\tincrementTotalCount();\n\t\tfinal String title = alert.getTitle();\n\t\tif(!alertTitleToItem.containsKey(title)) {\n\t\t\talertTitleToItem.put(title, createAlertItemRow(title));\n\t\t\tgetParent().layout();\n\t\t}\n\t\tAlertItemRow row = alertTitleToItem.get(title);\n\t\trow.incrementCount();\n\t}\n\t\n\tprivate AlertItemRow createAlertItemRow(String title) {\n\t\tAlertItemRow row = new AlertItemRow(this, title);\n\t\tGridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\tgd.horizontalSpan = 3;\n\t\tgd.horizontalIndent = 15;\n\t\trow.setLayoutData(gd);\n\t\treturn row;\n\t}\n\t\n\tprivate void incrementTotalCount() {\n\t\tif(totalCount == 0) {\n\t\t\tif(!imageLabel.isDisposed()) {\n\t\t\t\timageLabel.setImage(image);\n\t\t\t}\n\t\t\trestoreLabelForeground(labelLabel);\n\t\t\trestoreLabelForeground(countLabel);\n\t\t}\n\t\ttotalCount += 1;\n\t\tif(!countLabel.isDisposed()) {\n\t\t\tcountLabel.setText(\"(\"+ Integer.toString(totalCount) +\" found)\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/CrawlerPane.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.swt.widgets.Label;\n\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\n\npublic class CrawlerPane extends Composite {\n\tprivate final CrawlerProgressPane progressPane;\n\tprivate final Label pathLabel;\n\tprivate final Label crawlLabel;\n\tprivate volatile boolean changed;\n\tprivate boolean isScannerPaused;\n\tprivate int scannerStatus;\n\tprivate String scannerPath;\n\tprivate int crawlerTotal;\n\tprivate int crawlerCompleted;\n\tprivate double crawlerPercent;\n\n\tCrawlerPane(Composite parent) {\n\t\tsuper(parent, SWT.NONE);\n\n\t\tsetLayout(new GridLayout());\n\t\t\n\t\tprogressPane = new CrawlerProgressPane(this, parent.getBackground());\n\t\tGridData gd = new GridData(SWT.CENTER, SWT.BOTTOM, true, true);\n\t\tgd.widthHint = 300;\n\t\tprogressPane.setLayoutData(gd);\n\t\t\n\t\tpathLabel = new Label(this, SWT.CENTER);\n\t\tpathLabel.setFont(JFaceResources.getBannerFont());\n\t\tgd = new GridData(SWT.CENTER, SWT.CENTER, true, true);\n\t\tgd.widthHint = 400;\n\t\tpathLabel.setLayoutData(gd);\n\t\tpathLabel.setBackground(parent.getBackground());\n\t\t\n\t\tcrawlLabel = new Label(this, SWT.CENTER);\n\t\tcrawlLabel.setFont(JFaceResources.getBannerFont());\n\t\tgd = new GridData(SWT.CENTER, SWT.CENTER, true, true);\n\t\tgd.widthHint = 300;\n\t\tcrawlLabel.setLayoutData(gd);\n\t\tcrawlLabel.setBackground(parent.getBackground());\n\t}\n\n\tvoid setScannerPaused(boolean value) {\n\t\tisScannerPaused = value;\n\t}\n\n\tvoid renderChanges() {\n\t\tif(!changed || isDisposed())\n\t\t\treturn;\n\t\t\n\t\tfinal Display display = getDisplay();\n\t\tif(display.isDisposed())\n\t\t\treturn;\n\t\tdisplay.syncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\trenderProgress();\n\t\t\t\trenderLabel();\t\n\t\t\t}\n\t\t});\n\t}\n\t\n\tsynchronized void updateCrawlerProgress(int status, String currentPath, int total, int completed) {\n\t\tif(status == scannerStatus && scannerPath == currentPath && total == crawlerTotal && completed == crawlerCompleted ) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tscannerStatus = status;\n\t\tscannerPath = currentPath;\n\t\tcrawlerTotal = total;\n\t\tcrawlerCompleted = completed;\n\t\tif(crawlerTotal == 0) {\n\t\t\tcrawlerPercent = 0.0;\n\t\t} else {\n\t\t\tcrawlerPercent = ((double)crawlerCompleted) / ((double)crawlerTotal) * 100.0;\n\t\t}\n\t\tchanged = true;\t\n\t}\n\t\n\tprivate void renderProgress() {\n\t\tswitch(scannerStatus) {\n\t\tcase IScanInstance.SCAN_CONFIG:\n\t\tcase IScanInstance.SCAN_PROBING:\n\t\t\tprogressPane.setLabelText(\"Probing server..\");\n\t\tcase IScanInstance.SCAN_STARTING:\n\t\tcase IScanInstance.SCAN_AUDITING:\n\t\t\tprogressPane.setProgressBarValue((int) crawlerPercent);\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_CANCELLED:\n\t\t\tprogressPane.setLabelText(\"Scanner canceled.\");\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_COMPLETED:\n\t\t\tprogressPane.setLabelText(\"Scanner completed.\");\n\t\t\tbreak;\n\t\t\t\n\t\t}\n\t}\n\t\n\tprivate void renderLabel() {\n\t\tif(crawlLabel.isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\tif(crawlerPercent < 0.01) {\n\t\t\tcrawlLabel.setText(\"\");\n\t\t}\n\n\t\tif(scannerPath != null) {\n\t\t\tpathLabel.setText(scannerPath);\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(crawlerCompleted);\n\t\tsb.append(\" out of \");\n\t\tsb.append(crawlerTotal);\n\t\tsb.append(\" scanned (\");\n\t\tif(isScannerPaused) {\n\t\t\tsb.append(\"Scanner Paused\");\n\t\t} else {\n\t\t\tsb.append(String.format(\"%.1f%%\", crawlerPercent));\n\t\t}\n\t\tsb.append(\")\");\n\t\tcrawlLabel.setText(sb.toString());\n\t}\n\t\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/CrawlerProgressPane.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StackLayout;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.ProgressBar;\n\npublic class CrawlerProgressPane extends Composite {\n\n\tprivate final StackLayout stack;\n\tprivate final Composite progressBarPage;\n\tprivate final Composite progressLabelPage;\n\tprivate final Label progressLabel;\n\tprivate final ProgressBar progressBar;\n\t\n\tpublic CrawlerProgressPane(Composite parent, Color background) {\n\t\tsuper(parent, SWT.NONE);\n\t\tstack = new StackLayout();\n\t\tsetLayout(stack);\n\t\tsetBackground(background);\n\t\tprogressBarPage = createPage(this, background);\n\t\tprogressLabelPage = createPage(this, background);\n\t\t\n\t\tprogressLabel = createProgressLabel(progressLabelPage);\n\t\tprogressLabel.setBackground(background);\n\t\tprogressBar = createProgressBar(progressBarPage);\n\t\tprogressBar.setBackground(background);\n\t\t\n\t\tsetLabelText(\"Scanner idle.\");\n\t}\n\t\n\tprivate Composite createPage(Composite parent, Color background) {\n\t\tComposite page = new Composite(parent, SWT.NONE);\n\t\tpage.setLayout(new GridLayout());\n\t\tpage.setBackground(background);\n\t\treturn page;\n\t}\n\t\n\tprivate Label createProgressLabel(Composite parent) {\n\t\tfinal Label label = new Label(parent, SWT.CENTER);\n\t\tlabel.setFont(JFaceResources.getBannerFont());\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\tgd.widthHint = 400;\n\t\tgd.verticalIndent = 20;\n\t\tlabel.setLayoutData(gd);\n\t\treturn label;\n\t}\n\t\n\tprivate ProgressBar createProgressBar(Composite parent) {\n\t\tfinal ProgressBar progress = new ProgressBar(parent, SWT.SMOOTH);\n\t\tprogress.setMinimum(0);\n\t\tprogress.setMaximum(100);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, true);\n\t\tgd.widthHint = 400;\n\t\tprogress.setLayoutData(gd);\n\t\treturn progress;\n\t}\n\n\tvoid setLabelText(String text) {\n\t\tif(progressLabel.isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\tprogressLabel.setText(text);\n\t\tif(stack.topControl != progressLabelPage) {\n\t\t\tstack.topControl = progressLabelPage;\n\t\t\tlayout();\n\t\t}\n\t}\n\t\n\tvoid setProgressBarValue(int value) {\n\t\tif(progressBar.isDisposed()) {\n\t\t\treturn;\n\t\t}\n\t\tprogressBar.setSelection(value);\n\t\tif(stack.topControl != progressBarPage) {\n\t\t\tstack.topControl = progressBarPage;\n\t\t\tlayout();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/DashboardPane.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport java.util.Timer;\nimport java.util.TimerTask;\n\nimport org.eclipse.jface.resource.JFaceResources;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.DisposeEvent;\nimport org.eclipse.swt.events.DisposeListener;\nimport org.eclipse.swt.graphics.RGB;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Display;\nimport org.eclipse.ui.forms.widgets.FormText;\nimport org.eclipse.ui.forms.widgets.FormToolkit;\nimport org.eclipse.ui.forms.widgets.ScrolledForm;\nimport org.eclipse.ui.forms.widgets.ScrolledFormText;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanAlertRepository;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.NewScanAlertEvent;\nimport com.subgraph.vega.api.model.alerts.ScanPauseStateChangedEvent;\nimport com.subgraph.vega.api.model.alerts.ScanStatusChangeEvent;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class DashboardPane extends Composite implements IEventHandler {\n\tprivate static final RGB GREY_TEXT_COLOR = new RGB(200, 200, 200);\n\tprivate final static String VEGA_LOGO = \"icons/vega_small.png\";\n\n\tprivate static final int UPDATE_INTERVAL = 100;\n\tprivate final Display display;\n\tprivate final Timer renderTimer = new Timer();\n\tprivate TimerTask renderTask;\n\tprivate CrawlerPane crawlerPane;\n\tprivate AlertPane alertPane;\n\tprivate IScanInstance scanInstance;\n\tprivate volatile boolean outputRenderNeeded;\n\tprivate volatile boolean crawlerRenderNeeded;\n\tprivate volatile boolean disableRenderTaskStart;\n\tprivate volatile boolean isProgressPaneVisible;\n\tprivate FormToolkit toolkit;\n\tprivate ScrolledForm scrolledForm;\n\tprivate ScrolledFormText scrolledFormText;\n\t\n\tprivate int lastStatus;\n\tprivate int lastCompletedCount;\n\tprivate int lastTotalCount;\n\tprivate String lastCurrentPath;\n\t\n\tprivate boolean isProxyInstance;\n\t\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\n\t\n\tpublic DashboardPane(Composite parent) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.display = parent.getDisplay();\n\t\tsetLayout(new FillLayout());\n\t\ttoolkit = new FormToolkit(display);\n\t\ttoolkit.getColors().createColor(\"grey\", GREY_TEXT_COLOR);\n\t\tcreateDashboardForm();\n\t\trenderOutput();\n\t\tcreateDisposeListener();\n\t}\n\n\tprivate void createDisposeListener() {\n\t\taddDisposeListener(new DisposeListener() {\n\t\t\t@Override\n\t\t\tpublic void widgetDisposed(DisposeEvent e) {\n\t\t\t\timageCache.dispose();\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic void displayScanInstance(IScanInstance scanInstance) {\n\t\tif(this.scanInstance == scanInstance) {\n\t\t\treturn;\n\t\t}\n\t\tcancelRenderTask();\n\t\tdisableRenderTaskStart = true;\n\t\t\n\t\tif(this.scanInstance != null) {\n\t\t\tthis.scanInstance.removeScanEventListener(this);\n\t\t}\n\t\t\n\t\tthis.scanInstance = scanInstance;\n\t\talertPane.reset();\n\t\tisProxyInstance = (scanInstance == null) ? (false) : (scanInstance.getScanId() == IScanAlertRepository.PROXY_ALERT_ORIGIN_SCAN_ID);\n\t\tif(scanInstance != null) {\n\t\t\tthis.scanInstance.addScanEventListenerAndPopulate(this);\n\t\t\tlastStatus = 0;\n\t\t\tlastCompletedCount = 0;\n\t\t\tlastTotalCount = 0;\n\t\t\tmaybeUpdateCrawler(scanInstance.getScanStatus(), scanInstance.getScanCurrentPath(), scanInstance.getScanCompletedCount(), scanInstance.getScanTotalCount());\n\t\t\tmaybeUpdateStatus(scanInstance.getScanStatus());\n\t\t}\n\t\tfinal boolean progressPaneVisible = (!isProxyInstance && (scanInstance != null && scanInstance.getScanStatus() == IScanInstance.SCAN_AUDITING));\n\t\tsetProgressPaneVisible(progressPaneVisible);\n\t\trenderOutput();\n\t\tdisableRenderTaskStart = false;\n\t}\n\t\n\tpublic IScanInstance getScanInstance() {\n\t\treturn scanInstance;\n\t}\n\n\tpublic void reset() {\n\t\talertPane.reset();\n\t\tif(scanInstance == null) {\n\t\t\treturn;\n\t\t}\n\t\tfor(IScanAlert alert: scanInstance.getAllAlerts()) {\n\t\t\talertPane.addAlert(alert);\n\t\t}\n\t}\n\n\tprivate void setProgressPaneVisible(final boolean flag) {\n\t\tif(isProgressPaneVisible == flag) {\n\t\t\treturn;\n\t\t}\n\t\tdisplay.asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tcrawlerPane.setVisible(flag);\n\t\t\t\tisProgressPaneVisible = flag;\n\t\t\t\tlayout();\n\t\t\t\tcrawlerPane.redraw();\n\t\t\t\t\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void createDashboardForm() {\n\t\tif(scrolledForm != null)\n\t\t\tscrolledForm.dispose();\n\t\t\n\t\tscrolledForm = createForm(this, toolkit);\n\t\tscrolledFormText = createFormText(scrolledForm.getBody(), toolkit);\n\t\tFormText formText = scrolledFormText.getFormText();\n\t\t\n\t\t\n\t\tformText.setColor(\"grey\", toolkit.getColors().getColor(\"grey\"));\n\t\tformText.setFont(\"big\", JFaceResources.getBannerFont());\n\t\tformText.setFont(\"header\", JFaceResources.getHeaderFont());\t\t\n\t\tformText.setImage(\"logo\", imageCache.get(VEGA_LOGO));\n\n\t\tcrawlerPane = new CrawlerPane(formText);\n\t\t\n\t\tcrawlerPane.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);\n\t\ttoolkit.adapt(crawlerPane);\n\t\tformText.setControl(\"crawler\", crawlerPane);\n\n\t\t\n\t\talertPane = new AlertPane(formText);\n\t\talertPane.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);\n\t\ttoolkit.adapt(alertPane);\n\t\tformText.setControl(\"alerts\", alertPane);\n\n\t\ttoolkit.paintBordersFor(formText);\n\t\ttoolkit.decorateFormHeading(scrolledForm.getForm());\n\t\tthis.layout();\n\t}\n\t\n\tprivate static ScrolledForm createForm(Composite parent, FormToolkit toolkit) {\n\t\tfinal ScrolledForm form = toolkit.createScrolledForm(parent);\n\t\tform.getBody().setLayout(new FillLayout());\n\t\treturn form;\n\t}\n\t\n\tprivate static ScrolledFormText createFormText(Composite parent, FormToolkit toolkit) {\n\t\tfinal ScrolledFormText sftext = new ScrolledFormText(parent, SWT.WRAP | SWT.NO_FOCUS | SWT.V_SCROLL, false);\n\t\tfinal FormText text = toolkit.createFormText(sftext, false);\n\t\tsftext.setFormText(text);\n\t\ttext.marginWidth = 1;\n\t\ttext.marginHeight = 0;\n\t\ttext.setHyperlinkSettings(toolkit.getHyperlinkGroup());\n\t\ttext.setMenu(parent.getMenu());\n\t\ttext.setWhitespaceNormalized(false);\n\t\ttoolkit.adapt(sftext);\n\t\treturn sftext;\n\t}\n\t\n\t\n\tprivate void renderOutput() {\n\t\tfinal StringBuilder buffer = new StringBuilder();\n\t\tbuffer.append(\"<form>\");\n\t\taddHeader(buffer);\n\t\trenderCrawlerSection(buffer);\n\t\trenderAlertSummary(buffer);\n\t\taddVSpaces(buffer, 2);\n\t\tbuffer.append(\"</form>\");\n\t\t\n\t\tif(!display.isDisposed()) {\n\t\t\tdisplay.asyncExec(new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tif(!scrolledFormText.isDisposed()) {\n\t\t\t\t\t\tscrolledFormText.setText(buffer.toString());\n\t\t\t\t\t}\n\t\t\t\t\toutputRenderNeeded = false;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\t\n\tprivate void renderCrawlerOutput() {\n\t\tif(!display.isDisposed()) {\n\t\t\tdisplay.asyncExec(new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tif(!crawlerPane.isDisposed()) {\n\t\t\t\t\t\tcrawlerPane.renderChanges();\n\t\t\t\t\t}\n\t\t\t\t\tcrawlerRenderNeeded = false;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate void renderCrawlerSection(StringBuilder sb) {\n\t\tif(isProxyInstance) {\n\t\t\treturn;\n\t\t}\n\t\tif(scanInstance == null || scanInstance.getScanStatus() != IScanInstance.SCAN_AUDITING) {\n\t\t\tif(isProgressPaneVisible) {\n\t\t\t\tsetProgressPaneVisible(false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif(!isProgressPaneVisible) {\n\t\t\tsetProgressPaneVisible(true);\n\t\t}\n\n\t\tif(scanInstance.isScanPaused()) {\n\t\t\tcrawlerPane.setScannerPaused(true);\n\t\t\taddIndented(sb, 10, \"<span font='header'>Scanner Progress (Scanner Paused)</span>\");\n\t\t} else {\n\t\t\tcrawlerPane.setScannerPaused(false);\n\t\t\taddIndented(sb, 10, \"<span font='header'>Scanner Progress</span>\");\n\t\t}\n\t\n\t\taddVSpaces(sb, 2);\n\t\tcrawlerPane.renderChanges();\n\t\taddIndented(sb, 20, \"<control width='500' height='100' href='crawler'/>\");\n\t}\n\t\n\tprivate void renderAlertSummary(StringBuilder sb) {\n\t\taddVSpaces(sb, 2);\n\t\tfinal String title = isProxyInstance ? \"Proxy Alert Summary\" : \"Scan Alert Summary\";\n\t\taddIndented(sb, 10, \"<span font='header'>\" + title +\"</span>\");\n\t\taddVSpaces(sb, 2);\n\t\taddIndented(sb, 20, \"<control width='500' href='alerts'/>\");\n\t\taddVSpaces(sb, 2);\n\t}\n\t\n\tprivate void addIndented(StringBuilder sb, int indent, String text) {\n\t\tsb.append(\"<p>\");\n\t\tfor(int i = 0; i < indent; i++)\n\t\t\tsb.append(\" \");\n\t\tsb.append(text);\n\t\tsb.append(\"</p>\");\n\t}\n\t\n\tprivate void addHeader(StringBuilder sb) {\n\t\taddVSpaces(sb, 2);\n\t\taddIndented(sb, 10, \"<img href='logo'/>\");\n\t\taddVSpaces(sb, 2);\n\t}\n\t\n\tprivate void addVSpaces(StringBuilder sb, int count) {\n\t\tsb.append(\"<p>\");\n\t\tfor(int i = 0; i < count; i++)\n\t\t\tsb.append(\"\\n\");\n\t\tsb.append(\"</p>\");\n\t}\n\t\n\tprivate void processAlert(IScanAlert alert) {\n\t\talertPane.addAlert(alert);\n\t\toutputRenderNeeded = true;\n\t}\n\t\n\tprivate void handleScannerStatusChanged(ScanStatusChangeEvent event) {\n\t\tmaybeUpdateCrawler(event.getStatus(), event.getCurrentPath(), event.getCompletedCount(), event.getTotalCount());\n\t\tmaybeUpdateStatus(event.getStatus());\n\t}\n\t\n\tprivate void maybeUpdateCrawler(int status, String currentPath, int completed, int total) {\n\t\tif(currentPath != lastCurrentPath || completed != lastCompletedCount || total != lastTotalCount || status != lastStatus) {\n\t\t\tlastCurrentPath = currentPath;\n\t\t\tlastCompletedCount = completed;\n\t\t\tlastTotalCount = total;\n\t\t\tcrawlerPane.updateCrawlerProgress(status, currentPath, total, completed);\n\t\t\tcrawlerRenderNeeded = true;\n\t\t}\n\t}\n\n\tprivate void maybeUpdateStatus(int status) {\n\t\tif(status == lastStatus) {\n\t\t\treturn;\n\t\t}\n\t\tlastStatus = status;\n\t\toutputRenderNeeded = true;\n\t}\n\t\t\n\tprivate TimerTask createTimerTask() {\n\t\treturn new TimerTask() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tif(outputRenderNeeded) {\n\t\t\t\t\trenderOutput();\n\t\t\t\t}\n\t\t\t\tif(crawlerRenderNeeded) {\n\t\t\t\t\trenderCrawlerOutput();\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t};\n\t}\n\n\tprivate void cancelRenderTask() {\n\t\tsynchronized(renderTimer) {\n\t\t\tif(renderTask != null) {\n\t\t\t\trenderTask.cancel();\n\t\t\t\trenderTask = null;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void startRenderTask() {\n\t\tsynchronized(renderTimer) {\n\t\t\tif(renderTask == null) {\n\t\t\t\trenderTask = createTimerTask();\n\t\t\t\trenderTimer.scheduleAtFixedRate(renderTask, 0, UPDATE_INTERVAL);\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tsynchronized(renderTimer) {\n\t\t\tif(!disableRenderTaskStart && renderTask == null) {\n\t\t\t\tstartRenderTask();\n\t\t\t}\n\t\t}\n\n\t\tif (event instanceof ScanStatusChangeEvent) {\n\t\t\thandleScannerStatusChanged((ScanStatusChangeEvent) event);\n\t\t} else if (event instanceof NewScanAlertEvent) {\n\t\t\tprocessAlert(((NewScanAlertEvent)event).getAlert());\n\t\t} if(event instanceof ScanPauseStateChangedEvent) {\n\t\t\toutputRenderNeeded = true;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dashboard/ShowDashboardHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dashboard;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.scanner.info.ScanInfoView;\n\npublic class ShowDashboardHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tIWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(activePart instanceof ScanInfoView) {\n\t\t\t((ScanInfoView) activePart).showDashboard();\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/dialogs/ScanConfigDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.dialogs;\n\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.viewers.CheckboxTreeViewer;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.TabFolder;\nimport org.eclipse.swt.widgets.TabItem;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableItem;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModuleRegistry;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryCheckStateProvider;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryContentProvider;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryLabelProvider;\n\npublic class ScanConfigDialog extends Dialog {\n\n\tprivate IScannerModuleRegistry registry;\n\tprivate CheckboxTreeViewer viewer;\n\tprivate Text cookieString;\n\tprivate Table exclusionsTable;\n\n\tpublic ScanConfigDialog(Shell parentShell) {\n\t\tsuper(parentShell);\n\t\tsetShellStyle(SWT.RESIZE);\n\t}\n\t\n\tprotected Control createDialogArea(Composite parent) {\n\t\tregistry = Activator.getDefault().getIScannerModuleRegistry();\n\n\t\tComposite area = (Composite) super.createDialogArea(parent);\n\t\tarea.setLayout(new FillLayout());\n\n\t\tTabFolder tabFolder = new TabFolder(area, SWT.BORDER);\n\t\tcreateTabItemModules(tabFolder);\n\t\tcreateTabItemAuthentication(tabFolder);\n\t\tcreateTabItemCookieString(tabFolder);\n\t\tcreateTabItemExclusions(tabFolder);\n\t\t\n\t\treturn area;\n\t}\n\t\n\tprivate void createTabItemModules(TabFolder tabFolder) {\n\t\tTabItem tabItem = new TabItem(tabFolder, SWT.NONE);\n\t\ttabItem.setText(\"Modules\");\n\t\t\n\t\tComposite tabItemArea = new Composite(tabFolder,SWT.NULL);\n\t\tGridLayout gridLayout = new GridLayout(1, false);\n\t\ttabItemArea.setLayout(gridLayout);\n\t\ttabItemArea.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\tLabel label = new Label(tabItemArea,SWT.NONE);\n\t\tlabel.setText(\"Select Modules\");\n\t\t\n\t\tviewer = new CheckboxTreeViewer(tabItemArea,SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\tfinal ModuleRegistryCheckStateProvider checkStateProvider = new ModuleRegistryCheckStateProvider(viewer);\n\t\tviewer.setContentProvider(new ModuleRegistryContentProvider(checkStateProvider));\n\t\tviewer.setLabelProvider(new ModuleRegistryLabelProvider());\n\t\tviewer.setCheckStateProvider(checkStateProvider);\n\t\t\n\t\tviewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); \n\n\t    viewer.setInput(registry);\n        viewer.addCheckStateListener(checkStateProvider);\n\t\t\n\t\ttabItem.setControl(tabItemArea);\n\t}\n\n\tprivate void createTabItemAuthentication(TabFolder tabFolder) {\n\t\tTabItem tabItem = new TabItem(tabFolder, SWT.NONE);\n\t\ttabItem.setText(\"Authentication\");\n\n\t\tGridLayout innerLayout = new GridLayout();\n\t\tLabel basicLabel;\n\t\tLabel basicUsernameLabel;\n\t\tLabel basicPasswordLabel;\n\t\tLabel basicRealmLabel;\n\t\tLabel basicDomainLabel;\n\t\tLabel ntlmLabel;\n\t\tLabel ntlmUsernameLabel;\n\t\tLabel ntlmPasswordLabel;\n\t\t\n\t\tComposite tabItemArea = new Composite(tabFolder, SWT.NULL);\n\t\tGridData gd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tGridData gd2 = new GridData();\n\t\tgd2.horizontalSpan = 2;\n\t\t\n\t\tinnerLayout.numColumns = 2;\n\t\ttabItemArea.setLayout(innerLayout);\n\t\t\n\t\tbasicLabel = new Label(tabItemArea, SWT.NONE);\n\t\tbasicLabel.setText(\"Basic Authentication\");\n\t\tbasicLabel.setLayoutData(gd2);\n\t\n\t\tbasicUsernameLabel = new Label(tabItemArea, SWT.NONE);\n\t\tbasicUsernameLabel.setText(\"Username:\");\n\t\tText basicUsername = new Text(tabItemArea, SWT.SINGLE | SWT.BORDER);\n\t\tbasicUsername.setLayoutData(gd);\n\t\t\t\t\n\t\tbasicPasswordLabel = new Label(tabItemArea, SWT.NONE);\n\t\tbasicPasswordLabel.setText(\"Password:\");\n\t\tText basicPassword = new Text(tabItemArea, SWT.BORDER);\n\t\tbasicPassword.setLayoutData(gd);\n\t\t\n\t\tbasicRealmLabel = new Label(tabItemArea, SWT.NONE);\n\t\tbasicRealmLabel.setText(\"Realm:\");\n\t\tText basicRealm = new Text(tabItemArea, SWT.BORDER);\n\t\tbasicRealm.setLayoutData(gd);\n\t\t\n\t\tbasicDomainLabel = new Label(tabItemArea, SWT.NONE);\n\t\tbasicDomainLabel.setText(\"Domain\");\n\t\tText basicDomain = new Text(tabItemArea, SWT.BORDER);\n\t\tbasicDomain.setLayoutData(gd);\n\t\t\n\t\tntlmLabel = new Label(tabItemArea, SWT.NONE);\n\t\tntlmLabel.setText(\"NTLM Authentication\");\n\t\tntlmLabel.setLayoutData(gd2);\n\t\t\n\t\tntlmUsernameLabel = new Label(tabItemArea, SWT.NONE);\n\t\tntlmUsernameLabel.setText(\"Username:\");\n\t\tText ntlmUsername = new Text(tabItemArea, SWT.BORDER);\n\t\tntlmUsername.setLayoutData(gd);\n\t\t\n\t\tntlmPasswordLabel = new Label(tabItemArea, SWT.NONE);\n\t\tntlmPasswordLabel.setText(\"Password:\");\n\t\tText ntlmPassword = new Text(tabItemArea, SWT.BORDER);\n\t\tntlmPassword.setLayoutData(gd);\n\t\t\n\t\ttabItem.setControl(tabItemArea);\n\t}\n\n\tprivate void createTabItemCookieString(TabFolder tabFolder) {\t\t\n\t\tTabItem tabItem = new TabItem(tabFolder, SWT.NONE);\n\t\ttabItem.setText(\"Cookie String\");\n\n\t\tComposite tabItemArea = new Composite(tabFolder,SWT.NULL);\n\t\tGridLayout gridLayout = new GridLayout();\n\t\t\n\t\tGridData gridData = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgridData.widthHint = 140;\n\t\tgridData.heightHint = 60;\n\t\n\t\ttabItemArea.setLayout(gridLayout);\n\t\t\n\t\tLabel cookieLabel = new Label(tabItemArea, SWT.BORDER);\n\t\tcookieLabel.setText(\"Cookie string:\");\n\t\tcookieString = new Text(tabItemArea, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);\n\t\tcookieString.setLayoutData(gridData);\n\t\t\n\t\ttabItem.setControl(tabItemArea);\t\t\t\n\t}\n\t\n\tprivate void createTabItemExclusions(TabFolder tabFolder) {\n\t\tTabItem tabItem = new TabItem(tabFolder, SWT.NONE);\n\t\ttabItem.setText(\"Exclusions\");\n\t\t\n\t\tComposite tabItemArea = new Composite(tabFolder, SWT.NONE);\n\t\tGridLayout gridLayout = new GridLayout();\n\t\ttabItemArea.setLayout(gridLayout);\n\t\n\t\tLabel exclusionLabel = new Label(tabItemArea, SWT.NULL);\n\t\texclusionLabel.setText(\"Set scan exclusion patterns:\");\n\t\tfinal Text exclusionText = new Text(tabItemArea, SWT.BORDER | SWT.SINGLE);\n\t\texclusionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\texclusionText.setMessage(\"regular expression\");\n\t\tfinal Button addButton = new Button(tabItemArea, SWT.PUSH);\n\t\taddButton.setText(\"Add exclusion\");\n\t\t\n\t\texclusionsTable = new Table(tabItemArea, SWT.BORDER | SWT.MULTI);\n\t\texclusionsTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\t\t\n\t\n\t\tButton removeButton = new Button(tabItemArea, SWT.PUSH);\n\t\tremoveButton.setText(\"Remove selected exclusion(s)\");\n\t\t\n\t\tremoveButton.addListener(SWT.Selection, new Listener() {\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\texclusionsTable.remove(exclusionsTable.getSelectionIndices());\n\t\t\t}\n\t\t});\n\t\t\n\t\taddButton.addListener(SWT.Selection, new Listener() {\n\t        public void handleEvent(Event event) {\n\t\t          if (event.widget == addButton) {\n\t\t        \t  if (exclusionText.getText() != null) {\n\t\t        \t\t  TableItem items[] = exclusionsTable.getItems();\n\t\t        \t\t  for (TableItem t: items) { \n\t\t        \t\t\t  if (exclusionText.getText().equals(t.getText())) {\n\t\t        \t\t\t\t  return;\n\t\t        \t\t\t  }\n\t\t        \t\t  }\n\t\t        \t\t  TableItem newExclusion = new TableItem(exclusionsTable,SWT.NONE);\n\t\t        \t\t  newExclusion.setText(exclusionText.getText());\n\t\t        \t  }\n\t\t          }\n\t        }\n\t\t});\n\t\ttabItem.setControl(tabItemArea);\n\t}\n\n\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\tcreateSaveButton(parent, true);\n\t\t//createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);\n\t\tcreateButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);\n\t}\n\t\n\tprotected Button createSaveButton(Composite parent,  boolean defaultButton) {\n\t\t((GridLayout) parent.getLayout()).numColumns++;\n\t\tButton button = new Button(parent, SWT.PUSH);\n\t\tbutton.setText(\"Save\");\n\t\tbutton.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tokPressed();\n\n\t\t\t}\n\t\t});\n\t\tif (defaultButton) {\n\t\t\tShell shell = parent.getShell();\n\t\t\tif (shell != null) {\n\t\t\t\tshell.setDefaultButton(button);\n\t\t\t}\n\t\t}\n\t\tsetButtonLayoutData(button);\n\t\treturn button;\n\t}\n\n\tprotected void configureShell(Shell newShell) {\n\t\tsuper.configureShell(newShell);\n\t\tnewShell.setText(\"Scan Configuration\");\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/info/AlertRenderer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.info;\n\nimport java.io.IOException;\nimport java.io.StringWriter;\nimport java.net.URL;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.NameValuePair;\nimport org.apache.http.RequestLine;\nimport org.apache.http.client.utils.URLEncodedUtils;\nimport org.eclipse.core.runtime.FileLocator;\nimport org.eclipse.core.runtime.IPath;\nimport org.eclipse.core.runtime.Path;\nimport org.osgi.framework.Bundle;\nimport org.w3c.dom.Document;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.requests.IRequestLog;\nimport com.subgraph.vega.api.model.requests.IRequestLogRecord;\nimport com.subgraph.vega.api.xml.IXmlRepository;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.scanner.preferences.IPreferenceConstants;\n\nimport freemarker.cache.TemplateLoader;\nimport freemarker.ext.dom.NodeModel;\nimport freemarker.log.Logger;\nimport freemarker.template.Configuration;\nimport freemarker.template.DefaultObjectWrapper;\nimport freemarker.template.Template;\nimport freemarker.template.TemplateException;\n\npublic class AlertRenderer {\n\tprivate final Logger logger = Logger.getLogger(\"alert-render\");\n\tprivate Configuration configuration;\n\tprivate final String imageURL;\n\tprivate final String bulletPointURL;\n\tprivate final String bannerPatternURL;\n\tprivate final String bannerLogoURL;\n\tprivate final String titlePatternURL;\n\tprivate final String redArrowURL;\n\tprivate final String sectionGradientURL;\n\tprivate final String linkArrowURL;\n\tprivate final Map<String, Document> alertDocumentCache = new HashMap<String, Document>();\n\tprivate IRequestLog requestLog;\n\t\n\tpublic AlertRenderer(TemplateLoader templateLoader) {\n\t\timageURL = findImage(\"icons/vega_logo.png\");\n\t\tbulletPointURL = findImage(\"icons/doubleArrow.png\");\n\t\tbannerPatternURL = findImage(\"icons/bannerPattern.png\");\n\t\tbannerLogoURL = findImage(\"icons/bannerLogo.png\");\n\t\ttitlePatternURL = findImage(\"icons/titlePattern.png\");\n\t\tredArrowURL = findImage(\"icons/redArrow.png\");\n\t\tsectionGradientURL = findImage(\"icons/sectionGradient.png\");\n\t\tlinkArrowURL = findImage(\"icons/linkArrow.png\");\n\t\t\n\t\tconfiguration = new Configuration();\n\t\tconfiguration.setTemplateLoader(templateLoader);\n\t\tconfiguration.setObjectWrapper(new DefaultObjectWrapper());\n\t\tfinal IWorkspace currentWorkspace = Activator.getDefault().getModel().addWorkspaceListener(new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof WorkspaceOpenEvent)\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceCloseEvent)\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\telse if(event instanceof WorkspaceResetEvent)\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tif(currentWorkspace != null)\n\t\t\trequestLog = currentWorkspace.getRequestLog();\n\t}\n\t\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\trequestLog = event.getWorkspace().getRequestLog();\n\t}\n\t\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\trequestLog = null;\n\t}\n\t\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\trequestLog = event.getWorkspace().getRequestLog();\n\t}\n\t\n\tpublic String render(IScanAlert alert) {\n\t\tfinal int maxAlertString = Activator.getDefault().getPreferenceStore().getInt(IPreferenceConstants.P_MAX_ALERT_STRING);\n\t\tMap<String, Object> root = new HashMap<String, Object>();\n\t\ttry {\n\t\t\tTemplate t = configuration.getTemplate(\"main.ftl\");\n\t\t\tDocument xmlRoot = getAlertDocument(alert.getName());\n\t\t\tif(xmlRoot == null)\n\t\t\t\treturn \"\";\n\t\t\tNodeModel nodeModel = NodeModel.wrap(xmlRoot);\n\t\t\troot.put(\"doc\", nodeModel);\n\t\t\tMap<String,Object> vars = new HashMap<String,Object>();\n\t\t\tfor(String k: alert.propertyKeys()) {\n\t\t\t\tObject value = alert.getProperty(k);\n\t\t\t\tif(value instanceof String) {\n\t\t\t\t\tString s = (String) value;\n\t\t\t\t\tif(s.length() > maxAlertString) {\n\t\t\t\t\t\ts = s.substring(0, maxAlertString) + \"...\";\n\t\t\t\t\t} \n\t\t\t\t\tvars.put(k, s);\n\t\t\t\t} else {\n\t\t\t\t\tvars.put(k, alert.getProperty(k));\n\t\t\t\t}\n\t\t\t}\n\t\t\tString severityVar = severityToString(alert.getSeverity());\n\t\t\tif(severityVar != null) {\n\t\t\t\tvars.put(\"severity\", severityVar);\n\t\t\t}\n\t\t\tString severityCSSVar = severityToSeverityCSSClass(alert.getSeverity());\n\t\t\tif(severityCSSVar != null) {\n\t\t\t\tvars.put(\"severityCSS\", severityCSSVar);\n\t\t\t}\n\t\t\tif(imageURL != null)\n\t\t\t\tvars.put(\"imageURL\", imageURL);\n\t\t\tif(bulletPointURL != null)\n\t\t\t\tvars.put(\"bulletPointURL\", bulletPointURL);\n\t\t\tif(bannerPatternURL != null)\n\t\t\t\tvars.put(\"bannerPatternURL\", bannerPatternURL);\n\t\t\tif(bannerLogoURL != null)\n\t\t\t\tvars.put(\"bannerLogoURL\", bannerLogoURL);\n\t\t\tif(titlePatternURL != null)\n\t\t\t\tvars.put(\"titlePatternURL\", titlePatternURL);\n\t\t\tif(redArrowURL != null)\n\t\t\t\tvars.put(\"redArrowURL\", redArrowURL);\n\t\t\tif(redArrowURL != null)\n\t\t\t\tvars.put(\"sectionGradientURL\", sectionGradientURL);\n\t\t\tif(linkArrowURL != null)\n\t\t\t\tvars.put(\"linkArrowURL\", linkArrowURL);\n\t\t\t\n\t\t\tif(alert.getRequestId() >= 0 && requestLog != null) {\n\t\t\t\tfinal IRequestLogRecord record = requestLog.lookupRecord(alert.getRequestId());\n\t\t\t\tif(record != null) {\n\t\t\t\t\tif(record.getRequest() instanceof HttpEntityEnclosingRequest) {\n\t\t\t\t\t\tvars.put(\"requestText\", renderEntityEnclosingRequest((HttpEntityEnclosingRequest) record.getRequest()));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvars.put(\"requestText\", renderBasicRequest(record.getRequest()));\n\t\t\t\t\t}\n\t\t\t\t\tvars.put(\"requestId\", Long.toString(alert.getRequestId()));\n\t\t\t\t}\n\t\t\t}\n\t\t\troot.put(\"vars\", vars);\n\t\t\t\n\t\t\tStringWriter out = new StringWriter();\n\t\t\tt.process(root, out);\n\t\t\tout.flush();\n\t\t\treturn out.toString();\n\t\t} catch (IOException e) {\n\t\t\treturn \"I/O error reading alert template file alerts/\"+ alert.getName() + \".xml :<br><br>\"+ e.getMessage();\n\t\t} catch (TemplateException e) {\n\t\t\treturn \"Error processing alert template file alerts/\"+ alert.getName() +\".xml :<br><br>\"+ e.getMessage();\n\t\t}\n\t}\n\t\n\tpublic String renderList(List<IScanAlert> alerts) {\n\t\tfinal int maxAlertString = Activator.getDefault().getPreferenceStore().getInt(IPreferenceConstants.P_MAX_ALERT_STRING);\n\n\t\tMap<String, Object> root = new HashMap<String, Object>();\n\t\tString output = \"<html><head><title>Report</title></head><body>\";\n\n\t\tfor (IScanAlert alert : alerts) {\n\t\t\ttry {\n\t\t\t\tTemplate t = configuration.getTemplate(\"report-alert.ftl\");\n\t\t\t\tDocument xmlRoot = getAlertDocument(alert.getName());\n\t\t\t\tif(xmlRoot == null)\n\t\t\t\t\treturn \"\";\n\t\t\t\tNodeModel nodeModel = NodeModel.wrap(xmlRoot);\n\t\t\t\troot.put(\"doc\", nodeModel);\n\t\t\t\tMap<String,Object> vars = new HashMap<String,Object>();\n\t\t\t\tfor(String k: alert.propertyKeys()) {\n\t\t\t\t\tObject value = alert.getProperty(k);\n\t\t\t\t\tif(value instanceof String) {\n\t\t\t\t\t\tString s = (String) value;\n\t\t\t\t\t\tif(s.length() > maxAlertString) {\n\t\t\t\t\t\t\ts = s.substring(0, maxAlertString) + \"...\";\n\t\t\t\t\t\t} \n\t\t\t\t\t\tvars.put(k, s);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvars.put(k, alert.getProperty(k));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tString severityVar = severityToString(alert.getSeverity());\n\t\t\t\tif(severityVar != null) {\n\t\t\t\t\tvars.put(\"severity\", severityVar);\n\t\t\t\t}\n\t\t\t\tString severityCSSVar = severityToSeverityCSSClass(alert.getSeverity());\n\t\t\t\tif(severityCSSVar != null) {\n\t\t\t\t\tvars.put(\"severityCSS\", severityCSSVar);\n\t\t\t\t}\n\t\t\t\tif(imageURL != null)\n\t\t\t\t\tvars.put(\"imageURL\", imageURL);\n\t\t\t\tif(bulletPointURL != null)\n\t\t\t\t\tvars.put(\"bulletPointURL\", bulletPointURL);\n\t\t\t\tif(bannerPatternURL != null)\n\t\t\t\t\tvars.put(\"bannerPatternURL\", bannerPatternURL);\n\t\t\t\tif(bannerLogoURL != null)\n\t\t\t\t\tvars.put(\"bannerLogoURL\", bannerLogoURL);\n\t\t\t\tif(titlePatternURL != null)\n\t\t\t\t\tvars.put(\"titlePatternURL\", titlePatternURL);\n\t\t\t\tif(redArrowURL != null)\n\t\t\t\t\tvars.put(\"redArrowURL\", redArrowURL);\n\t\t\t\tif(redArrowURL != null)\n\t\t\t\t\tvars.put(\"sectionGradientURL\", sectionGradientURL);\n\t\t\t\tif(linkArrowURL != null)\n\t\t\t\t\tvars.put(\"linkArrowURL\", linkArrowURL);\n\t\t\t\t\n\t\t\t\tif(alert.getRequestId() >= 0 && requestLog != null) {\n\t\t\t\t\tfinal IRequestLogRecord record = requestLog.lookupRecord(alert.getRequestId());\n\t\t\t\t\tif(record != null) {\n\t\t\t\t\t\tif(record.getRequest() instanceof HttpEntityEnclosingRequest) {\n\t\t\t\t\t\t\tvars.put(\"requestText\", renderEntityEnclosingRequest((HttpEntityEnclosingRequest) record.getRequest()));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvars.put(\"requestText\", renderBasicRequest(record.getRequest()));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvars.put(\"requestId\", Long.toString(alert.getRequestId()));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\troot.put(\"vars\", vars);\n\t\t\t\t\n\t\t\t\tStringWriter out = new StringWriter();\n\t\t\t\tt.process(root, out);\n\t\t\t\tout.flush();\n\t\t\t\toutput += out.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\treturn \"I/O error reading alert template file alerts/\"+ alert.getName() + \".xml :<br><br>\"+ e.getMessage();\n\t\t\t} catch (TemplateException e) {\n\t\t\t\treturn \"Error processing alert template file alerts/\"+ alert.getName() +\".xml :<br><br>\"+ e.getMessage();\n\t\t\t}\n\t\t}\n\t\toutput += \"</body></html>\";\n\t\treturn output;\n\t}\n\t\n\tprivate String renderEntityEnclosingRequest(HttpEntityEnclosingRequest request) {\n\t\tfinal HttpEntity entity = request.getEntity();\n\t\tif(entity == null || !URLEncodedUtils.isEncoded(entity)) {\n\t\t\treturn renderBasicRequest(request);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\tList<NameValuePair> args = URLEncodedUtils.parse(entity);\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(renderBasicRequest(request));\n\t\t\tsb.append(\"\\n[\");\n\t\t\tfor(NameValuePair nvp: args) {\n\t\t\t\tsb.append(nvp.getName());\n\t\t\t\tif(nvp.getValue() != null) {\n\t\t\t\t\tsb.append(\"=\");\n\t\t\t\t\tsb.append(nvp.getValue());\n\t\t\t\t}\n\t\t\t\tsb.append(\"\\n\");\n\t\t\t}\n\t\t\tsb.append(\"]\");\n\t\t\treturn sb.toString();\n\t\t} catch (IOException e) {\n\t\t\treturn renderBasicRequest(request);\n\t\t}\n\t}\n\t\n\tprivate String renderBasicRequest(HttpRequest request) {\n\t\tfinal RequestLine line = request.getRequestLine();\n\t\treturn line.getMethod() +\" \"+ line.getUri();\n\t}\n\tprivate Document getAlertDocument(String name) {\n\t\tif(alertDocumentCache.containsKey(name))\n\t\t\treturn alertDocumentCache.get(name);\n\t\tfinal IXmlRepository xmlRepository = Activator.getDefault().getXmlRepository();\n\t\tif(xmlRepository == null) {\n\t\t\tlogger.warn(\"Could not render alert because xml repository service is not available\");\n\t\t\treturn null;\n\t\t}\n\t\t\n\t\tDocument alertDocument = xmlRepository.getDocument(\"alerts/\"+ name + \".xml\");\n\t\tif(alertDocument == null)\n\t\t\talertDocument = xmlRepository.getDocument(\"alerts/default.xml\");\n\t\tif(alertDocument == null) {\n\t\t\tlogger.warn(\"Could not load XML data for alert named '\"+ name + \"'\");\n\t\t\treturn null;\n\t\t}\n\t\talertDocumentCache.put(name, alertDocument);\n\t\treturn alertDocument;\n\t}\n\tprivate String findImage(String imagePath) {\n\t\tBundle b = Activator.getDefault().getBundle();\n\t\tIPath relativePagePath = new Path(imagePath);\n\t\tURL fileInPlugin = FileLocator.find(b, relativePagePath, null);\n\t\ttry {\n\t\t\tURL pageUrl = FileLocator.toFileURL(fileInPlugin);\n\t\t\treturn pageUrl.toString();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\tprivate String severityToString(IScanAlert.Severity s) {\n\t\tswitch(s) {\n\t\tcase HIGH:\n\t\t\treturn \"High\";\n\t\tcase MEDIUM:\n\t\t\treturn \"Medium\";\n\t\tcase LOW:\n\t\t\treturn \"Low\";\n\t\tcase INFO:\n\t\t\treturn \"Info\";\n\t\tcase UNKNOWN:\n\t\t\treturn \"Unknown\";\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate String severityToSeverityCSSClass(IScanAlert.Severity s) {\n\t\tswitch(s) {\n\t\tcase HIGH:\n\t\t\treturn \"highrisk\";\n\t\tcase MEDIUM:\n\t\t\treturn \"medrisk\";\n\t\tcase LOW:\n\t\t\treturn \"lowrisk\";\n\t\tcase INFO:\n\t\t\treturn \"inforisk\";\n\t\tcase UNKNOWN:\n\t\t\treturn \"unknownrisk\";\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/info/LinkHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.info;\n\nimport java.util.logging.Logger;\n\nimport org.eclipse.core.commands.Command;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.core.commands.IParameter;\nimport org.eclipse.core.commands.NotEnabledException;\nimport org.eclipse.core.commands.NotHandledException;\nimport org.eclipse.core.commands.Parameterization;\nimport org.eclipse.core.commands.ParameterizedCommand;\nimport org.eclipse.core.commands.common.NotDefinedException;\nimport org.eclipse.swt.browser.Browser;\nimport org.eclipse.swt.browser.BrowserFunction;\nimport org.eclipse.ui.IViewPart;\nimport org.eclipse.ui.IWorkbenchCommandConstants;\nimport org.eclipse.ui.IWorkbenchPage;\nimport org.eclipse.ui.PartInitException;\nimport org.eclipse.ui.PlatformUI;\nimport org.eclipse.ui.commands.ICommandService;\nimport org.eclipse.ui.handlers.IHandlerService;\nimport org.eclipse.ui.services.IServiceLocator;\n\nimport com.subgraph.vega.ui.http.request.view.HttpRequestView;\nimport com.subgraph.vega.ui.scanner.ScannerPerspectiveFactory;\n\npublic class LinkHandler extends BrowserFunction {\n\tfinal private static Logger logger = Logger.getLogger(\"alertView\");\n\t\n\tprivate final IServiceLocator serviceLocator;\n\t\n\tpublic LinkHandler(Browser browser, IServiceLocator serviceLocator) {\n\t\tsuper(browser, \"linkClick\");\n\t\tthis.serviceLocator = serviceLocator;\n\t}\n\t\n\t@Override\n\tpublic Object function (Object[] arguments) {\n\t\ttry {\n\t\t\tIHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);\n\t\t\tICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);\n\t\t\tCommand showView = commandService.getCommand(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW);\n\t\t\tIParameter parm1 = showView.getParameter(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW_PARM_ID);\n\t\t\tParameterization parmId1 = new Parameterization(parm1, HttpRequestView.ID);\n\t\t\tIParameter parm2 = showView.getParameter(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW_SECONDARY_ID);\n\t\t\tParameterization parmId2 = new Parameterization(parm2, ScannerPerspectiveFactory.HTTP_VIEW_SECONDARY_ID);\n\t\t\tParameterizedCommand parmCommand = new ParameterizedCommand(showView, new Parameterization[] { parmId1, parmId2 });\n\t\t\thandlerService.executeCommand(parmCommand, null);\n\n\t\t\tIViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(HttpRequestView.ID, ScannerPerspectiveFactory.HTTP_VIEW_SECONDARY_ID, IWorkbenchPage.VIEW_VISIBLE);\n\t\t\tif(view instanceof HttpRequestView && arguments[0] instanceof String) {\n\t\t\t\tfinal HttpRequestView requestView = (HttpRequestView) view;\n\t\t\t\ttry {\n\t\t\t\t\tlong id = Long.parseLong((String) arguments[0]);\n\t\t\t\t\trequestView.focusOnRecord(id);\n\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (PartInitException e) {\n\t\t\tlogger.warning(\"Failed to open HTTP request viewer\");\n\t\t} catch (NotDefinedException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (ExecutionException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (NotEnabledException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (NotHandledException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/info/ScanInfoView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.info;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.List;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.browser.Browser;\nimport org.eclipse.swt.browser.BrowserFunction;\nimport org.eclipse.swt.custom.StackLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.ISelectionListener;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.alerts.ActiveScanInstanceEvent;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.RemoveScanAlertsEvent;\nimport com.subgraph.vega.api.model.alerts.RemoveScanInstanceEvent;\nimport com.subgraph.vega.api.paths.IPathFinder;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.scanner.alerts.ScanAlertView;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertScanNode;\nimport com.subgraph.vega.ui.scanner.alerts.tree.AlertTitleNode;\nimport com.subgraph.vega.ui.scanner.dashboard.DashboardPane;\n\nimport freemarker.cache.FileTemplateLoader;\nimport freemarker.cache.TemplateLoader;\n\npublic class ScanInfoView extends ViewPart implements IEventHandler {\n\tprivate final Logger logger = Logger.getLogger(\"info-view\");\n\n\tpublic static String ID = \"com.subgraph.vega.views.scaninfo\";\n\t\n\tprivate Browser browser;\n\tprivate IScanAlert currentBrowserAlert;\n\tprivate DashboardPane dashboard;\n\tprivate Composite contentPanel;\n\tprivate final AlertRenderer renderer;\n\tprivate StackLayout stackLayout = new StackLayout();\n\tprivate BrowserFunction linkClick;\n\tprivate IWorkspace currentWorkspace;\n\t\n\tpublic ScanInfoView() {\n\t\tfinal TemplateLoader loader = createTemplateLoader();\n\t\tif(loader == null)\n\t\t\trenderer = null;\n\t\telse\n\t\t\trenderer = new AlertRenderer(loader);\n\t}\n\t\n\tprivate TemplateLoader createTemplateLoader() {\n\t\tfinal IPathFinder pathFinder = Activator.getDefault().getPathFinder();\n\t\tif(pathFinder == null)\n\t\t\tthrow new IllegalStateException(\"Cannot find templates to render because path finder service is not available\");\n\t\tfinal File templateDirectory = new File(pathFinder.getDataDirectory(), \"templates\");\n\t\ttry {\n\t\t\treturn new FileTemplateLoader(templateDirectory);\n\t\t} catch (IOException e) {\n\t\t\tlogger.log(Level.WARNING, \"Failed to open template directory: \"+ e.getMessage());\n\t\t\treturn null;\n\t\t}\n\t\t\n\t}\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tcontentPanel = new Composite(parent, SWT.NONE);\n\t\tcontentPanel.setLayout(stackLayout);\n\t\tdashboard = new DashboardPane(contentPanel);\n\t\tbrowser = new Browser(contentPanel, SWT.NONE);\n\t\t// Some day I will regret this, but it's currently the only way to have clickable links in the alert viewer\n\t\tbrowser.setJavascriptEnabled(true);\n\t\tlinkClick = new LinkHandler(browser, getSite());\n\t\t\n\t\tgetSite().getPage().addSelectionListener(new ISelectionListener() {\n\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(IWorkbenchPart part, ISelection selection) {\n\t\t\t\tif(!(selection instanceof IStructuredSelection))\n\t\t\t\t\treturn;\n\t\t\t\tObject o = ((IStructuredSelection)selection).getFirstElement();\n\t\t\t\tif(o instanceof IScanAlert) {\t\t\n\t\t\t\t\tIScanAlert alert = (IScanAlert) o;\n\t\t\t\t\tdisplayAlert(alert);\n\t\t\t\t} else if (o instanceof AlertScanNode) {\n\t\t\t\t\tfinal AlertScanNode node = (AlertScanNode) o;\n\t\t\t\t\tdisplayScanSummary(node.getScanInstance());\n\t\t\t\t} else if (o instanceof AlertTitleNode) {\n\t\t\t\t\tfinal AlertTitleNode node = (AlertTitleNode) o;\n\t\t\t\t\tif(node.getAlertCount() == 1) {\n\t\t\t\t\t\tdisplayAlert(node.getFirstAlert());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\tstackLayout.topControl = dashboard;\n\t\tcontentPanel.layout();\n\t\t\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tif(model != null) {\n\t\t\tsetCurrentWorkspace(model.addWorkspaceListener(this));\n\t\t}\n\t\tIStructuredSelection selection = (IStructuredSelection) getSite().getPage().getSelection(ScanAlertView.ID);\n\t\tif(selection != null && selection.getFirstElement() instanceof AlertScanNode) {\n\t\t\tAlertScanNode node = (AlertScanNode) selection.getFirstElement();\n\t\t\tdisplayScanSummary(node.getScanInstance());\n\t\t}\n\t}\n\t\n\tprivate void resetState() {\n\t\tbrowser.setText(\"\");\n\t\tdashboard.displayScanInstance(null);\n\t\tshowDashboard();\n\t}\n\n\tprivate void displayAlert(IScanAlert alert) {\n\t\tString html = renderer.render(alert);\n\t\tif(html != null && !browser.isDisposed()) {\n\t\t\tbrowser.setText(html, true);\n\t\t\tcurrentBrowserAlert = alert;\n\t\t}\n\t\tstackLayout.topControl = browser;\n\t\tcontentPanel.layout();\n\t}\n\t\n\tprivate void displayScanSummary(final IScanInstance scan) {\n\t\tif(scan == null) {\n\t\t\treturn;\n\t\t}\n\t\tif(!dashboard.getDisplay().isDisposed()) {\n\t\t\tdashboard.getDisplay().asyncExec(new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tdashboard.displayScanInstance(scan);\n\t\t\t\t\tshowDashboard();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t}\n\t}\n\tpublic void showDashboard() {\n\t\tcurrentBrowserAlert = null;\n\t\tstackLayout.topControl = dashboard;\n\t\tif(!contentPanel.isDisposed()) {\n\t\t\tcontentPanel.layout();\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void setFocus() {\n\t\tbrowser.setFocus();\n\t}\n\t\n\tpublic void dispose() {\n\t\tif(linkClick != null)\n\t\t\tlinkClick.dispose();\n\t\tsuper.dispose();\n\t}\n\n\t@Override\n\tpublic void handleEvent(IEvent event) {\n\t\tif(event instanceof WorkspaceOpenEvent) {\n\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t} else if(event instanceof WorkspaceCloseEvent) {\n\t\t\thandleWorkspaceCloseEvent((WorkspaceCloseEvent) event);\n\t\t} else if(event instanceof WorkspaceResetEvent) {\n\t\t\thandleWorkspaceResetEvent((WorkspaceResetEvent) event);\n\t\t} else if(event instanceof ActiveScanInstanceEvent) {\n\t\t\thandleActiveScanInstance((ActiveScanInstanceEvent) event);\n\t\t} else if(event instanceof RemoveScanAlertsEvent) {\n\t\t\thandleRemoveScanAlertsEvent((RemoveScanAlertsEvent) event);\n\t\t} else if(event instanceof RemoveScanInstanceEvent) {\n\t\t\thandleRemoveScanInstanceEvent((RemoveScanInstanceEvent) event);\n\t\t\t\n\t\t}\n\t}\n\t\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tsetCurrentWorkspace(event.getWorkspace());\n\t}\n\t\n\tprivate void handleWorkspaceCloseEvent(WorkspaceCloseEvent event) {\n\t\tsetCurrentWorkspace(null);\n\t\tresetState();\n\t}\n\t\n\tprivate void handleWorkspaceResetEvent(WorkspaceResetEvent event) {\n\t\tsetCurrentWorkspace(event.getWorkspace());\n\t\tresetState();\n\t}\n\t\n\tprivate void handleActiveScanInstance(ActiveScanInstanceEvent event) {\n\t\tsetActiveScanInstance(event.getScanInstance());\n\t}\n\t\n\tprivate void handleRemoveScanAlertsEvent(RemoveScanAlertsEvent event) {\n\t\tif(currentBrowserAlert != null) {\n\t\t\tfor(IScanAlert alert: event.getRemovedEvents()) {\n\t\t\t\tif(alert == currentBrowserAlert) {\n\t\t\t\t\tresetState();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdashboard.reset();\n\t}\n\t\n\tprivate void handleRemoveScanInstanceEvent(RemoveScanInstanceEvent event) {\n\t\tif(currentBrowserAlert != null && currentBrowserAlert.getScanId() == event.getScanInstance().getScanId()) {\n\t\t\tresetState();\n\t\t}\n\t\tif(stackLayout.topControl == dashboard && dashboard.getScanInstance() == event.getScanInstance()) {\n\t\t\tresetState();\n\t\t}\n\t}\n\n\tprivate void setCurrentWorkspace(IWorkspace workspace) {\n\t\tif(currentWorkspace != null) {\n\t\t\tcurrentWorkspace.getScanAlertRepository().removeActiveScanInstanceListener(this);\n\t\t}\n\t\tif(workspace == null) {\n\t\t\tsetActiveScanInstance(null);\n\t\t\tcurrentWorkspace = null;\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal List<IScanInstance> activeScanInstanceList = workspace.getScanAlertRepository().addActiveScanInstanceListener(this);\n\t\tif (activeScanInstanceList.size() != 0) {\n\t\t\tsetActiveScanInstance(activeScanInstanceList.get(0));\n\t\t}\n\t\tcurrentWorkspace = workspace;\n\t}\n\t\n\tprivate void setActiveScanInstance(IScanInstance scanInstance) {\n\t\tdisplayScanSummary(scanInstance);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/preferences/IPreferenceConstants.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.preferences;\n\npublic interface IPreferenceConstants {\n\tpublic static final String P_USER_AGENT = \"UserAgent\";\n\tpublic static final String P_MAX_SCAN_DESCENDANTS = \"MaxScanDescendants\";\n\tpublic static final String P_MAX_SCAN_CHILDREN = \"MaxScanChildren\";\n\tpublic static final String P_MAX_SCAN_DEPTH = \"MaxScanDepth\";\n\tpublic static final String P_MAX_SCAN_DUPLICATE_PATHS = \"MaxScanDuplicatePaths\";\n\tpublic static final String P_MAX_ALERT_STRING = \"MaxAlertString\";\n\tpublic static final String P_MAX_REQUESTS_PER_SECOND = \"MaxRequestsPerSecond\";\n\tpublic static final String P_MAX_RESPONSE_LENGTH = \"MaxResponseLength\";\n\n\tpublic static final String P_LOG_ALL_REQUESTS = \"LogAllRequests\";\n\tpublic static final String P_DISPLAY_DEBUG_OUTPUT = \"DisplayDebugOutput\";\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/preferences/ScannerDebugPreferenceInitializer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.preferences;\n\nimport org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\nimport org.eclipse.jface.preference.IPreferenceStore;\n\nimport com.subgraph.vega.ui.scanner.Activator;\n\n\npublic class ScannerDebugPreferenceInitializer extends AbstractPreferenceInitializer {\n\n\tpublic ScannerDebugPreferenceInitializer() {\n\t\tIPreferenceStore store = Activator.getDefault().getPreferenceStore();\n\t\tstore.setDefault(IPreferenceConstants.P_LOG_ALL_REQUESTS, false);\n\t\tstore.setDefault(IPreferenceConstants.P_DISPLAY_DEBUG_OUTPUT, false);\n\t}\n\n\t@Override\n\tpublic void initializeDefaultPreferences() {\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/preferences/ScannerDebugPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.preferences;\n\n\nimport org.eclipse.jface.preference.BooleanFieldEditor;\nimport org.eclipse.jface.preference.FieldEditorPreferencePage;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\nimport com.subgraph.vega.ui.scanner.Activator;\n\npublic class ScannerDebugPreferencePage extends FieldEditorPreferencePage implements\n\tIWorkbenchPreferencePage {\n\n\tpublic ScannerDebugPreferencePage() {\n\t\tsuper(GRID);\n\t}\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t\tsetDescription(\"Scanner Debugging Options\");\t\t\n\t}\n\n\t@Override\n\tprotected void createFieldEditors() {\n\t\tBooleanFieldEditor logRequestsField = new BooleanFieldEditor(IPreferenceConstants.P_LOG_ALL_REQUESTS, \"Log all scanner requests\", getFieldEditorParent());\n\t\tBooleanFieldEditor debugOutputField = new BooleanFieldEditor(IPreferenceConstants.P_DISPLAY_DEBUG_OUTPUT, \"Display debug output in console\", getFieldEditorParent());\n\t\taddField(logRequestsField);\n\t\taddField(debugOutputField);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/preferences/ScannerOptionsPreferenceInitializer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.preferences;\n\nimport org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\nimport org.eclipse.jface.preference.IPreferenceStore;\n\nimport com.subgraph.vega.api.http.requests.IHttpRequestEngineFactory;\nimport com.subgraph.vega.api.scanner.IScannerConfig;\nimport com.subgraph.vega.ui.scanner.Activator;\n\npublic class ScannerOptionsPreferenceInitializer extends\n\t\tAbstractPreferenceInitializer {\n\n\tpublic ScannerOptionsPreferenceInitializer() {\n\t\tfinal IPreferenceStore store = Activator.getDefault().getPreferenceStore();\n\t\tstore.setDefault(IPreferenceConstants.P_USER_AGENT, IHttpRequestEngineFactory.DEFAULT_USER_AGENT);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_SCAN_DESCENDANTS, IScannerConfig.DEFAULT_MAX_DESCENDANTS);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_SCAN_CHILDREN, IScannerConfig.DEFAULT_MAX_CHILDREN);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_SCAN_DEPTH, IScannerConfig.DEFAULT_MAX_DEPTH);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_SCAN_DUPLICATE_PATHS, IScannerConfig.DEFAULT_MAX_DUPLICATE_PATHS);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_REQUESTS_PER_SECOND, IScannerConfig.DEFAULT_MAX_REQUEST_PER_SECOND);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_ALERT_STRING, 400);\n\t\tstore.setDefault(IPreferenceConstants.P_MAX_RESPONSE_LENGTH, IScannerConfig.DEFAULT_MAX_RESPONSE_KILOBYTES);\n\t}\n\n\t@Override\n\tpublic void initializeDefaultPreferences() {\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/preferences/ScannerOptionsPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.preferences;\n\nimport org.eclipse.jface.preference.FieldEditorPreferencePage;\nimport org.eclipse.jface.preference.IntegerFieldEditor;\nimport org.eclipse.jface.preference.StringFieldEditor;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\nimport com.subgraph.vega.ui.scanner.Activator;\n\npublic class ScannerOptionsPreferencePage extends FieldEditorPreferencePage implements\n\t\tIWorkbenchPreferencePage {\n\n\tpublic ScannerOptionsPreferencePage() {\n\t\tsuper(GRID);\n\t}\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t\tsetDescription(\"Scanner Options\");\n\t}\n\n\t@Override\n\tprotected void createFieldEditors() {\n\t\tfinal StringFieldEditor userAgent = new StringFieldEditor(IPreferenceConstants.P_USER_AGENT, \"&User-Agent:\", 60, getFieldEditorParent());\n\t\taddField(userAgent);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_SCAN_DESCENDANTS, \"Maximum number of total path descendants\", 10, 100000);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_SCAN_CHILDREN, \"Maximum number child paths for a single node\", 10, 100000);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_SCAN_DEPTH, \"Maximum path depth\", 1, 10000);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_SCAN_DUPLICATE_PATHS, \"Maximum number of duplicate path elements\", 2, 100);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_ALERT_STRING, \"Maximum length of strings to display in alert reports\", 10, 100000);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_REQUESTS_PER_SECOND, \"Maximum number of requests per second to send\", 1, 10000);\n\t\taddIntegerField(IPreferenceConstants.P_MAX_RESPONSE_LENGTH, \"Maximum response size to process in kilobytes (0 for unlimited)\", 0, 100000);\n\t}\n\t\n\tprivate void addIntegerField(String var, String description, int min, int max) {\n\t\tfinal Composite parent = getFieldEditorParent();\n\t\tfinal IntegerFieldEditor editor = new IntegerFieldEditor(var, description, parent);\n\t\teditor.setValidRange(min, max);\n\t\taddField(editor);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/scope/BasePathWidget.java",
    "content": "package com.subgraph.vega.ui.scanner.scope;\n\nimport java.net.URI;\n\nimport org.eclipse.jface.viewers.StructuredViewer;\nimport org.eclipse.swt.widgets.Composite;\n\nimport com.subgraph.vega.api.util.UriTools;\n\npublic class BasePathWidget extends RemovableItemWidget {\n\n\tpublic BasePathWidget(Composite parent, StructuredViewer scopeViewer) {\n\t\tsuper(parent, \"Base Paths\", scopeViewer);\n\t}\n\n\t\t@Override\n\tboolean verifyText(String input) {\n\t\treturn UriTools.isTextValidURI(input);\n\t}\n\n\t@Override\n\tboolean handleInput(String input) {\n\t\tfinal URI uri = UriTools.getURIFromText(input);\n\t\tif(uri == null || currentScope == null) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentScope.addScopeURI(uri);\n\t\treturn true;\n\t}\n\n\t@Override\n\tboolean handleRemoveElement(Object element) {\n\t\tif(currentScope == null || !(element instanceof URI)) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentScope.removeScopeURI((URI) element, false);\n\t\treturn true;\n\t}\n\n\t@Override\n\tObject[] getTableInput() {\n\t\tif(currentScope == null) {\n\t\t\treturn new Object[0];\n\t\t} else {\n\t\t\treturn currentScope.getScopeURIs().toArray();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/scope/EditScopeDialog.java",
    "content": "package com.subgraph.vega.ui.scanner.scope;\n\nimport org.eclipse.jface.dialogs.Dialog;\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.ui.scanner.Activator;\n\npublic class EditScopeDialog extends Dialog {\n\n\tpublic EditScopeDialog(Shell parentShell) {\n\t\tsuper(parentShell);\n\t}\n\t\n\t@Override\n\tprotected Point getInitialSize() {\n\t\treturn new Point(500,600);\n\t}\n\t\n\t@Override\n\tprotected boolean isResizable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tComposite area = (Composite) super.createDialogArea(parent);\n\t\tcreateDialogPanel(area);\n\t\treturn area;\n\t}\n\t\n\tprivate void createDialogPanel(Composite parent) {\n\t\t\n\t\tfinal Composite panel = new Composite(parent, SWT.NONE);\n\t\tpanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\tcreateLabel(panel);\n\t\tfinal IWorkspace workspace = Activator.getDefault().getModel().getCurrentWorkspace();\n\t\tScopeSelector scopeSelector = new ScopeSelector(panel, workspace.getTargetScopeManager());\n\t\tscopeSelector.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));\n\t\tComposite c1 = new BasePathWidget(panel, scopeSelector.getViewer());\n\t\tc1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));\n\t\tComposite c2 = new ExcludeWidget(panel, scopeSelector.getViewer());\n\t\tc2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));\n\t\tpanel.setLayout(new GridLayout());\n\t}\n\t\n\tprivate void createLabel(Composite parent) {\n\t\tfinal Label label = new Label(parent, SWT.NONE);\n\t\tlabel.setText(\"Target Scope\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));\n\t}\n\n\t@Override\n\tprotected void createButtonsForButtonBar(Composite parent) {\n\t\tcreateButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\n\t\t\t\ttrue);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/scope/ExcludeWidget.java",
    "content": "package com.subgraph.vega.ui.scanner.scope;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.regex.Pattern;\nimport java.util.regex.PatternSyntaxException;\n\nimport org.eclipse.jface.viewers.StructuredViewer;\nimport org.eclipse.swt.widgets.Composite;\n\npublic class ExcludeWidget extends RemovableItemWidget {\n\n\tpublic ExcludeWidget(Composite parent, StructuredViewer scopeViewer) {\n\t\tsuper(parent, \"Exclude (URL or pattern)\", scopeViewer);\n\t}\n\n\t@Override\n\tObject[] getTableInput() {\n\t\tif(currentScope == null) {\n\t\t\treturn new Object[0];\n\t\t} else {\n\t\t\tfinal List<Object> exclusions = new ArrayList<Object>(currentScope.getExclusionURIs());\n\t\t\texclusions.addAll(currentScope.getExclusionPatterns());\n\t\t\treturn exclusions.toArray();\n\t\t}\n\t}\n\n\t@Override\n\tboolean verifyText(String input) {\n\t\ttry {\n\t\t\tPattern.compile(input);\n\t\t\treturn true;\n\t\t} catch (PatternSyntaxException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t@Override\n\tboolean handleInput(String input) {\n\t\tif(currentScope == null) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentScope.addExclusionPattern(input);\n\t\treturn true;\n\t}\n\n\t@Override\n\tboolean handleRemoveElement(Object element) {\n\t\tif(currentScope == null) {\n\t\t\treturn false;\n\t\t} else if(element instanceof String) {\n\t\t\tcurrentScope.removeExclusionPattern((String) element);\n\t\t\treturn true;\n\t\t} else if(element instanceof URI) {\n\t\t\tcurrentScope.removeExclusionURI((URI) element);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/scope/RemovableItemWidget.java",
    "content": "package com.subgraph.vega.ui.scanner.scope;\n\nimport org.eclipse.jface.layout.TableColumnLayout;\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ColumnLabelProvider;\nimport org.eclipse.jface.viewers.ColumnLayoutData;\nimport org.eclipse.jface.viewers.ColumnPixelData;\nimport org.eclipse.jface.viewers.ColumnWeightData;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.viewers.StructuredViewer;\nimport org.eclipse.jface.viewers.TableViewer;\nimport org.eclipse.jface.viewers.TableViewerColumn;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.events.TraverseEvent;\nimport org.eclipse.swt.events.TraverseListener;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableColumn;\nimport org.eclipse.swt.widgets.TableItem;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic abstract class RemovableItemWidget extends Composite {\n\tprivate final static String REMOVE_ICON = \"icons/remove.png\";\n\tprivate final static ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\t\n\tprotected final Text addText;\n\tprotected final Button addButton;\n\tprivate final TableViewer tableViewer;\n\t\n\tprotected ITargetScope currentScope;\n\n\tpublic RemovableItemWidget(Composite parent, String title, StructuredViewer scopeViewer) {\n\t\tsuper(parent, SWT.NONE);\n\t\tsetLayout(new FillLayout());\n\t\tfinal Group group = new Group(this, SWT.NONE);\n\t\tgroup.setText(title);\n\t\tgroup.setLayout(new GridLayout(2, false));\n\t\ttableViewer = createTableViewer(group);\n\t\taddText = createText(group, createModifyListener());\n\t\taddButton = createAddButton(group, createSelectionListener());\n\t\tcurrentScope = getScopeFromSelection(scopeViewer.getSelection());\n\t\tscopeViewer.addSelectionChangedListener(createSelectionChangedListener());\n\t\treloadInput();\n\t}\n\t\n\t\n\t\n\tprotected void reloadInput() {\n\t\ttableViewer.setInput(getTableInput());\n\t\ttableViewer.getTable().getParent().layout();\n\t}\n\t\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tcurrentScope = getScopeFromSelection(event.getSelection());\n\t\t\t\treloadInput();\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate ITargetScope getScopeFromSelection(ISelection selection) {\n\t\tif(!(selection instanceof StructuredSelection)) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal Object ob = ((StructuredSelection)selection).getFirstElement();\n\t\tif(!(ob instanceof ITargetScope)) {\n\t\t\treturn null;\n\t\t}\n\t\treturn (ITargetScope) ob;\n\t}\n\t\n\tprivate ModifyListener createModifyListener() {\n\t\treturn new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\taddButton.setEnabled(verifyText(addText.getText()));\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createTextSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t\tif(handleInput(addText.getText())) {\n\t\t\t\t\taddText.setText(\"\");\n\t\t\t\t\treloadInput();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate SelectionAdapter createSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif(handleInput(addText.getText())) {\n\t\t\t\t\taddText.setText(\"\");\n\t\t\t\t\treloadInput();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tabstract Object[] getTableInput();\n\tabstract boolean verifyText(String input);\n\tabstract boolean handleInput(String input);\n\tabstract boolean handleRemoveElement(Object element);\n\t\n\tprivate Text createText(Composite parent, ModifyListener modifyListener) {\n\t\tfinal Text text = new Text(parent, SWT.BORDER);\n\t\ttext.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\ttext.addModifyListener(modifyListener);\n\t\ttext.addSelectionListener(createTextSelectionListener());\n\t\ttext.addTraverseListener(new TraverseListener() {\n\t\t\t@Override\n\t\t\tpublic void keyTraversed(TraverseEvent e) {\n\t\t\t\tif(e.detail == SWT.TRAVERSE_RETURN) {\n\t\t\t\t\te.doit = false;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn text;\n\t}\n\n\tprivate Button createAddButton(Composite parent, SelectionListener selectionListener) {\n\t\tfinal Button button = new Button(parent, SWT.NONE);\n\t\tbutton.setText(\"Add\");\n\t\tbutton.setEnabled(false);\n\t\tbutton.addSelectionListener(selectionListener);\n\t\treturn button;\n\t}\n\t\n\tprivate TableViewer createTableViewer(Composite parent) {\n\t\tfinal Composite tableComposite = new Composite(parent, SWT.NONE);\n\t\tfinal TableViewer tableViewer = new TableViewer(tableComposite, SWT.V_SCROLL | SWT.BORDER);\n\t\tfinal Table table = tableViewer.getTable();\n\t\ttable.setHeaderVisible(false);\n\t\ttable.addListener(SWT.MouseDown, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\thandleTableMouseDown(event, tableViewer);\n\t\t\t}\n\t\t});\n\t\tfinal TableColumnLayout layout = new TableColumnLayout();\n\t\tcreateDataColumn(tableViewer, layout);\n\t\tcreateRemoveColumn(tableViewer, layout);\n\t\ttableComposite.setLayout(layout);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\tgd.horizontalSpan = 2;\n\t\tgd.heightHint = 80;\n\t\ttableComposite.setLayoutData(gd);\n\t\ttableViewer.setContentProvider(new ArrayContentProvider());\n\t\treturn tableViewer;\n\t}\n\t\n\tprivate void handleTableMouseDown(Event e, TableViewer tableViewer) {\n\t\tfinal Table table = tableViewer.getTable();\n\t\tfinal Rectangle clientArea = table.getClientArea();\n\t\tPoint point = new Point(e.x, e.y);\n\t\tfor(int i = table.getTopIndex(); i < table.getItemCount(); i++) {\n\t\t\tTableItem item = table.getItem(i);\n\t\t\tRectangle rect = item.getBounds(1);\n\t\t\tif(!rect.intersects(clientArea)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(rect.contains(point)) {\n\t\t\t\tif(handleRemoveElement(tableViewer.getElementAt(i))) {\n\t\t\t\t\treloadInput();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate void createDataColumn(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal TableViewerColumn tvc = createTableColumn(viewer, layout, SWT.LEFT, new ColumnWeightData(100));\n\t\ttvc.setLabelProvider(new ColumnLabelProvider());\n\t}\n\t\n\tprivate void createRemoveColumn(TableViewer viewer, TableColumnLayout layout) {\n\t\tfinal TableViewerColumn tvc = createTableColumn(viewer, layout, SWT.CENTER, new ColumnPixelData(20, false, true));\n\t\ttvc.setLabelProvider(new ColumnLabelProvider() {\n\t\t\t@Override\n\t\t\tpublic String getText(Object element) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic Image getImage(Object element) {\n\t\t\t\treturn imageCache.get(REMOVE_ICON);\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate TableViewerColumn createTableColumn(TableViewer viewer, TableColumnLayout layout, int align, ColumnLayoutData layoutData) {\n\t\tfinal TableViewerColumn tvc = new TableViewerColumn(viewer, align);\n\t\tfinal TableColumn tc = tvc.getColumn();\n\t\ttc.setMoveable(false);\n\t\ttc.setResizable(false);\n\t\tlayout.setColumnData(tc, layoutData);\n\t\treturn tvc;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/scope/ScopeSelector.java",
    "content": "package com.subgraph.vega.ui.scanner.scope;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.ISelection;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.StackLayout;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.events.TraverseEvent;\nimport org.eclipse.swt.events.TraverseListener;\nimport org.eclipse.swt.layout.FillLayout;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\n\npublic class ScopeSelector extends Composite {\n\n\tprivate final ITargetScopeManager targetScopeManager;\n\tprivate final StackLayout stack;\n\tprivate final Composite stackPanel;\n\tprivate final Text scopeText;\n\tprivate final ComboViewer scopeComboViewer;\n\t\n\tprivate final Button addButton;\n\tprivate final Button editButton;\n\tprivate final Button removeButton;\n\tprivate boolean isEditable;\n\t\n\tpublic ScopeSelector(Composite parent, ITargetScopeManager scopeManager) {\n\t\tsuper(parent, SWT.NONE);\n\t\tthis.targetScopeManager = scopeManager;\n\t\tstack = new StackLayout();\n\t\tstackPanel = new Composite(this, SWT.NONE);\n\t\tstackPanel.setLayout(stack);\n\t\t\n\t\tthis.scopeText = createText(stackPanel);\n\t\tthis.scopeComboViewer = createComboViewer(stackPanel);\n\t\t\n\t\tfinal Composite buttonPanel = new Composite(this, SWT.NONE);\n\t\tbuttonPanel.setLayout(new RowLayout(SWT.HORIZONTAL));\n\t\tthis.addButton = createAddButton(buttonPanel);\n\t\tthis.editButton = createEditButton(buttonPanel);\n\t\tthis.removeButton = createRemoveButton(buttonPanel);\n\t\trefreshScopeCombo();\n\t\tsetReadOnly();\n\t\tsetEnabledButtonsForState();\n\t\tsetLayout(new FillLayout());\n\t}\n\t\n\tpublic ComboViewer getViewer() {\n\t\treturn scopeComboViewer;\n\t}\n\n\tprivate Text createText(Composite parent) {\n\t\tfinal Text text = new Text(parent, SWT.BORDER);\n\t\ttext.addSelectionListener(createTextSelectionListener());\n\t\ttext.addTraverseListener(new TraverseListener() {\n\t\t\t@Override\n\t\t\tpublic void keyTraversed(TraverseEvent e) {\n\t\t\t\tif(e.detail == SWT.TRAVERSE_RETURN) {\n\t\t\t\t\te.doit = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t});\n\t\treturn text;\n\t}\n\t\n\tprivate SelectionAdapter createTextSelectionListener() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t\tfinal String text = scopeText.getText();\n\t\t\t\tif(!text.isEmpty()) {\n\t\t\t\t\tgetScopeFromCombo().setName(text);\n\t\t\t\t\tscopeComboViewer.refresh(true);\n\t\t\t\t\tsetReadOnly();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\tprivate ComboViewer createComboViewer(Composite parent) {\n\t\tfinal ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY);\n\t\tviewer.setContentProvider(ArrayContentProvider.getInstance());\n\t\tviewer.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tfinal StructuredSelection ss = (StructuredSelection) event.getSelection();\n\t\t\t\tif(ss.getFirstElement() instanceof ITargetScope) {\n\t\t\t\t\ttargetScopeManager.setActiveScope((ITargetScope) ss.getFirstElement());\n\t\t\t\t\tsetEnabledButtonsForState();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn viewer;\n\t}\n\t\n\tprivate Button createAddButton(Composite parent) {\n\t\treturn createButton(parent, \"Add\", new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandleAdd();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate Button createEditButton(Composite parent) {\n\t\treturn createButton(parent, \"Edit\", new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandleEdit();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate Button createRemoveButton(Composite parent) {\n\t\treturn createButton(parent, \"Remove\", new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\thandleRemove();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate void refreshScopeCombo() {\n\t\tscopeComboViewer.setInput(targetScopeManager.getAllScopes().toArray());\n\t\tscopeComboViewer.setSelection(new StructuredSelection(targetScopeManager.getActiveScope()));\n\t\tsetEnabledButtonsForState();\n\t}\n\n\tprivate Button createButton(Composite parent, String text, SelectionListener listener) {\n\t\tfinal Button b = new Button(parent, SWT.NONE);\n\t\tb.setText(text);\n\t\tb.addSelectionListener(listener);\n\t\treturn b;\n\t}\n\n\tprivate void handleEdit() {\n\t\tsetEditable();\n\t}\n\t\n\tprivate void handleRemove() {\n\t\tif(targetScopeManager.getAllScopes().size() <= 1) {\n\t\t\treturn;\n\t\t}\n\t\ttargetScopeManager.removeScope(getScopeFromCombo());\n\t\trefreshScopeCombo();\n\t}\n\t\n\tprivate void handleAdd() {\n\t\tfinal ITargetScope newScope = targetScopeManager.createNewScope();\n\t\ttargetScopeManager.saveScope(newScope);\n\t\ttargetScopeManager.setActiveScope(newScope);\n\t\trefreshScopeCombo();\n\t\tsetEditable();\n\t}\n\t\n\tprivate void setEditable() {\n\t\tfinal String name = getScopeFromCombo().getName();\n\t\tif(name != null) {\n\t\t\tisEditable = true;\n\t\t\tstack.topControl = scopeText;\n\t\t\tstackPanel.layout();\n\t\t\tsetEnabledButtonsForState();\n\n\t\t\tscopeText.setText(name);\n\t\t\tscopeText.setSelection(0, name.length());\n\t\t\tscopeText.setFocus();\n\t\t}\n\t}\n\n\tprivate void setReadOnly() {\n\t\tisEditable = false;\n\t\tstack.topControl = scopeComboViewer.getCombo();\n\t\tstackPanel.layout();\n\t\tsetEnabledButtonsForState();\n\t}\n\n\tprivate ITargetScope getScopeFromCombo() {\n\t\tfinal ISelection selection = scopeComboViewer.getSelection();\n\t\tif(!(selection instanceof StructuredSelection)) {\n\t\t\treturn null;\n\t\t}\n\t\tfinal Object ob = ((StructuredSelection) selection).getFirstElement();\n\t\tif(!(ob instanceof ITargetScope)) {\n\t\t\treturn null;\n\t\t}\n\t\treturn (ITargetScope) ob;\n\t}\n\t\n\tprivate void setEnabledButtonsForState() {\n\t\tif(isEditable) {\n\t\t\taddButton.setEnabled(false);\n\t\t\teditButton.setEnabled(false);\n\t\t\tremoveButton.setEnabled(false);\n\t\t\treturn;\n\t\t} \n\t\tif(getScopeFromCombo().isDefaultScope()) {\n\t\t\taddButton.setEnabled(true);\n\t\t\teditButton.setEnabled(false);\n\t\t\tremoveButton.setEnabled(false);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\taddButton.setEnabled(true);\n\t\teditButton.setEnabled(true);\n\t\tremoveButton.setEnabled(true);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/InScopeWebVisitor.java",
    "content": "package com.subgraph.vega.ui.scanner.wizards;\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Set;\nimport java.util.TreeSet;\n\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebModelVisitor;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\n\npublic class InScopeWebVisitor implements IWebModelVisitor {\n\t\n\tprivate final ITargetScope scope;\n\tprivate final Set<URI> scopeURIs;\n\t\n\tInScopeWebVisitor(ITargetScope scope) {\n\t\tthis.scope = scope;\n\t\tthis.scopeURIs = new TreeSet<URI>();\n\t}\n\n\tpublic Collection<URI> getScopeURIs() {\n\t\treturn Collections.unmodifiableCollection(new ArrayList<URI>(scopeURIs));\n\t}\n\n\t@Override\n\tpublic void visit(IWebHost host) {\n\t\tfinal URI u = host.getUri();\n\t\tif(scope.filter(u)) {\n\t\t\tscopeURIs.add(u);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void visit(IWebPath path) {\n\t\tfinal URI u = path.getUri();\n\t\tif(scope.filter(u)) {\n\t\t\tscopeURIs.add(u);\n\t\t}\n\t}\n\n\t@Override\n\tpublic void visit(IWebResponse response) {\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/NewScanAuthPage.java",
    "content": "package com.subgraph.vega.ui.scanner.wizards;\n\nimport java.net.HttpCookie;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Table;\nimport org.eclipse.swt.widgets.TableItem;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.identity.IIdentity;\n\npublic class NewScanAuthPage extends WizardPage {\n\tprivate Table cookiesTable;\n\tstatic private final Object emptyIdentity = new Object();\n\tprivate final List<Object> identities;\n\tprivate ComboViewer scanIdentityViewer;\n\n\n\tprotected NewScanAuthPage(Collection<IIdentity> identities) {\n\t\tsuper(\"Authentication\");\n\t\tsetTitle(\"Authentication Options\");\n\t\tsetDescription(\"Configure cookies and authentication identity to use during scan\");\n\t\tthis.identities = new ArrayList<Object>(identities.size() + 1);\n\t\tthis.identities.add(emptyIdentity);\n\t\tthis.identities.addAll(identities);\n\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\tfinal Composite container = new Composite(parent, SWT.NONE);\n\t\tcontainer.setLayout(new GridLayout());\n\t\tcreateIdentityPart(container);\n\t\tcreateCookiesPart(container);\n\t\tsetControl(container);\n\t}\n\n\tprivate void createIdentityPart(Composite parent) {\n\t\tLabel label = new Label(parent, SWT.NONE);\n\t\tlabel.setText(\"Identity to scan site as:\");\n\n\t\tscanIdentityViewer = new ComboViewer(parent, SWT.READ_ONLY);\n\t\tscanIdentityViewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tscanIdentityViewer.setContentProvider(ArrayContentProvider.getInstance());\n\t\tscanIdentityViewer.setLabelProvider(new LabelProvider() {\n\t\t\tpublic String getText(Object element) {\n\t\t\t\tif (element != emptyIdentity) {\n\t\t\t\t\treturn ((IIdentity)element).getName();\n\t\t\t\t} else {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tObject[] identitiesCp = identities.toArray(new Object[0]);\n\t\tscanIdentityViewer.setInput(identitiesCp);\n\t\tscanIdentityViewer.setSelection(new StructuredSelection(identitiesCp[0]));\n\t}\n\n\tprivate void createCookiesPart(Composite parent) {\n\t\t\n\t\tfinal Label cookieLabel = new Label(parent, SWT.NULL);\n\t\tcookieLabel.setText(\"Set-Cookie or Set-Cookie2 value:\");\n\n\t\tfinal Text cookieText = new Text(parent, SWT.BORDER | SWT.SINGLE);\n\t\tcookieText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\n\t\tfinal Button addButton = new Button(parent, SWT.PUSH);\n\t\taddButton.setText(\"Add cookie\");\n\t\taddButton.addListener(SWT.Selection, new Listener() {\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tif (event.widget == addButton) {\n\t\t\t\t\tfinal String value = cookieText.getText();\n\t\t\t\t\tif (value != null) {\n\t\t\t\t\t\tTableItem items[] = cookiesTable.getItems();\n\t\t\t\t\t\tfor (TableItem t : items) {\n\t\t\t\t\t\t\tif (cookieText.getText().equals(t.getText())) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tHttpCookie.parse(cookieText.getText());\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tsetErrorMessage(\"Cookie error: \" + e.getMessage());\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTableItem newCookie = new TableItem(cookiesTable,\n\t\t\t\t\t\t\t\tSWT.NONE);\n\t\t\t\t\t\tnewCookie.setText(cookieText.getText());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tcookiesTable = new Table(parent, SWT.BORDER | SWT.MULTI);\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\tgd.widthHint = 140;\n\t\tgd.heightHint = 60;\n\t\tcookiesTable.setLayoutData(gd);\n\t\t\n\t\tfinal Button removeButton = new Button(parent, SWT.PUSH);\n\t\tremoveButton.setText(\"Remove selected cookie(s)\");\n\t\tremoveButton.addListener(SWT.Selection, new Listener() {\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tcookiesTable.remove(cookiesTable.getSelectionIndices());\n\t\t\t}\n\t\t});\n\t}\n\t\n\tpublic List<String> getCookieStringList() {\n\t\treturn getTableItemsAsString(cookiesTable);\n\t}\n\n\tprivate List<String> getTableItemsAsString(Table table) {\n\t\tArrayList<String> list = new ArrayList<String>();\n\t\tfor (TableItem t: table.getItems()) {\n\t\t\tlist.add(t.getText());\n\t\t}\n\t\treturn list;\n\t}\n\n\tpublic IIdentity getScanIdentity() {\n\t\tObject selection = ((IStructuredSelection) scanIdentityViewer.getSelection()).getFirstElement();\n\t\tif (selection != emptyIdentity) {\n\t\t\treturn  (IIdentity)selection;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/NewScanModulesPage.java",
    "content": "package com.subgraph.vega.ui.scanner.wizards;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.CheckboxTreeViewer;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryCheckStateProvider;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryContentProvider;\nimport com.subgraph.vega.ui.util.modules.ModuleRegistryLabelProvider;\n\npublic class NewScanModulesPage extends WizardPage {\n\n\tprivate final List<IScannerModule> modules;\n\tprivate CheckboxTreeViewer viewer;\n\t\n\tNewScanModulesPage(List<IScannerModule> modules) {\n\t\tsuper(\"Select Modules\");\n\t\tsetTitle(\"Select Modules\");\n\t\tsetDescription(\"Choose which scanner modules to enable for this scan\");\n\t\t\n\t\tthis.modules = modules;\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\tfinal Composite container = new Composite(parent, SWT.NULL);\n\t\tcontainer.setLayout(new GridLayout());\n\t\tcreateModulesPart(container);\n\t\tsetControl(container);\n\t}\n\t\n\tprivate void createModulesPart(Composite parent) {\n\t\tfinal Label label = new Label(parent, SWT.NONE);\n\t\tlabel.setText(\"Select modules to run:\");\n\t\t\n\t\tviewer = new CheckboxTreeViewer(parent, SWT.BORDER| SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);\n\t\tfinal ModuleRegistryCheckStateProvider checkStateProvider = new ModuleRegistryCheckStateProvider(viewer);\n\t\tviewer.setContentProvider(new ModuleRegistryContentProvider(checkStateProvider));\n\t\tviewer.setLabelProvider(new ModuleRegistryLabelProvider());\n\t\tviewer.setCheckStateProvider(checkStateProvider);\t\t\n\t\tviewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); \n\t    viewer.setInput(modules.toArray(new IScannerModule[0]));\n        viewer.addCheckStateListener(checkStateProvider);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/NewScanParameterPage.java",
    "content": "package com.subgraph.vega.ui.scanner.wizards;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.ListViewer;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Text;\n\npublic class NewScanParameterPage extends WizardPage {\n\n\tprivate final List<String> parameterNames;\n\tprivate Button enableExcludedParameters;\n\tprivate ListViewer excludedParameterList;\n\tprivate Text parameterNameText;\n\tprivate Button addParameterButton;\n\tprivate Button removeParameterButton;\n\t\n\tprotected NewScanParameterPage(Collection<String> parameterNames) {\n\t\tsuper(\"Parameters\");\n\t\tsetTitle(\"Parameters\");\n\t\tsetDescription(\"Add names of parameters to avoid fuzzing during scan\");\n\t\tthis.parameterNames = new ArrayList<String>(parameterNames);\n\t}\n\t\n\tpublic Set<String> getExcludedParameterNames() {\n\t\tif(enableExcludedParameters.getSelection()) {\n\t\t\treturn Collections.unmodifiableSet(new HashSet<String> (parameterNames));\n\t\t} else {\n\t\t\treturn Collections.emptySet();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\tfinal Composite container = new Composite(parent, SWT.NULL);\n\t\tcontainer.setLayout(new GridLayout());\n\t\tfinal Group group = createGroupControl(container);\n\t\tcreateEnableButton(group);\n\t\tcreateParameterExcludeList(group);\n\t\tcreateAddRemoveWidget(group);\n\t\tupdatePage();\n\t\tsetControl(container);\n\t}\n\n\tprivate Group createGroupControl(Composite parent) {\n\t\tfinal Group group = new Group(parent, SWT.NONE);\n\t\tgroup.setText(\"Exclude Parameters\");\n\t\tfinal GridLayout layout = new GridLayout();\n\t\tlayout.verticalSpacing = 15;\n\t\tgroup.setLayout(layout);\n\t\tgroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\treturn group;\n\t}\n\t\n\tprivate void createEnableButton(Composite parent) {\n\t\tenableExcludedParameters = new Button(parent, SWT.CHECK);\n\t\tenableExcludedParameters.setText(\"Exclude listed parameters from scan\");\n\t\tenableExcludedParameters.setSelection(true);\n\t\tenableExcludedParameters.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tenableExcludedParameters.addListener(SWT.Selection, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tif(excludedParameterList != null) {\n\t\t\t\t\tupdatePage();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate void createParameterExcludeList(Composite parent) {\n\t\texcludedParameterList = new ListViewer(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);\n\t\texcludedParameterList.setContentProvider(ArrayContentProvider.getInstance());\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\t\n\t\texcludedParameterList.getList().setLayoutData(gd);\n\t\texcludedParameterList.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tupdatePage();\n\t\t\t}\n\t\t});\n\t\texcludedParameterList.setInput(parameterNames.toArray());\n\t}\n\t\n\t\n\tprivate void createAddRemoveWidget(Composite parent) {\n\t\tfinal Composite composite = new Composite(parent, SWT.NONE);\n\t\tcomposite.setLayout(new RowLayout());\n\t\tcomposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));\n\t\tparameterNameText = new Text(composite, SWT.BORDER | SWT.SINGLE);\n\t\tparameterNameText.setMessage(\"Enter name of parameter to exclude\");\n\t\t\n\t\taddParameterButton = new Button(composite, SWT.PUSH);\n\t\taddParameterButton.setText(\"Add\");\n\t\tremoveParameterButton = new Button(composite, SWT.PUSH);\n\t\tremoveParameterButton.setText(\"Remove\");\n\t\t\n\t\tparameterNameText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tupdatePage();\n\t\t\t}\n\t\t});\n\t\t\n\t\taddParameterButton.addListener(SWT.Selection, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\thandleAddParameter();\n\t\t\t}\n\t\t});\n\t\t\n\t\tremoveParameterButton.addListener(SWT.Selection, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\thandleRemoveParameter();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate void handleAddParameter() {\n\t\tfinal String name = parameterNameText.getText();\n\t\tif(!parameterNames.contains(name)) {\n\t\t\tparameterNames.add(name.toLowerCase());\n\t\t\texcludedParameterList.setInput(parameterNames.toArray());\n\t\t}\n\t\tparameterNameText.setText(\"\");\n\t}\n\t\n\tprivate void handleRemoveParameter() {\n\t\tfinal IStructuredSelection selection = (IStructuredSelection) excludedParameterList.getSelection();\n\t\tfor(Object elem: selection.toArray()) {\n\t\t\tif(elem instanceof String) {\n\t\t\t\tparameterNames.remove(elem);\n\t\t\t}\n\t\t}\n\t\texcludedParameterList.setInput(parameterNames.toArray());\n\t\tupdatePage();\n\t}\n\t\n\tprivate void updatePage() {\n\t\tif(enableExcludedParameters.getSelection()) {\n\t\t\texcludedParameterList.getList().setEnabled(true);\n\t\t\tsetAddRemoveWidgetEnabled();\n\t\t} else {\n\t\t\texcludedParameterList.getList().setEnabled(false);\n\t\t\tsetAddRemoveWidgetDisabled();\n\t\t}\n\t}\n\n\tprivate void setAddRemoveWidgetDisabled() {\n\t\tparameterNameText.setEnabled(false);\n\t\taddParameterButton.setEnabled(false);\n\t\tremoveParameterButton.setEnabled(false);\n\t}\n\t\n\tprivate void setAddRemoveWidgetEnabled() {\n\t\tparameterNameText.setEnabled(true);\n\t\tsetAddRemoveButtonsEnabledForState();\n\t}\n\tprivate void setAddRemoveButtonsEnabledForState() {\n\t\taddParameterButton.setEnabled(!parameterNameText.getText().isEmpty());\n\t\tremoveParameterButton.setEnabled(!excludedParameterList.getSelection().isEmpty());\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/NewScanTargetPage.java",
    "content": "package com.subgraph.vega.ui.scanner.wizards;\n\nimport org.eclipse.jface.viewers.ArrayContentProvider;\nimport org.eclipse.jface.viewers.ComboViewer;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.ListViewer;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.layout.RowData;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\nimport com.subgraph.vega.api.util.UriTools;\nimport com.subgraph.vega.ui.scanner.scope.EditScopeDialog;\n\npublic class NewScanTargetPage extends WizardPage {\n\tprivate final static String TARGET_TITLE = \"Select a Scan Target\";\n\tprivate final static String TARGET_DESCRIPTION = \n\t\t\t\"Choose a target for new scan\";\n\t\n\tprivate final IWorkspace workspace;\n\tprivate final String targetUriText;\n\t\n\tprivate Text scanTargetUriText;\n\tprivate ComboViewer scopeComboViewer;\n\tprivate ListViewer scopeURIViewer;\n\tprivate Button includeModelContent;\n\tprivate ITargetScope comboScope;\n\tprivate ITargetScope uriScope;\n\t\n\tpublic NewScanTargetPage(IWorkspace workspace, String targetValue) {\n\t\tsuper(TARGET_TITLE);\n\t\tsetTitle(TARGET_TITLE);\n\t\tsetDescription(TARGET_DESCRIPTION);\n\t\tthis.workspace = workspace;\n\t\tthis.targetUriText = targetValue;\n\t}\n\t\n\tpublic boolean isTargetValid() {\n\t\treturn isValidScope(getScanTargetScope());\n\t}\n\t\n\tprivate boolean isValidScope(ITargetScope scope) {\n\t\treturn scope != null && !scope.isEmpty();\n\t}\n\t\n\tpublic ITargetScope getScanTargetScope() {\n\t\tif(scanTargetUriText.isEnabled()) {\n\t\t\treturn uriScope;\n\t\t} else {\n\t\t\treturn comboScope;\n\t\t}\n\t}\n\t\n\tpublic String getUriTextIfValid() {\n\t\tfinal String text = scanTargetUriText.getText();\n\t\tif(UriTools.isTextValidURI(text)) {\n\t\t\treturn text;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\tfinal Composite container = new Composite(parent, SWT.NULL);\n\t\tcontainer.setLayout(new GridLayout(1, false));\n\t\tcreateTargetGroup(container);\n\t\tcreateScopeURIGroup(container);\n\t\tif(targetUriText != null && !targetUriText.isEmpty()) {\n\t\t\tscanTargetUriText.setText(targetUriText);\n\t\t\tsetUriScopeFromText(targetUriText);\n\t\t}\n\n\t\trefreshScopeCombo();\n\t\tupdatePage();\n\t\tsetControl(container);\n\t}\n\t\n\tprivate void createTargetGroup(Composite parent) {\n\t\tfinal Group group = createTargetGroupControl(parent);\n\t\tcreateBaseURIControls(group);\n\t\tcreateScopeControls(group);\n\t}\n\t\n\tprivate Group createTargetGroupControl(Composite parent) {\n\t\tfinal Group group = new Group(parent, SWT.NONE);\n\t\tgroup.setText(\"Scan Target\");\n\t\tfinal GridLayout layout = new GridLayout();\n\t\tlayout.verticalSpacing = 15;\n\t\tlayout.marginBottom = 15;\n\t\tgroup.setLayout(layout);\n\t\tgroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));\n\t\treturn group;\n\t}\n\n\tprivate void createBaseURIControls(Composite parent) {\n\t\tfinal Button radio = new Button(parent, SWT.RADIO);\n\t\tradio.setText(\"Enter a base URI for scan:\");\n\t\tradio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));\n\t\t\n\t\tscanTargetUriText = new Text(parent, SWT.BORDER | SWT.SINGLE);\n\t\tfinal GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, false);\n\t\tgd.widthHint = 300;\n\t\tgd.horizontalIndent = 20;\n\t\tscanTargetUriText.setLayoutData(gd);\n\t\tscanTargetUriText.setMessage(\"Enter URI to scan\");\n\t\tscanTargetUriText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tsetUriScopeFromText(scanTargetUriText.getText());\n\t\t\t}\n\t\t});\n\t\t\n\t\tradio.addListener(SWT.Selection, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tscanTargetUriText.setEnabled(radio.getSelection());\n\t\t\t\tupdatePage();\n\t\t\t}\n\t\t});\n\t\tradio.setSelection(true);\n\t}\n\t\n\tprivate void setUriScopeFromText(String text) {\n\t\tif(uriScope == null) {\n\t\t\turiScope = workspace.getTargetScopeManager().createNewScope();\n\t\t}\n\t\turiScope.clear();\n\t\tif(UriTools.isTextValidURI(text)) {\n\t\t\turiScope.addScopeURI(UriTools.getURIFromText(text));\n\t\t}\n\t\tupdatePage();\n\t}\n\n\t\n\tprivate void createScopeControls(Composite parent) {\n\t\tfinal Button radio = new Button(parent, SWT.RADIO);\n\t\tradio.setText(\"Choose a target scope for scan\");\n\t\t\n\t\tfinal Composite c = new Composite(parent, SWT.NONE);\n\t\tc.setLayout(new RowLayout());\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\n\t\tgd.horizontalIndent = 20;\n\t\tc.setLayoutData(gd);\n\t\t\n\t\tscopeComboViewer = new ComboViewer(c, SWT.READ_ONLY);\n\t\tscopeComboViewer.setContentProvider(ArrayContentProvider.getInstance());\n\t\tscopeComboViewer.getCombo().setEnabled(false);\n\t\tscopeComboViewer.getCombo().setLayoutData(new RowData(250, SWT.DEFAULT));\n\t\tscopeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tfinal StructuredSelection ss = (StructuredSelection) event.getSelection();\n\t\t\t\tif(ss.getFirstElement() instanceof ITargetScope) {\n\t\t\t\t\tcomboScope = (ITargetScope) ss.getFirstElement();\n\t\t\t\t\tupdatePage();\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t\tfinal Button editButton = new Button(c, SWT.NONE);\n\t\teditButton.setText(\"Edit Scopes\");\n\t\teditButton.addListener(SWT.Selection, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\thandleEditScopes();\n\t\t\t}\n\t\t});\n\t\teditButton.setEnabled(false);\n\t\t\n\t\tradio.addListener(SWT.Selection, new Listener() {\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tfinal boolean flag = radio.getSelection();\n\t\t\t\tscopeComboViewer.getCombo().setEnabled(flag);\n\t\t\t\teditButton.setEnabled(flag);\n\t\t\t\tupdatePage();\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate void handleEditScopes() {\n\t\tfinal EditScopeDialog dialog = new EditScopeDialog(getShell());\n\t\tdialog.create();\n\t\tdialog.open();\n\t\trefreshScopeCombo();\n\t}\n\t\n\tprivate void refreshScopeCombo() {\n\t\tfinal ITargetScopeManager scopeManager = workspace.getTargetScopeManager();\n\t\tscopeComboViewer.setInput(scopeManager.getAllScopes().toArray());\n\t\tscopeComboViewer.setSelection(new StructuredSelection(scopeManager.getActiveScope()));\n\t}\n\t\n\tprivate void createScopeURIGroup(Composite parent) {\n\t\tfinal Group group = new Group(parent, SWT.NONE);\n\t\tincludeModelContent = new Button(group, SWT.CHECK);\n\t\tscopeURIViewer = new ListViewer(group, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);\n\t\t\n\t\tgroup.setText(\"Web Model\");\n\t\tgroup.setLayout(new GridLayout());\n\t\tgroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\n\t\t\n\t\t\n\t\tincludeModelContent.setText(\"Include previously discovered paths from Web model\");\n\t\tincludeModelContent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\n\t\tincludeModelContent.setSelection(true);\n\t\t\n\t\tscopeURIViewer.setContentProvider(ArrayContentProvider.getInstance());\n\t\tfinal GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\n\n\t\tscopeURIViewer.getList().setLayoutData(gd);\n\t\t\n\t\tincludeModelContent.addListener(SWT.Selection, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tscopeURIViewer.getList().setEnabled(includeModelContent.getSelection());\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate void updatePage() {\n\t\trefreshScopeUriList(getScanTargetScope());\n\t\tenableButtonForIncludeModel();\n\t\tmaybeDisplayError();\n\t\tsetPageComplete(isTargetValid());\n\t}\n\t\n\tprivate void refreshScopeUriList(ITargetScope scope) {\n\t\tif(scope == null) {\n\t\t\tscopeURIViewer.setInput(new Object[0]);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tfinal InScopeWebVisitor visitor = new InScopeWebVisitor(scope);\n\t\tworkspace.getWebModel().accept(visitor);\n\t\tscopeURIViewer.setInput(visitor.getScopeURIs().toArray());\n\t}\n\t\n\tprivate void enableButtonForIncludeModel() {\n\t\tincludeModelContent.setEnabled(scopeURIViewer.getList().getItems().length != 0);\n\t}\n\t\n\tprivate void maybeDisplayError() {\n\t\tsetMessage(null);\n\t\tsetErrorMessage(null);\n\t\tif(scanTargetUriText.isEnabled()) {\n\t\t\tmaybeDisplayErrorForUriText();\n\t\t} else {\n\t\t\tmaybeDisplayErrorForScopeCombo();\n\t\t}\n\t}\n\t\n\tprivate void maybeDisplayErrorForUriText() {\n\t\tfinal String text = scanTargetUriText.getText();\n\t\tif(text.isEmpty()) {\n\t\t\tsetMessage(\"Enter a target URI\");\n\t\t\treturn;\n\t\t}\n\t\tif(!UriTools.isTextValidURI(scanTargetUriText.getText())) {\n\t\t\tsetErrorMessage(\"Target URI is invalid.  Enter a properly formatted target URI.\");\n\t\t}\n\t}\n\t\n\tprivate void maybeDisplayErrorForScopeCombo() {\n\t\tif(comboScope == null) {\n\t\t\tsetMessage(\"Select a Target Scope\");\n\t\t} else if(comboScope.isEmpty()) {\n\t\t\tsetErrorMessage(\"Selected Target Scope is empty.  Edit scope to add target URIs\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/NewScanWizard.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.wizards;\n\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.Set;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.jface.wizard.Wizard;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.identity.IIdentity;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\nimport com.subgraph.vega.ui.scanner.Activator;\nimport com.subgraph.vega.ui.util.images.ImageCache;\n\npublic class NewScanWizard extends Wizard {\n\tprivate final static String VEGA_LOGO = \"icons/vega_small.png\";\n\t\n\tprivate final ImageCache imageCache;\n\tprivate NewScanTargetPage targetPage;\n\tprivate NewScanModulesPage modulesPage;\n\tprivate NewScanAuthPage authPage;\n\tprivate NewScanParameterPage parameterPage;\n\tprivate ITargetScope scanTargetScope;\n\tprivate IIdentity scanIdentity;\n\tprivate List<String> cookieStringList;\n\tprivate Set<String> excludedParameterNames;\n\tprivate String targetFieldString;\n\n\tpublic NewScanWizard(String target, Collection<IIdentity> identities, List<IScannerModule> modules, Set<String> defaultExcludeParameters) {\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\timageCache = new ImageCache(Activator.PLUGIN_ID);\n\t\tfinal ImageDescriptor logo = ImageDescriptor.createFromImage(imageCache.get(VEGA_LOGO));\n\t\t\n\t\ttargetPage = new NewScanTargetPage(model.getCurrentWorkspace(), target);\n\t\ttargetPage.setImageDescriptor(logo);\n\t\t\n\t\tmodulesPage = new NewScanModulesPage(modules);\n\t\tmodulesPage.setImageDescriptor(logo);\n\t\t\n\t\tauthPage = new NewScanAuthPage(identities);\n\t\tauthPage.setImageDescriptor(logo);\n\t\t\n\t\tparameterPage = new NewScanParameterPage(defaultExcludeParameters);\n\t\tparameterPage.setImageDescriptor(logo);\n\t}\n\t\n\t@Override\n\tpublic void addPages() {\n\t\taddPage(targetPage);\n\t\taddPage(modulesPage);\n\t\taddPage(authPage);\n\t\taddPage(parameterPage);\n\t}\n\t\n\t@Override \n\tpublic boolean canFinish() {\n\t\treturn targetPage.isTargetValid();\n\t}\n\t\n\t@Override\n\tpublic boolean performFinish() {\n\t\tscanIdentity = authPage.getScanIdentity();\n\t\tcookieStringList = authPage.getCookieStringList();\n\t\tscanTargetScope = targetPage.getScanTargetScope();\n\t\ttargetFieldString = targetPage.getUriTextIfValid();\n\t\texcludedParameterNames = parameterPage.getExcludedParameterNames();\n\t\treturn scanTargetScope != null;\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\t\n\tpublic ITargetScope getScanTargetScope() {\n\t\treturn scanTargetScope;\n\t}\n\n\tpublic String getTargetField() {\n\t\treturn targetFieldString;\n\t}\n\t\n\tpublic List<String> getCookieStringList() {\n\t\treturn cookieStringList;\n\t}\n\n\tpublic IIdentity getScanIdentity() { \n\t\treturn scanIdentity;\n\t}\n\t\n\tpublic Set<String> getExcludedParameterNames() {\n\t\treturn excludedParameterNames;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.scanner/src/com/subgraph/vega/ui/scanner/wizards/NewWizardDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.scanner.wizards;\n\nimport org.eclipse.jface.wizard.IWizard;\nimport org.eclipse.jface.wizard.WizardDialog;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.Shell;\n\npublic class NewWizardDialog extends WizardDialog {\n\n\tpublic NewWizardDialog(Shell parentShell, IWizard newWizard) {\n\t\tsuper(parentShell, newWizard);\n\t\tsetShellStyle(SWT.CLOSE | SWT.MAX | SWT.TITLE | SWT.BORDER | SWT.RESIZE | getDefaultOrientation());\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.tags</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Tags\nBundle-SymbolicName: com.subgraph.vega.ui.tags\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.tags.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nExport-Package: com.subgraph.vega.ui.tags.taggableeditor,\n com.subgraph.vega.ui.tagsl.taggablepopup\nImport-Package: com.subgraph.vega.api.events,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.tags\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/internal/ui/tags/taggableeditor/TagModifier.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.tags.taggableeditor;\n\nimport com.subgraph.vega.api.model.tags.ITag;\nimport com.subgraph.vega.api.model.tags.ITagModel;\n\n/**\n * Decorator for ITag to manage manipulation to a tag without storing the changes to the database.\n */\npublic class TagModifier implements ITag {\n\tprivate ITag tagOrig; /** Tag stored in the workspace, or null if it isn't */\n\tprivate String name;\n\tprivate String description;\n\tprivate int nameColor;\n\tprivate int rowColor;\n\tprivate boolean isModified;\n\t\n\tpublic TagModifier(ITag tagOrig) {\n\t\tthis.tagOrig = tagOrig;\n\t\tname = tagOrig.getName();\n\t\tdescription = tagOrig.getDescription();\n\t\tnameColor = tagOrig.getNameColor();\n\t\trowColor = tagOrig.getRowColor();\n\t\tisModified = false;\n\t}\n\t\n\tpublic ITag getTagOrig() {\n\t\treturn tagOrig;\n\t}\n\n\tpublic boolean isModified() {\n\t\treturn isModified;\n\t}\n\t\n\t@Override\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t\tisModified = true;\n\t}\n\n\t@Override\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\t@Override\n\tpublic void setDescription(String description) {\n\t\tthis.description = description;\n\t\tisModified = true;\n\t}\n\n\t@Override\n\tpublic String getDescription() {\n\t\treturn description;\n\t}\n\n\t@Override\n\tpublic void setNameColor(int color) {\n\t\tthis.nameColor = color;\n\t\tisModified = true;\n\t}\n\n\t@Override\n\tpublic int getNameColor() {\n\t\treturn nameColor;\n\t}\n\n\t@Override\n\tpublic void setRowColor(int color) {\n\t\tthis.rowColor = color;\n\t\tisModified = true;\n\t}\n\n\t@Override\n\tpublic int getRowColor() {\n\t\treturn rowColor;\n\t}\n\n\tpublic void store(ITagModel tagModel) {\n\t\tif (isModified == true) {\n\t\t\tITag tag = tagOrig;\n\t\t\tif (tag == null) {\n\t\t\t\ttag = tagModel.createTag();\n\t\t\t}\n\n\t\t\ttagOrig.setName(name);\n\t\t\ttagOrig.setDescription(description);\n\t\t\ttagOrig.setNameColor(nameColor);\n\t\t\ttagOrig.setRowColor(rowColor);\n\n\t\t\tif (tagOrig != tag) {\n\t\t\t\ttagModel.store(tag);\n\t\t\t\ttagOrig = tag;\n\t\t\t}\n\t\t\tisModified = false;\n\t\t}\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/internal/ui/tags/taggableeditor/TagTableCheckStateManager.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.tags.taggableeditor;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.CheckStateChangedEvent;\nimport org.eclipse.jface.viewers.ICheckStateListener;\nimport org.eclipse.jface.viewers.ICheckStateProvider;\n\npublic class TagTableCheckStateManager implements ICheckStateProvider, ICheckStateListener {\n\tprivate List<TagModifier> tagList = new ArrayList<TagModifier>(); /** List of selected TagModifiers */\n\n\t@Override\n\tpublic void checkStateChanged(CheckStateChangedEvent event) {\n\t\tTagModifier tagModifier = (TagModifier) event.getElement();\n\t\tif (event.getChecked() != false) {\n\t\t\ttagList.add(tagModifier);\n\t\t} else {\n\t\t\ttagList.remove(tagModifier);\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean isChecked(Object element) {\n\t\treturn (tagList.indexOf(element) != -1);\n\t}\n\n\t@Override\n\tpublic boolean isGrayed(Object element) {\n\t\treturn false;\n\t}\n\t\n\tpublic void addChecked(TagModifier tagModifier) {\n\t\ttagList.add(tagModifier);\n\t}\n\n\tpublic List<TagModifier> getCheckedList() {\n\t\treturn tagList;\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/internal/ui/tags/taggableeditor/TagTableContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.tags.taggableeditor;\n\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.IStructuredContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\npublic class TagTableContentProvider implements IStructuredContentProvider {\n\tprivate List<TagModifier> tagList;\n\t\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\ttagList = (List<TagModifier>) newInput;\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\treturn tagList.toArray();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/internal/ui/tags/taggableeditor/TagTableLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.tags.taggableeditor;\n\nimport org.eclipse.jface.viewers.ILabelProvider;\nimport org.eclipse.jface.viewers.ILabelProviderListener;\nimport org.eclipse.swt.graphics.Image;\n\npublic class TagTableLabelProvider implements ILabelProvider {\n\n\t@Override\n\tpublic void addListener(ILabelProviderListener listener) {\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic boolean isLabelProperty(Object element, String property) {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic void removeListener(ILabelProviderListener listener) {\n\t}\n\n\t@Override\n\tpublic Image getImage(Object element) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getText(Object element) {\n\t\treturn ((TagModifier) element).getName();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/internal/ui/tags/taggableeditor/TagTableSearchFilter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.tags.taggableeditor;\n\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerFilter;\n\npublic class TagTableSearchFilter extends ViewerFilter {\n\tprivate String matchFilter;\n\n\tpublic void setMatchFilter(String matchFilter) {\n\t\tthis.matchFilter = matchFilter;\n\t}\n\t\n\t@Override\n\tpublic boolean select(Viewer viewer, Object parentElement, Object element) {\n\t\tif (matchFilter != null) {\n\t\t\treturn ((TagModifier) element).getName().contains(matchFilter);\n\t\t}\n\t\treturn true;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/ui/tags/Activator.java",
    "content": "package com.subgraph.vega.ui.tags;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.model.IModel;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.tags\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t\t\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\t\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/ui/tags/tageditor/TagEditorDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tags.tageditor;\n\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.jface.preference.ColorSelector;\nimport org.eclipse.jface.util.IPropertyChangeListener;\nimport org.eclipse.jface.util.PropertyChangeEvent;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.graphics.FontMetrics;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.graphics.RGB;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.MessageBox;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagModifier;\nimport com.subgraph.vega.ui.tagsl.taggablepopup.ITagModifierValidator;\n\npublic class TagEditorDialog extends TitleAreaDialog {\n\tprivate final ITagModifierValidator validator;\n\tprivate final TagModifier tag;\n\tprivate Composite parentComposite;\n\tprivate boolean tagModified;\n\tprivate Text tagNameText;\n\tprivate Text tagDescText;\n\tprivate ColorSelector nameColorSelector;\n\tprivate ColorSelector rowColorSelector;\n\n\tstatic public TagEditorDialog createDialog(Shell parentShell, TagModifier tag, ITagModifierValidator validator) {\n\t\tfinal TagEditorDialog dialog = new TagEditorDialog(parentShell, tag, validator);\n\t\tdialog.create();\n\t\tdialog.getShell().addListener(SWT.Traverse, new Listener() {\n        \tpublic void handleEvent(Event e) {\n        \t\tif (e.detail == SWT.TRAVERSE_ESCAPE) {\n        \t\t\te.doit = false;\n        \t\t}\n        \t}\n        });\n\t\treturn dialog;\n\t}\n\n\tprivate TagEditorDialog(Shell parentShell, TagModifier tag, ITagModifierValidator validator) {\n\t\tsuper(parentShell);\n\t\tthis.tag = tag;\n\t\tthis.validator = validator;\n\t}\n\n\t@Override\n\tpublic void create() {\n\t\tsuper.create();\n\t\tsetTitle(\"Edit Tag\");\n\t\tsetMessage(\"Edit the properties of the tag below.\");\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tfinal Composite dialogArea = (Composite) super.createDialogArea(parent);\n\n\t\tparentComposite = new Composite(dialogArea, SWT.NULL);\n\t    parentComposite.setLayout(new GridLayout(1, false));\n\t    parentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));\n\n\t\tcreateArea(parentComposite).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\t\n\t\treturn dialogArea;\n\t}\n\n\t@Override\n\tprotected void okPressed() {\n\t\ttag.setName(tagNameText.getText().trim());\n\t\ttag.setDescription(tagDescText.getText().trim());\n\t\ttag.setNameColor(rgbToTagColor(nameColorSelector.getColorValue()));\n\t\ttag.setRowColor(rgbToTagColor(rowColorSelector.getColorValue()));\n\n\t\tfinal String errorMsg = validator.validate(tag);\n\t\tsetErrorMessage(errorMsg);\n\t\tif (errorMsg != null) {\n\t\t\treturn;\n\t\t}\n\n\t\tsuper.okPressed();\n\t}\n\n\t@Override\n\tprotected void cancelPressed() {\n\t\tif (tagModified) {\n\t\t\tif (confirmLoseTagModification() == false) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tsuper.cancelPressed();\n\t}\n\t\n\tprivate GridLayout createGaplessGridLayout(int numColumns, boolean makeColumnsEqualWidth) {\n\t\tfinal GridLayout layout = new GridLayout(numColumns, makeColumnsEqualWidth);\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.marginLeft = 0;\n\t\tlayout.marginTop = 0;\n\t\tlayout.marginRight = 0;\n\t\tlayout.marginBottom = 0;\n\t\treturn layout;\n\t}\n\n\tprivate Group createArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"Tag Information\");\n\n\t\tcreateNameControl(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tcreateDescControl(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tcreateColorControl(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tsetTagFields();\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate Composite createNameControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(createGaplessGridLayout(2, false));\n\t\t\n\t\tfinal Label label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Name:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));\n\n\t\ttagNameText = new Text(rootControl, SWT.BORDER | SWT.SINGLE);\n\t\ttagNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));\n\t\ttagNameText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\ttagModified = true;\n\t\t\t}\n\t\t});\n\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createDescControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(createGaplessGridLayout(1, false));\n\t\t\n\t\tfinal Label label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Description:\");\n\n\t\ttagDescText = new Text(rootControl, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);\n\t\tfinal FontMetrics tagDescTextFm = new GC(tagDescText).getFontMetrics();\n\t\tGridData tagDescTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);\n\t\ttagDescTextGd.heightHint = tagDescTextFm.getHeight() * 5;\n\t\ttagDescText.setLayoutData(tagDescTextGd);\n\t\ttagDescText.addModifyListener(new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\ttagModified = true;\n\t\t\t}\n\t\t});\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate Composite createColorControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(createGaplessGridLayout(2, false));\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Name color:\");\n\t\tnameColorSelector = new ColorSelector(rootControl);\n\t\tnameColorSelector.addListener(new IPropertyChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\t\t\tif (event.getProperty().equals(\"colorValue\")) {\n\t\t\t\t\ttagModified = true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tlabel = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Row background color:\");\n\t\trowColorSelector = new ColorSelector(rootControl);\n\t\trowColorSelector.addListener(new IPropertyChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\t\t\tif (event.getProperty().equals(\"colorValue\")) {\n\t\t\t\t\ttagModified = true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate void setTagFields() {\n\t\tif (tag.getName() != null) {\n\t\t\ttagNameText.setText(tag.getName());\n\t\t} else {\n\t\t\ttagNameText.setText(\"\");\n\t\t}\n\t\tif (tag.getDescription() != null) {\n\t\t\ttagDescText.setText(tag.getDescription());\n\t\t} else {\n\t\t\ttagDescText.setText(\"\");\n\t\t}\n\t\tnameColorSelector.setColorValue(tagColorToRgb(tag.getNameColor()));\n\t\trowColorSelector.setColorValue(tagColorToRgb(tag.getRowColor()));\n\t\ttagModified = false;\n\t}\n\t\n\tprivate RGB tagColorToRgb(int color) {\n\t\treturn new RGB((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);\n\t}\n\n\tprivate int rgbToTagColor(RGB rgb) {\n\t\treturn (rgb.red << 16) | (rgb.green << 8) | rgb.blue; \n\t}\n\n\tprivate boolean confirmLoseTagModification() {\n\t\tMessageBox messageDialog = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);\n\t\tmessageDialog.setText(\"Warning\");\n\t\tmessageDialog.setMessage(\"Changes were made to the tag. Proceed without saving?\");\n\t\tif (messageDialog.open() == SWT.CANCEL) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/ui/tags/taggableeditor/TaggableEditorDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tags.taggableeditor;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.dialogs.IDialogConstants;\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.jface.preference.ColorSelector;\nimport org.eclipse.jface.viewers.CheckboxTableViewer;\nimport org.eclipse.jface.viewers.ISelectionChangedListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.SelectionChangedEvent;\nimport org.eclipse.jface.viewers.StructuredSelection;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.ModifyEvent;\nimport org.eclipse.swt.events.ModifyListener;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.graphics.FontMetrics;\nimport org.eclipse.swt.graphics.GC;\nimport org.eclipse.swt.graphics.RGB;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Listener;\nimport org.eclipse.swt.widgets.MessageBox;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.tags.ITag;\nimport com.subgraph.vega.api.model.tags.ITagModel;\nimport com.subgraph.vega.api.model.tags.ITaggable;\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagModifier;\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagTableCheckStateManager;\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagTableContentProvider;\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagTableLabelProvider;\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagTableSearchFilter;\nimport com.subgraph.vega.ui.tags.Activator;\nimport com.subgraph.vega.ui.tags.tageditor.TagEditorDialog;\nimport com.subgraph.vega.ui.tagsl.taggablepopup.ITagModifierValidator;\n\npublic class TaggableEditorDialog extends TitleAreaDialog implements ITagModifierValidator {\n\tprotected static final String IStructuredSelection = null;\n\tprivate final ITaggable taggable;\n\tprivate ITagModel tagModel;\n\tprivate IEventHandler workspaceListener;\n\tprivate ArrayList<TagModifier> tagList = new ArrayList<TagModifier>();\n\tprivate TagModifier tagSelected;\n\tprivate Composite parentComposite;\n\tprivate Text tagFilterText;\n\tprivate CheckboxTableViewer tagTableViewer;\n\tprivate TagTableCheckStateManager checkStateManager;\n\tprivate TagTableSearchFilter tagTableSearchFilter;\n\tprivate Button createButton;\n\tprivate Button editButton;\n\tprivate Text tagNameText;\n\tprivate Text tagDescText;\n\tprivate ColorSelector nameColorSelector;\n\tprivate ColorSelector rowColorSelector;\n\n\tstatic public TaggableEditorDialog createDialog(Shell parentShell, ITaggable taggable) {\n\t\tfinal TaggableEditorDialog dialog = new TaggableEditorDialog(parentShell, taggable);\n\t\tdialog.initialize();\n\t\tdialog.create();\n\t\tdialog.getShell().addListener(SWT.Traverse, new Listener() {\n        \tpublic void handleEvent(Event e) {\n        \t\tif (e.detail == SWT.TRAVERSE_ESCAPE) {\n        \t\t\te.doit = false;\n        \t\t}\n        \t}\n        });\n\t\treturn dialog;\n\t}\n\t\n\tprivate TaggableEditorDialog(Shell parentShell, ITaggable taggable) {\n\t\tsuper(parentShell);\n\t\tthis.taggable = taggable;\n\t\tworkspaceListener = new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif (event instanceof WorkspaceOpenEvent) {\n\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceCloseEvent) {\n\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t} else if (event instanceof WorkspaceResetEvent) {\n\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tcheckStateManager = new TagTableCheckStateManager(); \n\t\ttagTableSearchFilter = new TagTableSearchFilter();\n\t}\n\n\tprivate void initialize() {\n\t\tIWorkspace currentWorkspace = Activator.getDefault().getModel().addWorkspaceListener(workspaceListener);\n\t\ttagModel = currentWorkspace.getTagModel();\n\t}\n\t\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\ttagModel = event.getWorkspace().getTagModel();\n\t}\n\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\t// REVISIT this is really bad. pop up a warning and exit?\n\t\ttagModel = null;\n\t}\n\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\ttagModel = event.getWorkspace().getTagModel();\n\t}\n\n\t@Override\n\tpublic void create() {\n\t\tsuper.create();\n\t\tsetTitle(\"Select Tags\");\n\t\tsetMessage(\"Tags can be used to signify a result as noteworthy and to simplify searching for it. Select \" +\n\t\t\t       \"which tags apply to this result.\");\n\t}\n\t\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tfinal Composite dialogArea = (Composite) super.createDialogArea(parent);\n\n\t\tparentComposite = new Composite(dialogArea, SWT.NULL);\n\t    parentComposite.setLayout(new GridLayout(1, false));\n\t    parentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));\n\n\t    createTagsArea(parentComposite).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t    createTagInfoArea(parentComposite).setLayoutData(new GridData(GridData.FILL_BOTH));\n\n\t\tfor (ITag tag: tagModel.getAllTags()) {\n\t\t\tTagModifier tagModifier = new TagModifier(tag);\n\t\t\ttagList.add(tagModifier);\n\t\t\tfor (ITag tagged: taggable.getAllTags()) {\n\t\t\t\tif (tagModifier.getTagOrig() == tagged) {\n\t\t\t\t\tcheckStateManager.addChecked(tagModifier);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttagTableViewer.setInput(tagList);\n\n\t\tsetTagSelected(null);\n\t\t\n\t\treturn dialogArea;\n\t}\n\n\t@Override\n\tprotected void okPressed() {\n\t\tfor (TagModifier tagModifier: tagList) {\n\t\t\tif (tagModifier.isModified()) {\n\t\t\t\ttagModifier.store(tagModel);\n\t\t\t}\n\t\t}\n\n\t\tList<TagModifier> checked = checkStateManager.getCheckedList(); \n\t\tArrayList<ITag> checkedList = new ArrayList<ITag>(checked.size());\n\t\tfor (Object tagModifier: checked) {\n\t\t\tcheckedList.add(((TagModifier) tagModifier).getTagOrig());\n\t\t}\n\t\ttaggable.setTags(checkedList);\n\n\t\tsuper.okPressed();\n\t}\n\n\t@Override\n\tprotected void cancelPressed() {\n\t\tint tagModifiedCnt = 0;\n\t\tfor (TagModifier tagModifier: tagList) {\n\t\t\tif (tagModifier.isModified()) {\n\t\t\t\ttagModifiedCnt++;\n\t\t\t}\n\t\t}\n\t\tif (tagModifiedCnt != 0) {\n\t\t\tif (confirmLoseTagModifications(tagModifiedCnt) == false) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tsuper.cancelPressed();\n\t}\n\t\n\t@Override\n\tpublic boolean close() {\n\t\tif (workspaceListener != null) {\n\t\t\tActivator.getDefault().getModel().removeWorkspaceListener(workspaceListener);\n\t\t\tworkspaceListener = null;\n\t\t}\n\t\treturn super.close();\n\t}\n\t\n\tprivate GridLayout createGaplessGridLayout(int numColumns, boolean makeColumnsEqualWidth) {\n\t\tfinal GridLayout layout = new GridLayout(numColumns, makeColumnsEqualWidth);\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.marginLeft = 0;\n\t\tlayout.marginTop = 0;\n\t\tlayout.marginRight = 0;\n\t\tlayout.marginBottom = 0;\n\t\treturn layout;\n\t}\n\t\n\tprivate Control createTagsArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"Available Tags\");\n\n\t\ttagFilterText = new Text(rootControl, SWT.SEARCH);\n\t\ttagFilterText.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\ttagFilterText.setMessage(\"type filter text\");\n\t\ttagFilterText.addModifyListener(createTagFilterModifyListener());\n\n\t\tGridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);\n\t\tfinal Control tagTableControl = createTagTable(rootControl, gd, 7);\n\t\ttagTableControl.setLayoutData(gd);\n\n\t\tcreateTagAreaButtonsControl(rootControl).setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate ModifyListener createTagFilterModifyListener() {\n\t\treturn new ModifyListener() {\n\t\t\t@Override\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tfinal String matchFilter = tagFilterText.getText();\n\t\t\t\tif (!matchFilter.isEmpty()) {\n\t\t\t\t\ttagTableSearchFilter.setMatchFilter(matchFilter);\n\t\t\t\t} else {\t\t\t\t\t\n\t\t\t\t\ttagTableSearchFilter.setMatchFilter(null);\n\t\t\t\t}\n\t\t\t\ttagTableViewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate Control createTagTable(Composite parent, GridData gd, int heightInRows) {\n\t\ttagTableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);\n\t\ttagTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\ttagTableViewer.setLabelProvider(new TagTableLabelProvider());\n\t\ttagTableViewer.setContentProvider(new TagTableContentProvider());\n\t\ttagTableViewer.addSelectionChangedListener(createSelectionChangedListener());\n\t\ttagTableViewer.setCheckStateProvider(checkStateManager);\n\t\ttagTableViewer.addCheckStateListener(checkStateManager);\n\t\ttagTableViewer.addFilter(tagTableSearchFilter);\n\t\tgd.heightHint = tagTableViewer.getTable().getItemHeight() * heightInRows;\n\t\treturn tagTableViewer.getTable();\n\t}\n\n\tprivate ISelectionChangedListener createSelectionChangedListener() {\n\t\treturn new ISelectionChangedListener() {\n\t\t\t@Override\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tboolean isEmpty = event.getSelection().isEmpty(); \n\t\t\t\teditButton.setEnabled(!isEmpty);\n\t\t\t\tif (isEmpty == false) {\n\t\t\t\t\tfinal TagModifier tagModifier = (TagModifier)((IStructuredSelection) event.getSelection()).getFirstElement();\n\t\t\t\t\tsetTagSelected(tagModifier);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate Composite createTagAreaButtonsControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(2, false));\n\n\t\tcreateButton = new Button(rootControl, SWT.PUSH);\n\t\tcreateButton.setText(\"Create\");\n\t\tcreateButton.addSelectionListener(createSelectionListenerCreateButton());\n\n\t\teditButton = new Button(rootControl, SWT.PUSH);\n\t\teditButton.setText(\"Edit\");\n\t\teditButton.addSelectionListener(createSelectionListenerEditButton());\n\t\teditButton.setEnabled(false);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate SelectionListener createSelectionListenerCreateButton() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tTagModifier tag = new TagModifier(tagModel.createTag());\n\t\t\t\tTagEditorDialog dialog = TagEditorDialog.createDialog(getShell(), tag, TaggableEditorDialog.this);\n\t\t\t\tif (dialog.open() == IDialogConstants.OK_ID) {\n\t\t\t\t\ttagList.add(tag);\n\t\t\t\t\ttagTableViewer.refresh();\n\t\t\t\t\ttagTableViewer.setSelection(new StructuredSelection(tag));\n\t\t\t\t\tsetTagSelected(tag);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate SelectionListener createSelectionListenerEditButton() {\n\t\treturn new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tfinal TagModifier tag = (TagModifier)((IStructuredSelection) tagTableViewer.getSelection()).getFirstElement();\n\t\t\t\tif (tag != null) {\n\t\t\t\t\tTagEditorDialog dialog = TagEditorDialog.createDialog(getShell(), tag, TaggableEditorDialog.this);\n\t\t\t\t\tif (dialog.open() == IDialogConstants.OK_ID) {\n\t\t\t\t\t\ttagTableViewer.refresh();\n\t\t\t\t\t\tsetTagSelected(tag);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate Group createTagInfoArea(Composite parent) {\n\t\tfinal Group rootControl = new Group(parent, SWT.NONE);\n\t\trootControl.setLayout(new GridLayout(1, false));\n\t\trootControl.setText(\"Tag Information\");\n\n\t\tcreateTagInfoNameControl(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tcreateTagInfoDescControl(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tcreateTagInfoColorControl(rootControl).setLayoutData(new GridData(GridData.FILL_BOTH));\n\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createTagInfoNameControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(createGaplessGridLayout(2, false));\n\t\t\n\t\tfinal Label label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Name:\");\n\t\tlabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));\n\n\t\ttagNameText = new Text(rootControl, SWT.BORDER | SWT.SINGLE);\n\t\ttagNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));\n\t\ttagNameText.setEnabled(false);\n\n\t\treturn rootControl;\n\t}\n\n\tprivate Composite createTagInfoDescControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(createGaplessGridLayout(1, false));\n\t\t\n\t\tfinal Label label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Description:\");\n\n\t\ttagDescText = new Text(rootControl, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);\n\t\tfinal FontMetrics tagDescTextFm = new GC(tagDescText).getFontMetrics();\n\t\tGridData tagDescTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);\n\t\ttagDescTextGd.heightHint = tagDescTextFm.getHeight() * 5;\n\t\ttagDescText.setLayoutData(tagDescTextGd);\n\t\ttagDescText.setEditable(false);\n\n\t\treturn rootControl;\n\t}\n\t\n\tprivate Composite createTagInfoColorControl(Composite parent) {\n\t\tfinal Composite rootControl = new Composite(parent, SWT.NONE);\n\t\trootControl.setLayout(createGaplessGridLayout(2, false));\n\n\t\tLabel label = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Name color:\");\n\t\tnameColorSelector = new ColorSelector(rootControl);\n\t\tnameColorSelector.setColorValue(new RGB(0, 0, 0));\n\t\tnameColorSelector.setEnabled(false);\n\n\t\tlabel = new Label(rootControl, SWT.NONE);\n\t\tlabel.setText(\"Row background color:\");\n\t\trowColorSelector = new ColorSelector(rootControl);\n\t\trowColorSelector.setColorValue(new RGB(255, 255, 255));\n\t\trowColorSelector.setEnabled(false);\n\t\t\n\t\treturn rootControl;\n\t}\n\n\tprivate RGB tagColorToRgb(int color) {\n\t\treturn new RGB((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);\n\t}\n\n\tprivate void setTagSelected(TagModifier tag) {\n\t\tthis.tagSelected = tag;\n\t\tif (tag != null) {\n\t\t\ttagNameText.setText(tag.getName());\n\t\t\tif (tag.getDescription() != null) {\n\t\t\t\ttagDescText.setText(tag.getDescription());\n\t\t\t} else {\n\t\t\t\ttagDescText.setText(\"\");\n\t\t\t}\n\t\t\tnameColorSelector.setColorValue(tagColorToRgb(tag.getNameColor()));\n\t\t\trowColorSelector.setColorValue(tagColorToRgb(tag.getRowColor()));\n\t\t} else {\n\t\t\ttagNameText.setText(\"\");\n\t\t\ttagDescText.setText(\"\");\n\t\t\tnameColorSelector.setColorValue(new RGB(0, 0, 0));\n\t\t\trowColorSelector.setColorValue(new RGB(255, 255, 255));\n\t\t}\n\t}\n\n\tprivate boolean confirmLoseTagModifications(int cnt) {\n\t\tMessageBox messageDialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);\n\t\tmessageDialog.setText(\"Warning\");\n\t\tmessageDialog.setMessage(cnt + \" tags were modified. Proceed without saving?\");\n\t\tif (messageDialog.open() == SWT.CANCEL) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t@Override\n\tpublic String validate(TagModifier modifier) {\n\t\tfinal String name = modifier.getName();\n\t\tif (name.isEmpty()) {\n\t\t\treturn \"Tag name cannot be empty\";\n\t\t}\n\t\tfor (TagModifier tagModifier: tagList) {\n\t\t\tif (tagModifier != modifier && tagModifier.getName().equalsIgnoreCase(name)) {\n\t\t\t\treturn \"A tag of that name already exists\";\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/ui/tagsl/taggablepopup/ITagModifierValidator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tagsl.taggablepopup;\n\nimport com.subgraph.vega.internal.ui.tags.taggableeditor.TagModifier;\n\npublic interface ITagModifierValidator {\n\t/**\n\t * Validate changes made to a tag modifier.\n\t * @param modifier Tag modifier.\n\t * @return String describing the problem if the tag does not pass, otherwise null.\n\t */\n\tString validate(TagModifier modifier);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.tags/src/com/subgraph/vega/ui/tagsl/taggablepopup/TaggablePopupDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tagsl.taggablepopup;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport org.eclipse.jface.dialogs.PopupDialog;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.DisposeEvent;\nimport org.eclipse.swt.events.DisposeListener;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Device;\nimport org.eclipse.swt.graphics.Font;\nimport org.eclipse.swt.graphics.FontData;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.api.model.tags.ITag;\nimport com.subgraph.vega.api.model.tags.ITaggable;\n\npublic class TaggablePopupDialog extends PopupDialog {\n\tprivate Composite parentComposite;\n\tprivate ITaggable taggable;\n\tprivate Point origin;\n\tprivate List<Label> tagLabelList;\n\t\n\tpublic TaggablePopupDialog(Shell parent, ITaggable taggable, Point origin) {\n\t\tsuper(parent, HOVER_SHELLSTYLE, false, false, false, false, false, null, null);\n\t\tthis.taggable = taggable;\n\t\tthis.origin = origin;\n\t\t\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tparentComposite = new Composite(parent, SWT.NONE);\n\t\tparentComposite.setLayout(new GridLayout(1, false));\n\n\t\tLabel header = new Label(parentComposite, SWT.NONE);\n\t\theader.setText(\"Tags:\");\n\t\tFontData[] fd = header.getFont().getFontData();\n\t\tfd[0].setStyle(SWT.BOLD);\n\t\tfinal Font newFont = new Font(parentComposite.getDisplay(), fd[0]);\n\t\theader.setFont(newFont);\n\t\theader.addDisposeListener(new DisposeListener() {\n\t\t    public void widgetDisposed(DisposeEvent e) {\n\t\t    \tnewFont.dispose();\n\t\t    }\n\t\t});\n\n\t\tfinal Collection<ITag> tagList = taggable.getAllTags();\n\t\ttagLabelList = new ArrayList<Label>(tagList.size());\n\t\tfor (ITag tag: tagList) {\n\t\t\ttagLabelList.add(createTagLabel(parentComposite, tag));\n\t\t}\n\n\t\treturn parentComposite;\n\t}\n\t\n\t@Override\n\tprotected boolean hasInfoArea() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tprotected boolean hasTitleArea() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tprotected Point getInitialLocation(Point initialSize) {\n\t\tfinal int diff = origin.x - initialSize.x;\n\t\tfinal int x = (diff > 0) ? (diff) : (origin.x); \n\t\treturn new Point(x, origin.y);\n\t}\n\t\n\t@Override\n\tprotected Color getBackground() {\n\t\treturn parentComposite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);\n\t}\n\n\t@SuppressWarnings({ \"rawtypes\", \"unchecked\" })\n\t@Override\n\tprotected List getForegroundColorExclusions() {\n\t\tfinal List superExclusions = super.getForegroundColorExclusions();\n\t\tfinal List exclusions = new ArrayList(superExclusions.size() + tagLabelList.size());\n\t\texclusions.addAll(superExclusions);\n\t\texclusions.addAll(tagLabelList);\n\t\treturn exclusions;\n\t}\n\t\n\tprivate Label createTagLabel(Composite parent, ITag tag) {\n\t\tfinal Label label = new Label(parent, SWT.NONE);\n\t\tlabel.setText(tag.getName());\n\t\tfinal Color color = tagColorToColor(label.getDisplay(), tag.getNameColor());\n\t\tlabel.setForeground(color);\n\t\tlabel.addDisposeListener(new DisposeListener() {\n\t\t\tpublic void widgetDisposed(DisposeEvent e) {\n\t\t\t\tcolor.dispose();\n\t\t\t}\n\t\t});\n\t\treturn label;\n\t}\n\n\tprivate Color tagColorToColor(Device device, int color) {\n\t\treturn new Color(device, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.util</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Util\nBundle-SymbolicName: com.subgraph.vega.ui.util;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.util.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nExport-Package: com.subgraph.vega.ui.util.dialogs,\n com.subgraph.vega.ui.util.export,\n com.subgraph.vega.ui.util.images,\n com.subgraph.vega.ui.util.modules,\n com.subgraph.vega.ui.util.preferences\nImport-Package: com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.alerts,\n com.subgraph.vega.api.scanner.modules,\n com.subgraph.vega.export\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.preferencePages\">\n      <page\n            category=\"com.subgraph.vega.preferences.general\"\n            class=\"com.subgraph.vega.ui.util.preferencepage.AppearancePreferencePage\"\n            id=\"com.subgraph.vega.ui.util.preferences.appearance\"\n            name=\"Appearance\">\n      </page>\n   </extension>\n   <extension\n         point=\"org.eclipse.equinox.preferences.preferences\">\n      <initializer\n            class=\"com.subgraph.vega.ui.util.preferencepage.PreferenceInitializer\">\n      </initializer>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/internal/ui/util/PopupConfigDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.util;\n\nimport org.eclipse.jface.dialogs.PopupDialog;\nimport org.eclipse.jface.layout.GridDataFactory;\nimport org.eclipse.jface.layout.GridLayoutFactory;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.ui.util.dialogs.IConfigDialogContent;\n\npublic class PopupConfigDialog extends PopupDialog {\n\tprivate static final GridDataFactory LAYOUTDATA_GRAB_BOTH = \n\t\tGridDataFactory.fillDefaults().grab(true, true);\n\tprivate static final GridLayoutFactory POPUP_LAYOUT_FACTORY = \n\t\tGridLayoutFactory\n\t\t\t.fillDefaults().margins(POPUP_MARGINWIDTH, POPUP_MARGINHEIGHT)\n\t\t\t.spacing(POPUP_HORIZONTALSPACING, POPUP_VERTICALSPACING);\n\tprivate final Point origin;\n\tprivate final IConfigDialogContent content;\n\tprivate Control dialogArea;\n\t\n\tpublic PopupConfigDialog(Shell parentShell, Point origin, IConfigDialogContent content) {\n\t\tsuper(parentShell, PopupDialog.INFOPOPUP_SHELLSTYLE, true, false, false, false, false, content.getTitle(), \"Press 'ESC' to close\");\n\t\tthis.origin = origin;\n\t\tthis.content = content;\n\t}\n\t\n\t@Override\n\tpublic boolean close() {\n\t\tcontent.onOk();\n\t\tcontent.onClose();\n\t\treturn super.close();\n\t}\n\n\t@Override\n\tprotected Control getFocusControl() {\n\t\treturn content.getFocusControl();\n\t}\n\t\n\t@Override\n\tprotected Point getInitialLocation(Point initialSize) {\n\t\tfinal int diff = origin.x - initialSize.x;\n\t\tfinal int x = (diff > 0) ? (diff) : (origin.x); \n\t\treturn new Point(x, origin.y);\n\t}\n\t\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\treturn content.createContents(parent);\n\t}\n\n\t@Override\n\tprotected Control createContents(Composite parent) {\n\t\tComposite composite = new Composite(parent, SWT.NONE);\n\t\tPOPUP_LAYOUT_FACTORY.applyTo(composite);\n\t\t\n\t\t//LAYOUTDATA_GRAB_BOTH.applyTo(composite);\n\t\tGridData gd = LAYOUTDATA_GRAB_BOTH.create();\n\t\t\n\t\tcomposite.setLayoutData(gd);\n\t\tif(hasTitleArea()) {\n\t\t\tcreateTitleMenuArea(composite);\n\t\t\tcreateHorizontalSeparator(composite);\n\t\t}\n\t\tdialogArea = createDialogArea(composite);\n\t\tif(dialogArea.getLayoutData() == null)\n\t\t\tLAYOUTDATA_GRAB_BOTH.applyTo(composite);\n\t\t\n\t\tgd = LAYOUTDATA_GRAB_BOTH.create();\n\t\tdialogArea.pack();\n\t\tgd.widthHint = dialogArea.getSize().x;\n\t\tgd.heightHint = dialogArea.getSize().y;\n\t\tdialogArea.setLayoutData(gd);\n\t\t\n\t\tif(hasInfoArea()) {\n\t\t\tcreateHorizontalSeparator(composite);\n\t\t\tcreateInfoTextArea(composite);\n\t\t}\n\t\treturn composite;\n\t\t\n\t}\n\t\n\tprivate Control createHorizontalSeparator(Composite parent) {\n\t\tLabel separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL\n\t\t\t\t| SWT.LINE_DOT);\n\t\tGridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,\n\t\t\t\tfalse).applyTo(separator);\n\t\treturn separator;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/internal/ui/util/TitleAreaConfigDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.internal.ui.util;\n\nimport org.eclipse.jface.dialogs.TitleAreaDialog;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.swt.widgets.Shell;\n\nimport com.subgraph.vega.ui.util.dialogs.IConfigDialogContent;\n\npublic class TitleAreaConfigDialog extends TitleAreaDialog {\n\n\tprivate final IConfigDialogContent content;\n\t\n\tpublic TitleAreaConfigDialog(Shell parentShell, IConfigDialogContent content) {\n\t\tsuper(parentShell);\n\t\tthis.content = content;\n\t}\n\t\n\t@Override\n\tprotected boolean isResizable() {\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic void create() {\n\t\tsuper.create();\n\t\tsetTitle(content.getTitle());\n\t\tsetMessage(content.getMessage());\n\t}\n\n\t@Override\n\tprotected void okPressed() {\n\t\tcontent.onOk();\n\t\tsuper.okPressed();\n\t}\n\n\t@Override\n\tpublic boolean close() {\n\t\tcontent.onClose();\n\t\treturn super.close();\n\t}\n\n\t@Override\n\tprotected Control createDialogArea(Composite parent) {\n\t\tfinal Composite dialogAreaComposite = (Composite) super.createDialogArea(parent);\n\t\tcontent.createContents(dialogAreaComposite);\n\t\treturn dialogAreaComposite;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/Activator.java",
    "content": "package com.subgraph.vega.ui.util;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.model.IModel;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.util\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t\tmodelTracker = new ServiceTracker<IModel, IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/dialogs/ConfigDialogCreator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.dialogs;\n\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.jface.window.Window;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.ToolItem;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.internal.ui.util.PopupConfigDialog;\nimport com.subgraph.vega.internal.ui.util.TitleAreaConfigDialog;\nimport com.subgraph.vega.ui.util.Activator;\nimport com.subgraph.vega.ui.util.preferencepage.IPreferenceConstants;\n\npublic class ConfigDialogCreator {\n\t\n\tpublic static Window createDialog(ExecutionEvent event, IConfigDialogContent content) {\n\t\tfinal Shell parentShell = HandlerUtil.getActiveShell(event);\n\t\treturn createDialog(parentShell, eventToPoint(event), content);\n\t}\n\t\n\tpublic static Window createDialog(ToolItem toolItem, IConfigDialogContent content) {\n\t\tfinal Shell parentShell = toolItem.getParent().getShell();\n\t\treturn createDialog(parentShell, toolItemToPoint(toolItem), content);\n\t}\n\t\n\tpublic static Window createDialog(Shell parentShell, Point origin, IConfigDialogContent content) {\n\t\tboolean popup = Activator.getDefault().getPreferenceStore().getBoolean(IPreferenceConstants.P_CONFIG_POPUP);\n\t\tif(popup) {\n\t\t\treturn new PopupConfigDialog(parentShell, origin, content);\n\t\t} else {\n\t\t\treturn new TitleAreaConfigDialog(parentShell, content);\n\t\t}\n\t}\n\n\tprivate static Point eventToPoint(ExecutionEvent event) {\n\t\tif(event.getTrigger() instanceof Event) {\n\t\t\tfinal Event e = (Event) event.getTrigger();\n\t\t\tif(e.widget instanceof ToolItem) {\n\t\t\t\treturn toolItemToPoint((ToolItem) e.widget);\n\t\t\t}\n\t\t}\n\t\treturn new Point(100, 100);\n\t}\n\t\n\tprivate static Point toolItemToPoint(ToolItem toolItem) {\n\t\tfinal int x = toolItem.getBounds().x;\n\t\tfinal int y = toolItem.getBounds().y + toolItem.getBounds().height;\n\t\treturn toolItem.getDisplay().map(toolItem.getParent(), null, x, y);\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/dialogs/ErrorDialog.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.dialogs;\n\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.widgets.MessageBox;\nimport org.eclipse.swt.widgets.Shell;\n\n// temporary class, probably\npublic class ErrorDialog {\n\n\tstatic public void displayError(Shell shell, String text) {\n\t\tMessageBox messageDialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);\n\t\tmessageDialog.setText(\"Error\");\n\t\tif (text == null) {\n\t\t\ttext = \"Unexpected error occurred\";\n\t\t}\n\t\tmessageDialog.setMessage(text);\n\t\tmessageDialog.open();\n\t}\n\n\tstatic public void displayExceptionError(Shell shell, Exception e) {\n\t\tif (e.getMessage() != null) {\n\t\t\tdisplayError(shell, e.getMessage());\n\t\t} if (e.getCause() != null) {\n\t\t\tdisplayError(shell, e.getCause().getMessage());\n\t\t} else {\n\t\t\tdisplayError(shell, e.toString());\n\t\t}\n\t}\n\n\tstatic public void displayExceptionError(Shell shell, NullPointerException e) {\n\t\tdisplayError(shell, \"Unexpected error encountered\");\n\t}\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/dialogs/IConfigDialogContent.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.dialogs;\n\n\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\n\npublic interface IConfigDialogContent {\n\tComposite createContents(Composite parent);\n\tString getTitle();\n\tString getMessage();\n\tControl getFocusControl();\n\tvoid onClose();\n\tvoid onOk();\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/AlertExportWizard.java",
    "content": "package com.subgraph.vega.ui.util.export;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.wizard.Wizard;\n\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.export.AlertExporter;\n\npublic class AlertExportWizard extends Wizard {\n\n\tprotected ExportWizardPageOne one;\n\tprotected ExportWizardPageTwo two;\n\tprotected ExportWizardPageThree three;\n\tprivate IScanInstance scanInstance = null;\n\t\n\tpublic AlertExportWizard(IScanInstance s) {\n\t\tsuper();\n\t\tscanInstance = s;\n\t}\n\t\n\tpublic AlertExportWizard() {\n\t\tsuper();\n\t}\n\t\n\t@Override\n\tpublic void addPages() {\n\t\tone = new ExportWizardPageOne();\n\t\ttwo = new ExportWizardPageTwo(scanInstance);\n\t\tthree = new ExportWizardPageThree();\n\t\taddPage(one);\n\t\taddPage(two);\n\t\taddPage(three);\n\t\t\n\t}\n\t\n\t@Override\n\tpublic boolean performFinish() {\n\t\t\t\t\n\t\tList<IScanAlert> alerts;\n\t\talerts = two.allAlertsFromTree();\n\t\t\n\t\tAlertExporter exporter = new AlertExporter();\n\t\texporter.exportAlertsbyList(alerts);\n\t\t\n\t\treturn true;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageOne.java",
    "content": "package com.subgraph.vega.ui.util.export;\n\n\n\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Group;\nimport org.eclipse.swt.widgets.Label;\n\npublic class ExportWizardPageOne extends WizardPage {\n\n\t\n\tprivate Composite container;\n\tprivate Group radioGroup;\n\tprivate String choice = \"HTML\";\n\t\n\tprotected ExportWizardPageOne() {\n\t\tsuper(\"Output format\");\n\t\tsetTitle(\"Output format\");\n\t\tsetDescription(\"HTML or XML output format.\");\n\t\t\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\n\t\tcontainer = new Composite(parent, SWT.NONE);\n\t\t\n\t\tGridData gd = new GridData();\n\t\tgd.grabExcessHorizontalSpace = true;\n\t\tcontainer.setLayoutData(gd);\n\t\t\n\t\tGridLayout layout = new GridLayout();\n\t\t\n\t\tcontainer.setLayout(layout);\n\t\tlayout.numColumns = 1;\n\t\t\n\t\t/*Label l = new Label(container, SWT.NONE);\n\t\tl.setText(\"Select XML or HTML output.\");*/\n\t\t\n\t\t\n\t\tradioGroup = new Group(container, SWT.SHADOW_IN);\n\t\t//radioGroup.setText(\"Select XML or HTML output.\");\n\t\tgd.grabExcessHorizontalSpace = true;\n\t\tradioGroup.setLayoutData(gd);\n\t\t\n\t\tradioGroup.setLayout(new RowLayout(SWT.VERTICAL));\n\t\tButton htmlButton = new Button(radioGroup, SWT.RADIO);\n\t\t/*Button xmlButton = new Button(radioGroup, SWT.RADIO | SWT.);\n\t    xmlButton.setText(\"XML\");*/\n\t\thtmlButton.setText(\"HTML\");\n\t\thtmlButton.setSelection(true);\n\t\t/*xmlButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tchoice = xmlButton.getText();\n\t\t\t}\n\t\t});\n\t\t*/\n\t\t\n\t\thtmlButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tchoice = htmlButton.getText();\n\t\t\t}\n\t\t});\n\t\t\n\t\tsetControl(container);\n\t\t\n\t}\n\t\n\tprotected String getChoice() {\n\t\treturn this.choice;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageThree.java",
    "content": "package com.subgraph.vega.ui.util.export;\n\nimport java.text.DateFormat;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\n\nimport org.eclipse.jface.wizard.IWizardPage;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.FileDialog;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Shell;\nimport org.eclipse.swt.widgets.Text;\n\npublic class ExportWizardPageThree extends WizardPage {\n\n\tprotected FileDialog dialog;\n\tprotected Text textField;\n\tprotected Composite container;\n\tprivate String saveFilename = null;\n\tprivate String filename = null;\n\t\n\tfinal static int VISIBLE_PATH_LENGTH = 255;\n\t\n\tprotected ExportWizardPageThree() {\n\t\tsuper(\"Output destination\");\n\t\t\n\n\t\t\n\t\tsetTitle(\"Destination for report output.\");\n\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\n\t\tcontainer = new Composite(parent, SWT.NONE);\n\t\t\n\t\tGridLayout layout = new GridLayout();\n\t\tcontainer.setLayout(layout);\n\t\tlayout.numColumns = 2;\n\t\t\n\t\tLabel label = new Label(container, SWT.NONE);\n\t\tlabel.setText(\"Choose file:\");\n\t\ttextField = new Text(container, SWT.READ_ONLY | SWT.FILL);\n\t\ttextField.setSize(VISIBLE_PATH_LENGTH, textField.getSize().y);\n\t\tButton button = new Button(container, SWT.NONE);\n\t\tbutton.setText(\"Open\");\n\t\t\n\t\tGridData buttonGridData = new GridData();\n\t\tbuttonGridData.horizontalSpan = 2;\n\t\tbuttonGridData.horizontalAlignment = SWT.END;\n\t\tbutton.setLayoutData(buttonGridData);\n\t\t\n\t\tGridData textFieldGridData = new GridData();\n\t\ttextFieldGridData.widthHint = 300;\n\t\ttextField.setLayoutData(textFieldGridData);\n\t\t\n\t\tbutton.addSelectionListener (new SelectionListener() { \n\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdoFileDialog(parent.getShell());\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t\t// TODO Auto-generated method stub\n\t\t\t\t\n\t\t\t}}); \n\t\n\t\tDateFormat dateFormat = new SimpleDateFormat(\"yyyy-MM-dd-HH-mm-ss\");\n\t\tfilename = \"Vega-report-\"+dateFormat.format(new Date());\n\t\t\n\t\tIWizardPage pageOne = getPreviousPage().getPreviousPage();\n\t\tString ext = ((ExportWizardPageOne) pageOne).getChoice();\n\t\t\n\t\tif (ext.equals(\"HTML\")) {\n\t\t\tfilename += \".html\";\n\t\t} else if (ext.equals(\"XML\")){\n\t\t\tfilename += \".xml\";\n\t\t}\n\t\t\n\t\tsetPageComplete(false);\n\t\tsetControl(container);\n\t}\n\n\tprivate void doFileDialog(Shell shell) {\n\t\tdialog = new FileDialog(shell, SWT.SAVE);\n\t\tdialog.setText(\"Choose an output file\");\n\n\t    dialog.setFileName(filename);\n\t    saveFilename = dialog.open();\n\t    if (saveFilename != null) {    \n\t    \ttextField.setText(saveFilename);\n\t    \tsetPageComplete(true);\n\t    }\n\t}\n\t\n\tString getSaveFilename() { \n\t\treturn saveFilename;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java",
    "content": "package com.subgraph.vega.ui.util.export;\n\nimport java.text.SimpleDateFormat;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.logging.Logger;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.jface.viewers.TreeSelection;\nimport org.eclipse.jface.wizard.WizardPage;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.custom.ScrolledComposite;\nimport org.eclipse.swt.events.SelectionAdapter;\nimport org.eclipse.swt.events.SelectionEvent;\nimport org.eclipse.swt.events.SelectionListener;\nimport org.eclipse.swt.events.TreeEvent;\nimport org.eclipse.swt.events.TreeListener;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.Point;\nimport org.eclipse.swt.graphics.Rectangle;\nimport org.eclipse.swt.layout.GridData;\nimport org.eclipse.swt.layout.GridLayout;\nimport org.eclipse.swt.layout.RowLayout;\nimport org.eclipse.swt.widgets.Button;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Label;\nimport org.eclipse.swt.widgets.Tree;\nimport org.eclipse.swt.widgets.TreeItem;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.alerts.IScanInstance;\nimport com.subgraph.vega.api.model.alerts.IScanAlert;\nimport com.subgraph.vega.ui.util.Activator;\n\npublic class ExportWizardPageTwo extends WizardPage {\n\n\tprotected Label label;\n\tprivate Composite container;\n\tprivate final IModel model;\n\tprivate IScanInstance scanInstance = null;\n\tprivate final Logger logger = Logger.getLogger(\"export-wizard\");\n\tprivate final SimpleDateFormat dateFormat = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");\n\t\n    Tree alertsTree;\n    ScrolledComposite treeContainer;\n    \n\tprivate final static String SCAN_IMAGE = \"/icons/scanner.png\";\n\tprivate final static String PROXY_IMAGE = \"/icons/proxy.png\";\n\n\tprotected ExportWizardPageTwo(IScanInstance s) {\n\t\tsuper(\"Alerts\");\n\t\tsetTitle(\"Scans to include in report.\");\n\n\t\tscanInstance = s;\n\t\t\n\t\tmodel = Activator.getDefault().getModel();\n\t\tif (model == null) {\n\t\t\tlogger.warning(\"Failed to obtain reference to model\");\n\t\t\treturn;\n\t\t}\n\t\t//model.getCurrentWorkspace().getScanAlertRepository().\n\n\t}\n\n\t@Override\n\tpublic void createControl(Composite parent) {\n\t\t\n\t\tcontainer = new Composite(parent, SWT.NONE);\n\t\tGridLayout layout = new GridLayout();\n\t\tTreeItem scanInstanceItem = null;\n\t\t\n\t\tcontainer.setLayout(layout);\n\t\tlayout.numColumns = 2;\n\t\tsetPageComplete(false);\n\t    \n\t\tLabel selectAllLabel = new Label(container, SWT.NONE);\n\t\tselectAllLabel.setText(\"Select all:\");\n\t\tButton selectAllButton = new Button(container, SWT.CHECK);\n\t\t\n\t\tselectAllButton.addSelectionListener(new SelectionListener() { \n\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\n\t\t\t\tif (selectAllButton.getSelection() == true) {\n\t\t\t\t\tfor (TreeItem t: alertsTree.getItems()) {\n\t\t\t\t\t\tt.setChecked(true);\n\t\t\t\t\t\tsetPageComplete(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t  \t\t\ttreeContainer.setOrigin (0, 10);\n\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t\t// TODO Auto-generated method stub\n\t\t\t\t\n\t\t\t}}); \n\t\t\n\t\ttreeContainer = new ScrolledComposite (container, SWT.VERTICAL);\n\t\t\n\t\tGridData treeContainerGridData = new GridData();\n\t\ttreeContainerGridData.horizontalSpan = 2;\n\t\ttreeContainerGridData.horizontalAlignment = GridData.FILL;\n\t\ttreeContainer.setLayoutData(treeContainerGridData);\n\t\ttreeContainer.setBounds (10, 10, 280, 200);\n\t\t\n\t\talertsTree = new Tree(treeContainer, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL\n\t            | SWT.H_SCROLL | SWT.MULTI);\n\t\t\n\n\t    IScanInstance proxyScanInstance = model.getCurrentWorkspace().getScanAlertRepository().getProxyScanInstance(); \n\t\tif (proxyScanInstance != null) {\n\t\t\tTreeItem item = new TreeItem(alertsTree, SWT.NONE);\n\t\t\titem.setText(\"Proxy alerts (\" + model.getCurrentWorkspace().getScanAlertRepository().getProxyScanInstance().getAllAlerts().size() + \")\");\t\n\t\t\t// TODO: If proxy scan is enabled, we probably shouldn't be letting the user export its alerts, but maybe we don't care..\n\t\t\titem.setImage(ImageDescriptor.createFromURL(getClass().getResource(PROXY_IMAGE)).createImage());\n\t\t\titem.setData(proxyScanInstance.getAllAlerts());\n\t\t}\n\n\t\tfor (IScanInstance s: model.getCurrentWorkspace().getScanAlertRepository().getAllScanInstances()) {\n\t\t\tString time = \"\";\n\t\t\tif (s.getStartTime() != null && \n\t\t\t\t\t((s.getScanStatus() == IScanInstance.SCAN_CANCELLED) || (s.getScanStatus() == IScanInstance.SCAN_COMPLETED))) {\n\t\t\t\tTreeItem item = new TreeItem(alertsTree, SWT.NONE);\n\t\t\t\ttime = dateFormat.format(s.getStartTime());\n\t\t\t\titem.setText(time + \" [\" + statusToString(s.getScanStatus()) + \"] (\"+s.getAllAlerts().size()+\")\");\n\t\t\t\titem.setImage(ImageDescriptor.createFromURL(getClass().getResource(SCAN_IMAGE)).createImage());\n\t\t\t\titem.setData(s.getAllAlerts());\n\t\t\t\tif (scanInstance != null) {\n\t\t\t\t\tif (s.getScanId() == scanInstance.getScanId()) {\n\t\t\t\t\t\titem.setChecked(true);\n\t\t\t\t\t\tsetPageComplete(true);\n\t\t\t\t\t\tscanInstanceItem = item;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\ttreeContainer.setContent(alertsTree);\n\n\t    final int width = treeContainer.getClientArea ().width;\n\n\t\tint height = alertsTree.computeSize (SWT.DEFAULT, SWT.DEFAULT).y;\n\t\talertsTree.setSize (width, height > 280 ? 280 : height);\n\t\t\n\t\talertsTree.addTreeListener (new TreeListener () {\n\t\t\t@Override\n\t\t\tpublic void treeExpanded (TreeEvent e) {\n\t\t\t\tint height = alertsTree.computeSize (SWT.DEFAULT, SWT.DEFAULT).y;\n\t\t\t\talertsTree.setSize (width, height);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void treeCollapsed (TreeEvent e) {\n\t\t\t\tint height = alertsTree.computeSize (SWT.DEFAULT, SWT.DEFAULT).y;\n\t\t\t\talertsTree.setSize (width, height);\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t});\n\t\t\n\t\talertsTree.addSelectionListener(new SelectionAdapter() {\n\t\t      public void widgetSelected(SelectionEvent e) {\n\t\t          TreeItem ti = (TreeItem) e.item;\n\t\t          if (ti.getChecked() == false) {\n\t\t        \t  if (selectAllButton.getSelection() == true) {\n\t\t        \t\t  selectAllButton.setSelection(false);\n\t\t        \t  }\n\t\t        \t\n\t\t          }\n\t\t          \n\t\t          boolean anyChecked = false;\n\t\t          for (TreeItem t : alertsTree.getItems()) {\n\t\t        \t  if (t.getChecked() == true) {\n\t\t        \t\tanyChecked = true;\n\t\t        \t  }\n\t\t          }\n\t\t          setPageComplete(anyChecked);\n\t\t      }\n\t\t\t\n\t\t});\n\t\t\n\n\t\tsetControl(container);\n\t\t\n\t\tif (scanInstanceItem != null) {\n\t\t\tfor (TreeItem sItem : alertsTree.getItems()) {\n\t\t\t\tif (sItem == scanInstanceItem) {\n\t\t\t\t\tRectangle itemRectangle = sItem.getBounds();\n\t\t\t\t\tRectangle clientArea = treeContainer.getClientArea();\n\t\t\t\t\tPoint origin = treeContainer.getOrigin();\n\t\t\t\t\tif (itemRectangle.x < origin.x || itemRectangle.y < origin.y\n\t\t\t\t\t\t\t|| itemRectangle.x + itemRectangle.width > origin.x + clientArea.width\n\t\t\t\t\t\t\t|| itemRectangle.y + itemRectangle.height > origin.y + clientArea.height) {\n\t\t\t\t\t\ttreeContainer.setOrigin(0, itemRectangle.y);\n\t\t\t\t\t\torigin = treeContainer.getOrigin();\n\t\t\t\t\t\ttreeContainer.setOrigin(new Point(sItem.getBounds().x, sItem.getBounds().y));\n\t\t\t\t\t} \n\t\t\t\t\telse {\n\t\t\t\t\t\tSystem.out.println(\"nope\");\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\t\n\t}\n\t\n\t\n\tprotected List<IScanAlert> allAlertsFromTree() {\n\t\t\n\t\tList<IScanAlert> alerts = new ArrayList<IScanAlert>();\n\t\t\t\t\n\t\tfor (TreeItem t : alertsTree.getItems()) {\n\t\t\tif (t.getChecked() == true) {\n\t\t//\t\tIScanInstance s = (IScanInstance)(t.getData());\n\t\t\t\tList<IScanAlert> scanInstanceAlerts = (List<IScanAlert>) t.getData();\n\t\t\t\t//s.getAllAlerts();\n\t\t\t\talerts.addAll(scanInstanceAlerts);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn alerts;\n\t\t\n\t}\n\t\n\tprivate String statusToString(int status) {\n\t\t\n\t\tString s = \"\";\n\t\t\n\t\tswitch(status) {\n\t\t\n\t\tcase IScanInstance.SCAN_PROBING:\n\t\t\ts = \"Probing Server\";\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_STARTING:\n\t\t\ts =  \"Starting\";\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_AUDITING:\n\t\t\ts = \"Auditing\";\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_CANCELLED:\n\t\t\ts = \"Cancelled\";\n\t\t\tbreak;\n\t\tcase IScanInstance.SCAN_COMPLETED:\n\t\t\ts = \"Completed\";\n\t\t\tbreak;\n\t\t}\n\t\treturn s;\n\t\n\t}\n\t\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/images/ImageCache.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.images;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.SWT;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\n\npublic class ImageCache {\n\tprivate final String pluginId;\n\tprivate final Map<ImageDescriptor, Image> imageMap = new HashMap<ImageDescriptor, Image>();\n\tprivate final Map<String, Image> disabledMap = new HashMap<String, Image>();\n\t\n\tpublic ImageCache(String pluginId) {\n\t\tthis.pluginId = pluginId;\n\t}\n\t\n\tpublic Image get(String key) {\n\t\treturn get(getDescriptor(key));\n\t}\n\t\n\tpublic Image getDisabled(String key) {\n\t\tsynchronized (disabledMap) {\n\t\t\tfinal Image image = disabledMap.get(key);\n\t\t\tif(image == null)\n\t\t\t\treturn getDisabledImageAndCache(key);\n\t\t\telse\n\t\t\t\treturn image;\n\t\t}\n\t}\n\t\n\tprivate Image getDisabledImageAndCache(String key) {\n\t\tfinal Image originalImage = get(key);\n\t\tif(originalImage == null)\n\t\t\treturn null;\n\t\tfinal Image newImage = new Image(originalImage.getDevice(), originalImage, SWT.IMAGE_GRAY);\n\t\tdisabledMap.put(key, newImage);\n\t\treturn newImage;\n\t}\n\t\n\tpublic Image get(ImageDescriptor descriptor) {\n\t\tif(descriptor == null)\n\t\t\treturn null;\n\t\tsynchronized (imageMap) {\n\t\t\tfinal Image image = imageMap.get(descriptor);\n\t\t\tif(image == null)\n\t\t\t\treturn getImageAndCache(descriptor);\n\t\t\treturn image;\n\t\t}\n\t}\n\tprivate ImageDescriptor getDescriptor(String key) {\n\t\treturn AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, key);\n\t}\n\t\n\tprivate Image getImageAndCache(ImageDescriptor descriptor) {\n\t\tfinal Image image = descriptor.createImage();\n\t\timageMap.put(descriptor, image);\n\t\treturn image;\n\t}\n\t\n\tpublic void dispose() {\n\t\tsynchronized (imageMap) {\n\t\t\tfor(Image image: imageMap.values())\n\t\t\t\timage.dispose();\n\t\t}\n\t\timageMap.clear();\n\t\tsynchronized (disabledMap) {\n\t\t\tfor(Image image: disabledMap.values())\n\t\t\t\timage.dispose();\n\t\t}\n\t\tdisabledMap.clear();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/modules/ModuleRegistryCheckStateProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.modules;\n\nimport org.eclipse.jface.viewers.CheckStateChangedEvent;\nimport org.eclipse.jface.viewers.CheckboxTreeViewer;\nimport org.eclipse.jface.viewers.ICheckStateListener;\nimport org.eclipse.jface.viewers.ICheckStateProvider;\n\nimport com.subgraph.vega.api.scanner.modules.IEnableableModule;\n\npublic class ModuleRegistryCheckStateProvider implements ICheckStateProvider, ICheckStateListener {\n\n\tprivate final CheckboxTreeViewer viewer;\n\tprivate ModuleTreeData treeData;\n\t\n\tpublic ModuleRegistryCheckStateProvider(CheckboxTreeViewer viewer) {\n\t\tthis.viewer = viewer;\n\t}\n\n\t@Override\n\tpublic boolean isChecked(Object element) {\n\t\tif(element instanceof IEnableableModule) {\n\t\t\tfinal IEnableableModule m = (IEnableableModule) element;\n\t\t\treturn m.isEnabled();\n\t\t} else if((element instanceof String) && (treeData != null)) {\n\t\t\tfinal String category = (String) element;\n\t\t\treturn treeData.someEnabledInCategory(category);\n\t\t}\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic boolean isGrayed(Object element) {\n\t\tif(!(element instanceof String))\n\t\t\treturn false;\n\t\tif(treeData == null)\n\t\t\treturn false;\n\t\tfinal String category = (String) element;\n\t\treturn (treeData.someEnabledInCategory(category) && !treeData.allEnabledInCategory(category));\n\t}\n\n\tprivate void setEnableStateForCategory(String category, boolean state) {\n\t\tif(treeData == null)\n\t\t\treturn;\n\t\telse\n\t\t\ttreeData.setEnableStateForCategory(category, state);\n\t}\n\n\tvoid setTreeData(ModuleTreeData treeData) {\n\t\tthis.treeData = treeData;\n\t}\n\n\t@Override\n\tpublic void checkStateChanged(CheckStateChangedEvent event) {\n\t\tif(event.getElement() instanceof IEnableableModule) {\n\t\t\tfinal IEnableableModule m = (IEnableableModule) event.getElement();\n\t\t\tm.setEnabled(event.getChecked());\n\t\t\tviewer.refresh();\n\t\t} else if(event.getElement() instanceof String) {\n\t\t\tfinal String category = (String) event.getElement();\n\t\t\tsetEnableStateForCategory(category, event.getChecked());\n\t\t\tviewer.setSubtreeChecked(event.getElement(), event.getChecked());\n\t\t\tviewer.refresh();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/modules/ModuleRegistryContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.modules;\n\nimport java.util.Arrays;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\n\npublic class ModuleRegistryContentProvider implements ITreeContentProvider {\n\n\tprivate final Object[] EMPTY_OBJECT_ARRAY = new Object[0];\n\tprivate final ModuleRegistryCheckStateProvider checkStateProvider;\n\tprivate ModuleTreeData treeData;\n\t\n\tpublic ModuleRegistryContentProvider(ModuleRegistryCheckStateProvider checkStateProvider) {\n\t\tthis.checkStateProvider = checkStateProvider;\n\t}\n\n\t@Override\n\tpublic void dispose() {\n\t}\n\n\t@Override\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tif (newInput instanceof IScannerModule[]) {\n\t\t\tIScannerModule[] modules = (IScannerModule[]) newInput;\n\t\t\ttreeData = new ModuleTreeData(Arrays.asList(modules));\n\t\t\tcheckStateProvider.setTreeData(treeData);\t\n\t\t}\t\n\t}\n\n\t@Override\n\tpublic Object[] getElements(Object inputElement) {\n\t\tif(treeData != null)\n\t\t\treturn treeData.getAllCategories().toArray();\n\t\telse\n\t\t\treturn EMPTY_OBJECT_ARRAY;\n\t}\n\n\t@Override\n\tpublic Object[] getChildren(Object parentElement) {\n\t\tif ((parentElement instanceof String) && (treeData != null)) {\n\t\t\treturn treeData.getModuleListForCategory((String) parentElement).toArray();\n\t\t}\n\t\treturn EMPTY_OBJECT_ARRAY;\n\t}\n\n\t@Override\n\tpublic Object getParent(Object element) {\n\t\tif (element instanceof IScannerModule) \n\t\t\treturn ((IScannerModule) element).getModuleCategoryName();\n\t\telse\n\t\t\treturn null;\n\t}\n\n\t@Override\n\tpublic boolean hasChildren(Object element) {\n\t\tif ((element instanceof String) && (treeData != null)) {\n\t\t\treturn treeData.getModuleListForCategory((String) element).size() > 0;\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/modules/ModuleRegistryLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.modules;\n\nimport org.eclipse.jface.viewers.LabelProvider;\n\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\n\npublic class ModuleRegistryLabelProvider extends LabelProvider {\n\n\tpublic String getText(Object element) {\n\t\tif (element instanceof IScannerModule)\n\t\t\treturn ((IScannerModule) element).getModuleName();\n\t\telse if (element instanceof String)\n\t\t\treturn (String) element;\n\t\telse\n\t\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/modules/ModuleTreeData.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.modules;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport com.subgraph.vega.api.scanner.modules.IEnableableModule;\nimport com.subgraph.vega.api.scanner.modules.IScannerModule;\n\npublic class ModuleTreeData {\n\n\tprivate final Map<String, List<IScannerModule>> categoryToModules;\n\t\n\tModuleTreeData(List<IScannerModule> modules) {\n\t\tcategoryToModules = new HashMap<String, List<IScannerModule>>();\n\t\tpopulateModuleMap(modules);\n\t}\n\n\tprivate void populateModuleMap(List<IScannerModule> modules) {\n\t\tfor(IScannerModule m : modules) \n\t\t\tgetModuleListForCategory(m.getModuleCategoryName()).add(m);\n\t}\n\n\tpublic List<IScannerModule> getModuleListForCategory(String categoryName) {\n\t\tif(!categoryToModules.containsKey(categoryName))\n\t\t\tcategoryToModules.put(categoryName, new ArrayList<IScannerModule>());\n\t\treturn categoryToModules.get(categoryName);\n\t}\n\n\tvoid setEnableStateForCategory(String category, boolean state) {\n\t\tfor(IScannerModule m: getModuleListForCategory(category)) {\n\t\t\tif(m instanceof IEnableableModule)\n\t\t\t\t((IEnableableModule)m).setEnabled(state);\n\t\t}\n\t}\n\n\tboolean someEnabledInCategory(String category) {\n\t\tfor(IScannerModule m: getModuleListForCategory(category)) {\n\t\t\tif(m instanceof IEnableableModule) \n\t\t\t\tif(((IEnableableModule)m).isEnabled())\n\t\t\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tboolean allEnabledInCategory(String category) {\n\t\tfor(IScannerModule m: getModuleListForCategory(category)) {\n\t\t\tif(m instanceof IEnableableModule) \n\t\t\t\tif(!((IEnableableModule)m).isEnabled())\n\t\t\t\t\treturn false;\n\t\t}\t\t\n\t\treturn true;\n\t}\n\n\tList<String> getAllCategories() {\n\t\treturn new ArrayList<String>(categoryToModules.keySet());\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/preferencepage/AppearancePreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.preferencepage;\n\nimport org.eclipse.jface.preference.BooleanFieldEditor;\nimport org.eclipse.jface.preference.FieldEditorPreferencePage;\nimport org.eclipse.ui.IWorkbench;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\nimport com.subgraph.vega.ui.util.Activator;\n\npublic class AppearancePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IPreferenceConstants {\n\n\tpublic AppearancePreferencePage() {\n\t\tsuper(GRID);\n\t}\n\n\t@Override\n\tpublic void init(IWorkbench workbench) {\n\t\tsetPreferenceStore(Activator.getDefault().getPreferenceStore());\n\t\tsetDescription(\"General Appearance Configuration\");\n\t}\n\n\t@Override\n\tprotected void createFieldEditors() {\n\t\tfinal BooleanFieldEditor configPopup = new BooleanFieldEditor(P_CONFIG_POPUP, \"Use Popup style configuration dialogs\", getFieldEditorParent());\n\t\taddField(configPopup);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/preferencepage/IPreferenceConstants.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.preferencepage;\n\npublic interface IPreferenceConstants {\n\tpublic static final String P_CONFIG_POPUP = \"ConfigPopup\";\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/preferencepage/PreferenceInitializer.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.preferencepage;\n\nimport org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\nimport org.eclipse.jface.preference.IPreferenceStore;\n\nimport com.subgraph.vega.ui.util.Activator;\n\npublic class PreferenceInitializer extends AbstractPreferenceInitializer implements IPreferenceConstants {\n\n\tpublic PreferenceInitializer() {\n\t\tIPreferenceStore store = Activator.getDefault().getPreferenceStore();\n\t\tstore.setDefault(P_CONFIG_POPUP, true);\n\t}\n\n\t@Override\n\tpublic void initializeDefaultPreferences() {\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/preferences/VegaPreferencePage.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.util.preferences;\n\nimport java.util.ArrayList;\nimport java.util.Iterator;\n\nimport org.eclipse.jface.util.IPropertyChangeListener;\nimport org.eclipse.jface.util.PropertyChangeEvent;\nimport org.eclipse.jface.preference.FieldEditor;\nimport org.eclipse.jface.preference.PreferencePage;\nimport org.eclipse.jface.resource.ImageDescriptor;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.swt.widgets.Control;\nimport org.eclipse.ui.IWorkbenchPreferencePage;\n\n/**\n * A flexible replacement for FieldEditorPreferencePage. Requires the inheriting class to set up fields within\n * createContents(Composite).\n */\npublic abstract class VegaPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IPropertyChangeListener {\n\tprivate ArrayList<FieldEditor> fieldList = new ArrayList<FieldEditor>();\n\n    protected VegaPreferencePage() {\n        this(\"\");\n    }\n\n    protected VegaPreferencePage(String title) {\n        super(title);\n    }\n\n    protected VegaPreferencePage(String title, ImageDescriptor image) {\n        super(title, image);\n    }\n\n\t@Override\n\tprotected Control createContents(Composite parent) {\n\t\tControl control = createPage(parent);\n\t    for (Iterator<FieldEditor> iter = fieldList.iterator(); iter.hasNext();) {\n\t    \tFieldEditor editor = iter.next();\n\t\t\teditor.setPage(this);\n\t\t\teditor.setPropertyChangeListener(this);\n\t\t\teditor.setPreferenceStore(getPreferenceStore());\n\t    \teditor.load();\n\t    }\n\t\tcheckState();\n\t\treturn control;\n\t}\n\n\t/**\n\t * Create a SWT control containing page contents for the preferences page.\n\t * @param parent Parent control.\n\t * @return Created control.\n\t */\n\tabstract protected Control createPage(Composite parent);\n\t\n\t@Override\n\tprotected void performDefaults() {\n\t    super.performDefaults();\n\t    for (Iterator<FieldEditor> iter = fieldList.iterator(); iter.hasNext();) {\n\t    \t((FieldEditor) iter.next()).loadDefault();\n\t    }\n\t\tcheckState();\n\t}\n\n\t@Override\n\tpublic boolean performOk() {\n\t    boolean rv = super.performOk();\n\t    if (rv) {\n\t\t    for (Iterator<FieldEditor> iter = fieldList.iterator(); iter.hasNext();) {\n\t\t    \t((FieldEditor) iter.next()).store();\n\t\t    }\n\t    }\n\t    return rv;\n\t}\n\n\t@Override\n\tpublic void propertyChange(PropertyChangeEvent event) {\n\t\tif (event.getProperty().equals(FieldEditor.IS_VALID)) {\n            boolean value = ((Boolean) event.getNewValue()).booleanValue();\n            if (value) {\n                checkState();\n            } else {\n                setValid(false);\n            }\n        }\n\t}\n\n    /**\n     * Add a field editor to the list of field editors managed on the page.\n     * @param editor FieldEditor.\n     */\n\tprotected void addField(FieldEditor editor) {\n\t\tfieldList.add(editor);\n\t}\n\n\tprivate void checkState() {\n\t    for (Iterator<FieldEditor> iter = fieldList.iterator(); iter.hasNext();) {\n\t    \tif (!((FieldEditor) iter.next()).isValid()) {\n\t    \t\tsetValid(false);\n\t    \t\treturn;\n\t    \t}\n\t    }\n\t    setValid(true);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>com.subgraph.vega.ui.web</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.ManifestBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.pde.SchemaBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.pde.PluginNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/META-INF/MANIFEST.MF",
    "content": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: Web\nBundle-SymbolicName: com.subgraph.vega.ui.web;singleton:=true\nBundle-Version: 1.0.0.qualifier\nBundle-Activator: com.subgraph.vega.ui.web.Activator\nBundle-Vendor: SUBGRAPH\nRequire-Bundle: org.eclipse.ui,\n org.eclipse.core.runtime\nBundle-RequiredExecutionEnvironment: JavaSE-1.7,\n JavaSE-1.6\nBundle-ActivationPolicy: lazy\nImport-Package: com.google.common.collect,\n com.subgraph.vega.api.crawler,\n com.subgraph.vega.api.events,\n com.subgraph.vega.api.model,\n com.subgraph.vega.api.model.scope,\n com.subgraph.vega.api.model.web,\n com.subgraph.vega.ui.scanner,\n com.subgraph.vega.ui.util\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/build.properties",
    "content": "source.. = src/\noutput.. = bin/\nbin.includes = META-INF/,\\\n               .,\\\n               plugin.xml,\\\n               icons/\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/epl-v10.html",
    "content": "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n<title>Eclipse Public License - Version 1.0</title>\n<style type=\"text/css\">\n  body {\n    size: 8.5in 11.0in;\n    margin: 0.25in 0.5in 0.25in 0.5in;\n    tab-interval: 0.5in;\n    }\n  p {  \t\n    margin-left: auto;\n    margin-top:  0.5em;\n    margin-bottom: 0.5em;\n    }\n  p.list {\n  \tmargin-left: 0.5in;\n    margin-top:  0.05em;\n    margin-bottom: 0.05em;\n    }\n  </style>\n\n</head>\n\n<body lang=\"EN-US\">\n\n<p align=center><b>Eclipse Public License - v 1.0</b></p>\n\n<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\nPUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR\nDISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS\nAGREEMENT.</p>\n\n<p><b>1. DEFINITIONS</b></p>\n\n<p>&quot;Contribution&quot; means:</p>\n\n<p class=\"list\">a) in the case of the initial Contributor, the initial\ncode and documentation distributed under this Agreement, and</p>\n<p class=\"list\">b) in the case of each subsequent Contributor:</p>\n<p class=\"list\">i) changes to the Program, and</p>\n<p class=\"list\">ii) additions to the Program;</p>\n<p class=\"list\">where such changes and/or additions to the Program\noriginate from and are distributed by that particular Contributor. A\nContribution 'originates' from a Contributor if it was added to the\nProgram by such Contributor itself or anyone acting on such\nContributor's behalf. Contributions do not include additions to the\nProgram which: (i) are separate modules of software distributed in\nconjunction with the Program under their own license agreement, and (ii)\nare not derivative works of the Program.</p>\n\n<p>&quot;Contributor&quot; means any person or entity that distributes\nthe Program.</p>\n\n<p>&quot;Licensed Patents&quot; mean patent claims licensable by a\nContributor which are necessarily infringed by the use or sale of its\nContribution alone or when combined with the Program.</p>\n\n<p>&quot;Program&quot; means the Contributions distributed in accordance\nwith this Agreement.</p>\n\n<p>&quot;Recipient&quot; means anyone who receives the Program under\nthis Agreement, including all Contributors.</p>\n\n<p><b>2. GRANT OF RIGHTS</b></p>\n\n<p class=\"list\">a) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free copyright license to reproduce, prepare derivative works\nof, publicly display, publicly perform, distribute and sublicense the\nContribution of such Contributor, if any, and such derivative works, in\nsource code and object code form.</p>\n\n<p class=\"list\">b) Subject to the terms of this Agreement, each\nContributor hereby grants Recipient a non-exclusive, worldwide,\nroyalty-free patent license under Licensed Patents to make, use, sell,\noffer to sell, import and otherwise transfer the Contribution of such\nContributor, if any, in source code and object code form. This patent\nlicense shall apply to the combination of the Contribution and the\nProgram if, at the time the Contribution is added by the Contributor,\nsuch addition of the Contribution causes such combination to be covered\nby the Licensed Patents. The patent license shall not apply to any other\ncombinations which include the Contribution. No hardware per se is\nlicensed hereunder.</p>\n\n<p class=\"list\">c) Recipient understands that although each Contributor\ngrants the licenses to its Contributions set forth herein, no assurances\nare provided by any Contributor that the Program does not infringe the\npatent or other intellectual property rights of any other entity. Each\nContributor disclaims any liability to Recipient for claims brought by\nany other entity based on infringement of intellectual property rights\nor otherwise. As a condition to exercising the rights and licenses\ngranted hereunder, each Recipient hereby assumes sole responsibility to\nsecure any other intellectual property rights needed, if any. For\nexample, if a third party patent license is required to allow Recipient\nto distribute the Program, it is Recipient's responsibility to acquire\nthat license before distributing the Program.</p>\n\n<p class=\"list\">d) Each Contributor represents that to its knowledge it\nhas sufficient copyright rights in its Contribution, if any, to grant\nthe copyright license set forth in this Agreement.</p>\n\n<p><b>3. REQUIREMENTS</b></p>\n\n<p>A Contributor may choose to distribute the Program in object code\nform under its own license agreement, provided that:</p>\n\n<p class=\"list\">a) it complies with the terms and conditions of this\nAgreement; and</p>\n\n<p class=\"list\">b) its license agreement:</p>\n\n<p class=\"list\">i) effectively disclaims on behalf of all Contributors\nall warranties and conditions, express and implied, including warranties\nor conditions of title and non-infringement, and implied warranties or\nconditions of merchantability and fitness for a particular purpose;</p>\n\n<p class=\"list\">ii) effectively excludes on behalf of all Contributors\nall liability for damages, including direct, indirect, special,\nincidental and consequential damages, such as lost profits;</p>\n\n<p class=\"list\">iii) states that any provisions which differ from this\nAgreement are offered by that Contributor alone and not by any other\nparty; and</p>\n\n<p class=\"list\">iv) states that source code for the Program is available\nfrom such Contributor, and informs licensees how to obtain it in a\nreasonable manner on or through a medium customarily used for software\nexchange.</p>\n\n<p>When the Program is made available in source code form:</p>\n\n<p class=\"list\">a) it must be made available under this Agreement; and</p>\n\n<p class=\"list\">b) a copy of this Agreement must be included with each\ncopy of the Program.</p>\n\n<p>Contributors may not remove or alter any copyright notices contained\nwithin the Program.</p>\n\n<p>Each Contributor must identify itself as the originator of its\nContribution, if any, in a manner that reasonably allows subsequent\nRecipients to identify the originator of the Contribution.</p>\n\n<p><b>4. COMMERCIAL DISTRIBUTION</b></p>\n\n<p>Commercial distributors of software may accept certain\nresponsibilities with respect to end users, business partners and the\nlike. While this license is intended to facilitate the commercial use of\nthe Program, the Contributor who includes the Program in a commercial\nproduct offering should do so in a manner which does not create\npotential liability for other Contributors. Therefore, if a Contributor\nincludes the Program in a commercial product offering, such Contributor\n(&quot;Commercial Contributor&quot;) hereby agrees to defend and\nindemnify every other Contributor (&quot;Indemnified Contributor&quot;)\nagainst any losses, damages and costs (collectively &quot;Losses&quot;)\narising from claims, lawsuits and other legal actions brought by a third\nparty against the Indemnified Contributor to the extent caused by the\nacts or omissions of such Commercial Contributor in connection with its\ndistribution of the Program in a commercial product offering. The\nobligations in this section do not apply to any claims or Losses\nrelating to any actual or alleged intellectual property infringement. In\norder to qualify, an Indemnified Contributor must: a) promptly notify\nthe Commercial Contributor in writing of such claim, and b) allow the\nCommercial Contributor to control, and cooperate with the Commercial\nContributor in, the defense and any related settlement negotiations. The\nIndemnified Contributor may participate in any such claim at its own\nexpense.</p>\n\n<p>For example, a Contributor might include the Program in a commercial\nproduct offering, Product X. That Contributor is then a Commercial\nContributor. If that Commercial Contributor then makes performance\nclaims, or offers warranties related to Product X, those performance\nclaims and warranties are such Commercial Contributor's responsibility\nalone. Under this section, the Commercial Contributor would have to\ndefend claims against the other Contributors related to those\nperformance claims and warranties, and if a court requires any other\nContributor to pay any damages as a result, the Commercial Contributor\nmust pay those damages.</p>\n\n<p><b>5. NO WARRANTY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS\nPROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS\nOF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,\nANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY\nOR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely\nresponsible for determining the appropriateness of using and\ndistributing the Program and assumes all risks associated with its\nexercise of rights under this Agreement , including but not limited to\nthe risks and costs of program errors, compliance with applicable laws,\ndamage to or loss of data, programs or equipment, and unavailability or\ninterruption of operations.</p>\n\n<p><b>6. DISCLAIMER OF LIABILITY</b></p>\n\n<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT\nNOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING\nWITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR\nDISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED\nHEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>\n\n<p><b>7. GENERAL</b></p>\n\n<p>If any provision of this Agreement is invalid or unenforceable under\napplicable law, it shall not affect the validity or enforceability of\nthe remainder of the terms of this Agreement, and without further action\nby the parties hereto, such provision shall be reformed to the minimum\nextent necessary to make such provision valid and enforceable.</p>\n\n<p>If Recipient institutes patent litigation against any entity\n(including a cross-claim or counterclaim in a lawsuit) alleging that the\nProgram itself (excluding combinations of the Program with other\nsoftware or hardware) infringes such Recipient's patent(s), then such\nRecipient's rights granted under Section 2(b) shall terminate as of the\ndate such litigation is filed.</p>\n\n<p>All Recipient's rights under this Agreement shall terminate if it\nfails to comply with any of the material terms or conditions of this\nAgreement and does not cure such failure in a reasonable period of time\nafter becoming aware of such noncompliance. If all Recipient's rights\nunder this Agreement terminate, Recipient agrees to cease use and\ndistribution of the Program as soon as reasonably practicable. However,\nRecipient's obligations under this Agreement and any licenses granted by\nRecipient relating to the Program shall continue and survive.</p>\n\n<p>Everyone is permitted to copy and distribute copies of this\nAgreement, but in order to avoid inconsistency the Agreement is\ncopyrighted and may only be modified in the following manner. The\nAgreement Steward reserves the right to publish new versions (including\nrevisions) of this Agreement from time to time. No one other than the\nAgreement Steward has the right to modify this Agreement. The Eclipse\nFoundation is the initial Agreement Steward. The Eclipse Foundation may\nassign the responsibility to serve as the Agreement Steward to a\nsuitable separate entity. Each new version of the Agreement will be\ngiven a distinguishing version number. The Program (including\nContributions) may always be distributed subject to the version of the\nAgreement under which it was received. In addition, after a new version\nof the Agreement is published, Contributor may elect to distribute the\nProgram (including its Contributions) under the new version. Except as\nexpressly stated in Sections 2(a) and 2(b) above, Recipient receives no\nrights or licenses to the intellectual property of any Contributor under\nthis Agreement, whether expressly, by implication, estoppel or\notherwise. All rights in the Program not expressly granted under this\nAgreement are reserved.</p>\n\n<p>This Agreement is governed by the laws of the State of New York and\nthe intellectual property laws of the United States of America. No party\nto this Agreement will bring a legal action under this Agreement more\nthan one year after the cause of action arose. Each party waives its\nrights to a jury trial in any resulting litigation.</p>\n\n</body>\n\n</html>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/plugin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n   <extension\n         point=\"org.eclipse.ui.views\">\n      <view\n            class=\"com.subgraph.vega.ui.web.views.WebsiteView\"\n            icon=\"icons/websites.png\"\n            id=\"com.subgraph.vega.views.website\"\n            name=\"Website View\"\n            restorable=\"true\">\n      </view>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.commands\">\n      <command\n            id=\"com.subgraph.vega.ui.command.hideUnvisited\"\n            name=\"Hide Unvisited Sites\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.command.filterByScope\"\n            name=\"Filter By Scope\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.web.expandAll\"\n            name=\"Expand All Web Tree\">\n      </command>\n      <command\n            id=\"com.subgraph.vega.ui.web.collapseAll\"\n            name=\"Collapse All Web Tree\">\n      </command>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.menus\">\n      <menuContribution\n            allPopups=\"false\"\n            locationURI=\"toolbar:com.subgraph.vega.views.website\">\n         <command\n               commandId=\"com.subgraph.vega.ui.command.hideUnvisited\"\n               icon=\"icons/hide_unvisited.png\"\n               label=\"Hide Unvisited Sites\"\n               style=\"toggle\"\n               tooltip=\"Hide unvisited websites and paths\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.ui.command.filterByScope\"\n               icon=\"icons/scope.png\"\n               label=\"Filter By Scope\"\n               style=\"toggle\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.ui.web.expandAll\"\n               icon=\"icons/expandall.png\"\n               label=\"Expand All\"\n               style=\"push\">\n         </command>\n         <command\n               commandId=\"com.subgraph.vega.ui.web.collapseAll\"\n               icon=\"icons/collapseall.png\"\n               label=\"Collapse All\"\n               style=\"push\">\n         </command>\n      </menuContribution>\n   </extension>\n   <extension\n         point=\"org.eclipse.core.expressions.definitions\">\n      <definition\n            id=\"oneElementSelected\">\n         <with\n               variable=\"selection\">\n            <count\n                  value=\"1\">\n            </count>\n         </with>\n      </definition>\n   </extension>\n   <extension\n         point=\"org.eclipse.ui.handlers\">\n      <handler\n            class=\"com.subgraph.vega.ui.web.commands.HideUnvisitedHandler\"\n            commandId=\"com.subgraph.vega.ui.command.hideUnvisited\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.web.commands.FilterByScopeHandler\"\n            commandId=\"com.subgraph.vega.ui.command.filterByScope\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.web.commands.ExpandAllHandler\"\n            commandId=\"com.subgraph.vega.ui.web.expandAll\">\n      </handler>\n      <handler\n            class=\"com.subgraph.vega.ui.web.commands.CollapseAllHandler\"\n            commandId=\"com.subgraph.vega.ui.web.collapseAll\">\n      </handler>\n   </extension>\n\n</plugin>\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/tree/ITreeAdapter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tree;\n\npublic interface ITreeAdapter<E> {\n\tObject[] getChildren(E item);\n\tint getChildrenCount(E item);\n\tObject getParent(E item);\n\tString getLabel(E item);\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/tree/web/WebHostTreeStrategy.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tree.web;\n\nimport java.util.Collection;\n\nimport com.google.common.collect.Iterables;\n\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.ui.tree.ITreeAdapter;\n\npublic class WebHostTreeStrategy implements ITreeAdapter<IWebHost> {\n\tprivate final WebPathTreeStrategy pathTreeStrategy = new WebPathTreeStrategy();\n\t\n\t@Override\n\tpublic Object[] getChildren(IWebHost item) {\n\t\tIWebPath rootPath = item.getRootPath();\n\t\tboolean noResponses = (rootPath.getGetResponses().size() == 0) && (rootPath.getPostResponses().size() == 0);\n\n\t\tCollection<IWebPath> childPaths = rootPath.getChildPaths();\n\t\t\n\t\tif(childPaths.isEmpty() && noResponses)\n\t\t\treturn new Object[] { rootPath };\n\t\telse if(childPaths.isEmpty())\n\t\t\treturn Iterables.toArray(childPaths, Object.class);\n\t\telse\n\t\t\treturn pathTreeStrategy.getChildren(rootPath);\n\t}\n\n\t@Override\n\tpublic int getChildrenCount(IWebHost item) {\n\t\treturn getChildren(item).length;\n\t}\n\n\t@Override\n\tpublic Object getParent(IWebHost item) {\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic String getLabel(IWebHost item) {\n\t\treturn item.getHostname();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/tree/web/WebModelAdapter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tree.web;\n\n\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\nimport com.subgraph.vega.ui.tree.ITreeAdapter;\n\n\npublic class WebModelAdapter {\n\t\n\tprivate final static Object[] EMPTY_OBJECT_ARRAY = new Object[0];\n\tprivate final ITreeAdapter<IWebHost> webHostAdapter = new WebHostTreeStrategy();\n\tprivate final ITreeAdapter<IWebPath> webPathAdapter = new WebPathTreeStrategy();\n\tprivate final ITreeAdapter<IWebResponse> webResponseAdapter = new WebResponseTreeStrategy();\n\n\t\n\tpublic Object[] getChildren(Object parentElement) {\n\t\tif(parentElement instanceof IWebHost) \n\t\t\treturn webHostAdapter.getChildren((IWebHost) parentElement);\n\t\telse if(parentElement instanceof IWebPath)\n\t\t\treturn webPathAdapter.getChildren((IWebPath) parentElement);\n\t\telse if(parentElement instanceof IWebResponse)\n\t\t\treturn webResponseAdapter.getChildren((IWebResponse) parentElement);\n\t\telse\n\t\t\treturn EMPTY_OBJECT_ARRAY;\n\t}\n\t\n\tpublic Object getParent(Object element) {\n\t\tif(element instanceof IWebHost)\n\t\t\treturn webHostAdapter.getParent((IWebHost) element);\n\t\telse if(element instanceof IWebPath)\n\t\t\treturn webPathAdapter.getParent((IWebPath) element);\n\t\telse if(element instanceof IWebResponse) \n\t\t\treturn webResponseAdapter.getParent((IWebResponse) element);\n\t\telse\n\t\t\treturn null;\n\t}\n\t\n\tpublic boolean hasChildren(Object element) {\n\t\treturn childCount(element) > 0;\n\t}\n\t\n\tprivate int childCount(Object element) {\n\t\tif(element instanceof IWebPath) \n\t\t\treturn webPathAdapter.getChildrenCount((IWebPath) element);\n\t\telse if(element instanceof IWebResponse)\n\t\t\treturn webResponseAdapter.getChildrenCount((IWebResponse) element);\n\t\telse  if(element instanceof IWebHost)\n\t\t\treturn webHostAdapter.getChildrenCount((IWebHost) element);\n\t\telse\n\t\t\treturn 0;\n\t}\n\t\n\tpublic String getLabel(Object element) {\n\t\tif(element instanceof IWebPath)\n\t\t\treturn webPathAdapter.getLabel((IWebPath) element);\n\t\tif(element instanceof IWebResponse)\n\t\t\treturn webResponseAdapter.getLabel((IWebResponse) element);\n\t\tif(element instanceof IWebHost)\n\t\t\treturn webHostAdapter.getLabel((IWebHost) element);\n\t\telse\n\t\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/tree/web/WebPathTreeStrategy.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tree.web;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\nimport com.subgraph.vega.ui.tree.ITreeAdapter;\n\npublic class WebPathTreeStrategy implements ITreeAdapter<IWebPath> {\n\n\t@Override\n\tpublic Object[] getChildren(IWebPath item) {\n\t\tList<Object> children = new ArrayList<Object>();\n\t\tfor(IWebPath cp : item.getChildPaths()) {\n\t\t\tObject node = collapsedNode(item, cp);\n\t\t\tif(node != null)\n\t\t\t\tchildren.add(node);\n\t\t\tfor(IWebResponse r: cp.getGetResponses()) \n\t\t\t\tchildren.add(r);\n\t\t\tfor(IWebResponse r: cp.getPostResponses())\n\t\t\t\tchildren.add(r);\n\t\t}\n\t\t\n\t\treturn children.toArray();\n\t}\n\t\n\tprivate Object collapsedNode(IWebPath root, IWebPath p) {\n\t\tboolean noResponses = (p.getGetResponses().size() == 0) && (p.getPostResponses().size() == 0);\n\t\tif(p.getChildPaths().size() == 1 && noResponses)\n\t\t\treturn collapsedNode(root, p.getChildPaths().iterator().next());\n\t\telse if(p.getChildPaths().isEmpty() && !noResponses) {\n\t\t\tIWebPath pp = p.getParentPath();\n\t\t\tif(pp == null || pp == root)\n\t\t\t\treturn null;\n\t\t\telse\n\t\t\t\treturn pp;\n\t\t} else {\n\t\t\treturn p;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic int getChildrenCount(IWebPath item) {\n\t\treturn getChildren(item).length;\n\t}\n\n\t@Override\n\tpublic Object getParent(IWebPath item) {\n\t\tif(item.getParentPath() == null)\n\t\t\treturn item.getMountPoint().getWebHost();\n\t\telse if(item.getParentPath().getChildPaths().size() == 1)\n\t\t\treturn getParent(item.getParentPath());\n\t\telse\n\t\t\treturn item.getParentPath();\n\t}\n\n\t@Override\n\tpublic String getLabel(IWebPath item) {\n\t\tif(item.getParentPath() == null)\n\t\t\treturn \"/\";\n\t\telse if(getChildrenCount(item) == 0 && (item.getPathComponent().contains(\".\") || item.getMimeType() != null)) {\n\t\t\treturn item.getPathComponent();\n\t\t\t\n\t\t} else {\n\t\t\treturn prevLabel(item) + \"/\" + item.getPathComponent();\n\t\t}\n\t}\n\t\n\tprivate String prevLabel(IWebPath item) {\n\t\tIWebPath pp = item.getParentPath();\n\t\tif(pp.getChildPaths().size() == 1 && pp.getParentPath() != null)\n\t\t\treturn getLabel(pp);\n\t\telse\n\t\t\treturn \"\";\n\t}\n\n\t\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/tree/web/WebResponseTreeStrategy.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.tree.web;\n\nimport com.subgraph.vega.api.model.web.IWebResponse;\nimport com.subgraph.vega.ui.tree.ITreeAdapter;\n\npublic class WebResponseTreeStrategy implements ITreeAdapter<IWebResponse>{\n\n\t@Override\n\tpublic Object[] getChildren(IWebResponse item) {\n\t\treturn new Object[0];\n\t}\n\n\t@Override\n\tpublic int getChildrenCount(IWebResponse item) {\n\t\treturn 0;\n\t}\n\n\t@Override\n\tpublic Object getParent(IWebResponse item) {\n\t\treturn item.getParent();\n\t}\n\n\t@Override\n\tpublic String getLabel(IWebResponse item) {\n\t\treturn getPathLabel(item) + getQueryLabel(item);\n\t}\n\n\tprivate String getPathLabel(IWebResponse item) {\n\t\tString p = item.getPathEntity().getPathComponent();\n\t\tif(p == null || p.isEmpty())\n\t\t\treturn \"/\";\n\t\telse\n\t\t\treturn p;\n\t}\n\tprivate String getQueryLabel(IWebResponse item) {\n\t\tif(item.getQueryString().isEmpty())\n\t\t\treturn \"\";\n\t\telse\n\t\t\treturn \" [\"+ item.getQueryString() +\"]\";\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/Activator.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.web;\n\nimport org.eclipse.ui.plugin.AbstractUIPlugin;\nimport org.osgi.framework.BundleContext;\nimport org.osgi.util.tracker.ServiceTracker;\n\nimport com.subgraph.vega.api.crawler.IWebCrawlerFactory;\nimport com.subgraph.vega.api.model.IModel;\n\n/**\n * The activator class controls the plug-in life cycle\n */\npublic class Activator extends AbstractUIPlugin {\n\n\t// The plug-in ID\n\tpublic static final String PLUGIN_ID = \"com.subgraph.vega.ui.web\"; //$NON-NLS-1$\n\n\t// The shared instance\n\tprivate static Activator plugin;\n\t\n\tprivate ServiceTracker<IModel, IModel> modelTracker;\n\tprivate ServiceTracker<IWebCrawlerFactory, IWebCrawlerFactory> crawlerTracker;\n\t\n\t/**\n\t * The constructor\n\t */\n\tpublic Activator() {\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\n\t */\n\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\tplugin = this;\n\t\tmodelTracker = new ServiceTracker<IModel,IModel>(context, IModel.class.getName(), null);\n\t\tmodelTracker.open();\n\t\tcrawlerTracker = new ServiceTracker<IWebCrawlerFactory, IWebCrawlerFactory>(context, IWebCrawlerFactory.class.getName(), null);\n\t\tcrawlerTracker.open();\n\t}\n\n\t/*\n\t * (non-Javadoc)\n\t * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\n\t */\n\tpublic void stop(BundleContext context) throws Exception {\n\t\tplugin = null;\n\t\tsuper.stop(context);\n\t}\n\n\t/**\n\t * Returns the shared instance\n\t *\n\t * @return the shared instance\n\t */\n\tpublic static Activator getDefault() {\n\t\treturn plugin;\n\t}\n\t\n\tpublic IWebCrawlerFactory getWebCrawlerFactory() {\n\t\treturn crawlerTracker.getService();\n\t}\n\t\n\tpublic IModel getModel() {\n\t\treturn modelTracker.getService();\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/commands/CollapseAllHandler.java",
    "content": "package com.subgraph.vega.ui.web.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.web.views.WebsiteView;\n\npublic class CollapseAllHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(activePart instanceof WebsiteView) {\n\t\t\t((WebsiteView)activePart).collapseAll();\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/commands/ExpandAllHandler.java",
    "content": "package com.subgraph.vega.ui.web.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.web.views.WebsiteView;\n\npublic class ExpandAllHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(activePart instanceof WebsiteView) {\n\t\t\t((WebsiteView)activePart).expandAll();\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/commands/FilterByScopeHandler.java",
    "content": "package com.subgraph.vega.ui.web.commands;\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.ToolItem;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.web.views.WebsiteView;\n\npublic class FilterByScopeHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(event.getTrigger() instanceof Event) {\n\t\t\tfinal Event e = (Event) event.getTrigger();\n\t\t\tif(e.widget instanceof ToolItem) {\n\t\t\t\tToolItem item = (ToolItem) e.widget;\n\t\t\t\tif(activePart instanceof WebsiteView) {\n\t\t\t\t\t((WebsiteView)activePart).setFilterByScope(item.getSelection());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/commands/HideUnvisitedHandler.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.web.commands;\n\n\nimport org.eclipse.core.commands.AbstractHandler;\nimport org.eclipse.core.commands.ExecutionEvent;\nimport org.eclipse.core.commands.ExecutionException;\nimport org.eclipse.swt.widgets.Event;\nimport org.eclipse.swt.widgets.ToolItem;\nimport org.eclipse.ui.IWorkbenchPart;\nimport org.eclipse.ui.handlers.HandlerUtil;\n\nimport com.subgraph.vega.ui.web.views.WebsiteView;\n\npublic class HideUnvisitedHandler extends AbstractHandler {\n\n\t@Override\n\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tfinal IWorkbenchPart activePart = HandlerUtil.getActivePart(event);\n\t\tif(event.getTrigger() instanceof Event) {\n\t\t\tfinal Event e = (Event) event.getTrigger();\n\t\t\tif(e.widget instanceof ToolItem) {\n\t\t\t\tToolItem item = (ToolItem) e.widget;\n\t\t\t\tif(activePart instanceof WebsiteView) {\n\t\t\t\t\t((WebsiteView)activePart).setHideUnvisitedSites(item.getSelection());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/AbstractScopeAction.java",
    "content": "package com.subgraph.vega.ui.web.views;\n\n\nimport java.net.URI;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.action.Action;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.StructuredViewer;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\n\npublic abstract class AbstractScopeAction extends Action {\n\tprotected final IModel model;\n\tprotected final StructuredViewer viewer;\n\t\n\tAbstractScopeAction(StructuredViewer viewer, IModel model, String text) {\n\t\tthis.model = model;\n\t\tthis.viewer = viewer;\n\t\tsetText(text);\n\t}\n\t\n\t\n\tabstract protected void handleSelectedURI(ITargetScope scope, URI uri);\n\tabstract protected boolean isEnabledForURIs(ITargetScope scope, List<URI> uris);\n\t\n\t@Override\n\tpublic void run() {\n\t\tfinal ITargetScope scope = getCurrentActiveScope();\n\t\tif(scope == null) {\n\t\t\treturn;\n\t\t}\n\t\tfinal IStructuredSelection ss = (IStructuredSelection) viewer.getSelection();\n\t\tfor(Object ob: ss.toList()) {\n\t\t\tURI uri = elementToURI(ob);\n\t\t\tif(uri != null) {\n\t\t\t\thandleSelectedURI(scope, uri);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic boolean isEnabledForSelection() {\n\t\tfinal ITargetScope scope = getCurrentActiveScope();\n\t\tif(scope == null) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tfinal IStructuredSelection ss = (IStructuredSelection) viewer.getSelection();\n\t\tfinal List<URI> uris = new ArrayList<URI>();\n\t\tfor(Object ob : ss.toList()) {\n\t\t\tURI uri = elementToURI(ob);\n\t\t\tif(uri != null) {\n\t\t\t\turis.add(uri);\n\t\t\t}\n\t\t}\n\t\tif(uris.isEmpty()) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn isEnabledForURIs(scope, uris);\n\t\t}\n\t}\n\t\n\tprivate ITargetScope getCurrentActiveScope() {\n\t\tfinal IWorkspace ws = model.getCurrentWorkspace();\n\t\tif(ws == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn ws.getTargetScopeManager().getActiveScope();\n\t}\n\t\n\tprivate URI elementToURI(Object element) {\n\t\tif(element instanceof IWebHost) {\n\t\t\treturn ((IWebHost)element).getUri();\n\t\t} else if (element instanceof IWebPath) {\n\t\t\treturn ((IWebPath)element).getUri();\n\t\t} else if (element instanceof IWebResponse) {\n\t\t\treturn ((IWebResponse)element).getPathEntity().getUri();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/AddScopeAction.java",
    "content": "package com.subgraph.vega.ui.web.views;\n\nimport java.net.URI;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.StructuredViewer;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\n\npublic class AddScopeAction extends AbstractScopeAction {\n\tprivate final static String ADD_TEXT = \"Add to current scope\";\n\tAddScopeAction(StructuredViewer viewer, IModel model) {\n\t\tsuper(viewer, model, ADD_TEXT);\n\t}\n\n\t@Override\n\tprotected void handleSelectedURI(ITargetScope scope, URI uri) {\n\t\tif(!scope.isInsideScope(uri)) {\n\t\t\tscope.addScopeURI(uri);\n\t\t}\n\t}\n\n\t@Override\n\tprotected boolean isEnabledForURIs(ITargetScope scope, List<URI> uris) {\n\t\tfor(URI u: uris) {\n\t\t\tif(!scope.isInsideScope(u)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/ExcludeScopeAction.java",
    "content": "package com.subgraph.vega.ui.web.views;\n\nimport java.net.URI;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.StructuredViewer;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\n\npublic class ExcludeScopeAction extends AbstractScopeAction {\n\tprivate final static String EXCLUDE_TEXT = \"Exclude from current scope\";\n\tExcludeScopeAction(StructuredViewer viewer, IModel model) {\n\t\tsuper(viewer, model, EXCLUDE_TEXT);\n\t}\n\n\t@Override\n\tprotected void handleSelectedURI(ITargetScope scope, URI uri) {\n\t\tif(scope.isInsideScope(uri)) {\n\t\t\tscope.addExclusionURI(uri);\n\t\t}\n\t}\n\n\t@Override\n\tprotected boolean isEnabledForURIs(ITargetScope scope, List<URI> uris) {\n\t\tfor(URI u: uris) {\n\t\t\tif(scope.isInsideScope(u)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/ScopeFilter.java",
    "content": "package com.subgraph.vega.ui.web.views;\n\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerFilter;\n\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.scope.ITargetScope;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\n\npublic class ScopeFilter extends ViewerFilter {\n\n\tprivate final IModel model;\n\t\n\tScopeFilter(IModel model) {\n\t\tthis.model = model;\n\t}\n\t\n\t@Override\n\tpublic boolean select(Viewer viewer, Object parentElement, Object element) {\n\t\tfinal ITargetScope activeScope = getActiveScope();\n\t\tif(activeScope == null) {\n\t\t\treturn true;\n\t\t} else if(element instanceof IWebEntity) {\n\t\t\treturn isFiltered(activeScope, ((IWebEntity)element));\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\t\n\t\n\tprivate boolean isFiltered(ITargetScope scope, IWebEntity entity) {\n\t\tif(entity instanceof IWebHost) {\n\t\t\treturn isHostFiltered(scope, ((IWebHost)entity));\n\t\t} else if(entity instanceof IWebPath) {\n\t\t\treturn isPathFiltered(scope, ((IWebPath)entity));\n\t\t} else if(entity instanceof IWebResponse) {\n\t\t\treturn isPathFiltered(scope, ((IWebResponse)entity).getPathEntity());\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate boolean isHostFiltered(ITargetScope scope, IWebHost host) {\n\t\tif(scope.filter(host.getUri())) {\n\t\t\treturn true;\n\t\t}\n\t\treturn isPathFiltered(scope, host.getRootPath());\n\t}\n\n\tprivate boolean isPathFiltered(ITargetScope scope, IWebPath path) {\n\t\tif(scope.filter(path.getUri())) {\n\t\t\treturn true;\n\t\t}\n\t\tfor(IWebPath child: path.getChildPaths()) {\n\t\t\tif(isPathFiltered(scope, child)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t\n\tprivate ITargetScope getActiveScope() {\n\t\tfinal IWorkspace ws = model.getCurrentWorkspace();\n\t\tif(ws == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn ws.getTargetScopeManager().getActiveScope();\n\t}\n\t\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/Sorter.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.web.views;\n\nimport org.eclipse.jface.viewers.ViewerSorter;\n\nimport com.subgraph.vega.api.model.web.IWebEntity;\n\n\npublic class Sorter extends ViewerSorter {\n\tpublic int category(Object element) {\n\t\tif(!(element instanceof IWebEntity))\n\t\t\treturn 3;\n\t\tfinal IWebEntity we = (IWebEntity) element;\n\t\treturn (we.isVisited()) ? (1) : (2);\n\t}\n\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/WebsiteContentProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.web.views;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.viewers.ITreeContentProvider;\nimport org.eclipse.jface.viewers.StructuredViewer;\nimport org.eclipse.jface.viewers.Viewer;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.NewWebEntityEvent;\nimport com.subgraph.vega.api.model.web.UpdatedWebEntityEvent;\nimport com.subgraph.vega.ui.tree.web.WebModelAdapter;\n\npublic class WebsiteContentProvider implements ITreeContentProvider {\n\tprivate final Object[] NULL_OB = new Object[0];\n\tprivate IWorkspace workspace;\n\tprivate StructuredViewer viewer;\n\tprivate final IEventHandler modelListener = createModelListener();\n\tprivate final List<IWebHost> webHosts = new ArrayList<IWebHost>();\n\tprivate final WebModelAdapter treeAdapter = new WebModelAdapter();\n\t\n\tpublic Object[] getChildren(Object parentElement) {\n\t\treturn treeAdapter.getChildren(parentElement);\n\t}\n\t\n\tpublic Object getParent(Object element) {\n\t\treturn treeAdapter.getParent(element);\n\t}\n\t\n\tpublic boolean hasChildren(Object element) {\n\t\treturn treeAdapter.hasChildren(element);\n\t}\n\t\n\tpublic Object[] getElements(Object inputElement) {\n\t\tif(inputElement instanceof IWorkspace) {\n\t\t\treturn webHosts.toArray(NULL_OB);\n\t\t} else {\n\t\t\treturn treeAdapter.getChildren(inputElement);\n\t\t}\n\t}\n\t\n\tpublic void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\n\t\tif(newInput == null)\n\t\t\tsetNullWorkspace();\n\t\telse if(newInput instanceof IWorkspace)\n\t\t\tsetNewWorkspaceAndViewer((IWorkspace) newInput, (StructuredViewer)viewer);\n\t}\n\t\n\tprivate void setNullWorkspace() {\n\t\twebHosts.clear();\n\t\tworkspace = null;\n\t}\n\t\n\tprivate void setNewWorkspaceAndViewer(IWorkspace newWorkspace, StructuredViewer newViewer) {\n\t\tif(newWorkspace != workspace) {\n\t\t\tif(workspace != null) {\n\t\t\t\tworkspace.getWebModel().removeChangeListener(modelListener);\n\t\t\t}\n\t\t\tworkspace = newWorkspace;\n\t\t\twebHosts.clear();\n\t\t\tworkspace.getWebModel().addChangeListenerAndPopulate(modelListener);\n\t\t\tthis.viewer = newViewer;\n\t\t}\n\t}\n\t\n\tpublic void dispose() { \n\t}\n\t\n\tprivate IEventHandler createModelListener() {\n\t\treturn new IEventHandler() {\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tif(event instanceof NewWebEntityEvent)\n\t\t\t\t\thandleNewWebEntity((NewWebEntityEvent) event);\n\t\t\t\telse if(event instanceof UpdatedWebEntityEvent)\n\t\t\t\t\thandleUpdatedWebEntity((UpdatedWebEntityEvent) event);\n\t\t\t}\n\t\t};\n\t}\n\t\n\tprivate void handleNewWebEntity(NewWebEntityEvent event) {\n\t\tfinal IWebEntity entity = event.getEntity();\n\t\tif(entity instanceof IWebHost) {\n\t\t\twebHosts.add((IWebHost) entity);\n\t\t}\n\t\trefreshViewer();\n\t}\n\t\n\tprivate void handleUpdatedWebEntity(UpdatedWebEntityEvent event) {\n\t\trefreshElement(event.getEntity());\n\t}\n\t\n\tprivate void refreshElement(final IWebEntity element) {\n\t\tguiRun(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tviewer.refresh(element, true);\n\t\t\t}\n\t\t});\n\t}\n\t\n\tprivate void refreshViewer() {\n\t\tguiRun(new Runnable() {\n\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tviewer.refresh(true);\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t});\n\t}\n\t\n\tprivate void guiRun(Runnable runnable) {\n\t\tif(viewer != null && !viewer.getControl().isDisposed()) {\n\t\t\tsynchronized(viewer) {\n\t\t\t\tviewer.getControl().getDisplay().asyncExec(runnable);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/WebsiteLabelProvider.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.web.views;\n\nimport org.eclipse.jface.viewers.IColorProvider;\nimport org.eclipse.jface.viewers.LabelProvider;\nimport org.eclipse.swt.graphics.Color;\nimport org.eclipse.swt.graphics.Image;\nimport org.eclipse.swt.graphics.RGB;\nimport org.eclipse.swt.widgets.Display;\n\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.api.model.web.IWebHost;\nimport com.subgraph.vega.api.model.web.IWebPath;\nimport com.subgraph.vega.api.model.web.IWebResponse;\nimport com.subgraph.vega.ui.tree.web.WebModelAdapter;\nimport com.subgraph.vega.ui.util.ImageCache;\nimport com.subgraph.vega.ui.web.Activator;\n\npublic class WebsiteLabelProvider extends LabelProvider implements IColorProvider {\n\tprivate final static Color UNVISITED_COLOR = new Color(\n\t\t\tDisplay.getCurrent(), new RGB(180, 180, 180));\n\tprivate final static Color IN_SCOPE_BACKGROUND = new Color(Display.getCurrent(), new RGB(230, 230, 250));\n\n\tprivate final static String WEBSITE = \"icons/websites.png\";\n\n\tprivate final static String ARCHIVE = \"icons/mimetype/archive.png\";\n\tprivate final static String AUDIO = \"icons/mimetype/audio.png\";\n\tprivate final static String BINARY = \"icons/mimetype/binary.png\";\n\tprivate final static String EXECUTABLE = \"icons/mimetype/executable.png.png\";\n\tprivate final static String FLASH = \"icons/mimetype/flash.png\";\n\tprivate final static String FONT = \"icons/mimetype/font.png\";\n\tprivate final static String HTML = \"icons/mimetype/html.png\";\n\tprivate final static String IMAGE = \"icons/mimetype/image.png\";\n\tprivate final static String PDF = \"icons/mimetype/pdf.png\";\n\tprivate final static String POSTSCRIPT = \"icons/mimetype/postscript.png\";\n\tprivate final static String RSS = \"icons/mimetype/rss.png\";\n\tprivate final static String SCRIPT = \"icons/mimetype/script.png\";\n\tprivate final static String TEXT = \"icons/mimetype/text.png\";\n\tprivate final static String VIDEO = \"icons/mimetype/video.png\";\n\tprivate final static String XML = \"icons/mimetype/xml.png\";\n\tprivate final static String MSWORD = \"icons/mimetype/msword.png\";\n\tprivate final static String PRESENTATION = \"icons/mimetype/presentation.png\";\n\tprivate final static String SPREADSHEET = \"icons/mimetype/spreadsheet.png\";\n\n\tprivate final ImageCache imageCache = new ImageCache(Activator.PLUGIN_ID);\n\tprivate final WebModelAdapter webAdapter = new WebModelAdapter();\n\tprivate ITargetScopeManager scopeManager;\n\t\n\tvoid setTargetScopeManager(ITargetScopeManager scopeManager) {\n\t\tthis.scopeManager = scopeManager;\n\t}\n\tpublic String getText(Object element) { \n\t\treturn webAdapter.getLabel(element);\n\t}\n\t\n\tpublic Image getImage(Object element) {\n\t\tif(element instanceof IWebHost) {\n\t\t\tIWebHost wh = (IWebHost) element;\n\t\t\tif(wh.isVisited())\n\t\t\t\treturn imageCache.get(WEBSITE);\n\t\t\telse\n\t\t\t\treturn imageCache.getDisabled(WEBSITE);\n\t\t} else {\n\t\t\tfinal String mimeType = getMimeTypeForElement(element);\n\t\t\treturn getMimeImage(mimeType);\n\t\t}\n\t}\n\t\n\tprivate String getMimeTypeForElement(Object element) {\n\t\tif(element instanceof IWebResponse) {\n\t\t\treturn ((IWebResponse)element).getMimeType();\n\t\t} else if(element instanceof IWebPath) {\n\t\t\treturn ((IWebPath) element).getMimeType();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\t@Override\n\tpublic void dispose() {\n\t\timageCache.dispose();\n\t\tsuper.dispose();\n\t}\n\n\t@Override\n\tpublic Color getForeground(Object element) {\n\t\tif(element instanceof IWebEntity) {\n\t\t\tIWebEntity we = (IWebEntity) element;\n\t\t\treturn (we.isVisited()) ? (null) : (UNVISITED_COLOR);\n\t\t}\t\t\t\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic Color getBackground(Object element) {\n\t\tif(element instanceof IWebEntity) {\n\t\t\tif(isInScope((IWebEntity) element)) {\n\t\t\t\treturn IN_SCOPE_BACKGROUND;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\t\n\tprivate boolean isInScope(IWebEntity entity) {\n\t\tif(scopeManager == null) {\n\t\t\treturn false;\n\t\t} else if(entity instanceof IWebHost) {\n\t\t\treturn scopeManager.getActiveScope().filter(((IWebHost)entity).getUri());\n\t\t} else if(entity instanceof IWebPath) {\n\t\t\treturn scopeManager.getActiveScope().filter(((IWebPath)entity).getUri());\n\t\t} else if(entity instanceof IWebResponse){\n\t\t\tIWebPath path = ((IWebResponse)entity).getPathEntity();\n\t\t\treturn scopeManager.getActiveScope().filter(path.getUri());\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate Image getMimeImage(String contentType) {\n\t\tString path = getMimeImagePath(contentType);\n\t\tif(path == null) {\n\t\t\treturn null;\n\t\t} else {\n\t\t\treturn imageCache.get(path);\n\t\t}\n\t}\n\t\n\tprivate String getMimeImagePath(String contentType) {\n\t\tif(contentType == null) return null;\n\t\telse if(contentType.matches(\"text/html.*\")) return HTML;\n\t\telse if(contentType.matches(\"text/(javascript|vbscript|tcl)|application/(x-)?(javascript|perl|tcl|c?sh)\")) return SCRIPT;\n\t\telse if(contentType.matches(\"((text|application)/xml|application/x-(xhtml|xml)).*\")) return XML;\n\t\telse if(contentType.matches(\"text/.*\")) return TEXT;\n\t\telse if(contentType.matches(\"image/.*\")) return IMAGE;\n\t\telse if(contentType.matches(\"audio/.*\")) return AUDIO;\n\t\telse if(contentType.matches(\"video/.*\")) return VIDEO;\n\t\telse if(contentType.matches(\"application/x-(archive|arj|.?zip(-compressed)?|compress|cpio|jar|lha|lhz|rar|rpm|deb|stuffit|g?tar|shar).*\")) return ARCHIVE;\n\t\telse if(contentType.matches(\"application/java-archive\")) return ARCHIVE;\n\t\telse if(contentType.matches(\"application/.*zip.*\")) return ARCHIVE;\n\t\telse if(contentType.matches(\"application.*executable.*\")) return EXECUTABLE;\n\t\telse if(contentType.matches(\"application/x-shockwave.*\")) return FLASH;\n\t\telse if(contentType.matches(\"application/pdf\")) return PDF;\n\t\telse if(contentType.matches(\"application/postscript\")) return POSTSCRIPT;\n\t\telse if(contentType.matches(\"application/msword\")) return MSWORD;\n\t\telse if(contentType.matches(\"application/.*excel\")) return SPREADSHEET;\n\t\telse if(contentType.matches(\"application/.*powerpoint\")) return PRESENTATION;\n\t\telse if(contentType.matches(\"application/.*font.*\")) return FONT;\n\t\telse if(contentType.matches(\"application/(rss|atom)\\\\+xml.*\")) return RSS;\n\t\telse if(contentType.matches(\"application/octet-stream\")) return BINARY;\n\t\telse return null;\n\t\t\n\t}\n}\n"
  },
  {
    "path": "platform/com.subgraph.vega.ui.web/src/com/subgraph/vega/ui/web/views/WebsiteView.java",
    "content": "/*******************************************************************************\n * Copyright (c) 2011 Subgraph.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors:\n *     Subgraph - initial API and implementation\n ******************************************************************************/\npackage com.subgraph.vega.ui.web.views;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.eclipse.jface.action.IMenuListener;\nimport org.eclipse.jface.action.IMenuManager;\nimport org.eclipse.jface.action.IToolBarManager;\nimport org.eclipse.jface.action.MenuManager;\nimport org.eclipse.jface.viewers.DoubleClickEvent;\nimport org.eclipse.jface.viewers.IDoubleClickListener;\nimport org.eclipse.jface.viewers.IStructuredSelection;\nimport org.eclipse.jface.viewers.TreeViewer;\nimport org.eclipse.jface.viewers.Viewer;\nimport org.eclipse.jface.viewers.ViewerFilter;\nimport org.eclipse.swt.widgets.Composite;\nimport org.eclipse.ui.IActionBars;\nimport org.eclipse.ui.part.DrillDownAdapter;\nimport org.eclipse.ui.part.ViewPart;\n\nimport com.subgraph.vega.api.events.IEvent;\nimport com.subgraph.vega.api.events.IEventHandler;\nimport com.subgraph.vega.api.model.IModel;\nimport com.subgraph.vega.api.model.IWorkspace;\nimport com.subgraph.vega.api.model.WorkspaceCloseEvent;\nimport com.subgraph.vega.api.model.WorkspaceOpenEvent;\nimport com.subgraph.vega.api.model.WorkspaceResetEvent;\nimport com.subgraph.vega.api.model.scope.ITargetScopeManager;\nimport com.subgraph.vega.api.model.web.IWebEntity;\nimport com.subgraph.vega.ui.web.Activator;\n\npublic class WebsiteView extends ViewPart implements IDoubleClickListener {\n\n\tprivate static class UnvisitedFilter extends ViewerFilter {\n\n\t\t@Override\n\t\tpublic boolean select(Viewer viewer, Object parentElement, Object element) {\n\t\t\tif(element instanceof IWebEntity) {\n\t\t\t\tfinal IWebEntity entity = (IWebEntity) element;\n\t\t\t\treturn entity.isVisited();\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\tprivate TreeViewer viewer;\n\tprivate DrillDownAdapter drillDown;\n\tprivate WebsiteLabelProvider labelProvider;\n\tprivate ITargetScopeManager scopeManager;\n\tprivate IEventHandler scopeChangeHandler;\n\tprivate AbstractScopeAction addAction;\n\tprivate AbstractScopeAction excludeAction;\n\t\n\tprivate ViewerFilter scopeFilter;\n\tprivate boolean filterUnvisited;\n\tprivate boolean filterByScope;\n\n\t@Override\n\tpublic void createPartControl(Composite parent) {\n\t\tscopeChangeHandler = createScopeChangeHandler();\n\t\tviewer = new TreeViewer(parent);\n\t\tviewer.setContentProvider(new WebsiteContentProvider());\n\t\tlabelProvider = new WebsiteLabelProvider();\n\t\tviewer.setLabelProvider(labelProvider);\n\t\tfinal IModel model = Activator.getDefault().getModel();\n\t\tif(model != null) {\n\t\t\tfinal IWorkspace currentWorkspace = model.addWorkspaceListener(new IEventHandler() {\n\n\t\t\t\t@Override\n\t\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\t\tif(event instanceof WorkspaceOpenEvent)\n\t\t\t\t\t\thandleWorkspaceOpen((WorkspaceOpenEvent) event);\n\t\t\t\t\telse if(event instanceof WorkspaceCloseEvent)\n\t\t\t\t\t\thandleWorkspaceClose((WorkspaceCloseEvent) event);\n\t\t\t\t\telse if(event instanceof WorkspaceResetEvent)\n\t\t\t\t\t\thandleWorkspaceReset((WorkspaceResetEvent) event);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif(currentWorkspace != null) {\n\t\t\t\tsetScopeManager(currentWorkspace.getTargetScopeManager());\n\t\t\t\tviewer.setInput(currentWorkspace);\n\t\t\t}\n\t\t}\n\n\t\tscopeFilter = new ScopeFilter(model);\n\t\tviewer.setSorter(new Sorter());\n\t\tviewer.addDoubleClickListener(this);\n\t\tfinal MenuManager menuManager = new MenuManager(\"\");\n\t\tmenuManager.setRemoveAllWhenShown(true);\n\t\tmenuManager.addMenuListener(createMenuListener());\n\t\taddAction = new AddScopeAction(viewer, model);\n\t\texcludeAction = new ExcludeScopeAction(viewer, model);\n\t\tviewer.getControl().setMenu(menuManager.createContextMenu(viewer.getControl()));\n\t\tgetSite().setSelectionProvider(viewer);\n\t\tdrillDown = new DrillDownAdapter(viewer);\n\t\tcontributeToActionBars();\t\t\n\t}\n\n\tprivate void setScopeManager(ITargetScopeManager scopeManager) {\n\t\tif(this.scopeManager != null) {\n\t\t\tthis.scopeManager.removeActiveScopeChangeListener(scopeChangeHandler);\n\t\t}\n\t\tthis.scopeManager = scopeManager;\n\t\tlabelProvider.setTargetScopeManager(scopeManager);\n\t\tif(scopeManager != null) {\n\t\t\tscopeManager.addActiveScopeChangeListener(scopeChangeHandler);\n\t\t}\n\t}\n\n\tprivate IEventHandler createScopeChangeHandler() {\n\t\treturn new IEventHandler() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(IEvent event) {\n\t\t\t\tviewer.refresh();\n\t\t\t}\n\t\t};\n\t}\n\tpublic void setHideUnvisitedSites(boolean value) {\n\t\tfilterUnvisited = value;\n\t\tsetFiltersForFlags();\n\t}\n\t\n\tpublic void setFilterByScope(boolean value) {\n\t\tfilterByScope = value;\n\t\tsetFiltersForFlags();\n\t}\n\t\n\tprivate void setFiltersForFlags() {\n\t\tfinal List<ViewerFilter> filters = new ArrayList<ViewerFilter>();\n\t\tif(filterUnvisited) {\n\t\t\tfilters.add(new UnvisitedFilter());\n\t\t}\n\t\tif(filterByScope) {\n\t\t\tfilters.add(scopeFilter);\n\t\t}\n\t\tviewer.setFilters(filters.toArray(new ViewerFilter[0]));\n\t}\n\tprivate IMenuListener createMenuListener() {\n\t\treturn new IMenuListener() {\n\t\t\t@Override\n\t\t\tpublic void menuAboutToShow(IMenuManager manager) {\n\t\t\t\tif(addAction.isEnabledForSelection()) {\n\t\t\t\t\tmanager.add(addAction);\n\t\t\t\t}\n\t\t\t\tif(excludeAction.isEnabledForSelection()) {\n\t\t\t\t\tmanager.add(excludeAction);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tprivate void handleWorkspaceOpen(WorkspaceOpenEvent event) {\n\t\tsetScopeManager(event.getWorkspace().getTargetScopeManager());\n\t\tviewer.setInput(event.getWorkspace());\n\t}\n\t\n\tprivate void handleWorkspaceClose(WorkspaceCloseEvent event) {\n\t\tsetScopeManager(null);\n\t\tviewer.setInput(null);\n\t}\n\t\n\tprivate void handleWorkspaceReset(WorkspaceResetEvent event) {\n\t\tsetScopeManager(event.getWorkspace().getTargetScopeManager());\n\t\tviewer.setInput(null);\n\t\tviewer.setInput(event.getWorkspace());\n\t}\n\t\n\t@Override\n\tpublic void setFocus() {\n\t\tviewer.getTree().setFocus();\t\t\n\t}\n\t\n\tprivate void contributeToActionBars() {\n\t\tIActionBars bars = getViewSite().getActionBars();\n\t\tfillToolBar(bars.getToolBarManager());\n\t}\n\t\n\tprivate void fillToolBar(IToolBarManager manager) {\n\t\tdrillDown.addNavigationActions(manager);\n\t}\n\n\t@Override\n\tpublic void doubleClick(DoubleClickEvent event) {\n\t\tfinal IStructuredSelection selection = (IStructuredSelection) event.getSelection();\n\t\tfinal Object element = selection.getFirstElement();\n\t\tif(viewer.isExpandable(element)) {\n\t\t\tviewer.setExpandedState(element, !viewer.getExpandedState(element));\n\t\t}\n\t}\n\t\n\tpublic void collapseAll() {\n\t\tif(viewer != null) {\n\t\t\tviewer.collapseAll();\n\t\t}\n\t}\n\n\tpublic void expandAll() {\n\t\tif(viewer != null) {\n\t\t\tviewer.expandAll();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "scripts/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>scripts</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.wst.jsdt.core.jsNature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "scripts/.settings/.jsdtscope",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"scanner/modules/directory\"/>\n\t<classpathentry kind=\"src\" path=\"scanner/modules/response\"/>\n\t<classpathentry kind=\"src\" path=\"scanner/modules/server\"/>\n\t<classpathentry kind=\"src\" path=\"scanner/prelude\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.wst.jsdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"\"/>\n</classpath>\n"
  },
  {
    "path": "scripts/.settings/org.eclipse.wst.jsdt.ui.superType.container",
    "content": "org.eclipse.wst.jsdt.launching.JRE_CONTAINER"
  },
  {
    "path": "scripts/.settings/org.eclipse.wst.jsdt.ui.superType.name",
    "content": "Global"
  },
  {
    "path": "scripts/scanner/modules/injection/bash-inject.js",
    "content": "var module = {\n\tname: \"Bash Environment Variable Blind OS Injection (CVE-2014-6271, CVE-2014-6278) Checks\",\n\tcategory: \"Injection Modules\",\n\tdifferential: true\n};\n\nvar alteredRequests = [];\n\nvar sleepPayload = \"() { :;}; /bin/sleep 31\"; \nvar payload6271 = \"() { :; }; printf 'Content-Type: text/json\\\\r\\\\n\\\\r\\\\n%s vulnerable %s' 'VEGA123' 'VEGA123'\";\nvar payload6278 = \"() { _; } >_[\\$(\\$())] { printf 'Content-Type: text/html\\\\r\\\\n\\\\r\\\\n%s vulnerable %s' 'VEGA123' 'VEGA123'; }\";\n\nalteredRequests.push({\n\tpayload: payload6271,\n\theader: \"EchoAttackFirst\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6271,\n\theader: \"\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6271,\n\theader: \"Referer\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6271,\n\theader: \"Accept-Language\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6271,\n\theader: \"Cookie\",\n\tcheck: \"echo\"\n});\n\nalteredRequests.push({\n\tpayload: payload6278,\n\theader: \"User-Agent\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6278,\n\theader: \"\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6278,\n\theader: \"Referer\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6278,\n\theader: \"Accept-Language\",\n\tcheck: \"echo\"\n});\nalteredRequests.push({\n\tpayload: payload6278,\n\theader: \"Cookie\",\n\tcheck: \"echo\"\n});\n\n\nalteredRequests.push({\n\tpayload: sleepPayload,\n\theader: \"\",\n\tcheck: \"timeout\"\n});\nalteredRequests.push({\n\tpayload: sleepPayload,\n\theader: \"User-Agent\",\n\tcheck: \"timeout\"\n});\nalteredRequests.push({\n\tpayload: sleepPayload,\n\theader: \"Referer\",\n\tcheck: \"timeout\"\n});\nalteredRequests.push({\n\tpayload: sleepPayload,\n\theader: \"Accept-Language\",\n\tcheck: \"timeout\"\n});\nalteredRequests.push({\n\tpayload: sleepPayload,\n\theader: \"Cookie\",\n\tcheck: \"timeout\"\n});\n\nfunction initialize(ctx) {\n\tvar ps = ctx.getPathState();\n\t\tvar req = ps.createAlteredRequest(\"\", true);\n\t\treq.addHeader(\"User-Agent\",\"() { :; }; printf 'Content-Type: text/json\\\\r\\\\n\\\\r\\\\n%s vulnerable %s' 'VEGA123' 'VEGA123'\");\n\t\tctx.submitRequest(req, process, 0);\n\t \n}\n\nvar checkTiming = function(ctx, currentIndex) {\n\tif (ctx.getSavedResponse(currentIndex).milliseconds > 30000) {\n\t\treturn true;\n\t}\n\treturn false;\n};\n\n\nvar checkOutput = function(ctx, currentIndex) {\n\tif (ctx.getSavedResponse(currentIndex).bodyAsString.indexOf(\"VEGA123 vulnerable VEGA123\") > -1) {\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nfunction process(req, res, ctx) {\n\tif (ctx.hasModuleFailed()) return;\n\tif (res.fetchFail) {\n\t\tctx.error(req, res, \"During Bash Environment Variable injection checks\");\n\t\tctx.setModuleFailed();\n\t\treturn;\n\t}\n\tvar ps = ctx.getPathState();\n\t\n\tvar currentIndex = ctx.getCurrentIndex();\n\tctx.addRequestResponse(req, res);\n\tctx.incrementResponseCount();\n\t\n\tvar type=\"\";\n\tif (alteredRequests[currentIndex].check == \"echo\"){\n\t\t var detected = checkOutput(ctx, currentIndex); /* check for echod output first */\n\t\t type = detected ? \"Executed Commands on Host\" : \"\";\n\t}\n\telse{\n\t\t detected = checkTiming(ctx, currentIndex); /* check for timing attack */\n\t\t type = detected ? \"Blind Timing Analysis Checks\" : \"\";\n\t}\n\tif (detected){\n\t\tvar uri = String(req.requestLine.uri);                                      \n\t\tvar uripart = uri.replace(/\\?.*/, \"\");                                      \n\t\tif ((uripart.length > 2) && (uripart.slice(-1) == \"/\")) {\n\t\t\turipart = uripart.substring(0, uripart.length-1);\n\t\t}\n\n\t\tctx.alert(\"vinfo-bash-inject\", ctx.getSavedRequest(currentIndex), ctx.getSavedResponse(currentIndex), {\n\t\t\toutput: res.bodyAsString,                                                 \n\t\t\tkey: \"vinfo-shell-inject:\" + uripart + \":\" + ps.getFuzzableParameter().name,\n\t\t\tresource: uripart,                                                        \n\t\t\tdetectiontype: type,\n\t\t\tparam: ps.getFuzzableParameter().name                                     \n\t\t});              \n\t} else {\n\t\tif (currentIndex + 1 < alteredRequests.length) {\n\t\t\tif (alteredRequests[currentIndex + 1].header == \"\") {\n\t\t\t\treq = ps.createRequest();\n\t\t\t\treq = ps.createAlteredRequest(alteredRequests[currentIndex + 1].payload, false);\n\t\t\t} else {\n\t\t\t\treq = ps.createRequest();\n\t\t\t\treq.addHeader(alteredRequests[currentIndex + 1].header, alteredRequests[currentIndex + 1].payload);\n\t\t\t}\n\t\t\tctx.submitRequest(req, process, currentIndex + 1);\n\t\t\tvar submitted=currentIndex+1;\n\t\t}\n\t}\n\t\n\tif (ctx.allResponsesReceived()) {\n\t\tps.decrementFuzzCounter();\n\t}\n}\n\n"
  },
  {
    "path": "scripts/scanner/modules/injection/code-injection.js",
    "content": "var module = {\n  name: \"Eval Code Injection\",\n  category: \"Injection Modules\",\n  differential: false\n};\n\nvar alteredRequests = [];\n\nalteredRequests.push(\"phpinfo();\");\nalteredRequests.push(\"echo(str_repeat('vega',5));\");\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n  \n  var phpRegex = /\\.php$/;\n  var isPHP = phpRegex.test(ps.getPath().getUri());\n  if (isPHP) {\n    if (ps.isParametric) {\n      ctx.submitAlteredRequest(process, alteredRequests[0], false, 0);\n      ps.incrementFuzzCounter();\n    }\n  } \n}\n\nfunction checkContent(res, ctx, index) {\n  var phpInfoRegex = /<h1 class=\"p\">PHP Version [0-9.]+<\\/h1>/;\n  var echoStringRegex = /vegavegavegavegavega/;\n \n  if (phpInfoRegex.test(ctx.getSavedResponse(index).bodyAsString)) {\n    return true;\n  } else if (echoStringRegex.test(ctx.getSavedResponse(index).bodyAsString)) {\n    return true;\n  } else {\n    return false;\n  }\n};\n\nfunction process(req, res, ctx) {\n  if (ctx.hasModuleFailed()) return;\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During eval code injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n  \n  var ps = ctx.getPathState();\n  var currentIndex = ctx.getCurrentIndex();\n  ctx.addRequestResponse(req, res);\n  ctx.incrementResponseCount();\n  var detected = checkContent(res, ctx, currentIndex);\n  \n  if (detected) {\n    var uri = String(req.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n    ctx.alert(\"vinfo-code-inject\", ctx.getSavedRequest(currentIndex), ctx.getSavedResponse(currentIndex), {\n      output: res.bodyAsString,\n      key: \"vinfo-code-inject:\" + uripart + \":\" + ps.getFuzzableParameter().name,\n      resource: uripart,\n      detectiontype: \"Response Checks\",\n      param: ps.getFuzzableParameter().name\n    }); \n  } else {\n    if (currentIndex + 1 < alteredRequests.length) {\n      ctx.submitAlteredRequest(process, alteredRequests[currentIndex + 1].commandString, false, currentIndex + 1);\n    }\n  };\n\n  if (ctx.allResponsesReceived()) {\n    ps.decrementFuzzCounter();\n  }\n};\n"
  },
  {
    "path": "scripts/scanner/modules/injection/command-injection.js",
    "content": "var module = {\n\tname: \"Blind OS Command Injection Timing\",\n\tcategory: \"Injection Modules\",\n\tdifferential: false,\n\tdefaultDisabled: true\n};\n\nvar unixMetaChars = ['; ', '\" ; ', \"' ; \", \"| \", '\"| ', \"'| \"]; \nvar windowsMetaChars = ['', '\" '];\n\nvar commands = [\n  {command: \"/bin/sleep 31 ;\", os: \"Linux/Unix\"},\n  {command: \"ping.exe -n 31 127.0.0.1\", os: \"Windows\"},\n\n];\n\nvar alteredRequests = [];\n\nfor (var i = 0; i < commands.length; i++) {\n\tfor (var j = 0; j < unixMetaChars.length; j++) {\n\t\tif (commands[i].os === \"Linux/Unix\") { \n\t\t\talteredRequests.push({ \n\t\t\t\tcommandString: unixMetaChars[j] + commands[i].command,\n\t\t\t\tos: commands[i].os\n\t\t\t});\n\t\t}\n\t}\n\tfor (var k = 0; k < windowsMetaChars.length; k++) {\n\t\tif (commands[i].os === \"Windows\") { \n\t\t\talteredRequests.push({ \n\t\t\t\tcommandString: windowsMetaChars[k] + commands[i].command,\n\t\t\t\tos: commands[i].os\n\t\t\t});\n\t\t}\n\t}\n}\n\nvar checkTiming = function(ctx, currentIndex) {\n\tif (ctx.getSavedResponse(currentIndex).milliseconds > 30000) {\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nfunction initialize(ctx) {\n\tvar ps = ctx.getPathState();\n\tif (ps.isParametric()) {\n\t\tctx.submitAlteredRequest(process, alteredRequests[0].commandString, false, 0);\n    ps.incrementFuzzCounter();\n\t}\n};\n\nfunction process(req, res, ctx) {\n\tif (ctx.hasModuleFailed()) return;\n\tif (res.fetchFail) {\n    ctx.error(req, res, \"During command injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n\t\n\tvar ps = ctx.getPathState();\n\tvar currentIndex = ctx.getCurrentIndex();\n\tctx.addRequestResponse(req, res);\n  ctx.incrementResponseCount();\n  var detected = checkTiming(ctx, currentIndex);\n  \n\tif (detected) {\n\t\tvar uri = String(req.requestLine.uri);\n\t\tvar uripart = uri.replace(/\\?.*/, \"\");\n\t\tctx.alert(\"vinfo-shell-inject\", ctx.getSavedRequest(currentIndex), ctx.getSavedResponse(currentIndex), {\n\t\t\toutput: res.bodyAsString,\n\t\t\tkey: \"vinfo-shell-inject:\" + uripart + \":\" + ps.getFuzzableParameter().name,\n\t\t\tresource: uripart,\n\t\t\tdetectiontype: alteredRequests[currentIndex].os + \" Blind Timing Analysis Checks\",\n\t\t\tparam: ps.getFuzzableParameter().name\n\t\t});\n\t} else {\n\t\tif (currentIndex + 1 < alteredRequests.length) {\n\t\t\tctx.submitAlteredRequest(process, alteredRequests[currentIndex + 1].commandString, false, currentIndex + 1);\n\t\t}\n\t};\n\n\tif (ctx.allResponsesReceived()) {\n\t\tps.decrementFuzzCounter();\n\t}\n};\n"
  },
  {
    "path": "scripts/scanner/modules/injection/cross-domain-policy-audit.js",
    "content": "var module = {\n    name: \"Cross Domain Policy Auditor\",\n    category: \"Injection Modules\"\n};\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n  if (ps.isRootPath() || !ps.isParametric()) {\n    ctx.submitAlteredRequest(process, \"crossdomain.xml\", false, 0);\n  }\n}\n\nfunction process(req, res, ctx) {\n\tif (ctx.hasModuleFailed()) return;\n\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During cross-domain policy auditor checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n  \n  if (ctx.allResponsesReceived()) {\n    ctx.responseChecks(req, res);\n  }\n}\n\n\n"
  },
  {
    "path": "scripts/scanner/modules/injection/format-string-inject.js",
    "content": "var module = {\n  name: \"Format String Injection Checks\",\n  category: \"Injection Modules\",\n  differential: true,\n  defaultDisabled: true\n};\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n\n  if (ps.isParametric()) {\n    ctx.submitMultipleAlteredRequests(process, [\"vega%dn%dn%dn%dn%dn%dn%dn%dn\", \"vega%nd%nd%nd%nd%nd%nd%nd%nd\"]);\n  }\n}\n\nfunction process(req, res, ctx) {\n  if (ctx.hasModuleFailed()) return;\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During format string injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n  ctx.addRequestResponse(req, res);\n  if (ctx.incrementResponseCount() < 2) return;\n\n  if (!ctx.isFingerprintMatch(0, 1)) {\n    ctx.alert(\"vinfo-format-string\", \"Response to %dn%dn%dn... different than to %nd%nd%nd...\", ctx.getSavedRequest(1), ctx.getSavedResponse(1));\n    ctx.responseChecks(1);\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/header-inject.js",
    "content": "var module = {\n  name: \"HTTP Header Injection checks\",\n  category: \"Injection Modules\"\n};\n\nfunction initialize(ctx) {\n  ctx.submitMultipleAlteredRequests(process, [\"bogus\\nVega-Inject:bogus\", \"bogus\\rVega-Inject:bogus\"], true);\n}\n\nfunction process(req, res, ctx) {\n  if (res.hasHeader(\"Vega-Inject\")) {\n    ctx.alert(\"vinfo-header-inject\", request, response, {\n      message: \"Injected Vega-Inject header into response\",\n      resource: request.requestLine.uri\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/http-trace.js",
    "content": "var module = {\n  name: \"HTTP Trace Probes\",\n  category: \"Injection Modules\"\n};\n\nfunction initialize(ctx) {\n\n  var ps = ctx.getPathState();\n  var res = ps.getResponse();\n  var server = \"\";\n  var rootDone = 0;\n\n  if (res == null) {\n    return; // Temporary, possible bug here with null responses in some cases.\n  }\n  \n  var alertkey = \"vinfo-http-trace:\"+server;\n\n  if (ctx.alertExists(alertkey) || (ps.isParametric())) {\n    return;\n  }\n\n  /* Temporary hack to make sure that the root path gets a TRACE probe. */\n  /* Unavoidale race condition. TODO fix this */\n\n\n  var req = ps.createRawRequest(ps.path.getHttpHost(), \"TRACE\", ps.path.getFullPath());\n  req.addHeader(\"SQUEEM1SH\", \"OSS1FR4GE\");\n\n  rootDone = ctx.getIntegerProperty(alertkey);\n\n  if (rootDone == null) {\n      var rootReq = ps.createRawRequest(ps.path.getHttpHost(), \"TRACE\", \"/\");\n      ctx.submitRequest(rootReq, process);\n      ctx.setIntegerProperty(alertkey, 1);\n  }\n\n  ctx.submitRequest(req, process);\n\n}\n\nfunction process(req, res, ctx) {\n\n  if ((res.bodyAsString.indexOf(\"TRACE\") >= 0) && (res.bodyAsString.indexOf(\"OSS1FR4GE\") >= 0)) {\n\n    var server = headerValue(res, \"Server\");  \n\n    ctx.alert(\"vinfo-http-trace\", req, res, {\n      message: \"HTTP Trace Detected\",\n      output: res.bodyAsString,\n      key: \"vinfo-http-trace:\"+server,\n      resource: server\n    });\n  }\n}\n\nfunction headerValue(res, name) {\n  var hdr = res.getFirstHeader(name);\n  if (hdr) return hdr.value\n  else return \"\";\n}\n\n\n"
  },
  {
    "path": "scripts/scanner/modules/injection/integer-overflow-inject.js",
    "content": "var module = {\n  name: \"Integer Overflow Injection Checks\",\n  category: \"Injection Modules\",\n  differential: true,\n  defaultDisabled: true\n};\n\nfunction initialize(ctx) {\n  ctx.submitMultipleAlteredRequests(process, [\"-0000012345\", \"-2147483649\", \"-2147483648\", \"0000012345\", \"2147483647\", \"2147483648\", \"4294967295\", \"4294967296\", \"0000023456\"]);\n}\n\nfunction process(req, res, ctx) {\n  if (ctx.hasModuleFailed()) return;\n\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During integer overflow injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n\n  ctx.addRequestResponse(req, res);\n  if (ctx.incrementResponseCount() < 9) return;\n\n  if (!ctx.isFingerprintMatch(3, 8)) return;\n\n  if (!ctx.isFingerprintMatch(0, 1)) {\n    ctx.alert(\"vinfo-integer-overflow\", ctx.getSavedRequest(1), ctx.getSavedResponse(1), {\n      message: \"Response to -(2^31-1) different than to -12345\",\n      resource: ctx.getSavedRequest(1).requestLine.uri\n    });\n    ctx.responseChecks(1);\n  }\n\n  if (!ctx.isFingerprintMatch(0, 2)) {\n    ctx.alert(\"vinfo-integer-overflow\", ctx.getSavedRequest(2), ctx.getSavedResponse(2), {\n      message: \"Response to -2^31 different than to -12345\",\n      resource: ctx.getSavedRequest(2).requestLine.uri\n    });\n    ctx.responseChecks(2);\n  }\n\n  if (!ctx.isFingerprintMatch(3, 4)) {\n    ctx.alert(\"vinfo-integer-overflow\", ctx.getSavedRequest(4), ctx.getSavedResponse(4), {\n      message: \"Response to 2^31-1 different than to 12345\",\n      resource: ctx.getSavedRequest(4).requestLine.uri\n    });\n    ctx.responseChecks(4);\n  }\n\n  if (!ctx.isFingerprintMatch(3, 5)) {\n    ctx.alert(\"vinfo-integer-overflow\", ctx.getSavedRequest(5), ctx.getSavedResponse(5), {\n      message: \"Response to 2^31 different than to 12345\",\n      resource: ctx.getSavedRequest(5).requestLine.uri\n    });\n    ctx.responseChecks(5);\n  }\n\n  if (!ctx.isFingerprintMatch(3, 6)) {\n    ctx.alert(\"vinfo-integer-overflow\", ctx.getSavedRequest(6), ctx.getSavedResponse(6), {\n      message: \"Response to 2^32-1 different than to 12345\",\n      resource: ctx.getSavedRequest(6).requestLine.uri\n    });\n    ctx.responseChecks(6);\n  }\n\n  if (!ctx.isFingerprintMatch(3, 7)) {\n    ctx.alert(\"vinfo-integer-overflow\", ctx.getSavedRequest(7), ctx.getSavedResponse(7), {\n      message: \"Response to 2^32 different than to 12345\",\n      resource: ctx.getSavedRequest(7).requestLine.uri\n    });\n    ctx.responseChecks(7);\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/local-file-include.js",
    "content": "var module = {\t\n  name: \"Local File Include Checks\",\n  category: \"Injection Modules\",\n  differential: true\n};\n\nvar repeat = function(times, pattern) {\n  return (new Array(times + 1)).join(pattern);\n};\n\nvar checkResponse = function(ctx, currentIndex) {\n\tif (currentIndex === alteredRequests.length - 1) {\n\t\tif (!ctx.isFingerprintMatch(currentIndex, ctx.getOrigResponse().fingerprint)) {\n\t\t\tvar result = {\n\t\t\t\t\tdetected: true,\n\t\t\t\t\ttype: \"differential-lfi\"\n\t\t\t};\n\t\t\tctx.responseChecks(currentIndex);\n\t\t} else {\n\t\t\tvar result = {\n\t\t\t\t\tdetected: false,\n\t\t\t\t\ttype: \"\"\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t} else {\n\t\tvar passwdMatch = /root:.:0:0/; \n\t\tvar bootiniMatch = \"[boot loader]\";\n\t\tvar wininiMatch = \"; for 16-bit app support\";\n\t\t\n\t\tvar javaMatch = \"<web-app\";\n\t\tif (passwdMatch.test(ctx.getSavedResponse(currentIndex).bodyAsString)) {\n\t\t\tctx.addRegexCaseInsensitiveHighlight(\"root:.:0:0\");\n\t\t\tvar result = {\n\t\t\t\t\tdetected: true,\n\t\t\t\t\ttype: \"lfi\"\n\t\t\t};\n\t\t\treturn result;\n\t\t} else if (ctx.getSavedResponse(currentIndex).bodyAsString.indexOf(bootiniMatch) >= 0) {\n\t\t\tctx.addStringHighlight(bootiniMatch);\n\t\t\tvar result = {\n\t\t\t\t\tdetected: true,\n\t\t\t\t\ttype: \"lfi\"\n\t\t\t};\n\t\t\treturn result;\n\t\t} else if (ctx.getSavedResponse(currentIndex).bodyAsString.indexOf(wininiMatch) >= 0) {\n\t\t\tctx.addStringHighlight(wininiMatch);\n\t\t\tvar result = {\n\t\t\t\t\tdetected: true,\n\t\t\t\t\ttype: \"lfi\"\n\t\t\t};\n\t\t\treturn result;\n\t\t} else if (ctx.getSavedResponse(currentIndex).bodyAsString.indexOf(javaMatch) >= 0) {\n\t\t\tctx.addStringHighlight(javaMatch);\n\t\t\tvar result = {\n\t\t\t\t\tdetected: true,\n\t\t\t\t\ttype: \"lfi\"\n\t\t\t};\n\t\t\treturn result;\n\t\t} else {\n\t\t\tvar result = {\n\t\t\t\t\tdetected: false,\n\t\t\t\t\ttype: \"\"\n\t\t\t};\n\t\t  return result;\n\t\t}\n\t}\n};\n\nvar generateAlert = function (ctx, index, type) {\n\tvar uri = String(ctx.getSavedRequest(index).requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\n\tvar ps = ctx.getPathState();\n\t\n\tctx.alert(\"vinfo-\" + type, ctx.getSavedRequest(index), ctx.getSavedResponse(index), {\n\t\toutput: ctx.getSavedResponse(index).bodyAsString,\n\t\tkey: \"vinfo-lfi:\" + uripart + ps.getFuzzableParameter().name,\n\t\tresource: uripart\n\t});\n};\n\n// Sequences are the number of directory traversal sequences to pre-pended to the request\nvar javaSequences = [1, 3, 4, 5];\n\nvar sequenceGenerator = function(number, type) {\n\tif (type == \"Windows\") {\n\t  var pattern = \"..\\\\\";\n\t} else if (type == \"Evasion1\") {\n\t\tvar pattern = \"....//\";\n\t} else if (type == \"Evasion2\") {\n\t\tvar pattern = \"....\\\\\\\\\";\n\t} else {\n\t  var pattern = \"../\";\n\t}\t\n\treturn repeat(number, pattern);\n};\n\nvar alteredRequests = [];\n\n// Linux\nalteredRequests.push({\n\tpayload: \"/\" + sequenceGenerator(12) + \"etc/passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"/\" + sequenceGenerator(12) + \"etc/passwd\\0\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"/etc/passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"/etc/passwd\\0\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/etc/passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/etc/passwd\\0\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(12, \"Windows\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"\\\\\" + sequenceGenerator(12, \"Windows\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:\" + sequenceGenerator(12, \"Windows\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:\\\\\" + sequenceGenerator(12, \"Windows\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(12, \"Evasion1\") + \"etc/passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"/\" + sequenceGenerator(12, \"Evasion1\") + \"etc/passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"//../\" + sequenceGenerator(12, \"Evasion1\") + \"etc/passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(12, \"Evasion2\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"\\\\\" + sequenceGenerator(12, \"Evasion2\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\nalteredRequests.push({\n\tpayload: \"\\\\\\\\..\\\\\" + sequenceGenerator(12, \"Evasion2\") + \"etc\\\\passwd\",\n\ttype: \"Linux\"\n});\n\n// Windows\n\nalteredRequests.push({\n\tpayload: \"C:\\\\boot.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: \"C:/boot.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(12, \"Windows\") + \"boot.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/C:/boot.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/C:\\\\boot.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/boot.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: \"C:/windows/win.ini\"\n});\n\nalteredRequests.push({\n\tpayload: \"C:\\\\windows\\\\win.ini\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/C:/windows/win.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: \"file:/C:/windows/win.ini\",\n\ttype: \"Windows\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(12, \"Windows\") + \"/windows/win.ini\",\n\ttype: \"Windows\"\n});\n\n// Tomcat\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(2) + \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"/\" + sequenceGenerator(2) + \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(2, \"Windows\") + \"WEB-INF\\\\web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"\\\\\" + sequenceGenerator(2, \"Windows\") + \"WEB-INF\\\\web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: sequenceGenerator(2, \"Windows\") + \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"/WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"WEB-INF\\\\web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"\\\\WEB-INF\\\\web.xml\",\n\ttype: \"Java\"\n});\nalteredRequests.push({\n\tpayload: sequenceGenerator(2, \"Evasion1\") + \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"/\" + sequenceGenerator(2, \"Evasion1\") + \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\nalteredRequests.push({\n\tpayload: \"//..\" + sequenceGenerator(2, \"Evasion1\") + \"WEB-INF/web.xml\",\n\ttype: \"Java\"\n});\n\n// Brute-force\n\nfor (var k = 0; k < javaSequences.length; k++) {\n\talteredRequests.push({\n\t\t\tpayload: \"/\" + sequenceGenerator(javaSequences[k]) + \"WEB-INF/web.xml\",\n\t\t\ttype: \"Java\"\n\t});\n}\n\nfor (var k = 0; k < javaSequences.length; k++) {\n\talteredRequests.push({\n\t\t\tpayload: \"\\\\\" + sequenceGenerator(javaSequences[k], \"Windows\") + \"WEB-INF\\\\web.xml\",\n\t\t\ttype: \"Java\"\n\t});\n}\n\n// Path fingerprint requests must go last\nalteredRequests.push({\n\tpayload: \"/./\",\n\ttype: \"Path Fingerprint\"\n});\n\nfunction initialize(ctx) {\n\tvar ps = ctx.getPathState();\n\tif (ps.isParametric()) {\n\t  ctx.submitAlteredRequest(process, alteredRequests[0].payload, false, 0);\n          ps.incrementFuzzCounter();\n        }\n\t\n};\n\nfunction process(req, res, ctx) {\n\tif (ctx.hasModuleFailed()) return;\n\t\n\tif (res.fetchFail) {\n    ctx2.error(req, res, \"During command injection checks\");\n    ctx2.setModuleFailed();\n    return;\n  }\n\t\n\tvar ps = ctx.getPathState();\n\tvar currentIndex = ctx.getCurrentIndex();\n\tctx.addRequestResponse(req, res);\n  ctx.incrementResponseCount();\n  \n  var result = checkResponse(ctx, currentIndex);\n  if (result.detected) {\n  \tgenerateAlert(ctx, currentIndex, result.type);\n  } else {\n  \tif (currentIndex + 1 < alteredRequests.length) {\n\t\t\tctx.submitAlteredRequest(process, alteredRequests[currentIndex + 1].payload, false, currentIndex + 1);\n\t\t}\n  }\n  \n  if (ctx.allResponsesReceived()) {\n\t\tps.decrementFuzzCounter();\n\t}\n\n};\n"
  },
  {
    "path": "scripts/scanner/modules/injection/remote-file-include.js",
    "content": "var module = {\n  name: \"Remote File Include Checks\",\n  category: \"Injection Modules\"\n};\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n\n  if (ps.isParametric()) {\n\n    var injectables = createInjectables(ctx);\n    ctx.submitMultipleAlteredRequests(handler, injectables);\n  }\n}\n\nfunction createInjectables(ctx) {\n  var ps = ctx.getPathState();\n  var injectables = [\"http://www.google.com/humans.txt\", \n                     \"htTp://www.google.com/humans.txt\", \n                     \"hthttpttp://www.google.com/humans.txt\",\n                     \"hthttp://tp://www.google.com/humans.txt\",\n                     \"www.google.com/humans.txt\"];\n  \n  var ret = [];\n\n    for (var i = 0; i < injectables.length; i++)\n      ret.push(injectables[i]);\n   \n  return ret;\n}\n\n\nfunction handler(req, res, ctx) {\n\t\n  var content = \"Google is built by a large team of engineers, designers, researchers, robots\";\n  var ps = ctx.getPathState();\n  var fp = ps.getPathFingerprint();\t\n  \n  \n  if (res.bodyAsString.indexOf(content) >= 0) {\n\t  var uri = String(req.requestLine.uri);\n\t  var uripart = uri.replace(/\\?.*/, \"\");\n\t  var ps = ctx.getPathState();\n\t  if (uri.host != \"www.google.com\")\n\t\tctx.addStringHighlight(content);\n\t  \tctx.alert(\"vinfo-rfi\", req, res, {\n\t  \t\t\toutput: res.bodyAsString,\n\t  \t\t\tkey: \"vinfo-rfi:\" + uripart + ps.getFuzzableParameter().name,\n\t  \t\t\tresource: uripart\n\t  \t});\n  \t}\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/shell-injection.js",
    "content": "var module = {\n  name: \"Shell Injection Checks\",\n  category: \"Injection Modules\",\n  differential: true\n};\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n  if (ps.isParametric()) {\n    ctx.submitMultipleAlteredRequests(process, [\"`true`\", \"`false`\", \"`uname`\", \"\\\"`true`\\\"\", \"\\\"`false`\\\"\", \"\\\"`uname`\\\"\", \"'true'\", \"'false'\", \"'uname'\"], true);\n  }\n}\n\nfunction process(req, res, ctx) {\n  if (ctx.hasModuleFailed()) return;\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During shell injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n\n  ctx.addRequestResponse(req, res);\n  if (ctx.incrementResponseCount() < 9) return;\n\n  checkMatch(ctx, 0);\n  checkMatch(ctx, 3);\n  checkMatch(ctx, 6);\n}\n\nfunction checkMatch(ctx, idx) {\n  if (ctx.isFingerprintMatch(idx, idx + 1) && !ctx.isFingerprintMatch(idx, idx + 2)) {\n    \n    var uri = String(ctx.getSavedRequest(idx).requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vinfo-shell-inject\",  ctx.getSavedRequest(idx), ctx.getSavedResponse(idx), {\n      message: \"responses to `true` and `false` are different than `uname`\",\n      resource: uripart\n    });\n    ctx.responseChecks(idx + 2);\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/sql-arithmetic-inject.js",
    "content": "var module = {\n  name: \"Blind SQL Injection Arithmetic Evaluation Differential Checks\",\n  category: \"Injection Modules\",\n  differential: true\n};\n\nfunction initialize(ctx) {\n\n  var ps = ctx.getPathState();\n  var numeric = isNumericParameter(ps);\n\n  if (ps.isParametric()) {\n\n    var uri = String(ps.getPath().getUri());\n    var uripart = uri.replace(/\\?.*/, \"\");\n    var param = ps.getFuzzableParameter().name;\n    var pathkey;\n\n    if (ps.getPath().isPostTarget() == true) {\n      pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n    }\n    else\n    {\n      pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n    }\n\n    var k= pathkey;\n\n\n    if (ctx.alertExists(k)) {\n      return;\n    }\n\n    if (numeric) {\n      ctx.submitAlteredRequest(process, \"-0\", true, 0);\n      ctx.submitAlteredRequest(process, \"-0-0\", true, 1);\n      ctx.submitAlteredRequest(process, \"-0-9\", true, 2);\n    } else {\n      ctx.submitAlteredRequest(process, \"9-8\", 0);\n      ctx.submitAlteredRequest(process, \"8-7\", 1);\n      ctx.submitAlteredRequest(process, \"9-1\", 2);\n    }\n    submit(ctx, 3, \"\\\\\\'\\\\\\\"\");\n    submit(ctx, 4, \"\\'\\\"\");\n    submit(ctx, 5, \"\\\\\\\\\\'\\\\\\\\\\\"\");\n\n    if (numeric) {\n      ctx.submitAlteredRequest(process, \" - 0 - 0\", true, 6);\n      ctx.submitAlteredRequest(process, \" 0 0 - -\", true, 7);\n    } else {\n      ctx.submitAlteredRequest(process, \"9 - 1\", 6);\n      ctx.submitAlteredRequest(process, \"9 1 -\", 7);\n    }\n  }\n}\n\nfunction submit(ctx, idx, val) {\n  var req = ctx.getPathState().createAlteredRequest(val, true);\n  var s1 = \"vega\" + val;\n  var s2 = s1 + \",en\";\n  req.addHeader(\"User-Agent\", s1);\n  req.addHeader(\"Referer\", s1);\n  req.addHeader(\"Accept-Language\", s2);\n  ctx.submitRequest(req, process, idx);\n}\n\n\nfunction isNumericParameter(ps) {\n  if (!ps.isParametric()) return false;\n  var p = ps.getFuzzableParameter();\n  if (!(p && p.value)) return false;\n  var v = p.value;\n  var numchars = \"01234567890.+-\";\n  for (var i = 0; i < v.length; i++) {\n    if (numchars.indexOf(v[i]) == -1) return false;\n  }\n  return true;\n\n}\n\nfunction process(req, res, ctx) {\n  if (ctx.hasModuleFailed()) return;\n  var ps = ctx.getPathState();\n\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During SQL injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n\n  ctx.addRequestResponse(req, res);\n  if (ctx.incrementResponseCount() < 8) return;\n\n  var uri = String(ps.getPath().getUri());\n  var uripart = uri.replace(/\\?.*/, \"\");\n  var param = ps.getFuzzableParameter().name;\n  var pathkey;\n\n  if (ps.getPath().isPostTarget() == true) {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n  }\n  else\n  {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n  }\n\n  if (ctx.isFingerprintMatch(0, 1) && !ctx.isFingerprintMatch(0, 2)) {\n\n    ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(0), ctx.getSavedResponse(0), {\n      output: ctx.getSavedResponse(0).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Arithmetic Evaluation Differential\"\n\n    });\n\n    ctx.responseChecks(0);\n    ctx.responseChecks(2);\n  }\n\n  if (ctx.isFingerprintMatch(1, 6) && !ctx.isFingerprintMatch(6, 7)) {\n\n    ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(7), ctx.getSavedResponse(7), {\n      output: ctx.getSavedResponse(7).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Arithmetic Evaluation Differential\"\n    });\n    ctx.responseChecks(6);\n    ctx.responseChecks(7);\n  }\n\n  if (!ctx.isFingerprintMatch(3, 4) && !ctx.isFingerprintMatch(3, 5)) {\n\n    ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(4), ctx.getSavedResponse(4), {\n      output: ctx.getSavedResponse(4).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Arithmetic Evaluation Differential\"\n    });\n\n    ctx.responseChecks(3);\n    ctx.responseChecks(4);\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/sql-text-injection.js",
    "content": "var module = {\n  name: \"Blind SQL Text Injection Differential Checks\",\n  category: \"Injection Modules\",\n  differential: true\n};\n\nfunction initialize(ctx) {\n  \n  var ps = ctx.getPathState();\n\n  if (ps.isParametric()) {\n\n    var uri = String(ps.getPath().getUri());\n    var uripart = uri.replace(/\\?.*/, \"\");\n    var param = ps.getFuzzableParameter().name;\n    var pathkey;\n\n    if (ps.getPath().isPostTarget() == true) {\n      pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n    }\n    else\n    {\n      pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n    }\n\n    var k= pathkey;\n\n    if (ctx.alertExists(k)) {\n      return;\n    }\n\n\n    ctx.submitAlteredRequest(process, \"\\\\'\\\\\\\"\", true, 0);\n    ctx.submitAlteredRequest(process, \"'\\\"\", true, 1);\n    ctx.submitAlteredRequest(process, \"\\\\\\\\'\\\\\\\\\\\"\", true, 2);\n    ctx.submitAlteredRequest(process, \"''''\\\"\\\"\\\"\\\"\", true, 3);\n    ctx.submitAlteredRequest(process, \"'\\\"'\\\"'\\\"'\\\"\", true, 4);\n\n    ctx.submitAlteredRequest(process, \"' AND 1=1 -- \", true, 5);\n    ctx.submitAlteredRequest(process, \"' AND 1=2 -- \", true, 6);\n\n    ctx.submitAlteredRequest(process, \" AND 1=1 -- \", true, 7);\n    ctx.submitAlteredRequest(process, \" AND 1=2 -- \", true, 8);\n\n    ctx.submitAlteredRequest(process, \"\\\" AND 1=1 -- \", true, 9);\n    ctx.submitAlteredRequest(process, \"\\\" AND 1=2 -- \", true, 10);\n       \n    ctx.submitAlteredRequest(process, \"'\", true, 11);\n    ctx.submitAlteredRequest(process, \"\\\\'\", true, 12);    \n    ctx.submitAlteredRequest(process, \"''\", true, 13);\n    \n    ctx.submitAlteredRequest(process, \"' UNION SELECT 8, table_name, 'vega' FROM information_schema.taables WHERE taable_name like'%\", true, 14);   \n    ctx.submitAlteredRequest(process, \"' UNION SELECT 8, table_name, 'vega' FROM information_schema.tables WHERE table_name like'%\", true, 15);\n    ctx.submitAlteredRequest(process, \"\\\" UNION SELECT 8, table_name, 'vega' FROM information_schema.taables WHERE taable_name like'%\", true, 16);\n    ctx.submitAlteredRequest(process, \"\\\" UNION SELECT 8, table_name, 'vega' FROM information_schema.tables WHERE table_name like'%\", true, 17);\n\n    ctx.submitAlteredRequest(process, \"1 AND 1=1 -- \", false, 18);\n    ctx.submitAlteredRequest(process, \"1 AND 1=2 -- \", false, 19);\n\n    ctx.submitAlteredRequest(process, \"' AND 1=1 -- \", false, 20);\n    ctx.submitAlteredRequest(process, \"' AND 1=2 -- \", false, 21);\n\n    ctx.submitAlteredRequest(process, \"\\\" AND 1=1 -- \", false, 22);\n    ctx.submitAlteredRequest(process, \"\\\" AND 1=2 -- \", false, 23);\n\n  }\n  \n\n}\n\nfunction process(req, res, ctx) {\n\n  if (ctx.hasModuleFailed()) return;\n\n\n  if (res.fetchFail) {\t\n    ctx.error(req, res, \"During SQL injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n\n  ctx.addRequestResponse(req, res);\n  \n  var n = ctx.incrementResponseCount();\n  \n  if (n < 24) return;\n  \n  var ps = ctx.getPathState();\n  var fp = ps.getPathFingerprint();\n\n  var uri = String(ps.getPath().getUri());\n  var uripart = uri.replace(/\\?.*/, \"\");\n  var param = ps.getFuzzableParameter().name;\n  var pathkey;\n\n  if (ps.getPath().isPostTarget() == true) {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n  }\n  else\n  {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n  }\n\n  \n  if (!ctx.isFingerprintMatch(0, 1) && !ctx.isFingerprintMatch(1, 2)) {\n\t  ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(1), ctx.getSavedResponse(1), {\n      output: ctx.getSavedResponse(1).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n\n    ctx.responseChecks(0);\n    ctx.responseChecks(2);\n  }\n  \n  if (ctx.isFingerprintMatch(1, 4) && !ctx.isFingerprintMatch(3, 4)) {\n\t  ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(1), ctx.getSavedResponse(1), {\n      output: ctx.getSavedResponse(1).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(3);\n    ctx.responseChecks(4);\n  }\n\n  if (ctx.isFingerprintMatch(5, fp) && !ctx.isFingerprintMatch(5, 6)) {\n          ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(6), ctx.getSavedResponse(6), {\n      output: ctx.getSavedResponse(6).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(6);\n  }\n\n  if (ctx.isFingerprintMatch(7, fp) && !ctx.isFingerprintMatch(7, 8)) {\n          ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(8), ctx.getSavedResponse(8), {\n      output: ctx.getSavedResponse(8).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(8);\n  }\n\n  if (ctx.isFingerprintMatch(9, fp) && !ctx.isFingerprintMatch(9, 10)) {\n          ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(10), ctx.getSavedResponse(10), {\n      output: ctx.getSavedResponse(10).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(10);\n  }\n \n \n  if (ctx.isFingerprintMatch(19, fp) && !ctx.isFingerprintMatch(18, 19)) {\n          ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(19), ctx.getSavedResponse(19), {\n      output: ctx.getSavedResponse(19).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(19);\n  }\n\n  if (!ctx.isFingerprintMatch(20, 21)) {\n          ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(21), ctx.getSavedResponse(21), {\n      output: ctx.getSavedResponse(21).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(21);\n  }\n\n  if (!ctx.isFingerprintMatch(22, 23)) {\n          ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(23), ctx.getSavedResponse(23), {\n      output: ctx.getSavedResponse(19).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(23);\n  }\n\n  if (ctx.isFingerprintMatch(12, 13) && !ctx.isFingerprintMatch(11, 12)) {\n\t  ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(1), ctx.getSavedResponse(1), {\n      output: ctx.getSavedResponse(1).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(12);\n    ctx.responseChecks(13);\n  }  \n\n  if (ctx.isFingerprintMatch(14, fp) && !ctx.isFingerprintMatch(14, 15)) {\n\t  ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(15), ctx.getSavedResponse(15), {\n      output: ctx.getSavedResponse(1).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(15);\n  }  \n  \n  if (ctx.isFingerprintMatch(16, fp) && !ctx.isFingerprintMatch(17, 16)) {\n\t  ctx.alert(\"vinfo-sql-inject\", ctx.getSavedRequest(16), ctx.getSavedResponse(16), {\n      output: ctx.getSavedResponse(1).bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Text Injection Differential\"\n    });\n    ctx.responseChecks(16);\n  }  \n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/sql-timing-injection.js",
    "content": "var module = {\n  name: \"Blind SQL Injection Timing\",\n  category: \"Injection Modules\",\n  differential: false,\n  defaultDisabled: true\n};\n\nvar requests = [[\"1 AND SLEEP(30) -- \", false],\n               [\"1 OR (SELECT SLEEP(30)) -- \", false],\n               [\"\\\" AND SLEEP(30) -- \", true],\n               [\"' AND SLEEP(30) -- \", true],\n               [\"\\\" OR (SELECT SLEEP(30)) -- \", true],\n               [\"\\' OR (SELECT SLEEP(30)) -- \", true],\n               [\"' OR EXISTS(SELECT SLEEP(30)) -- \", true],\n               [\" OR EXISTS(SELECT SLEEP(30)) -- \", true],\n               [\"\\\" OR EEXISTS(SELECT SLEEP(30)) -- \", true],\n               [\" UNION SELECT SLEEP(30) -- \", true],\n               [\"' UNION SELECT SLEEP(30) -- \", true],\n               [\"\\\" UNION SELECT SLEEP(30) -- \", true],\n               [\"(1 AND (SELECT SLEEP(30))) -- \", false],\n\t       [\"1' AND SLEEP(30) -- \", false],\n               [\"1\\\" AND SLEEP(30) -- \", false],\n\n               /* SQL Server */ \n\n               [\" 1 AND (SELECT COUNT(*) from sysusers AS v1, sysusers AS v2, sysusers AS v3, sysusers AS v3, sysusers AS v4, sysusers AS v5, sysusers AS v6, sysusers AS v7, sysusers AS v8, sysusers AS v9, sysusers AS v10, sysusers AS v11, sysusers AS v12, sysusers AS v13, sysusers AS v14, sysusers AS v15, sysusers AS v16, sysusers AS v17, sysusers AS v18, sysusers AS v19, sysusers AS v30) -- \", false],\n               [\"\\\" WAITFOR DELAY '00:00:30' -- \", true],\n               [\"' WAITFOR DELAY '00:00:30' -- \", true],\n               [\"1 WAITFOR DELAY '00:00:30' --\", false],\n         \n               /* PostgreSQL */\n\n               [\"1 AND 81223=(SELECT 32233 FROM PG_SLEEP(35)) -- \",false],\n               [\"\\\" AND 81223=(SELECT 32233 FROM PG_SLEEP(35)) -- \",true],\n               [\"' AND 81223=(SELECT 32233 FROM PG_SLEEP(35)) -- \",true],\n               [\"\\\" AND 81223=(SELECT 32233 FROM PG_SLEEP(35)) --\",false],\n               [\"' AND 81223=(SELECT 32233 FROM PG_SLEEP(35)) --\", false]];\n\n\nfunction pathkey(ps) {\n\n  var uri = ps.getPath().getUri();\n  var param = ps.getFuzzableParameter().name;\n  if (ps.getPath().isPostTarget() == true) {\n    return uri + \"?\" + \"post\" + \"?\" + param;\n  }\n  else\n  {\n    return uri + \"?\" + \"get\" + \"?\" + param;\n  }\n\n}\n\nfunction initialize(ctx) {\n   \n  var ps = ctx.getPathState();\n  if (ps.isParametric()) {\n\n    var uri = String(ps.getPath().getUri());\n    var uripart = uri.replace(/\\?.*/, \"\");\n    var param = ps.getFuzzableParameter().name;\n    var pathkey;\n\n    if (ps.getPath().isPostTarget() == true) {\n      pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n    }\n    else\n    {\n      pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n    }\n\n    var k= pathkey;\n\n    if (ctx.alertExists(k)) {\n      return;\n    }\n     \n    ctx.setIntegerProperty(pathkey + \"?detected\", 0);\n    ctx.setIntegerProperty(pathkey + \"?alerted\", 0);\n\n    ctx.submitMultipleAlteredRequests(checkTiming, [\"bad1\", \"bad2\"], false);    \n    ps.incrementFuzzCounter();\n  }\n}\n\nfunction checkTiming(req, res, ctx) {\n  var ps = ctx.getPathState();\n\n  var uri = String(ps.getPath().getUri());\n  var uripart = uri.replace(/\\?.*/, \"\");\n  var pathkey;\n  var param = ps.getFuzzableParameter().name;\n\n  if (ps.getPath().isPostTarget() == true) {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n  }\n  else\n  {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n  }\n\n  if (res.fetchFail) {\n    ctx.error(req, res, \"During command injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n  \n  ctx.addRequestResponse(req, res);\n  if (ctx.incrementResponseCount() < 2) return;\n  var first = ctx.getSavedResponse(0).milliseconds;\n  var second = ctx.getSavedResponse(1).milliseconds;\n  ctx.setIntegerProperty(pathkey + \"?average\", (first + second / 2));\n  \n  ctx.submitAlteredRequest(process, requests[0][0], requests[0][1], 0);\n}\n\n\n\n\nfunction process(req2, res2, ctx2) {  \n  var ps = ctx2.getPathState();\n\n  var currentIndex = ctx2.getCurrentIndex();\n\n  var uri = String(ps.getPath().getUri());\n  var uripart = uri.replace(/\\?.*/, \"\");\n  var param = ps.getFuzzableParameter().name;\n  var pathkey;\n\n  if (ps.getPath().isPostTarget() == true) {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"post\" + \"?\" + param;\n  }\n  else\n  {\n    pathkey = \"vinfo-sql-inject:\" + uripart + \"?\" + \"get\" + \"?\" + param;\n  }\n\n  var average = ctx2.getIntegerProperty(pathkey + \"?average\");\n\n  ctx2.addRequestResponse(req2, res2);\n  ctx2.incrementResponseCount();\n\n  if ((average < 30000) && (ctx2.getSavedResponse(currentIndex).milliseconds >= 30000)) {\n    ctx2.setIntegerProperty(pathkey + \"?detected\", 1);\n  }\n\n   var detected = ctx2.getIntegerProperty(pathkey + \"?detected\");\n   var alerted = ctx2.getIntegerProperty(pathkey + \"?alerted\");\n\n  if ((detected == 1) && (alerted == 0)) {\n\n    ctx2.setIntegerProperty(pathkey + \"?alerted\", 1);\n\n    ctx2.alert(\"vinfo-sql-inject\", ctx2.getSavedRequest(currentIndex), ctx2.getSavedResponse(currentIndex), {\n      output: res2.bodyAsString,\n      key: pathkey,\n      resource: uripart,\n      detectiontype: \"Blind Timing Analysis Checks\",\n      param: ps.getFuzzableParameter().name\n    }); \n  } else {\n    if ((currentIndex + 1) < requests.length) {\n    var k= pathkey;\n\n    if (ctx2.alertExists(k)) {\n      return;\n    }\n      ctx2.submitAlteredRequest(process, requests[currentIndex + 1][0], requests[currentIndex + 1][1], currentIndex + 1);\n    }\n  }\n\n  if (ctx2.allResponsesReceived()) {\n    ps.decrementFuzzCounter();\n  }\n}\n\n\n"
  },
  {
    "path": "scripts/scanner/modules/injection/url-injection.js",
    "content": "var module = {\n  name: \"URL Injection checks\",\n  category: \"Injection Modules\"\n};\n\nfunction initialize(ctx) {\n\n  var ps = ctx.getPathState();\n  if (ps.isParametric()) {\n    ctx.submitMultipleAlteredRequests(process, [\"http://vega.invalid/;?\", \"//vega.invalid/;?\", \"vega://invalid/;?\", \" src=http://vega.invalid/;?\", \"\\\" src=http://vega.invalid/;?\"]);\n  }\n}\n\nfunction process(req, res, ctx) {\n  var loc = headerValue(res, \"Location\");\n  if (matchesInjectedUrls(loc)) {\n    ctx.alert(\"vinfo-url-inject\", request, response, {\n      message: \"Injected URL in Location header\",\n      resource: request.requestLine.uri\n    });\n\n  }\n  var refresh = headerValue(res, \"Refresh\");\n  if (testRefresh(refresh)) {\n    ctx.alert(\"vinfo-url-inject\", request, response, {\n      message: \"Injected URL in Refresh header\",\n      resource: request.requestLine.uri\n    });\n  }\n  ctx.contentChecks(req, res);\n}\n\nfunction testRefresh(refresh) {\n  if (!refresh) return false;\n  var ps = refresh.split(\"=\");\n  if (ps.length < 2) return false;\n  var val = ps[1];\n  var c = val[0];\n  var semiSafe = false;\n  if (c == '\"' || c == '\\'') {\n    val = val.substr(1);\n    semiSafe = true;\n  }\n  return (matchesInjectedUrls(val) || match(val, \"vega://\") || (semiSafe && (val.indexOf(\";\") != -1)));\n\n}\n\nfunction headerValue(res, name) {\n  var hdr = res.getFirstHeader(name);\n  if (hdr) return hdr.value\n  else return null;\n}\n\nfunction matchesInjectedUrls(val) {\n\n  return (val && match(val, \"http://vega.invalid\") && match(val, \"//vega.invalid/\"));\n}\n\nfunction match(val, str) {\n  return val.indexOf(str) == 0;\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/xml-injection.js",
    "content": "var module = {\n  name: \"XML Injection checks\",\n  category: \"Injection Modules\",\n  differential: true\n};\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n\n  if (ps.isParametric()) {\n    ctx.submitMultipleAlteredRequests(process, [\"vega>'>\\\"><vega></vega>\", \"vega>'>\\\"></vega><vega>\"]);\n  }\n}\n\nfunction process(req, res, ctx) {\n  if (ctx.hasModuleFailed()) return;\n\n  if (res.fetchFail) {\n    ctx.setModuleFailed();\n    return;\n  }\n  ctx.addRequestResponse(req, res);\n  if (ctx.incrementResponseCount() < 2) return;\n  if (!ctx.isFingerprintMatch(0, 1)) {\n    ctx.alert(\"vinfo-xml-inject\", ctx.getSavedRequest(0), ctx.getSavedResponse(0),{\n      message: \"responses for <vega></vega> and </vega><vega> look different\",\n      resource: ctx.getSavedRequest(0).requestLine.uri\n    });\n    ctx.responseChecks(1);\n  }\n\n}\n"
  },
  {
    "path": "scripts/scanner/modules/injection/xpath-injection.js",
    "content": "var module = {\n\tname: \"Blind XPath Injection Checks\",\n\tcategory: \"Injection Modules\",\n\tdifferential: true,\n\tdefaultDisabled: true\n};\n\n\nvar commands = [\n  {command: \"e'\", type: \"Test\"},\n  {command: \"e' or 1 eq 1 or 'a' = 'a\", type: \"XPath 2.0\"},\n  {command: 'e\" or 1 eq 1 or \"a\" = \"a', type: \"XPath 2.0\"},\n  {command: \"e' or true() or 'a'='a\", type: \"XPath\"},\t\n  {command: 'e\" or true() or \"a\"=\"a', type: \"XPath\"}\n];\n\nvar alteredRequests = [];\n\nfor (var i = 0; i < commands.length; i++) {\n\talteredRequests.push(commands[i]);\n}\n\nfunction initialize(ctx) {\n\tvar ps = ctx.getPathState();\n\tif (ps.isParametric()) {\n\t\tctx.submitMultipleAlteredRequests(process, [alteredRequests[0].command, alteredRequests[1].command], false);\n    ps.incrementFuzzCounter();\n\t}\n};\n\nfunction checkResponse(ctx) {\n\tvar currentIndex = ctx.getCurrentIndex();\n  if (!ctx.isFingerprintMatch(currentIndex, ctx.getSavedResponse(0).fingerprint)) {\n\t  return true;\n  } else {\n\t  return false;\n\t}\n};\n\nfunction process(req, res, ctx) {\n\tif (ctx.hasModuleFailed()) return;\n\tif (res.fetchFail) {\n    ctx.error(req, res, \"During XPath injection checks\");\n    ctx.setModuleFailed();\n    return;\n  }\n\t\n\tvar ps = ctx.getPathState();\n\tctx.addRequestResponse(req, res);\n\tvar currentIndex = ctx.getCurrentIndex();\n\t\n\tif (ctx.incrementResponseCount() < 2 || currentIndex < 1) return;\n\t\n\tvar detected = checkResponse(ctx);\n\t  \n\tif (detected) {\n\t\tvar uri = String(req.requestLine.uri);\n\t\tvar uripart = uri.replace(/\\?.*/, \"\");\n\t\tctx.alert(\"vinfo-differential-xpath\", ctx.getSavedRequest(currentIndex), ctx.getSavedResponse(currentIndex), {\n\t\t\toutput: res.bodyAsString,\n\t\t\tkey: \"vinfo-differential-xpath:\" + uripart + \":\" + ps.getFuzzableParameter().name,\n\t\t\tresource: uripart,\n\t\t\tdetectiontype: alteredRequests[currentIndex].type + \" Blind Injection Differential Checks\",\n\t\t\tparam: ps.getFuzzableParameter().name\n\t\t});\n\t} else {\n\t\tif (currentIndex + 1 < alteredRequests.length) {\n\t\t\tctx.submitAlteredRequest(process, alteredRequests[currentIndex + 1].command, false, currentIndex + 1);\n\t\t}\n\t};\n\n\tif (ctx.allResponsesReceived()) {\n\t\tps.decrementFuzzCounter();\n\t}\n};\n"
  },
  {
    "path": "scripts/scanner/modules/injection/xss-injection.js",
    "content": "var module = {\n  name: \"XSS Injection checks\",\n  category: \"Injection Modules\"\n};\n\nvar payloads = [\"\", \".htaccess.aspx\", \"</textarea>\", \"\\\" src=\", \" src=\", \"\\n \", \"*/ \", \"' \", \n                \"javascript:\", \"vbscript:\", \"\\\" onMouseOver=\", \"\\\" style=\", \"' onMouseOver=\", \n                \"' style=\", \"\\\" \", \"\\' \"];\n\nfunction createRequest(ps, index) {\n  if (index == 0) {\n    var xid = ps.allocateXssId();\n    var tag = ps.createXssTag(xid);\n    var req = ps.createAlteredRequest(tag, true);\n    req.addHeader(\"Referer\", tag);\n    ps.registerXssRequest(req, xid);\n    return req;\n  } else {\n    var xid = ps.allocateXssId();\n    var tag = ps.createXssTag(payloads[index], xid);\n    var req = ps.createAlteredRequest(tag, true);\n    ps.registerXssRequest(req, xid);\n    return req;\n  }\n};\n\nfunction initialize(ctx) {\n  var ps = ctx.getPathState();\n\n  if (ps.isParametric()) {  \n    for (var i = 0; i < payloads.length; i++) {\n      ctx.submitRequest(createRequest(ps, i), process, i);      \n    }\n  }\n};\n\nfunction process(req, res, ctx) {\n  ctx.contentChecks(req, res);\n};\n"
  },
  {
    "path": "scripts/scanner/modules/response/insecure-script-include.js",
    "content": "var module = {\n  name: \"Insecure Script Include\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var found = 0;\n\n  if (response.document) {\n    var script = jQuery(\"script\", response.document);\n    script.each(function() {\n      if (this.getAttribute(\"src\") != null) {\n        var scriptsrc = this.getAttribute(\"src\").toLowerCase();\n        if (scriptsrc.indexOf(\"http://\") == 0 || (scriptsrc.indexOf(\"https://\") == 0)) {\n\n          var scripthost = parseUri(scriptsrc).host.toLowerCase();\n\n          if ((ctx.isValidInternetDomainName(scripthost)) && (ctx.isValidInternetDomainName(response.host.hostName))) {\n\n            var local = ctx.internetDomainName(response.host.hostName.toLowerCase()).topPrivateDomain().name(); \n            var remote = ctx.internetDomainName(scripthost).topPrivateDomain().name();\n          \n              if (local != remote) {\n\n                var uristr = String(request.requestLine.uri);\n                var uripart = uristr.replace(/\\?.*/, \"\");\n\n                ctx.addStringHighlight(scriptsrc);\n\n                ctx.alert(\"xs-script-include\", request, response, {\n                          \"resource\": uripart,\n                          \"key\": \"xs-script-include:\" + uripart + \":\" + scriptsrc,\n    \t\t       \t  \"output\": \"Local domain: \"+response.host.hostName+\"\\n\"+\"Script source: \"+scriptsrc\n                          });\n              }\n            } else if (scripthost.toLowerCase() != response.host.hostName.toLowerCase()) {\n                var uristr = String(request.requestLine.uri);\n                var uripart = uristr.replace(/\\?.*/, \"\");\n\n                ctx.addStringHighlight(scriptsrc);\n\n                ctx.alert(\"xs-script-include\", request, response, {\n                          \"resource\": uripart,\n                          \"key\": \"xs-script-include:\" + uripart + \":\" + scriptsrc,\n                          \"output\": \"Local domain: \"+response.host.hostName+\"\\n\"+\"Script source: \"+scriptsrc\n                          });\n            }\n        }\n        if ((response.host.schemeName == \"https\") && (scriptsrc.indexOf(\"http://\") == 0)) {\n         var uristr = String(request.requestLine.uri);\n         var uripart = uristr.replace(/\\?.*/, \"\");\n\n         ctx.addStringHighlight(scriptsrc);\n\n         ctx.alert(\"insecure-script-include\", request, response, {\n                   \"resource\": uripart,\n                   \"key\": \"insecure-script-include:\" + uripart + \":\" + scriptsrc,\n\t\t   \"output\": \"Script source: \"+scriptsrc\n                  });\n       }\n\n      }\n    });\n  }\n}\n\n"
  },
  {
    "path": "scripts/scanner/modules/response/vauthhttp.js",
    "content": "var module = {\n  name: \"Cleartext Password Over HTTP\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\n  if (response.document) {\n    var form = jQuery(\"form\", response.document);\n    \n    form.each(function() {\n      if (((this.getAttribute(\"action\") == null) && (response.host.schemeName != \"https\")) || \n          ((this.getAttribute(\"action\") != null) && (this.getAttribute(\"action\").toLowerCase().indexOf(\"https\") != 0) && (response.host.schemeName != \"https\")) ||\n          ((this.getAttribute(\"action\") != null) && (this.getAttribute(\"action\").toLowerCase().indexOf(\"http:\") >= 0) && (response.host.schemeName == \"https\"))) {\n        $(this).find(\"input\").each(function() {\n\t  if ((this.getAttribute(\"type\") != null) && (this.getAttribute(\"type\") == \"password\")) {\n            var parent = $(this).closest(\"form\");\n            var parentName = \"\";\n            var uristr = String(request.requestLine.uri);\n\t    var uripart = uristr.replace(/\\?.*/, \"\");\n            if ($(parent).get(0).getAttribute(\"name\") != null) {\n              parentName = $(parent).get(0).getAttribute(\"name\");\n              var escaped = parentName.replace(/([\\\\\\(\\[\\{\\^\\$\\|\\(\\]\\}\\?\\*\\+\\.\\/])/g, \"\\\\$1\");\n              ctx.addRegexCaseInsensitiveHighlight(\"name=[\\\"']*\"+escaped+\"[\\\"']*\");\n            }\n            if ($(parent).get(0).getAttribute(\"action\") != null) {\n              formAction = $(parent).get(0).getAttribute(\"action\");\n              var escaped = formAction.replace(/([\\\\\\(\\[\\{\\^\\$\\|\\(\\]\\}\\?\\*\\+\\.\\/])/g, \"\\\\$1\");\n              ctx.addRegexCaseInsensitiveHighlight(\"action=([\\\"'])*\"+escaped+\"[\\\"']*\");\n            }\n\t    ctx.alert(\"vauthhttp\", request, response, {\n      \t              \"resource\": uripart,\n                      \"key\": \"vauthhttp:\" + uripart + \":\" + parentName\n                      });\n          }              \n        });\n       }\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vautocomplete.js",
    "content": "var module = {\n  name: \"Form autocomplete\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var found = 0;\n\n  if (response.document) {\n\n    var form = jQuery(\"form\", response.document);\n    form.find(\"input\").each(function() {\n      if ((this.getAttribute(\"type\") != null) && (this.getAttribute(\"type\") == \"password\")) {\n        if ((this.getAttribute(\"autocomplete\") == null) || (this.getAttribute(\"autocomplete\").toLowerCase() != \"off\")) {\n          ctx.addRegexCaseInsensitiveHighlight(\"type=[\\\"']*password[\\\"']*\");\n          found++;\n        }\n      }\n    });\n  }\n\n  if (found) {\n    var match;\n    ctx.addRegexCaseInsensitiveHighlight(\"type=[\\\"']*password[\\\"']*\");\n\n    var sub = request.requestLine.uri;\n    var index = sub.indexOf('?');\n\n    if (index >= 0) {\n      sub = sub.substring(0, index);\n    }\n\n    (found > 1) ? match = \"instances\" : match = \"instance\";\n    ctx.alert(\"vautocomplete\", request, response, {\n      \"resource\": sub,\n      key: \"vautocomplete:\" + sub\n    });\n\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vdirlist.js",
    "content": "var module = {\n  name: \"Directory Listing Detection\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var patterns = [/\\bIndex of\\b/gm, /\\bName\\b/gm, /\\bSize\\b/gm, /\\bParent Directory\\b/gm, /\\bFolder Listing\\b/gm, /\\bDirectory Listing\\b/gm];\n  var res = 0;\n  var url = String(request.requestLine.uri);\n  var uripart = url.replace(/\\?.*/, \"\");\n\n\n  for (i = 0; i <= patterns.length - 1; i += 1) {\n    // First match, good enough.\n    if (patterns[i].exec(response.bodyAsString)) {\n      res += 1;\n    }\n  }\n\n  if (url.search(\"C=\") <= 0 && res >= 2) {\n    ctx.alert(\"vdirlist\", request, response, {\n      output: response.bodyAsString,\n      key: \"vdirlist:\" + uripart,\n      resource: uripart\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vfileupload.js",
    "content": "var module = {\n  name: \"File Upload Detection\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var found = 0;\n\n  if (response.document) {\n    var input = jQuery(\"input:file\", response.document);\n    input.each(function() {\n    \tfound++;\n    });\n  }\n\n  if (found) {\n    var match;\n    var sub = request.requestLine.uri;\n    var index = sub.indexOf('?');\n\n    if (index >= 0) {\n      sub = sub.substring(0, index);\n    }\n\n    ctx.addRegexCaseInsensitiveHighlight(\"type=[\\\"']*file[\\\"']*\");\n\n    (found > 1) ? match = \"instances\" : match = \"instance\";\n\n    ctx.alert(\"vfileupload\", request, response, {\n              \"resource\": sub,\n              \"key\": \"vfileupload\" + sub\n    });\n\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vhttpauth.js",
    "content": "var module = {\n  name: \"HTTP Authentication Over Unencrypted HTTP\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\n  \n  if (response.code == 401 && response.host.schemeName != \"https\") {\n      var uri = String(request.requestLine.uri);\n      var uripart = uri.replace(/\\?.*/, \"\");\n\n      ctx.alert(\"vhttpauth\", request, response, {\n      output: response.bodyAsString,\n      key: \"vhttpauth:\" + uripart,\n      resource: uripart\n    });\n\n  }\n\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-1918.js",
    "content": "var module = {\n  name: \"Internal IP Addressess\",\n  type: \"response-processor\"\n};\n\nfunction validateAddress(ip) {\n  var ps = ip.split(\".\");\n  if (ps.length != 4) return false;\n  for (var i = 0; i < 4; i++) {\n    var n = parseInt(ps[i]);\n    if (isNaN(n) || n < 0 || n > 255) return false;\n  }\n  return true;\n}\n\nfunction run(request, response, ctx) {\n  var regex = /1(?:92|0|72)(?:\\.[12]?\\d{1,2}){3}/g,\n  body = response.bodyAsString,\n  result = [];\n\n  while (r = regex.exec(body)) {\n    if (String(response.host.hostName) !== r[0]) {\n      if (validateAddress(r[0]) && result.indexOf(r[0]) == -1) {\n        var regex2 = /(^127\\.0\\.0\\.1)|(^10\\.)|(^172\\.1[6-9]\\.)|(^172\\.2[0-9]\\.)|(^172\\.3[0-1]\\.)|(^192\\.168\\.)/;\n        if (regex2.exec(r[0])) {\n          ctx.addStringHighlight(r[0]);\n          result.push(r[0]);\n        }\n      }\n\n      if (result.length) {\n        var url = String(request.requestLine.uri);\n        var uripart = url.replace(/\\?.*/, \"\");\n\n        ctx.alert(\"vinfo-1918\", request, response, {\n          output: result.join(\" \"),\n          resource: uripart,\n          key: \"vinfo-1918\" + uripart + result.join(\" \")\n        });\n      }\n    }\n  }\n}"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-ajax.js",
    "content": "var module = {\n  name: \"AJAX Detector\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  if (response.document) {\n\n    var resp = response.bodyAsString;\n    var regexp = /<script\\b[^>]*?>([\\s\\S]*?)<\\/script>/gim;\n    var output = null;\n    while (res = regexp.exec(resp)) {\n      matchr = /(eval\\(|microsoft\\.xmlhttp|activexobject|msxml2\\.xmlhttp|xmlhttprequest)/gim;\n      if (res[1].match(matchr)) {\n        ctx.addStringHighlight(res[1]);\n        output = res[1];\n      }\n    }\n\n  }\n  if (output) {\n\n    var uri = String(request.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    if (output.length > 200) {\n      output = output.substr(0, 199) + \"...\";\n    }\n\n    ctx.alert(\"vinfo-ajax\", request, response, {\n      output: output,\n      resource: uripart,\n      key: \"vinfo-ajax:\" + uripart\n    });\n  }\n\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-blank.js",
    "content": "var module = {\n  name: \"Empty Reponse Body Module\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\n  if (response.bodyAsString == \"\") {\n\n    var i = 0;\n    var found = 0;\n    var headers = response.allHeaders\n    var url = String(request.requestLine.uri);\n    var uripart = url.replace(/\\?.*/, \"\");\n\n\n    for (i = 0; i < headers.length; i++) {\n      if (headers[i].name.toLowerCase() == \"location\") found = 1;\n    }\n    if (!found) {\n      if ((response.code != 401) && (response.code != 304) && (response.code != 404) && (response.code != 204)) {\n        ctx.addStringHighlight(request.requestLine.uri);\n        ctx.alert(\"vinfo-blank\", request, response, {\n          resource: uripart,\n          key: \"vinfo-blank:\" + uripart\n        });\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-comments.js",
    "content": "var module = {\n  name: \"HTML Interesting Comments Detection\",\n  type: \"response-processor\",\n  disabled: true\n};\n\nfunction run(request, response, ctx) {\n\tvar res = false;\n\tvar x = new Array();\n\tvar output = \"\";\n\n\tvar comments = [\"user\", \"pass\", \"bug\", \"fix\", \"hack\", \"caution\", \"account\", \"bypass\", \"login\", \"todo\", \"warning\", \"note\", \"admin\", \"backdoor\", \"config\"];\n  for (var i = 0; i <= comments.length - 1; i += 1) {\n    var current = new RegExp(\"(<!--(?:(?!-->)[\\\\s\\\\S])*\" + comments[i] + \"[\\\\s\\\\S]*?-->)\", \"ig\");\n    x = current.exec(response.bodyAsString);\n    if (x) {\n      ctx.addStringHighlight(x[1]);\n      output += x[1];\n      output += \"\\n\";\n      res = true;\n    }\n  }\n  if (res) {\n    var uri = String(request.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vinfo-comments\", request, response, {\n      \"output\": output,\n      \"resource\": uripart,\n      key: \"vinfo-comments\" + uripart + output\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-cookie-scope.js",
    "content": "var module = {\n\tname: \"Cookie Scope Detection\",\n\ttype: \"response-processor\"\n};\n\nvar ipRegex = /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/;\n\nfunction run(request, response, ctx) {\n\tvar uri = String(request.requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\n\tvar host = response.host;\n\tvar cookies = response.cookies;\n\tfor (var i = 0; i < cookies.length; i++) {\n\t\tvar tooLiberal = false;\n\t\tif (cookies[i].domain) {\n\t\t\tvar domain = String(cookies[i].domain);\n\t\t\tif (!ipRegex.test(response.host)) {\n\t\t\t\tif (domain !== host.hostName) {\n\t\t\t\t\tvar hostArray = String(host.hostName).split(\".\");\n\t\t\t\t\tvar domainArray = domain.split(\".\");\n\t\t\t\t\t// Domain: .bar.example.com vs. Host: foo.bar.example.com = too liberal\n\t\t\t\t\tif (domainArray.length < hostArray.length) {\n\t\t\t\t\t\ttooLiberal = true;\t\t\t\n\t\t\t\t\t// Domain: .example.com vs. Host: www.example.com = too liberal\n\t\t\t\t\t} else if (domainArray.length === hostArray.length && domainArray.shift() === \"\") {\n\t\t\t\t\t\ttooLiberal = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttooLiberal = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (tooLiberal) {\n                        var uripart = uri.replace(/\\?.*/, \"\");\n\t\t\tctx.addRegexCaseInsensitiveHighlight(\"Domain=[\\\"']*\"+String(cookies[i].domain)+\"[\\\"']*\");\n\t\t\tctx.alert(\"vinfo-cookie-scope\", request, response, {\n\t\t\t\t\"output\": cookies[i].getHeader(),\n\t\t\t\tkey: \"vinfo-cookie-scope\" +  uri.host + cookies[i].getName() + cookies[i].getDomain() + cookies[i].getPath(),\n\t\t\t\tresource: uripart\n\t\t\t});\n\t\t}\n\t\t\n\t}\n}\n\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-cookie.js",
    "content": "var module = {\n  name : \"Cookie Security Module\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\n  var sessionSubStrings = [\"ASP.NET_SessionId\",\n    \"ASPSESSIONID\",\n    \"sessionid\",\n    \"_session\",\n    \"JSESSIONID\",\n    \"PHPSESSID\",\n    \"symfony\",\n    \"PD-H-SESSION-ID\",\n    \"PD-S-SESSION-ID\",\n    \"SITESERVER\",\n    \"cfid\",\n    \"cftoken\",\n    \"jsessionid\",\n    \"sessid\",\n    \"sid\",\n    \"viewstate\",\n    \"zenid\"];\n  \n  var uri = String(request.requestLine.uri);\n  var uripart = uri.replace(/\\?.*/, \"\");\n  var ssl = false;\n  var cookies = [];\n  cookies = response.cookies;\n  var httpOnlyRegex = /;(\\s)*HttpOnly;*/i;\n\n  if (response.host.schemeName == \"https\") {\n    ssl = true;\n  }\n\n  // Parse cookies array and generate alerts\n  for (var i = 0; i < cookies.length; i++) {\n  \n    HttpOnly = false;\n    if (httpOnlyRegex.test(cookies[i].getHeader())) {\n      HttpOnly = true;\n    }    \n\n    var alerted = false;\n\n    // vinfo-sessioncookie-secure and vinfo-cookie-secure alerts\n\n    if(!cookies[i].isSecure()) {\n\n      var s; // session identifier substring\n      var alerted = false; // alerted\n      for (s = 0; s < sessionSubStrings.length; s++) {\n        var cookie = String(cookies[i].getHeader());\n        if (cookie.indexOf(sessionSubStrings[s]) >= 0) {\n            ctx.addStringHighlight(cookies[i].getHeader());\n            ctx.alert(\"vinfo-sessioncookie-secure\", request, response, {\n              output: cookies[i].getHeader(),\n              key: \"vinfo-cookie-secure:\" + uri.host + cookies[i].getName() + cookies[i].getPath(),\n              resource: uripart \n            }); \n\t    alerted = true;\n          }\n        }   \n      }\n \n      if (!cookies[i].isSecure() && ssl) {\n\n        if (!alerted) {\n          ctx.alert(\"vinfo-cookie-secure\", request, response, {\n            output: cookies[i].getHeader(),\n            key: \"vinfo-cookie-secure:\" + uri.host + cookies[i].getName() + cookies[i].getPath(),\n            resource: uripart\n          });\n        }\n      }\n\n    // vinfo-sessioncookie-httponly alert\n    \n    if(!HttpOnly) {\n      var s; // session identifier substring\n      var alerted = false; // alerted\n      for (s = 0; s < sessionSubStrings.length; s++) {\n        var cookie = String(cookies[i].getHeader());\n        if (cookie.indexOf(sessionSubStrings[s]) >= 0) {\n            ctx.addStringHighlight(cookies[i].getHeader());\n            ctx.alert(\"vinfo-sessioncookie-httponly\", request, response, {\n              output: cookies[i].getHeader(),\n              key: \"vinfo-sessioncookie-httponly:\" + uri.host + cookies[i].getName() + cookies[i].getPath() + cookies[i].getDomain,\n              resource: uripart\n            });\n            alerted = true;\n          }\n        }\n      if (!alerted) {\n        ctx.addStringHighlight(cookies[i].getHeader());\n        ctx.alert(\"vinfo-cookie-httponly\", request, response, {\n          output: cookies[i].getHeader(),\n          key: \"vinfo-cookie-httponly:\" + uri.host + cookies[i].getName() + cookies[i].getPath(),\n          resource: uripart\n        });\n      }\n    }\n\t\n    // vinfo-securecookie-insecurechannel alert\n\n    if(cookies[i].isSecure() && !ssl) {\n      ctx.addStringHighlight(cookies[i].getHeader());\n      ctx.alert(\"vinfo-securecookie-insecurechannel\", request, response, {\n        output: cookies[i].getHeader(),\n        key: \"vinfo-securecookie-insecurechannel:\" + uri.host + cookies[i].getName() + cookies[i].getPath(),\n        resource: uripart\n      });        \n    }\n  }\n}  \n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-crossdomain.js",
    "content": "var module = {\n  name: \"Insecure Cross-Domain Policy\",\n  type: \"response-processor\"\n};\n\nfunction generateAlert(ctx, request, response, type, highlight) {\n  var uristr = String(request.requestLine.uri);\n  var uripart = uristr.replace(/\\?.*/, \"\");\n  var alertType = type;\n  \n  ctx.addStringHighlight(highlight);\n  ctx.alert(\"vinfo-crossdomain-\" + alertType, request, response, {\n  \toutput: response.bodyAsString,\n  \tresource: uripart,\n  \tkey: \"vinfo-crossdomain-\" + alertType + uripart\n  });\n}\n\nfunction run(request, response, ctx) {\n  var uristr = String(request.requestLine.uri);\n  var uripart = uristr.replace(/\\?.*/, \"\");\n  var wildcardTldRegex = /^(\\*.[\\w]{2,6})$/;\n  \n  if (response.document && uripart.indexOf(\"crossdomain.xml\") !== -1) {\n    var siteControlElems = jQuery(\"site-control\", response.document);\n    var allowAccessFromElems = jQuery(\"allow-access-from\", response.document);\n    var allowHttpRequestHeadersElems = jQuery(\"allow-http-request-headers-from\", response.document);\n    \n    for (var h = 0; h < siteControlElems.length; h++) {\n      if (siteControlElems[h].getAttribute(\"permitted-cross-domain-policies\") === \"all\") {\n        var hlRegex0 = /<site-control[^<>]+permitted-cross-domain-policies\\s*=\\s*['\"]?all['\"]?[^<\\/>]*\\/>/im;\n        var match0 = hlRegex0.exec(response.bodyAsString);\n      \tgenerateAlert(ctx, request, response, \"sc-policies-all\", match0[0]);\n      }\n    }\n    for (var i = 0; i < allowAccessFromElems.length; i++) {  \n      if (allowAccessFromElems[i].getAttribute(\"domain\") === \"*\") {\n      \tvar hlRegex1 = /<allow-access-from[^<>]+domain\\s*=\\s*['\"]?\\\\*['\"]?[^<\\/>]*\\/>/im;\n      \tvar match1 = hlRegex1.exec(response.bodyAsString);\n        generateAlert(ctx, request, response, \"aafd-domain-wildcard\", match1[0]);\n      }\n      \n      if (wildcardTldRegex.test(allowAccessFromElems[i].getAttribute(\"domain\"))) {\n      \tvar hlRegex2 = /<allow-access-from[^<>]+domain\\s*=\\s*['\"]?\\*.[\\w]{2,6}['\"]?[^<\\/>]*\\/>/im;\n      \tvar match2 = hlRegex2.exec(response.bodyAsString);\n        generateAlert(ctx, request, response, \"aafd-domain-wildcardtld\", match2[0]);\n      }\n      \n      if (allowAccessFromElems[i].getAttribute(\"secure\") === \"false\") {\n      \tvar hlRegex3 = /<allow-access-from[^<>]+secure\\s*=\\s*['\"]?false['\"]?[^<\\/>]*\\/>/im;\n      \tvar match3 = hlRegex3.exec(response.bodyAsString);\n        generateAlert(ctx, request, response, \"aafd-secure-false\", match3[0]);\n      }      \n    }\n    \n    for (var j = 0; j < allowHttpRequestHeadersElems.length; j++) {\n      if (allowHttpRequestHeadersElems[j].getAttribute(\"domain\") === \"*\") {\n      \tvar hlRegex4 = /<allow-http-request-headers-from[^<>]+domain\\s*=\\s*['\"]?\\\\*['\"]?[^<\\/>]*\\/>/im;\n      \tvar match4 = hlRegex4.exec(response.bodyAsString);     \t\n        generateAlert(ctx, request, response, \"ahrf-domain-wildcard\", match4[0]);\n      }\n      \n      if (wildcardTldRegex.test(allowHttpRequestHeadersElems[j].getAttribute(\"domain\"))) {      \t\n      \tvar hlRegex5 = /<allow-http-request-headers-from[^<>]+domain\\s*=\\s*['\"]?\\*.[\\w]{2,6}['\"]?[^<\\/>]*\\/>/im;\n        var match5 = hlRegex5.exec(response.bodyAsString);\n      \tgenerateAlert(ctx, request, response, \"ahrf-domain-wildcardtld\", match5[0]);\n      }\n      \n      if (allowHttpRequestHeadersElems[j].getAttribute(\"headers\") === \"*\") {\n      \tvar hlRegex6 = /<allow-http-request-headers-from[^<>]+headers\\s*=\\s*['\"]?\\\\*['\"]?[^<\\/>]*\\/>/im;\n      \tvar match6 = hlRegex6.exec(response.bodyAsString);\n        generateAlert(ctx, request, response, \"ahrf-headers-wildcard\", match6[0]);\n      }\n      \n      if (allowHttpRequestHeadersElems[j].getAttribute(\"secure\") === \"false\") {\n      \tvar hlRegex7 = /<allow-http-request-headers-from[^<>]+secure\\s*=\\s*['\"]?false['\"]?[^<\\/>]*\\/>/im;\n      \tvar match7 = hlRegex7.exec(response.bodyAsString);\n        generateAlert(ctx, request, response, \"ahrf-secure-false\", match7[0]);\n      }\n    }\n  }\n}\n\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-emails.js",
    "content": "var module = {\n  name: \"E-Mail Finder Module\",\n  type: \"response-processor\",\n  defaultDisabled: true\n};\n\nfunction run(request, response, ctx) {\n  var atDomainRegex = /@(?:[^\\s.]{1,64}\\.)+\\S{2,6}/,\n      mailRegex = /\\w[^\\s@]*@(?:[^\\s.]{1,64}\\.)+\\S{2,6}/g,\n      strictMailRegex = /[\\w!#$%&'*+-\\/=?^`{|}~.]+@(?:(([a-z0-9]{1}[a-z0-9\\-]{0,62}[a-z0-9]{1})|[a-z])\\.)+(?:aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])/i,\n      body = response.bodyAsString,\n      emails = [],\n      r, sr, i, found;\n\n  if (!atDomainRegex.test(body)) return;\n\n  while (r = mailRegex.exec(body)) {\n    sr = strictMailRegex.exec(r[0]);\n    if (sr && emails.indexOf(sr[0]) == -1) {\n      found = 0;\n      for (i = 0; i < emails.length; i++) {\n        ctx.addStringHighlight(emails[i]);\n        if (emails[i] == sr[0].toLowerCase()) {\n          found = 1;\n        }\n      }\n      if (!found) {\n        emails.push(sr[0].toLowerCase());\n      }\n    }\n  }\n  if (emails.length) {\n    var key = emails.sort().join(\" \");\n    var uristr = String(request.requestLine.uri);\n    var uripart = uristr.replace(/\\?.*/, \"\");\n    ctx.alert(\"vinfo-emails\", request, response, {\n      \"output\": emails.join(\" \"),\n      \"resource\": uripart,\n      key: \"vinfo-emails\" + uripart + key\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-errorpages.js",
    "content": "var module = {\n  name: \"Error Page Detection\",\n  type: \"response-processor\"\n};\n\nvar errorStrings = [\n\t{ \n\t\ttype: \"java\",\n\t\tregex: \"<title>\\s*Apache Tomcat.+Error Report\\s*</title>\",\n\t\tresponseCode: [500]\n\t},\n\t{\n\t\ttype: \"java\",\n\t\tregex: \"java.lang.Exception\",\n\t},\n\t{ \n\t\ttype: \"cf\",\n\t\tregex: \"<title>\\s*Error Occurred While Processing Request\\s*</title>\"\n\t},\n\t{\n\t\ttype: \"php\",\n\t\tregex: \"<b>Warning</b>: .+</b> on line <b>\"\n\t},\n\t{ \n\t\ttype: \"php\",\n\t\tregex: \"<b>Fatal error</b>: .+</b> on line <b>\"\n\t},\n\t{\n\t\ttype: \"asp\",\n\t\tregex: \"<span><H1>Server Error in '/[/A-Za-z_0-9\\-]*' Application.<hr width=100% size=1 color=silver></H1>\"\n\t},\n\t{\n\t  type: \"asp\",\n\t  regex: \"<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>\",\n\t  responseCode: [401]\n\t},\n\t{\n\t  type: \"asp\",\n\t  regex: \"System.UnauthorizedAccessException: Access to the path\",\n\t},\n\t{\n\t\ttype: \"django\",\n\t\tregex: \"t = loader.get_template.+# You need to create a \\\\d{3}.html template.\"\n\t},\n\t{\n\t\ttype: \"django\",\n\t\tregex: \"PythonHandler django.core.handlers.modpython\"\n\t},\n\t{\n\t\ttype: \"ruby\",\n\t\tregex: \"<h1 class=\\\"error_title\\\">Ruby.+application could not be started</h1>\"\n\t},\n\t{\n\t\ttype: \"http\",\n\t\tregex: \"<TITLE>500 Internal Server Error</TITLE>\",\n\t\tresponseCode: [500]\n\t},\n\t{ \n\t\ttype: \"http\",\n\t\tregex: \"<TITLE>401 Authorization Required</TITLE>\",\n\t\tresponseCode: [401]\n\t},\n\t{\n\t  type: \"http\",\n\t  regex: \"<h1>HTTP Status 401 - </h1>\",\n\t  responseCode: [401]\n\t},\n\t{ \n\t\ttype: \"http\", \n\t\tregex: \"<TITLE>403 Forbidden</TITLE>\",\n\t\tresponseCode: [403]\n\t}\n];\n\nfunction run(request, response, ctx) {\n\tvar uri = String(request.requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\n\tvar responseCodeMatch = false;\n\tfor (var i = 0; i < errorStrings.length; i++) {\n\t\tif (!errorStrings[i].responseCode) {\n\t\t\tresponseCodeMatch = true;\n\t\t} else {\n\t\t\tif (errorStrings[i].responseCode.indexOf(response.code) >= 0) {\n\t\t\t\tresponseCodeMatch = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvar match = RegExp(errorStrings[i].regex, \"im\").exec(response.bodyAsString);\n\t\tif (match && responseCodeMatch) {\t\t\n\t\t\tctx.addRegexCaseInsensitiveHighlight(errorStrings[i].regex);\n\t\t\tctx.alert(\"vinfo-errorpages-\" + errorStrings[i].type, request, response, {\n\t\t\t\toutput: match[0],\n\t\t\t\tresource: uripart,\n\t\t\t\tkey: \"vinfo-errorpages\" + errorStrings[i].type + uripart + match[0]\n\t\t\t});\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-feeds.js",
    "content": "var module = {\n  name: \"RSS/Atom/OPL Feed Detector\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var output = \"\";\n  var res = 0;\n  var rss = new RegExp(\"<link.*rel=.*rss.*?>\", \"ig\");\n  var atom = new RegExp(\"<link.*rel=.*atom.*?>\", \"ig\");\n  var opml = new RegExp(\"<opml.*version.*?>\", \"ig\");\n\n  var x = rss.exec(response.bodyAsString);\n  if (x) {\n    ctx.addStringHighlight(x[0]);\n    output += x[0];\n    output += \"\\n\";\n    res = 1;\n  }\n  var y = atom.exec(response.bodyAsString);\n  if (y) {\n    ctx.addStringHighlight(y[0]);\n    output += y[0];\n    output += \"\\n\";\n    res = 1;\n  }\n  var z = opml.exec(response.bodyAsString);\n  if (z) {\n    ctx.addStringHighlight(z[0]);\n    output += z[0];\n    output += \"\\n\";\n    res = 1;\n  }\n\n  if (res) {\n     var uri = String(request.requestLine.uri);\n     var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vinfo-feeds\", request, response, {\n      \"output\": output,\n      \"resource\": uripart,\n      key: \"vinfo-feeds\" + output\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-headers.js",
    "content": "var module = {\n  name: \"HTTP Header Checks\",\n  type: \"response-processor\"\n};\n\nvar headers = [\"X-XSS-Protection\", \"Access-Control-Allow-Origin\"]; // May be an issue when these headers are present\n\nfunction run(request, response, ctx) {\n\tvar uri = String(request.requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\n\t\n\tfor (var i = 0; i < headers.length; i++) {\n\t\tif (response.hasHeader(headers[i])) {\n\t\t\tvar hdr = response.getFirstHeader(headers[i]);\n\t\t\tif (hdr.name == \"X-XSS-Protection\" && hdr.value == \"0\") {\n\t\t\t\tctx.addStringHighlight(hdr);\n\t\t\t\tctx.alert(\"vinfo-xss-filter-disabled\", request, response, {\n          \t\t\t\toutput: hdr,\n\t\t\t\t\tresource: uripart,\n          \t\t\t\tkey: \"vinfo-xss-filter-disabled\" + uripart\n        });\n\t\t\t}\n\t\t\t\n\t\t\tif (hdr.name == \"Access-Control-Allow-Origin\" && hdr.value == \"*\") {\n\t\t\t\tctx.addStringHighlight(hdr);\n\t\t\t\tctx.alert(\"vinfo-insecure-cors-ac\", request, response, {\n\t\t\t\t\toutput: hdr,\n\t\t\t\t\tresource: uripart,\n\t\t\t\t\tkey: \"vinfo-insecure-cors-ac\" + uripart\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-metatags.js",
    "content": "var module = {\n  name: \"Interesting Meta Tag Detection\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\tvar res = false;\n\tvar x = new Array();\n\tvar output = \"\";\n  var keywords = [\"user\", \"password\", \"source\", \"author\", \"microsoft\", \"visual\", \"linux\", \"release\", \"version\"];\n  for (var i = 0; i <= keywords.length - 1; i += 1) {\n    var current = new RegExp(\"(<meta(?:(?!>)[\\\\s\\\\S])*\" + keywords[i] + \"[\\\\s\\\\S]*?>)\", \"ig\");\n    x = current.exec(response.bodyAsString);\n    if (x) {\n      ctx.addStringHighlight(x[1]);\n      output += x[1];\n      output += \"\\n\";\n      res = true;\n    }\n  }\n  if (res) {\n   var uri = String(request.requestLine.uri);\n   var uripart = uri.replace(/\\?.*/, \"\");\n    ctx.alert(\"vinfo-metatags\", request, response, {\n      \"output\": output,\n      \"resource\": uripart,\n      key: \"vinfo-metatags\" + uripart + output\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-missing-charset.js",
    "content": "var module = {\n  name: \"Character Set Not Specified\",\n  type: \"response-processor\"\n};\n\n\nvar textSubtypeRegex = /^text\\/(\\w+)/;\nvar charsetHeaderRegex = /.+charset\\s?=.+/;\nvar charsetBodyRegex = /<meta.+charset\\s?=[^<>]+>/im;\n\n// Do not check these text/ subtypes:\nvar invalidSubtypes = [\"css\"];\n\nfunction run(request, response, ctx) {\n\tvar uri = String(request.requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\t\n\tvar alert = false;\n\t\n\t// TODO: Implement more checks to filter out static content from results.\n\t// Only check responses with \"Content-Type: text/*\"\n\tif (response.hasHeader(\"Content-Type\")) {\n\t\tvar hdr = response.getFirstHeader(\"Content-Type\");\n\t\tvar textSubtype = textSubtypeRegex.exec(hdr.value);\n\t\tif (textSubtype && invalidSubtypes.indexOf(textSubtype[1].toLowerCase()) === -1) {\n\t\t\tif (response.bodyAsString.length > 0) {\n\t\t\t\t// Alert if charset not specified in header and body.\n\t\t\t\tif (!charsetHeaderRegex.test(hdr.value) && !charsetBodyRegex.test(response.bodyAsString)) {\n\t\t\t\t\talert = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (alert) {\n\t\tctx.alert(\"vinfo-missing-charset\", request, response, {\n      \t\t\toutput: request.requestLine.uri,\n\t\t\tresource: uripart,\n      \t\t\tkey: \"vinfo-missing-charset:\" + uripart\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-oracle.js",
    "content": "importPackage(java.net);\n\nvar module = {\n  name: \"Oracle Application Server Fingerprint Module\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\n\n/*\n  var oraclefingerprints = [\"Oracle-Application-Server-10g\",\n                            \"Oracle-Application-Server-10g/10.1.2.0.0 Oracle-HTTP-Server\".\n                            \"Oracle-Application-Server-10g/9.0.4.1.0 Oracle-HTTP-Server\",\n                            \"Oracle-Application-Server-10g OracleAS-Web-Cache-10g/9.0.4.2.0 (N)\",\n\"Oracle-Application-Server-10g/9.0.4.0.0\",\n\"Oracle HTTP Server Powered by Apache\",\n\"Oracle HTTP Server Powered by Apache/1.3.19 (Unix) mod_plsql/3.0.9.8.3a\",\n\"Oracle HTTP Server Powered by Apache/1.3.19 (Unix) mod_plsql/3.0.9.8.3d\",\n\"Oracle HTTP Server Powered by Apache/1.3.12 (Unix) mod_plsql/3.0.9.8.5e\",\n\"Oracle HTTP Server Powered by Apache/1.3.12 (Win32) mod_plsql/3.0.9.8.5e\",\n\"Oracle HTTP Server Powered by Apache/1.3.19 (Win32) mod_plsql/3.0.9.8.3c\",\n\"Oracle HTTP Server Powered by Apache/1.3.22 (Unix) mod_plsql/3.0.9.8.3b\",\n\"Oracle HTTP Server Powered by Apache/1.3.22 (Unix) mod_plsql/9.0.2.0.0\",\n\"Oracle_Web_Listener/4.0.7.1.0EnterpriseEdition\",\n\"Oracle_Web_Listener/4.0.8.2EnterpriseEdition\",\n\"Oracle_Web_Listener/4.0.8.1.0EnterpriseEdition\",\n\"Oracle_Web_listener3.0.2.0.0/2.14FC1\",\n\"Oracle9iAS/9.0.2 Oracle HTTP Server\",\n\"Oracle9iAS/9.0.3.1 Oracle HTTP Server\"];\n*/\n  // Maybe we should not match these exact strings?  Will have to investigate.\n  // var oraclefingerprints = [\"Oracle\"];\n  // This module is incomplete but we're leaving it here.\n\n  // IBM fingerprint IBM_HTTP_SERVER\n  // Sun-ONE-Web-Server/6.1\n\n  if (response.bodyAsString.indexOf(\"<!-- Created by Oracle \") >= 0) {\n    var uri = String(request.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.addStringHighlight(\"<!-- Created by Oracle\");\n    ctx.alert(\"vinfo-oracle\", request, response, {\n      \"output\": \"<!-- Created by Oracle..\",\n      \"resource\": uripart,\n      key: \"vinfo-oracle:\" + uripart\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-paths.js",
    "content": "var module = {\n  name: \"Path Disclosure\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var pathlinux = new Array(\"/bin/\", \"/boot/\", \"/cdrom/\", \"/dev/\", \"/etc/\", \"/home/\", \"/initrd/\", \"/lib/\", \"/media/\", \"/mnt/\", \"/opt/\", \"/proc/\", \"/root/\", \"/sbin/\", \"/sys/\", \"/srv/\", \"/tmp/\", \"/usr/\", \"/var/\", \"/htdocs/\", \"/apache/\");\n\n  var pathwindows = new Array(\"C:\\\\\", \"D:\\\\\", \"E:\\\\\", \"Z:\\\\\", \"C:\\\\windows\", \"C:\\\\winnt\\\\\", \"C:\\\\win32\\\\\", \"C:\\\\win\\\\system\\\\\", \"C:\\\\windows\\\\system\\\\\", \"C:\\\\win32\\\\system\\\\\", \"C:\\\\winnt\\\\system\\\\\", \"C:\\\\Program Files\\\\\", \"C:\\\\Documents and Settings\\\\\");\n\n  var paths = [];\n  var i = 0;\n  var body = response.bodyAsString;\n  var matches = [];\n  var output = [];\n\n  /* Perhaps we can set an server.os field in the model */\n  /* For now, check them all */\n\n  paths = paths.concat(pathlinux).concat(pathwindows);\n\n  // first do a more efficient indexOf linear search //\n  for (i = 0; i < paths.length; i++) {\n    if (body.indexOf(paths[i]) >= 0) {\n      matches.push(paths[i]);\n    }\n  }\n\n  // if there was a match, use regexp // \n  if (matches.length) {\n    for (i = 0; i < matches.length; i++) {\n      var s = matches[i].replace(/\\\\/g, \"\\\\\\\\\");\n      var r = \"(\" + s + \"[A-Z\\\\._\\\\\\-\\\\\\\\/\\+~]*)\";\n      var regexp = new RegExp(r, \"ig\");\n      var res = regexp.exec(body);\n      var j = 0;\n      if (res) {\n        for (j = 0; j < res.length; j++) {\n          if (output.indexOf(res[j]) < 0) {\n            ctx.addStringHighlight(res[j]);\n            output.push(res[j]);\n          }\n        }\n      }\n    }\n  }\n\n\n\n  if (matches.length) {\n \n    var uri = String(request.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    var key = output.join(\" \");\n\n    ctx.alert(\"vinfo-paths\", request, response, {\n      \"output\": output.join(\" \"),\n      \"resource\": uripart,\n      key: \"vinfo-paths\" + key\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-source.js",
    "content": "var module = {\n  name: \"Source Code Disclosure Module\",\n  type: \"response-processor\"\n};\n\n\nvar xmlReject = /<?\\s*xml/i;\n\nfunction runTest(test, response) {\n  var output = \"\";\n  for (var i in test.regex) {\n    var regex = test.regex[i];\n    var res = regex.exec(response.bodyAsString);\n    if (res) {\n      if (!xmlReject.test(res[0])) {\n        output += res[0];\n      }\n    }\n  }\n  if (output.length > 0) return output;\n  else return null;\n}\n\nfunction run(request, response, ctx) {\n  var testData = [{\n    type: \"ASP or JSP\",\n    regex: [/<!--\\s*%[\\s\\S]+%\\s*(--)?>/g, /<%(?:(?!%>)[\\s\\S])+%>/g]\n  }, {\n    type: \"PHP\",\n    regex: [/<!--\\s*\\?[\\s\\S]+\\?\\s*(--)?>/g, /<\\?(?:(?!\\?>)[\\s\\S])+\\?>/g]\n  }, {\n    type: \"JSP Tag\",\n    regex: [/<jsp:.+\\s+(?:(?!\\/>)[\\s\\S])+\\/>/g, /<jsp:.+>(?:(:!<\\/jsp:)[\\s\\S])<\\/jsp:[^>]*>/g]\n  }];\n\n  var output = \"\";\n\n  for (var idx in testData) {\n    var result = runTest(testData[idx], response);\n    if (result) {\n      ctx.addStringHighlight(result);\n      output += (\"Possible \" + testData[idx].type + \" code: \\n\" + result);\n    }\n  }\n\n  if (output.length > 0) {\n    var uri = String(request.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vinfo-source\", request, response, {\n      \"output\": output,\n      \"resource\": uripart,\n      key: \"vinfo-source:\" + uripart\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-unsafe-charset.js",
    "content": "var module = {\n\tname: \"Unsafe Or Unrecognized Character Set\",\n\ttype: \"response-processor\"\n};\n\nvar textSubtypeRegex = /^text\\/\\w+/;\nvar charsetHeaderRegex = /^text\\/\\w+;.+charset\\s*=['\"]?([^'\";]+)['\"]?/i;\nvar charsetBodyRegex = /<meta.+charset\\s*=['\"]?([^'\"]+)['\"]?.*>/im;\n\nvar safeCharsets = [\"utf-8\",\n                    \"iso-8859-1\",\n                    \"iso-8859-2\",\n                    \"iso8859-1\",\n                    \"iso8859-2\",\n                    \"iso8859-15\",\n                    \"iso8859-16\",\n                    \"iso-8859-15\",\n                    \"iso-8859-16\",\n                    \"windows-1252\",\n                    \"windows-1250\",\n                    \"us-ascii\",\n                    \"koi8-r\"];\n\nfunction run(request, response, ctx) {\n\tvar uri = String(request.requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\n\t\n\tif (response.bodyAsString.length > 0) {\n\t\tif (response.hasHeader(\"Content-Type\")) {\n\t\t\tvar hdr = response.getFirstHeader(\"Content-Type\");\n\t\n\t\t\tvar matchHeader = charsetHeaderRegex.exec(hdr.value);\n\t\t\tif (matchHeader) {\n\t\t\t\tif (safeCharsets.indexOf(matchHeader[1].toLowerCase()) == -1) {\n\t\t\t\t\tunsafeHeader = true;\n\t\t\t\t\tctx.addStringHighlight(matchHeader[1]);\n\t\t\t\t\tctx.alert(\"vinfo-unsafe-charset-header\", request, response, {\n\t\t\t\t\t\toutput: hdr.name + \": \" + hdr.value,\n\t\t\t\t\t\tresource: uripart,\n\t\t\t\t\t\tkey: \"vinfo-unsafe-charset-header:\" + uripart\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\n\t\t\tvar matchBody = charsetBodyRegex.exec(response.bodyAsString);\n\t\t\tif (matchBody) {\n\t\t\t\tif (safeCharsets.indexOf(matchBody[1].toLowerCase()) == -1) {\n\t\t\t\t\tunsafeBody = false;\n\t\t\t\t\tctx.addStringHighlight(matchBody[1]);\n\t\t\t\t\tctx.alert(\"vinfo-unsafe-charset-body\", request, response, {\n\t\t\t\t\t\toutput: matchBody[0],\n\t\t\t\t\t\tresource: uripart,\n\t\t\t\t\t\tkey: \"vinfo-unsafe-charset-body:\" + uripart\n\t\t\t\t\t});\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\t\t"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-wsdl.js",
    "content": "var module = {\n  name: \"WSDL Detector\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n\n  wsdl = \"<wsdl:\";\n\n  if (response.bodyAsString.indexOf(wsdl) >= 0) {\n\n   var uri = String(request.requestLine.uri);\n   var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vinfo-wsdl\", request, response, {\n      \"output\": response.bodyAsString,\n      key: \"vinfo-wsdl:\" + uripart,\n      \"resource\": uripart\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vinfo-xframeoptions.js",
    "content": "var module = {\n  name: \"X-Frame Options Header Not Set\",\n  type: \"response-processor\",\n  defaultDisabled: true\n};\n\nvar valuesRegex = /(DENY|SAMEORIGIN)|(ALLOW-FROM\\s*:\\s*.+)/i;\nfunction run(request, response, ctx) {\n\tvar uri = String(request.requestLine.uri);\n\tvar uripart = uri.replace(/\\?.*/, \"\");\t\n\tvar alert = false;\n\t\n\tif (response.bodyAsString.length > 0) {\n\t\tif (response.mostlyAscii) {\n\t\t\tif (response.hasHeader(\"X-Frame-Options\")) {\n\t\t\t\tvar hdr = response.getFirstHeader(\"X-Frame-Options\");\n\t\t\t\tif (!valuesRegex.test(hdr.value)) {\n\t\t\t\t\talert = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\talert = true;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif (alert) {\n\t\tctx.alert(\"vinfo-xframeoptions\", request, response, {\n      output: request.requestLine.uri,\n\t\t\tresource: uripart,\n      key: \"vinfo-xframe-options\" + uripart\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vpii-cc.js",
    "content": "var module = {\n  name: \"Credit Card Identification\",\n  type: \"response-processor\",\n  defaultDisabled: true\n};\n\nfunction luhncheck(str) {\n  str = (str + '').replace(/\\D+/g, '').split('').reverse();\n  if (!str.length) return false;\n  var t = 0,\n      i;\n  for (i = 0; i < str.length; i++) {\n    str[i] = parseInt(str[i]);\n    t += i % 2 ? 2 * str[i] - (str[i] > 4 ? 9 : 0) : str[i];\n  }\n  return (t % 10) == 0;\n}\n\nfunction run(request, response, ctx) {\n  // Regex compatible with Visa (16&13 numbers), MC, Amex, Discover, JCB, Diner's Club\n  var regexp = /\\b(([453]\\d{3}|6011)([- ]?)\\d{4}\\3\\d{4}\\3\\d{4}|3\\d{3}([- ]?)\\d{6}\\4\\d{4,5}|4\\d{12})\\b/gm;\n  var cards = [];\n  var res;\n\n  while (res = regexp.exec(response.bodyAsString)) {\n    if (luhncheck(res[0])) {\n      ctx.addStringHighlight(res[0]);\n      cards.push(res[0]);\n    }\n  }\n  if (cards.length) {\n\t\n   var uri = String(request.requestLine.uri);\n   var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vpii-cc\", request, response, {\n      \"output\": cards.join(\"\\n\"),\n      \"resource\": uripart,\n      key: \"vpii-cc:\" + uripart + cards.join(\"\\n\")\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vpii-ssnsin.js",
    "content": "var module = {\n  name: \"Social Security/Social Insurance Number Detector\",\n  type: \"response-processor\",\n  defaultDisabled: true\n};\n\nvar resssn;\nvar resultssn;\nvar resultsin;\nvar outputssn = [];\nvar outputsin = [];\nvar ssn = /\\b\\d{3}([- ]?)(\\d{3}\\1\\d{3}|\\d{2}\\1\\d{4})\\b/gm;\n\nfunction run(request, response, ctx) {\n\n  function isValidSSN(value) {\n    var re = /^([0-6]\\d{2}|7[0-6]\\d|77[0-2])([ \\-]?)(\\d{2})\\2(\\d{4})$/;\n    if (!re.test(value)) {\n      return false;\n    }\n    var temp = value;\n    if (value.indexOf(\"-\") != -1) {\n      temp = (value.split(\"-\")).join(\"\");\n    }\n    if (value.indexOf(\" \") != -1) {\n      temp = (value.split(\" \")).join(\"\");\n    }\n    if (temp.substring(0, 3) == \"666\") {\n      return false;\n    }\n    if (temp.substring(0, 3) == \"000\") {\n      return false;\n    }\n    if (temp.substring(3, 5) == \"00\") {\n      return false;\n    }\n    if (temp.substring(5, 9) == \"0000\") {\n      return false;\n    }\n    return true;\n  }\n\n  function luhncheck(str) {\n    str = (str + '').replace(/\\D+/g, '').split('').reverse();\n    if (!str.length) return false;\n    var t = 0,\n        i;\n    for (i = 0; i < str.length; i++) {\n      str[i] = parseInt(str[i]);\n      t += i % 2 ? 2 * str[i] - (str[i] > 4 ? 9 : 0) : str[i];\n    }\n    return (t % 10) == 0;\n  }\n\n  while (resssn = ssn.exec(response.bodyAsString)) {\n    if (isValidSSN(resssn[0])) {\n      ctx.addStringHighlight(resssn[0]);\n      outputssn.push(resssn[0]);\n      resultssn = 1;\n    }\n    if (luhncheck(resssn[0])) {\n      ctx.addStringHighlight(resssn[0]);\n      outputsin.push(resssn[0]);\n      resultsin = 1;\n    }\n  }\n\n  if (resultssn) {\n    ctx.alert(\"vpii-ssnsin-ssn\", request, response, {\n      \"output\": outputssn.join(\"\\n\"),\n      \"resource\": uripart,\n      key: \"vpii-ssnsin-ssn\" + uripart,\n    });\n  }\n  if (resultsin) {\n    var uri = String(request.requestLine.uri);\n    var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vpii-ssnsin-sin\", request, response, {\n      \"output\": outputsin.join(\"\\n\"),\n      \"resource\": uripart,\n      key: \"vpii-ssnsin-sin\" + uripart\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/modules/response/vvcs-users.js",
    "content": "var module = {\n  name: \"Version Control String Detection\",\n  type: \"response-processor\"\n};\n\nfunction run(request, response, ctx) {\n  var regexp = /\\$.{1,12}: .*? .*? \\d{4}[-\\/]\\d{1,2}[-\\/]\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}.* (.*?) (Exp )?\\$/;\n  var res;\n\n  res = regexp.test(response.bodyAsString);\n  if (res) {\n   var uri = String(request.requestLine.uri);\n   var uripart = uri.replace(/\\?.*/, \"\");\n\n    ctx.alert(\"vvcs-users\", request, response, {\n      \"output\": response.bodyAsString,\n      \"resource\": uripart,\n      key: \"vvcs-users:\" + uripart\n    });\n  }\n}\n"
  },
  {
    "path": "scripts/scanner/prelude/base64.js",
    "content": "/*\n * Copyright (c) 2010 Nick Galbreath\n * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/* base64 encode/decode compatible with window.btoa/atob\n *\n * window.atob/btoa is a Firefox extension to convert binary data (the \"b\")\n * to base64 (ascii, the \"a\").\n *\n * It is also found in Safari and Chrome.  It is not available in IE.\n *\n * if (!window.btoa) window.btoa = base64.encode\n * if (!window.atob) window.atob = base64.decode\n *\n * The original spec's for atob/btoa are a bit lacking\n * https://developer.mozilla.org/en/DOM/window.atob\n * https://developer.mozilla.org/en/DOM/window.btoa\n *\n * window.btoa and base64.encode takes a string where charCodeAt is [0,255]\n * If any character is not [0,255], then an exception is thrown.\n *\n * window.atob and base64.decode take a base64-encoded string\n * If the input length is not a multiple of 4, or contains invalid characters\n *   then an exception is thrown.\n */\nbase64 = {};\nbase64.PADCHAR = '=';\nbase64.ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nbase64.getbyte64 = function(s,i) {\n    // This is oddly fast, except on Chrome/V8.\n    //  Minimal or no improvement in performance by using a\n    //   object with properties mapping chars to value (eg. 'A': 0)\n    var idx = base64.ALPHA.indexOf(s.charAt(i));\n    if (idx == -1) {\n\tthrow \"Cannot decode base64\";\n    }\n    return idx;\n};\n\nbase64.decode = function(s) {\n    // convert to string\n    s = \"\" + s;\n    var getbyte64 = base64.getbyte64;\n    var pads, i, b10;\n    var imax = s.length;\n    if (imax == 0) {\n        return s;\n    }\n\n    if (imax % 4 != 0) {\n\tthrow \"Cannot decode base64\";\n    }\n\n    pads = 0;\n    if (s.charAt(imax -1) == base64.PADCHAR) {\n        pads = 1;\n        if (s.charAt(imax -2) == base64.PADCHAR) {\n            pads = 2;\n        }\n        // either way, we want to ignore this last block\n        imax -= 4;\n    }\n\n    var x = [];\n    for (i = 0; i < imax; i += 4) {\n        b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) |\n            (getbyte64(s,i+2) << 6) | getbyte64(s,i+3);\n        x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff, b10 & 0xff));\n    }\n\n    switch (pads) {\n    case 1:\n        b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) | (getbyte64(s,i+2) << 6);\n        x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff));\n        break;\n    case 2:\n        b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12);\n        x.push(String.fromCharCode(b10 >> 16));\n        break;\n    }\n    return x.join('');\n};\n\nbase64.getbyte = function(s,i) {\n    var x = s.charCodeAt(i);\n    if (x > 255) {\n        throw \"INVALID_CHARACTER_ERR: DOM Exception 5\";\n    }\n    return x;\n};\n\n\nbase64.encode = function(s) {\n    if (arguments.length != 1) {\n\tthrow \"SyntaxError: Not enough arguments\";\n    }\n    var padchar = base64.PADCHAR;\n    var alpha   = base64.ALPHA;\n    var getbyte = base64.getbyte;\n\n    var i, b10;\n    var x = [];\n\n    // convert to string\n    s = \"\" + s;\n\n    var imax = s.length - s.length % 3;\n\n    if (s.length == 0) {\n        return s;\n    }\n    for (i = 0; i < imax; i += 3) {\n        b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8) | getbyte(s,i+2);\n        x.push(alpha.charAt(b10 >> 18));\n        x.push(alpha.charAt((b10 >> 12) & 0x3F));\n        x.push(alpha.charAt((b10 >> 6) & 0x3f));\n        x.push(alpha.charAt(b10 & 0x3f));\n    }\n    switch (s.length - imax) {\n    case 1:\n        b10 = getbyte(s,i) << 16;\n        x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +\n               padchar + padchar);\n        break;\n    case 2:\n        b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8);\n        x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +\n               alpha.charAt((b10 >> 6) & 0x3f) + padchar);\n        break;\n    }\n    return x.join('');\n};\n"
  },
  {
    "path": "scripts/scanner/prelude/jquery.js",
    "content": "/*!\n * jQuery JavaScript Library v1.4.3\n * http://jquery.com/\n *\n * Copyright 2010, John Resig\n * Dual licensed under the MIT or GPL Version 2 licenses.\n * http://jquery.org/license\n *\n * Includes Sizzle.js\n * http://sizzlejs.com/\n * Copyright 2010, The Dojo Foundation\n * Released under the MIT, BSD, and GPL Licenses.\n *\n * Date: Thu Oct 14 23:10:06 2010 -0400\n */\n\n\n(function(undefined) {\n\t\nvar document;\n\nvar jQuery = (function() {\n\t\nvar jQuery = function(selector, context) {\n\t\tif(context && context.nodeType && context.nodeType === 9) {\n\t\t\tjQuery.setDocument(context);\n\t\t}\n\t\treturn new jQuery.fn.init( selector, context );\n\t},\n\n\t// A central reference to the root jQuery(document)\n\trootjQuery,\n\n\t// A simple way to check for HTML strings or ID strings\n\t// (both of which we optimize for)\n\tquickExpr = /^(?:[^<]*(<[\\w\\W]+>)[^>]*$|#([\\w\\-]+)$)/,\n\n\t// Is it a simple selector\n\tisSimple = /^.[^:#\\[\\.,]*$/,\n\n\t// Check if a string has a non-whitespace character in it\n\trnotwhite = /\\S/,\n\trwhite = /\\s/,\n\n\t// Used for trimming whitespace\n\ttrimLeft = /^\\s+/,\n\ttrimRight = /\\s+$/,\n\n\t// Check for non-word characters\n\trnonword = /\\W/,\n\n\t// Check for digits\n\trdigit = /\\d/,\n\n\t// Match a standalone tag\n\trsingleTag = /^<(\\w+)\\s*\\/?>(?:<\\/\\1>)?$/,\n\n\t// JSON RegExp\n\trvalidchars = /^[\\],:{}\\s]*$/,\n\trvalidescape = /\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\n\trvalidtokens = /\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\n\trvalidbraces = /(?:^|:|,)(?:\\s*\\[)+/g,\n\n\t// Save a reference to some core methods\n\ttoString = Object.prototype.toString,\n\thasOwn = Object.prototype.hasOwnProperty,\n\tpush = Array.prototype.push,\n\tslice = Array.prototype.slice,\n\ttrim = String.prototype.trim,\n\tindexOf = Array.prototype.indexOf,\n\t\n\t// [[Class]] -> type pairs\n\tclass2type = {};\n\njQuery.fn = jQuery.prototype = {\n\tinit: function( selector, context ) {\n\t\tvar match, elem, ret, doc;\n\n\t\t// Handle $(\"\"), $(null), or $(undefined)\n\t\tif ( !selector ) {\n\t\t\treturn this;\n\t\t}\n\n\t\t// Handle $(DOMElement)\n\t\tif ( selector.nodeType ) {\n\t\t\tthis.context = this[0] = selector;\n\t\t\tthis.length = 1;\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t// The body element only exists once, optimize finding it\n\t\tif ( selector === \"body\" && !context && document.body ) {\n\t\t\tthis.context = document;\n\t\t\tthis[0] = document.body;\n\t\t\tthis.selector = \"body\";\n\t\t\tthis.length = 1;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Handle HTML strings\n\t\tif ( typeof selector === \"string\" ) {\n\t\t\t// Are we dealing with HTML string or an ID?\n\t\t\tmatch = quickExpr.exec( selector );\n\n\t\t\t// Verify a match, and that no context was specified for #id\n\t\t\tif ( match && (match[1] || !context) ) {\n\n\t\t\t\t// HANDLE: $(html) -> $(array)\n\t\t\t\tif ( match[1] ) {\n\t\t\t\t\tdoc = (context ? context.ownerDocument || context : document);\n\n\t\t\t\t\t// If a single string is passed in and it's a single tag\n\t\t\t\t\t// just do a createElement and skip the rest\n\t\t\t\t\tret = rsingleTag.exec( selector );\n\n\t\t\t\t\tif ( ret ) {\n\t\t\t\t\t\tif ( jQuery.isPlainObject( context ) ) {\n\t\t\t\t\t\t\tselector = [ document.createElement( ret[1] ) ];\n\t\t\t\t\t\t\tjQuery.fn.attr.call( selector, context, true );\n\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselector = [ doc.createElement( ret[1] ) ];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tret = jQuery.buildFragment( [ match[1] ], [ doc ] );\n\t\t\t\t\t\tselector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\treturn jQuery.merge( this, selector );\n\t\t\t\t\t\n\t\t\t\t// HANDLE: $(\"#id\")\n\t\t\t\t} else {\n\t\t\t\t\telem = document.getElementById( match[2] );\n\n\t\t\t\t\t// Check parentNode to catch when Blackberry 4.6 returns\n\t\t\t\t\t// nodes that are no longer in the document #6963\n\t\t\t\t\tif ( elem && elem.parentNode ) {\n\t\t\t\t\t\t// Otherwise, we inject the element directly into the jQuery object\n\t\t\t\t\t\tthis.length = 1;\n\t\t\t\t\t\tthis[0] = elem;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context = document;\n\t\t\t\t\tthis.selector = selector;\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\n\t\t\t// HANDLE: $(\"TAG\")\n\t\t\t} else if ( !context && !rnonword.test( selector ) ) {\n\t\t\t\tthis.selector = selector;\n\t\t\t\tthis.context = document;\n\t\t\t\tselector = document.getElementsByTagName( selector );\n\t\t\t\treturn jQuery.merge( this, selector );\n\n\t\t\t// HANDLE: $(expr, $(...))\n\t\t\t} else if ( !context || context.jquery ) {\n\t\t\t\treturn (context || rootjQuery).find( selector );\n\n\t\t\t// HANDLE: $(expr, context)\n\t\t\t// (which is just equivalent to: $(context).find(expr)\n\t\t\t} else {\n\t\t\t\treturn jQuery( context ).find( selector );\n\t\t\t}\n\n\t\t\n\t\t} \n\n\t\tif (selector.selector !== undefined) {\n\t\t\tthis.selector = selector.selector;\n\t\t\tthis.context = selector.context;\n\t\t}\n\n\t\treturn jQuery.makeArray( selector, this );\n\t},\n\n\t// Start with an empty selector\n\tselector: \"\",\n\n\t// The current version of jQuery being used\n\tjquery: \"1.4.3\",\n\n\t// The default length of a jQuery object is 0\n\tlength: 0,\n\n\t// The number of elements contained in the matched element set\n\tsize: function() {\n\t\treturn this.length;\n\t},\n\n\ttoArray: function() {\n\t\treturn slice.call( this, 0 );\n\t},\n\n\t// Get the Nth element in the matched element set OR\n\t// Get the whole matched element set as a clean array\n\tget: function( num ) {\n\t\treturn num == null ?\n\n\t\t\t// Return a 'clean' array\n\t\t\tthis.toArray() :\n\n\t\t\t// Return just the object\n\t\t\t( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );\n\t},\n\n\t// Take an array of elements and push it onto the stack\n\t// (returning the new matched element set)\n\tpushStack: function( elems, name, selector ) {\n\t\t// Build a new jQuery matched element set\n\t\tvar ret = jQuery();\n\n\t\tif ( jQuery.isArray( elems ) ) {\n\t\t\tpush.apply( ret, elems );\n\t\t\n\t\t} else {\n\t\t\tjQuery.merge( ret, elems );\n\t\t}\n\n\t\t// Add the old object onto the stack (as a reference)\n\t\tret.prevObject = this;\n\n\t\tret.context = this.context;\n\n\t\tif ( name === \"find\" ) {\n\t\t\tret.selector = this.selector + (this.selector ? \" \" : \"\") + selector;\n\t\t} else if ( name ) {\n\t\t\tret.selector = this.selector + \".\" + name + \"(\" + selector + \")\";\n\t\t}\n\n\t\t// Return the newly-formed element set\n\t\treturn ret;\n\t},\n\n\t// Execute a callback for every element in the matched set.\n\t// (You can seed the arguments with an array of args, but this is\n\t// only used internally.)\n\teach: function( callback, args ) {\n\t\treturn jQuery.each( this, callback, args );\n\t},\n\t\n\teq: function( i ) {\n\t\treturn i === -1 ?\n\t\t\tthis.slice( i ) :\n\t\t\tthis.slice( i, +i + 1 );\n\t},\n\n\tfirst: function() {\n\t\treturn this.eq( 0 );\n\t},\n\n\tlast: function() {\n\t\treturn this.eq( -1 );\n\t},\n\n\tslice: function() {\n\t\treturn this.pushStack( slice.apply( this, arguments ),\n\t\t\t\"slice\", slice.call(arguments).join(\",\") );\n\t},\n\n\tmap: function( callback ) {\n\t\treturn this.pushStack( jQuery.map(this, function( elem, i ) {\n\t\t\treturn callback.call( elem, i, elem );\n\t\t}));\n\t},\n\t\n\tend: function() {\n\t\treturn this.prevObject || jQuery(null);\n\t},\n\n\t// For internal use only.\n\t// Behaves like an Array's method, not like a jQuery method.\n\tpush: push,\n\tsort: [].sort,\n\tsplice: [].splice\n};\n\n// Give the init function the jQuery prototype for later instantiation\njQuery.fn.init.prototype = jQuery.fn;\n\njQuery.extend = jQuery.fn.extend = function() {\n\t// copy reference to target object\n\tvar target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray;\n\n\t// Handle a deep copy situation\n\tif ( typeof target === \"boolean\" ) {\n\t\tdeep = target;\n\t\ttarget = arguments[1] || {};\n\t\t// skip the boolean and the target\n\t\ti = 2;\n\t}\n\n\t// Handle case when target is a string or something (possible in deep copy)\n\tif ( typeof target !== \"object\" && !jQuery.isFunction(target) ) {\n\t\ttarget = {};\n\t}\n\n\t// extend jQuery itself if only one argument is passed\n\tif ( length === i ) {\n\t\ttarget = this;\n\t\t--i;\n\t}\n\n\tfor ( ; i < length; i++ ) {\n\t\t// Only deal with non-null/undefined values\n\t\tif ( (options = arguments[ i ]) != null ) {\n\t\t\t// Extend the base object\n\t\t\tfor ( name in options ) {\n\t\t\t\tsrc = target[ name ];\n\t\t\t\tcopy = options[ name ];\n\n\t\t\t\t// Prevent never-ending loop\n\t\t\t\tif ( target === copy ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Recurse if we're merging plain objects or arrays\n\t\t\t\tif ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {\n\t\t\t\t\tif ( copyIsArray ) {\n\t\t\t\t\t\tcopyIsArray = false;\n\t\t\t\t\t\tclone = src && jQuery.isArray(src) ? src : [];\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclone = src && jQuery.isPlainObject(src) ? src : {};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Never move original objects, clone them\n\t\t\t\t\ttarget[ name ] = jQuery.extend( deep, clone, copy );\n\n\t\t\t\t// Don't bring in undefined values\n\t\t\t\t} else if ( copy !== undefined ) {\n\t\t\t\t\ttarget[ name ] = copy;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the modified object\n\treturn target;\n};\n\njQuery.extend({\n\tsetDocument: function(d) {\n\t\tdocument = d;\n\t\trootjQuery = jQuery(d);\n\t},\n\t// See test/unit/core.js for details concerning isFunction.\n\t// Since version 1.3, DOM methods and functions like alert\n\t// aren't supported. They return false on IE (#2968).\n\tisFunction: function( obj ) {\n\t\treturn jQuery.type(obj) === \"function\";\n\t},\n\n\tisArray: Array.isArray || function( obj ) {\n\t\treturn jQuery.type(obj) === \"array\";\n\t},\n\n\t// A crude way of determining if an object is a window\n\tisWindow: function( obj ) {\n\t\treturn obj && typeof obj === \"object\" && \"setInterval\" in obj;\n\t},\n\n\tisNaN: function( obj ) {\n\t\treturn obj == null || !rdigit.test( obj ) || isNaN( obj );\n\t},\n\n\ttype: function( obj ) {\n\t\treturn obj == null ?\n\t\t\tString( obj ) :\n\t\t\tclass2type[ toString.call(obj) ] || \"object\";\n\t},\n\n\tisPlainObject: function( obj ) {\n\t\t// Must be an Object.\n\t\t// Because of IE, we also have to check the presence of the constructor property.\n\t\t// Make sure that DOM nodes and window objects don't pass through, as well\n\t\tif ( !obj || jQuery.type(obj) !== \"object\" || obj.nodeType || jQuery.isWindow( obj ) ) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// Not own constructor property must be Object\n\t\tif ( obj.constructor &&\n\t\t\t!hasOwn.call(obj, \"constructor\") &&\n\t\t\t!hasOwn.call(obj.constructor.prototype, \"isPrototypeOf\") ) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// Own properties are enumerated firstly, so to speed up,\n\t\t// if last one is own, then all properties are own.\n\t\n\t\tvar key;\n\t\tfor ( key in obj ) {}\n\t\t\n\t\treturn key === undefined || hasOwn.call( obj, key );\n\t},\n\n\tisEmptyObject: function( obj ) {\n\t\tfor ( var name in obj ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t},\n\t\n\terror: function( msg ) {\n\t\tthrow msg;\n\t},\n\t\n\n\tnoop: function() {},\n\n\n\tnodeName: function( elem, name ) {\n\t\treturn elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();\n\t},\n\n\t// args is for internal usage only\n\teach: function( object, callback, args ) {\n\t\tvar name, i = 0,\n\t\t\tlength = object.length,\n\t\t\tisObj = length === undefined || jQuery.isFunction(object);\n\n\t\tif ( args ) {\n\t\t\tif ( isObj ) {\n\t\t\t\tfor ( name in object ) {\n\t\t\t\t\tif ( callback.apply( object[ name ], args ) === false ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( ; i < length; ) {\n\t\t\t\t\tif ( callback.apply( object[ i++ ], args ) === false ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t// A special, fast, case for the most common use of each\n\t\t} else {\n\t\t\tif ( isObj ) {\n\t\t\t\tfor ( name in object ) {\n\t\t\t\t\tif ( callback.call( object[ name ], name, object[ name ] ) === false ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( var value = object[0];\n\t\t\t\t\ti < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}\n\t\t\t}\n\t\t}\n\n\t\treturn object;\n\t},\n\n\t// Use native String.trim function wherever possible\n\ttrim: trim ?\n\t\tfunction( text ) {\n\t\t\treturn text == null ?\n\t\t\t\t\"\" :\n\t\t\t\ttrim.call( text );\n\t\t} :\n\n\t\t// Otherwise use our own trimming functionality\n\t\tfunction( text ) {\n\t\t\treturn text == null ?\n\t\t\t\t\"\" :\n\t\t\t\ttext.toString().replace( trimLeft, \"\" ).replace( trimRight, \"\" );\n\t\t},\n\n\t// results is for internal usage only\n\tmakeArray: function( array, results ) {\n\t\tvar ret = results || [];\n\n\t\tif ( array != null ) {\n\t\t\t// The window, strings (and functions) also have 'length'\n\t\t\t// The extra typeof function check is to prevent crashes\n\t\t\t// in Safari 2 (See: #3039)\n\t\t\t// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930\n\t\t\tvar type = jQuery.type(array);\n\n\t\t\tif ( array.length == null || type === \"string\" || type === \"function\" || type === \"regexp\" || jQuery.isWindow( array ) ) {\n\t\t\t\tpush.call( ret, array );\n\t\t\t} else {\n\t\t\t\tjQuery.merge( ret, array );\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t},\n\n\tinArray: function( elem, array ) {\n\t\tif ( array.indexOf ) {\n\t\t\treturn array.indexOf( elem );\n\t\t}\n\n\t\tfor ( var i = 0, length = array.length; i < length; i++ ) {\n\t\t\tif ( array[ i ] === elem ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\n\t\treturn -1;\n\t},\n\n\tmerge: function( first, second ) {\n\t\tvar i = first.length, j = 0;\n\n\t\tif ( typeof second.length === \"number\" ) {\n\t\t\tfor ( var l = second.length; j < l; j++ ) {\n\t\t\t\tfirst[ i++ ] = second[ j ];\n\t\t\t}\n\t\t\n\t\t} else {\n\t\t\twhile ( second[j] !== undefined ) {\n\t\t\t\tfirst[ i++ ] = second[ j++ ];\n\t\t\t}\n\t\t}\n\n\t\tfirst.length = i;\n\n\t\treturn first;\n\t},\n\n\tgrep: function( elems, callback, inv ) {\n\t\tvar ret = [], retVal;\n\t\tinv = !!inv;\n\n\t\t// Go through the array, only saving the items\n\t\t// that pass the validator function\n\t\tfor ( var i = 0, length = elems.length; i < length; i++ ) {\n\t\t\tretVal = !!callback( elems[ i ], i );\n\t\t\tif ( inv !== retVal ) {\n\t\t\t\tret.push( elems[ i ] );\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t},\n\n\t// arg is for internal usage only\n\tmap: function( elems, callback, arg ) {\n\t\tvar ret = [], value;\n\n\t\t// Go through the array, translating each of the items to their\n\t\t// new value (or values).\n\t\tfor ( var i = 0, length = elems.length; i < length; i++ ) {\n\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\tif ( value != null ) {\n\t\t\t\tret[ ret.length ] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn ret.concat.apply( [], ret );\n\t},\n\n\t// A global GUID counter for objects\n\tguid: 1,\n\n\tproxy: function( fn, proxy, thisObject ) {\n\t\tif ( arguments.length === 2 ) {\n\t\t\tif ( typeof proxy === \"string\" ) {\n\t\t\t\tthisObject = fn;\n\t\t\t\tfn = thisObject[ proxy ];\n\t\t\t\tproxy = undefined;\n\n\t\t\t} else if ( proxy && !jQuery.isFunction( proxy ) ) {\n\t\t\t\tthisObject = proxy;\n\t\t\t\tproxy = undefined;\n\t\t\t}\n\t\t}\n\n\t\tif ( !proxy && fn ) {\n\t\t\tproxy = function() {\n\t\t\t\treturn fn.apply( thisObject || this, arguments );\n\t\t\t};\n\t\t}\n\n\t\t// Set the guid of unique handler to the same of original handler, so it can be removed\n\t\tif ( fn ) {\n\t\t\tproxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;\n\t\t}\n\n\t\t// So proxy can be declared as an argument\n\t\treturn proxy;\n\t},\n\n\t// Mutifunctional method to get and set values to a collection\n\t// The value/s can be optionally by executed if its a function\n\taccess: function( elems, key, value, exec, fn, pass ) {\n\t\tvar length = elems.length;\n\t\n\t\t// Setting many attributes\n\t\tif ( typeof key === \"object\" ) {\n\t\t\tfor ( var k in key ) {\n\t\t\t\tjQuery.access( elems, k, key[k], exec, fn, value );\n\t\t\t}\n\t\t\treturn elems;\n\t\t}\n\t\n\t\t// Setting one attribute\n\t\tif ( value !== undefined ) {\n\t\t\t// Optionally, function values get executed if exec is true\n\t\t\texec = !pass && exec && jQuery.isFunction(value);\n\t\t\n\t\t\tfor ( var i = 0; i < length; i++ ) {\n\t\t\t\tfn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );\n\t\t\t}\n\t\t\n\t\t\treturn elems;\n\t\t}\n\t\n\t\t// Getting an attribute\n\t\treturn length ? fn( elems[0], key ) : undefined;\n\t},\n\n\tnow: function() {\n\t\treturn (new Date()).getTime();\n\t}\n});\n\n// Populate the class2type map\njQuery.each(\"Boolean Number String Function Array Date RegExp Object\".split(\" \"), function(i, name) {\n\tclass2type[ \"[object \" + name + \"]\" ] = name.toLowerCase();\n});\n\nif ( indexOf ) {\n\tjQuery.inArray = function( elem, array ) {\n\t\treturn indexOf.call( array, elem );\n\t};\n}\n\n// Verify that \\s matches non-breaking spaces\n// (IE fails on this test)\nif ( !rwhite.test( \"\\xA0\" ) ) {\n\ttrimLeft = /^[\\s\\xA0]+/;\n\ttrimRight = /[\\s\\xA0]+$/;\n}\n\n// All jQuery objects should point back to these\n//rootjQuery = jQuery(document);\n\n// Expose jQuery to the global object\nreturn (this.jQuery = this.$ = jQuery);\n\n})();\n\n\n(function( jQuery ) {\n\nvar rclass = /[\\n\\t]/g,\n\trspaces = /\\s+/,\n\trreturn = /\\r/g,\n\trspecialurl = /^(?:href|src|style)$/,\n\trtype = /^(?:button|input)$/i,\n\trfocusable = /^(?:button|input|object|select|textarea)$/i,\n\trclickable = /^a(?:rea)?$/i,\n\trradiocheck = /^(?:radio|checkbox)$/i;\n\njQuery.fn.extend({\n\tattr: function( name, value ) {\n\t\treturn jQuery.access( this, name, value, true, jQuery.attr );\n\t},\n\n\thasClass: function( selector ) {\n\t\tvar className = \" \" + selector + \" \";\n\t\tfor ( var i = 0, l = this.length; i < l; i++ ) {\n\t\t\tif ( (\" \" + this[i].className + \" \").replace(rclass, \" \").indexOf( className ) > -1 ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t},\n\n\tval: function( value ) {\n\t\tif ( !arguments.length ) {\n\t\t\tvar elem = this[0];\n\n\t\t\tif ( elem ) {\n\t\t\t\tif ( jQuery.nodeName( elem, \"option\" ) ) {\n\t\t\t\t\t// attributes.value is undefined in Blackberry 4.7 but\n\t\t\t\t\t// uses .value. See #6932\n\t\t\t\t\tvar val = elem.attributes.value;\n\t\t\t\t\treturn !val || val.specified ? elem.value : elem.text;\n\t\t\t\t}\n\n\t\t\t\t// We need to handle select boxes special\n\t\t\t\tif ( jQuery.nodeName( elem, \"select\" ) ) {\n\t\t\t\t\tvar index = elem.selectedIndex,\n\t\t\t\t\t\tvalues = [],\n\t\t\t\t\t\toptions = elem.options,\n\t\t\t\t\t\tone = elem.type === \"select-one\";\n\n\t\t\t\t\t// Nothing was selected\n\t\t\t\t\tif ( index < 0 ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Loop through all the selected options\n\t\t\t\t\tfor ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {\n\t\t\t\t\t\tvar option = options[ i ];\n\n\t\t\t\t\t\t// Don't return options that are disabled or in a disabled optgroup\n\t\t\t\t\t\tif ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute(\"disabled\") === null) && \n\t\t\t\t\t\t\t\t(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, \"optgroup\" )) ) {\n\n\t\t\t\t\t\t\t// Get the specific value for the option\n\t\t\t\t\t\t\tvalue = jQuery(option).val();\n\n\t\t\t\t\t\t\t// We don't need an array for one selects\n\t\t\t\t\t\t\tif ( one ) {\n\t\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Multi-Selects return an array\n\t\t\t\t\t\t\tvalues.push( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn values;\n\t\t\t\t}\n\n\t\t\t\t// Handle the case where in Webkit \"\" is returned instead of \"on\" if a value isn't specified\n\t\t\t\tif ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {\n\t\t\t\t\treturn elem.getAttribute(\"value\") === null ? \"on\" : elem.value;\n\t\t\t\t}\n\t\t\t\t\n\n\t\t\t\t// Everything else, we just grab the value\n\t\t\t\treturn (elem.value || \"\").replace(rreturn, \"\");\n\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t}\n\n\t\tvar isFunction = jQuery.isFunction(value);\n\n\t\treturn this.each(function(i) {\n\t\t\tvar self = jQuery(this), val = value;\n\n\t\t\tif ( this.nodeType !== 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isFunction ) {\n\t\t\t\tval = value.call(this, i, self.val());\n\t\t\t}\n\n\t\t\t// Treat null/undefined as \"\"; convert numbers to string\n\t\t\tif ( val == null ) {\n\t\t\t\tval = \"\";\n\t\t\t} else if ( typeof val === \"number\" ) {\n\t\t\t\tval += \"\";\n\t\t\t} else if ( jQuery.isArray(val) ) {\n\t\t\t\tval = jQuery.map(val, function (value) {\n\t\t\t\t\treturn value == null ? \"\" : value + \"\";\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {\n\t\t\t\tthis.checked = jQuery.inArray( self.val(), val ) >= 0;\n\n\t\t\t} else if ( jQuery.nodeName( this, \"select\" ) ) {\n\t\t\t\tvar values = jQuery.makeArray(val);\n\n\t\t\t\tjQuery( \"option\", this ).each(function() {\n\t\t\t\t\tthis.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;\n\t\t\t\t});\n\n\t\t\t\tif ( !values.length ) {\n\t\t\t\t\tthis.selectedIndex = -1;\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tthis.value = val;\n\t\t\t}\n\t\t});\n\t}\n});\n\njQuery.extend({\n\tattrFn: {\n\t\tval: true,\n\t\tcss: true,\n\t\thtml: true,\n\t\ttext: true,\n\t\tdata: true,\n\t\twidth: true,\n\t\theight: true,\n\t\toffset: true\n\t},\n\t\t\n\tattr: function( elem, name, value, pass ) {\n\t\t// don't set attributes on text and comment nodes\n\t\tif ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( pass && name in jQuery.attrFn ) {\n\t\t\treturn jQuery(elem)[name](value);\n\t\t}\n\n\t\tvar notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),\n\t\t\t// Whether we are setting (or getting)\n\t\t\tset = value !== undefined;\n\n\t\t// Try to normalize/fix the name\n\t\tname = notxml && jQuery.props[ name ] || name;\n\n\t\t// Only do all the following if this is a node (faster for style)\n\t\tif ( elem.nodeType === 1 ) {\n\t\t\t// These attributes require special treatment\n\t\t\tvar special = rspecialurl.test( name );\n\n\t\t\t// Safari mis-reports the default selected property of an option\n\t\t\t// Accessing the parent's selectedIndex property fixes it\n\t\t\tif ( name === \"selected\" && !jQuery.support.optSelected ) {\n\t\t\t\tvar parent = elem.parentNode;\n\t\t\t\tif ( parent ) {\n\t\t\t\t\tparent.selectedIndex;\n\t\n\t\t\t\t\t// Make sure that it also works with optgroups, see #5701\n\t\t\t\t\tif ( parent.parentNode ) {\n\t\t\t\t\t\tparent.parentNode.selectedIndex;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If applicable, access the attribute via the DOM 0 way\n\t\t\t// 'in' checks fail in Blackberry 4.7 #6931\n\t\t\tif ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {\n\t\t\t\tif ( set ) {\n\t\t\t\t\t// We can't allow the type property to be changed (since it causes problems in IE)\n\t\t\t\t\tif ( name === \"type\" && rtype.test( elem.nodeName ) && elem.parentNode ) {\n\t\t\t\t\t\tjQuery.error( \"type property can't be changed\" );\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( value === null ) {\n\t\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\t\telem.removeAttribute( name );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\telem[ name ] = value;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// browsers index elements by id/name on forms, give priority to attributes.\n\t\t\t\tif ( jQuery.nodeName( elem, \"form\" ) && elem.getAttributeNode(name) ) {\n\t\t\t\t\treturn elem.getAttributeNode( name ).nodeValue;\n\t\t\t\t}\n\n\t\t\t\t// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set\n\t\t\t\t// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/\n\t\t\t\tif ( name === \"tabIndex\" ) {\n\t\t\t\t\tvar attributeNode = elem.getAttributeNode( \"tabIndex\" );\n\n\t\t\t\t\treturn attributeNode && attributeNode.specified ?\n\t\t\t\t\t\tattributeNode.value :\n\t\t\t\t\t\trfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?\n\t\t\t\t\t\t\t0 :\n\t\t\t\t\t\t\tundefined;\n\t\t\t\t}\n\n\t\t\t\treturn elem[ name ];\n\t\t\t}\n\n\t\t\tif ( !jQuery.support.style && notxml && name === \"style\" ) {\n\t\t\t\tif ( set ) {\n\t\t\t\t\telem.style.cssText = \"\" + value;\n\t\t\t\t}\n\n\t\t\t\treturn elem.style.cssText;\n\t\t\t}\n\n\t\t\tif ( set ) {\n\t\t\t\t// convert the value to a string (all browsers do this but IE) see #1070\n\t\t\t\telem.setAttribute( name, \"\" + value );\n\t\t\t}\n\n\t\t\t// Ensure that missing attributes return undefined\n\t\t\t// Blackberry 4.7 returns \"\" from getAttribute #6938\n\t\t\tif ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tvar attr = !jQuery.support.hrefNormalized && notxml && special ?\n\t\t\t\t\t// Some attributes require a special call on IE\n\t\t\t\t\telem.getAttribute( name, 2 ) :\n\t\t\t\t\telem.getAttribute( name );\n\n\t\t\t// Non-existent attributes return null, we normalize to undefined\n\t\t\treturn attr === null ? undefined : attr;\n\t\t}\n\t}\n});\n\n})( jQuery );\n/*!\n * Sizzle CSS Selector Engine - v1.0\n *  Copyright 2009, The Dojo Foundation\n *  Released under the MIT, BSD, and GPL Licenses.\n *  More information: http://sizzlejs.com/\n */\n(function(){\n\nvar chunker = /((?:\\((?:\\([^()]+\\)|[^()]+)+\\)|\\[(?:\\[[^\\[\\]]*\\]|['\"][^'\"]*['\"]|[^\\[\\]'\"]+)+\\]|\\\\.|[^ >+~,(\\[\\\\]+)+|[>+~])(\\s*,\\s*)?((?:.|\\r|\\n)*)/g,\n\tdone = 0,\n\ttoString = Object.prototype.toString,\n\thasDuplicate = false,\n\tbaseHasDuplicate = true;\n\n// Here we check if the JavaScript engine is using some sort of\n// optimization where it does not always call our comparision\n// function. If that is the case, discard the hasDuplicate value.\n//   Thus far that includes Google Chrome.\n[0, 0].sort(function(){\n\tbaseHasDuplicate = false;\n\treturn 0;\n});\n\nvar Sizzle = function(selector, context, results, seed) {\n\tresults = results || [];\n\tcontext = context || document;\n\n\tvar origContext = context;\n\n\tif ( context.nodeType !== 1 && context.nodeType !== 9 ) {\n\t\treturn [];\n\t}\n\t\n\tif ( !selector || typeof selector !== \"string\" ) {\n\t\treturn results;\n\t}\n\n\tvar parts = [], m, set, checkSet, extra, prune = true, contextXML = Sizzle.isXML(context),\n\t\tsoFar = selector, ret, cur, pop, i;\n\t\n\t// Reset the position of the chunker regexp (start from head)\n\tdo {\n\t\tchunker.exec(\"\");\n\t\tm = chunker.exec(soFar);\n\n\t\tif ( m ) {\n\t\t\tsoFar = m[3];\n\t\t\n\t\t\tparts.push( m[1] );\n\t\t\n\t\t\tif ( m[2] ) {\n\t\t\t\textra = m[3];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} while ( m );\n\n\tif ( parts.length > 1 && origPOS.exec( selector ) ) {\n\t\tif ( parts.length === 2 && Expr.relative[ parts[0] ] ) {\n\t\t\tset = posProcess( parts[0] + parts[1], context );\n\t\t} else {\n\t\t\tset = Expr.relative[ parts[0] ] ?\n\t\t\t\t[ context ] :\n\t\t\t\tSizzle( parts.shift(), context );\n\n\t\t\twhile ( parts.length ) {\n\t\t\t\tselector = parts.shift();\n\n\t\t\t\tif ( Expr.relative[ selector ] ) {\n\t\t\t\t\tselector += parts.shift();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tset = posProcess( selector, set );\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// Take a shortcut and set the context if the root selector is an ID\n\t\t// (but not if it'll be faster if the inner selector is an ID)\n\t\tif ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&\n\t\t\t\tExpr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {\n\t\t\tret = Sizzle.find( parts.shift(), context, contextXML );\n\t\t\tcontext = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];\n\t\t}\n\n\t\tif ( context ) {\n\t\t\tret = seed ?\n\t\t\t\t{ expr: parts.pop(), set: makeArray(seed) } :\n\t\t\t\tSizzle.find( parts.pop(), parts.length === 1 && (parts[0] === \"~\" || parts[0] === \"+\") && context.parentNode ? context.parentNode : context, contextXML );\n\t\t\tset = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;\n\n\t\t\tif ( parts.length > 0 ) {\n\t\t\t\tcheckSet = makeArray(set);\n\t\t\t} else {\n\t\t\t\tprune = false;\n\t\t\t}\n\n\t\t\twhile ( parts.length ) {\n\t\t\t\tcur = parts.pop();\n\t\t\t\tpop = cur;\n\n\t\t\t\tif ( !Expr.relative[ cur ] ) {\n\t\t\t\t\tcur = \"\";\n\t\t\t\t} else {\n\t\t\t\t\tpop = parts.pop();\n\t\t\t\t}\n\n\t\t\t\tif ( pop == null ) {\n\t\t\t\t\tpop = context;\n\t\t\t\t}\n\n\t\t\t\tExpr.relative[ cur ]( checkSet, pop, contextXML );\n\t\t\t}\n\t\t} else {\n\t\t\tcheckSet = parts = [];\n\t\t}\n\t}\n\n\tif ( !checkSet ) {\n\t\tcheckSet = set;\n\t}\n\n\tif ( !checkSet ) {\n\t\tSizzle.error( cur || selector );\n\t}\n\n\tif ( toString.call(checkSet) === \"[object Array]\" ) {\n\t\tif ( !prune ) {\n\t\t\tresults.push.apply( results, checkSet );\n\t\t} else if ( context && context.nodeType === 1 ) {\n\t\t\tfor ( i = 0; checkSet[i] != null; i++ ) {\n\t\t\t\tif ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {\n\t\t\t\t\tresults.push( set[i] );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; checkSet[i] != null; i++ ) {\n\t\t\t\tif ( checkSet[i] && checkSet[i].nodeType === 1 ) {\n\t\t\t\t\tresults.push( set[i] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tmakeArray( checkSet, results );\n\t}\n\n\tif ( extra ) {\n\t\tSizzle( extra, origContext, results, seed );\n\t\tSizzle.uniqueSort( results );\n\t}\n\n\treturn results;\n};\n\nSizzle.uniqueSort = function(results){\n\tif ( sortOrder ) {\n\t\thasDuplicate = baseHasDuplicate;\n\t\tresults.sort(sortOrder);\n\n\t\tif ( hasDuplicate ) {\n\t\t\tfor ( var i = 1; i < results.length; i++ ) {\n\t\t\t\tif ( results[i] === results[i-1] ) {\n\t\t\t\t\tresults.splice(i--, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn results;\n};\n\nSizzle.matches = function(expr, set){\n\treturn Sizzle(expr, null, null, set);\n};\n\nSizzle.matchesSelector = function(node, expr){\n\treturn Sizzle(expr, null, null, [node]).length > 0;\n};\n\nSizzle.find = function(expr, context, isXML){\n\tvar set;\n\n\tif ( !expr ) {\n\t\treturn [];\n\t}\n\n\tfor ( var i = 0, l = Expr.order.length; i < l; i++ ) {\n\t\tvar type = Expr.order[i], match;\n\t\t\n\t\tif ( (match = Expr.leftMatch[ type ].exec( expr )) ) {\n\t\t\tvar left = match[1];\n\t\t\tmatch.splice(1,1);\n\n\t\t\tif ( left.substr( left.length - 1 ) !== \"\\\\\" ) {\n\t\t\t\tmatch[1] = (match[1] || \"\").replace(/\\\\/g, \"\");\n\t\t\t\tset = Expr.find[ type ]( match, context, isXML );\n\t\t\t\tif ( set != null ) {\n\t\t\t\t\texpr = expr.replace( Expr.match[ type ], \"\" );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( !set ) {\n\t\tset = context.getElementsByTagName(\"*\");\n\t}\n\n\treturn {set: set, expr: expr};\n};\n\nSizzle.filter = function(expr, set, inplace, not){\n\tvar old = expr, result = [], curLoop = set, match, anyFound,\n\t\tisXMLFilter = set && set[0] && Sizzle.isXML(set[0]);\n\n\twhile ( expr && set.length ) {\n\t\tfor ( var type in Expr.filter ) {\n\t\t\tif ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {\n\t\t\t\tvar filter = Expr.filter[ type ], found, item, left = match[1];\n\t\t\t\tanyFound = false;\n\n\t\t\t\tmatch.splice(1,1);\n\n\t\t\t\tif ( left.substr( left.length - 1 ) === \"\\\\\" ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif ( curLoop === result ) {\n\t\t\t\t\tresult = [];\n\t\t\t\t}\n\n\t\t\t\tif ( Expr.preFilter[ type ] ) {\n\t\t\t\t\tmatch = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );\n\n\t\t\t\t\tif ( !match ) {\n\t\t\t\t\t\tanyFound = found = true;\n\t\t\t\t\t} else if ( match === true ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( match ) {\n\t\t\t\t\tfor ( var i = 0; (item = curLoop[i]) != null; i++ ) {\n\t\t\t\t\t\tif ( item ) {\n\t\t\t\t\t\t\tfound = filter( item, match, i, curLoop );\n\t\t\t\t\t\t\tvar pass = not ^ !!found;\n\n\t\t\t\t\t\t\tif ( inplace && found != null ) {\n\t\t\t\t\t\t\t\tif ( pass ) {\n\t\t\t\t\t\t\t\t\tanyFound = true;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcurLoop[i] = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if ( pass ) {\n\t\t\t\t\t\t\t\tresult.push( item );\n\t\t\t\t\t\t\t\tanyFound = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( found !== undefined ) {\n\t\t\t\t\tif ( !inplace ) {\n\t\t\t\t\t\tcurLoop = result;\n\t\t\t\t\t}\n\n\t\t\t\t\texpr = expr.replace( Expr.match[ type ], \"\" );\n\n\t\t\t\t\tif ( !anyFound ) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Improper expression\n\t\tif ( expr === old ) {\n\t\t\tif ( anyFound == null ) {\n\t\t\t\tSizzle.error( expr );\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\told = expr;\n\t}\n\n\treturn curLoop;\n};\n\nSizzle.error = function( msg ) {\n\tthrow \"Syntax error, unrecognized expression: \" + msg;\n};\n\nvar Expr = Sizzle.selectors = {\n\torder: [ \"ID\", \"NAME\", \"TAG\" ],\n\tmatch: {\n\t\tID: /#((?:[\\w\\u00c0-\\uFFFF\\-]|\\\\.)+)/,\n\t\tCLASS: /\\.((?:[\\w\\u00c0-\\uFFFF\\-]|\\\\.)+)/,\n\t\tNAME: /\\[name=['\"]*((?:[\\w\\u00c0-\\uFFFF\\-]|\\\\.)+)['\"]*\\]/,\n\t\tATTR: /\\[\\s*((?:[\\w\\u00c0-\\uFFFF\\-]|\\\\.)+)\\s*(?:(\\S?=)\\s*(['\"]*)(.*?)\\3|)\\s*\\]/,\n\t\tTAG: /^((?:[\\w\\u00c0-\\uFFFF\\*\\-]|\\\\.)+)/,\n\t\tCHILD: /:(only|nth|last|first)-child(?:\\((even|odd|[\\dn+\\-]*)\\))?/,\n\t\tPOS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\))?(?=[^\\-]|$)/,\n\t\tPSEUDO: /:((?:[\\w\\u00c0-\\uFFFF\\-]|\\\\.)+)(?:\\((['\"]?)((?:\\([^\\)]+\\)|[^\\(\\)]*)+)\\2\\))?/\n\t},\n\tleftMatch: {},\n\tattrMap: {\n\t\t\"class\": \"className\",\n\t\t\"for\": \"htmlFor\"\n\t},\n\tattrHandle: {\n\t\thref: function(elem){\n\t\t\treturn elem.getAttribute(\"href\");\n\t\t}\n\t},\n\trelative: {\n\t\t\"+\": function(checkSet, part){\n\t\t\tvar isPartStr = typeof part === \"string\",\n\t\t\t\tisTag = isPartStr && !/\\W/.test(part),\n\t\t\t\tisPartStrNotTag = isPartStr && !isTag;\n\n\t\t\tif ( isTag ) {\n\t\t\t\tpart = part.toLowerCase();\n\t\t\t}\n\n\t\t\tfor ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {\n\t\t\t\tif ( (elem = checkSet[i]) ) {\n\t\t\t\t\twhile ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}\n\n\t\t\t\t\tcheckSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?\n\t\t\t\t\t\telem || false :\n\t\t\t\t\t\telem === part;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( isPartStrNotTag ) {\n\t\t\t\tSizzle.filter( part, checkSet, true );\n\t\t\t}\n\t\t},\n\t\t\">\": function(checkSet, part){\n\t\t\tvar isPartStr = typeof part === \"string\",\n\t\t\t\telem, i = 0, l = checkSet.length;\n\n\t\t\tif ( isPartStr && !/\\W/.test(part) ) {\n\t\t\t\tpart = part.toLowerCase();\n\n\t\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\t\telem = checkSet[i];\n\t\t\t\t\tif ( elem ) {\n\t\t\t\t\t\tvar parent = elem.parentNode;\n\t\t\t\t\t\tcheckSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\t\telem = checkSet[i];\n\t\t\t\t\tif ( elem ) {\n\t\t\t\t\t\tcheckSet[i] = isPartStr ?\n\t\t\t\t\t\t\telem.parentNode :\n\t\t\t\t\t\t\telem.parentNode === part;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( isPartStr ) {\n\t\t\t\t\tSizzle.filter( part, checkSet, true );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\"\": function(checkSet, part, isXML){\n\t\t\tvar doneName = done++, checkFn = dirCheck, nodeCheck;\n\n\t\t\tif ( typeof part === \"string\" && !/\\W/.test(part) ) {\n\t\t\t\tpart = part.toLowerCase();\n\t\t\t\tnodeCheck = part;\n\t\t\t\tcheckFn = dirNodeCheck;\n\t\t\t}\n\n\t\t\tcheckFn(\"parentNode\", part, doneName, checkSet, nodeCheck, isXML);\n\t\t},\n\t\t\"~\": function(checkSet, part, isXML){\n\t\t\tvar doneName = done++, checkFn = dirCheck, nodeCheck;\n\n\t\t\tif ( typeof part === \"string\" && !/\\W/.test(part) ) {\n\t\t\t\tpart = part.toLowerCase();\n\t\t\t\tnodeCheck = part;\n\t\t\t\tcheckFn = dirNodeCheck;\n\t\t\t}\n\n\t\t\tcheckFn(\"previousSibling\", part, doneName, checkSet, nodeCheck, isXML);\n\t\t}\n\t},\n\tfind: {\n\t\tID: function(match, context, isXML){\n\t\t\tif ( typeof context.getElementById !== \"undefined\" && !isXML ) {\n\t\t\t\tvar m = context.getElementById(match[1]);\n\t\t\t\t// Check parentNode to catch when Blackberry 4.6 returns\n\t\t\t\t// nodes that are no longer in the document #6963\n\t\t\t\treturn m && m.parentNode ? [m] : [];\n\t\t\t}\n\t\t},\n\t\tNAME: function(match, context){\n\t\t\tif ( typeof context.getElementsByName !== \"undefined\" ) {\n\t\t\t\tvar ret = [], results = context.getElementsByName(match[1]);\n\n\t\t\t\tfor ( var i = 0, l = results.length; i < l; i++ ) {\n\t\t\t\t\tif ( results[i].getAttribute(\"name\") === match[1] ) {\n\t\t\t\t\t\tret.push( results[i] );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ret.length === 0 ? null : ret;\n\t\t\t}\n\t\t},\n\t\tTAG: function(match, context){\n\t\t\treturn context.getElementsByTagName(match[1]);\n\t\t}\n\t},\n\tpreFilter: {\n\t\tCLASS: function(match, curLoop, inplace, result, not, isXML){\n\t\t\tmatch = \" \" + match[1].replace(/\\\\/g, \"\") + \" \";\n\n\t\t\tif ( isXML ) {\n\t\t\t\treturn match;\n\t\t\t}\n\n\t\t\tfor ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {\n\t\t\t\tif ( elem ) {\n\t\t\t\t\tif ( not ^ (elem.className && (\" \" + elem.className + \" \").replace(/[\\t\\n]/g, \" \").indexOf(match) >= 0) ) {\n\t\t\t\t\t\tif ( !inplace ) {\n\t\t\t\t\t\t\tresult.push( elem );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if ( inplace ) {\n\t\t\t\t\t\tcurLoop[i] = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn false;\n\t\t},\n\t\tID: function(match){\n\t\t\treturn match[1].replace(/\\\\/g, \"\");\n\t\t},\n\t\tTAG: function(match, curLoop){\n\t\t\treturn match[1].toLowerCase();\n\t\t},\n\t\tCHILD: function(match){\n\t\t\tif ( match[1] === \"nth\" ) {\n\t\t\t\t// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'\n\t\t\t\tvar test = /(-?)(\\d*)n((?:\\+|-)?\\d*)/.exec(\n\t\t\t\t\tmatch[2] === \"even\" && \"2n\" || match[2] === \"odd\" && \"2n+1\" ||\n\t\t\t\t\t!/\\D/.test( match[2] ) && \"0n+\" + match[2] || match[2]);\n\n\t\t\t\t// calculate the numbers (first)n+(last) including if they are negative\n\t\t\t\tmatch[2] = (test[1] + (test[2] || 1)) - 0;\n\t\t\t\tmatch[3] = test[3] - 0;\n\t\t\t}\n\n\t\t\t// TODO: Move to normal caching system\n\t\t\tmatch[0] = done++;\n\n\t\t\treturn match;\n\t\t},\n\t\tATTR: function(match, curLoop, inplace, result, not, isXML){\n\t\t\tvar name = match[1].replace(/\\\\/g, \"\");\n\t\t\t\n\t\t\tif ( !isXML && Expr.attrMap[name] ) {\n\t\t\t\tmatch[1] = Expr.attrMap[name];\n\t\t\t}\n\n\t\t\tif ( match[2] === \"~=\" ) {\n\t\t\t\tmatch[4] = \" \" + match[4] + \" \";\n\t\t\t}\n\n\t\t\treturn match;\n\t\t},\n\t\tPSEUDO: function(match, curLoop, inplace, result, not){\n\t\t\tif ( match[1] === \"not\" ) {\n\t\t\t\t// If we're dealing with a complex expression, or a simple one\n\t\t\t\tif ( ( chunker.exec(match[3]) || \"\" ).length > 1 || /^\\w/.test(match[3]) ) {\n\t\t\t\t\tmatch[3] = Sizzle(match[3], null, null, curLoop);\n\t\t\t\t} else {\n\t\t\t\t\tvar ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);\n\t\t\t\t\tif ( !inplace ) {\n\t\t\t\t\t\tresult.push.apply( result, ret );\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t\treturn match;\n\t\t},\n\t\tPOS: function(match){\n\t\t\tmatch.unshift( true );\n\t\t\treturn match;\n\t\t}\n\t},\n\tfilters: {\n\t\tenabled: function(elem){\n\t\t\treturn elem.disabled === false && elem.type !== \"hidden\";\n\t\t},\n\t\tdisabled: function(elem){\n\t\t\treturn elem.disabled === true;\n\t\t},\n\t\tchecked: function(elem){\n\t\t\treturn elem.checked === true;\n\t\t},\n\t\tselected: function(elem){\n\t\t\t// Accessing this property makes selected-by-default\n\t\t\t// options in Safari work properly\n\t\t\telem.parentNode.selectedIndex;\n\t\t\treturn elem.selected === true;\n\t\t},\n\t\tparent: function(elem){\n\t\t\treturn !!elem.firstChild;\n\t\t},\n\t\tempty: function(elem){\n\t\t\treturn !elem.firstChild;\n\t\t},\n\t\thas: function(elem, i, match){\n\t\t\treturn !!Sizzle( match[3], elem ).length;\n\t\t},\n\t\theader: function(elem){\n\t\t\treturn (/h\\d/i).test( elem.nodeName );\n\t\t},\n\t\ttext: function(elem){\n\t\t\treturn \"text\" === elem.type;\n\t\t},\n\t\tradio: function(elem){\n\t\t\treturn \"radio\" === elem.type;\n\t\t},\n\t\tcheckbox: function(elem){\n\t\t\treturn \"checkbox\" === elem.type;\n\t\t},\n\t\tfile: function(elem){\n\t\t\treturn \"file\" === elem.type;\n\t\t},\n\t\tpassword: function(elem){\n\t\t\treturn \"password\" === elem.type;\n\t\t},\n\t\tsubmit: function(elem){\n\t\t\treturn \"submit\" === elem.type;\n\t\t},\n\t\timage: function(elem){\n\t\t\treturn \"image\" === elem.type;\n\t\t},\n\t\treset: function(elem){\n\t\t\treturn \"reset\" === elem.type;\n\t\t},\n\t\tbutton: function(elem){\n\t\t\treturn \"button\" === elem.type || elem.nodeName.toLowerCase() === \"button\";\n\t\t},\n\t\tinput: function(elem){\n\t\t\treturn (/input|select|textarea|button/i).test(elem.nodeName);\n\t\t}\n\t},\n\tsetFilters: {\n\t\tfirst: function(elem, i){\n\t\t\treturn i === 0;\n\t\t},\n\t\tlast: function(elem, i, match, array){\n\t\t\treturn i === array.length - 1;\n\t\t},\n\t\teven: function(elem, i){\n\t\t\treturn i % 2 === 0;\n\t\t},\n\t\todd: function(elem, i){\n\t\t\treturn i % 2 === 1;\n\t\t},\n\t\tlt: function(elem, i, match){\n\t\t\treturn i < match[3] - 0;\n\t\t},\n\t\tgt: function(elem, i, match){\n\t\t\treturn i > match[3] - 0;\n\t\t},\n\t\tnth: function(elem, i, match){\n\t\t\treturn match[3] - 0 === i;\n\t\t},\n\t\teq: function(elem, i, match){\n\t\t\treturn match[3] - 0 === i;\n\t\t}\n\t},\n\tfilter: {\n\t\tPSEUDO: function(elem, match, i, array){\n\t\t\tvar name = match[1], filter = Expr.filters[ name ];\n\n\t\t\tif ( filter ) {\n\t\t\t\treturn filter( elem, i, match, array );\n\t\t\t} else if ( name === \"contains\" ) {\n\t\t\t\treturn (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || \"\").indexOf(match[3]) >= 0;\n\t\t\t} else if ( name === \"not\" ) {\n\t\t\t\tvar not = match[3];\n\n\t\t\t\tfor ( var j = 0, l = not.length; j < l; j++ ) {\n\t\t\t\t\tif ( not[j] === elem ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tSizzle.error( \"Syntax error, unrecognized expression: \" + name );\n\t\t\t}\n\t\t},\n\t\tCHILD: function(elem, match){\n\t\t\tvar type = match[1], node = elem;\n\t\t\tswitch (type) {\n\t\t\t\tcase 'only':\n\t\t\t\tcase 'first':\n\t\t\t\t\twhile ( (node = node.previousSibling) )\t {\n\t\t\t\t\t\tif ( node.nodeType === 1 ) { \n\t\t\t\t\t\t\treturn false; \n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( type === \"first\" ) { \n\t\t\t\t\t\treturn true; \n\t\t\t\t\t}\n\t\t\t\t\tnode = elem;\n\t\t\t\tcase 'last':\n\t\t\t\t\twhile ( (node = node.nextSibling) )\t {\n\t\t\t\t\t\tif ( node.nodeType === 1 ) { \n\t\t\t\t\t\t\treturn false; \n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'nth':\n\t\t\t\t\tvar first = match[2], last = match[3];\n\n\t\t\t\t\tif ( first === 1 && last === 0 ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tvar doneName = match[0],\n\t\t\t\t\t\tparent = elem.parentNode;\n\t\n\t\t\t\t\tif ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {\n\t\t\t\t\t\tvar count = 0;\n\t\t\t\t\t\tfor ( node = parent.firstChild; node; node = node.nextSibling ) {\n\t\t\t\t\t\t\tif ( node.nodeType === 1 ) {\n\t\t\t\t\t\t\t\tnode.nodeIndex = ++count;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} \n\t\t\t\t\t\tparent.sizcache = doneName;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tvar diff = elem.nodeIndex - last;\n\t\t\t\t\tif ( first === 0 ) {\n\t\t\t\t\t\treturn diff === 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn ( diff % first === 0 && diff / first >= 0 );\n\t\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tID: function(elem, match){\n\t\t\treturn elem.nodeType === 1 && elem.getAttribute(\"id\") === match;\n\t\t},\n\t\tTAG: function(elem, match){\n\t\t\treturn (match === \"*\" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;\n\t\t},\n\t\tCLASS: function(elem, match){\n\t\t\treturn (\" \" + (elem.className || elem.getAttribute(\"class\")) + \" \")\n\t\t\t\t.indexOf( match ) > -1;\n\t\t},\n\t\tATTR: function(elem, match){\n\t\t\tvar name = match[1],\n\t\t\t\tresult = Expr.attrHandle[ name ] ?\n\t\t\t\t\tExpr.attrHandle[ name ]( elem ) :\n\t\t\t\t\telem[ name ] != null ?\n\t\t\t\t\t\telem[ name ] :\n\t\t\t\t\t\telem.getAttribute( name ),\n\t\t\t\tvalue = result + \"\",\n\t\t\t\ttype = match[2],\n\t\t\t\tcheck = match[4];\n\n\t\t\treturn result == null ?\n\t\t\t\ttype === \"!=\" :\n\t\t\t\ttype === \"=\" ?\n\t\t\t\tvalue === check :\n\t\t\t\ttype === \"*=\" ?\n\t\t\t\tvalue.indexOf(check) >= 0 :\n\t\t\t\ttype === \"~=\" ?\n\t\t\t\t(\" \" + value + \" \").indexOf(check) >= 0 :\n\t\t\t\t!check ?\n\t\t\t\tvalue && result !== false :\n\t\t\t\ttype === \"!=\" ?\n\t\t\t\tvalue !== check :\n\t\t\t\ttype === \"^=\" ?\n\t\t\t\tvalue.indexOf(check) === 0 :\n\t\t\t\ttype === \"$=\" ?\n\t\t\t\tvalue.substr(value.length - check.length) === check :\n\t\t\t\ttype === \"|=\" ?\n\t\t\t\tvalue === check || value.substr(0, check.length + 1) === check + \"-\" :\n\t\t\t\tfalse;\n\t\t},\n\t\tPOS: function(elem, match, i, array){\n\t\t\tvar name = match[2], filter = Expr.setFilters[ name ];\n\n\t\t\tif ( filter ) {\n\t\t\t\treturn filter( elem, i, match, array );\n\t\t\t}\n\t\t}\n\t}\n};\n\nvar origPOS = Expr.match.POS,\n\tfescape = function(all, num){\n\t\treturn \"\\\\\" + (num - 0 + 1);\n\t};\n\nfor ( var type in Expr.match ) {\n\tExpr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\\[]*\\])(?![^\\(]*\\))/.source) );\n\tExpr.leftMatch[ type ] = new RegExp( /(^(?:.|\\r|\\n)*?)/.source + Expr.match[ type ].source.replace(/\\\\(\\d+)/g, fescape) );\n}\n\nvar makeArray = function(array, results) {\n\tarray = Array.prototype.slice.call( array, 0 );\n\n\tif ( results ) {\n\t\tresults.push.apply( results, array );\n\t\treturn results;\n\t}\n\t\n\treturn array;\n};\n\nvar sortOrder = function( a, b ) {\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {\n\t\t\treturn a.compareDocumentPosition ? -1 : 1;\n\t\t}\n\n\t\treturn a.compareDocumentPosition(b) & 4 ? -1 : 1;\n};\n\n// Utility function for retreiving the text value of an array of DOM nodes\nSizzle.getText = function( elems ) {\n\tvar ret = \"\", elem;\n\n\tfor ( var i = 0; elems[i]; i++ ) {\n\t\telem = elems[i];\n\n\t\t// Get the text from text nodes and CDATA nodes\n\t\tif ( elem.nodeType === 3 || elem.nodeType === 4 ) {\n\t\t\tret += elem.nodeValue;\n\n\t\t// Traverse everything else, except comment nodes\n\t\t} else if ( elem.nodeType !== 8 ) {\n\t\t\tret += Sizzle.getText( elem.childNodes );\n\t\t}\n\t}\n\n\treturn ret;\n};\n\nfunction dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {\n\tfor ( var i = 0, l = checkSet.length; i < l; i++ ) {\n\t\tvar elem = checkSet[i];\n\t\tif ( elem ) {\n\t\t\telem = elem[dir];\n\t\t\tvar match = false;\n\n\t\t\twhile ( elem ) {\n\t\t\t\tif ( elem.sizcache === doneName ) {\n\t\t\t\t\tmatch = checkSet[elem.sizset];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif ( elem.nodeType === 1 && !isXML ){\n\t\t\t\t\telem.sizcache = doneName;\n\t\t\t\t\telem.sizset = i;\n\t\t\t\t}\n\n\t\t\t\tif ( elem.nodeName.toLowerCase() === cur ) {\n\t\t\t\t\tmatch = elem;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\telem = elem[dir];\n\t\t\t}\n\n\t\t\tcheckSet[i] = match;\n\t\t}\n\t}\n}\n\nfunction dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {\n\tfor ( var i = 0, l = checkSet.length; i < l; i++ ) {\n\t\tvar elem = checkSet[i];\n\t\tif ( elem ) {\n\t\t\telem = elem[dir];\n\t\t\tvar match = false;\n\n\t\t\twhile ( elem ) {\n\t\t\t\tif ( elem.sizcache === doneName ) {\n\t\t\t\t\tmatch = checkSet[elem.sizset];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\tif ( !isXML ) {\n\t\t\t\t\t\telem.sizcache = doneName;\n\t\t\t\t\t\telem.sizset = i;\n\t\t\t\t\t}\n\t\t\t\t\tif ( typeof cur !== \"string\" ) {\n\t\t\t\t\t\tif ( elem === cur ) {\n\t\t\t\t\t\t\tmatch = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {\n\t\t\t\t\t\tmatch = elem;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\telem = elem[dir];\n\t\t\t}\n\n\t\t\tcheckSet[i] = match;\n\t\t}\n\t}\n}\n\nSizzle.contains =  function(a, b){\n\treturn !!(a.compareDocumentPosition(b) & 16);\n};\n\nSizzle.isXML = function(elem){\n\t// documentElement is verified for cases where it doesn't yet exist\n\t// (such as loading iframes in IE - #4833) \n\tvar documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;\n\treturn documentElement ? documentElement.nodeName !== \"HTML\" : false;\n};\n\nvar posProcess = function(selector, context){\n\tvar tmpSet = [], later = \"\", match,\n\t\troot = context.nodeType ? [context] : context;\n\n\t// Position selectors must be done after the filter\n\t// And so must :not(positional) so we move all PSEUDOs to the end\n\twhile ( (match = Expr.match.PSEUDO.exec( selector )) ) {\n\t\tlater += match[0];\n\t\tselector = selector.replace( Expr.match.PSEUDO, \"\" );\n\t}\n\n\tselector = Expr.relative[selector] ? selector + \"*\" : selector;\n\n\tfor ( var i = 0, l = root.length; i < l; i++ ) {\n\t\tSizzle( selector, root[i], tmpSet );\n\t}\n\n\treturn Sizzle.filter( later, tmpSet );\n};\n\n// EXPOSE\njQuery.find = Sizzle;\njQuery.expr = Sizzle.selectors;\njQuery.expr[\":\"] = jQuery.expr.filters;\njQuery.unique = Sizzle.uniqueSort;\njQuery.text = Sizzle.getText;\njQuery.isXMLDoc = Sizzle.isXML;\njQuery.contains = Sizzle.contains;\n\n\n})();\n(function( jQuery ) {\n\nvar runtil = /Until$/,\n\trparentsprev = /^(?:parents|prevUntil|prevAll)/,\n\t// Note: This RegExp should be improved, or likely pulled from Sizzle\n\trmultiselector = /,/,\n\tisSimple = /^.[^:#\\[\\.,]*$/,\n\tslice = Array.prototype.slice,\n\tPOS = jQuery.expr.match.POS;\n\njQuery.fn.extend({\n\tfind: function( selector ) {\n\t\tvar ret = this.pushStack( \"\", \"find\", selector ), length = 0;\n\n\t\tfor ( var i = 0, l = this.length; i < l; i++ ) {\n\t\t\tlength = ret.length;\n\t\t\tjQuery.find( selector, this[i], ret );\n\n\t\t\tif ( i > 0 ) {\n\t\t\t\t// Make sure that the results are unique\n\t\t\t\tfor ( var n = length; n < ret.length; n++ ) {\n\t\t\t\t\tfor ( var r = 0; r < length; r++ ) {\n\t\t\t\t\t\tif ( ret[r] === ret[n] ) {\n\t\t\t\t\t\t\tret.splice(n--, 1);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t},\n\n\thas: function( target ) {\n\t\tvar targets = jQuery( target );\n\t\treturn this.filter(function() {\n\t\t\tfor ( var i = 0, l = targets.length; i < l; i++ ) {\n\t\t\t\tif ( jQuery.contains( this, targets[i] ) ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n\n\tnot: function( selector ) {\n\t\treturn this.pushStack( winnow(this, selector, false), \"not\", selector);\n\t},\n\n\tfilter: function( selector ) {\n\t\treturn this.pushStack( winnow(this, selector, true), \"filter\", selector );\n\t},\n\t\n\tis: function( selector ) {\n\t\treturn !!selector && jQuery.filter( selector, this ).length > 0;\n\t},\n\n\tclosest: function( selectors, context ) {\n\t\tvar ret = [], i, l, cur = this[0];\n\n\t\tif ( jQuery.isArray( selectors ) ) {\n\t\t\tvar match, matches = {}, selector, level = 1;\n\n\t\t\tif ( cur && selectors.length ) {\n\t\t\t\tfor ( i = 0, l = selectors.length; i < l; i++ ) {\n\t\t\t\t\tselector = selectors[i];\n\n\t\t\t\t\tif ( !matches[selector] ) {\n\t\t\t\t\t\tmatches[selector] = jQuery.expr.match.POS.test( selector ) ? \n\t\t\t\t\t\t\tjQuery( selector, context || this.context ) :\n\t\t\t\t\t\t\tselector;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\twhile ( cur && cur.ownerDocument && cur !== context ) {\n\t\t\t\t\tfor ( selector in matches ) {\n\t\t\t\t\t\tmatch = matches[selector];\n\n\t\t\t\t\t\tif ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {\n\t\t\t\t\t\t\tret.push({ selector: selector, elem: cur, level: level });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcur = cur.parentNode;\n\t\t\t\t\tlevel++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}\n\n\t\tvar pos = POS.test( selectors ) ? \n\t\t\tjQuery( selectors, context || this.context ) : null;\n\n\t\tfor ( i = 0, l = this.length; i < l; i++ ) {\n\t\t\tcur = this[i];\n\n\t\t\twhile ( cur ) {\n\t\t\t\tif ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {\n\t\t\t\t\tret.push( cur );\n\t\t\t\t\tbreak;\n\n\t\t\t\t} else {\n\t\t\t\t\tcur = cur.parentNode;\n\t\t\t\t\tif ( !cur || !cur.ownerDocument || cur === context ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tret = ret.length > 1 ? jQuery.unique(ret) : ret;\n\t\t\n\t\treturn this.pushStack( ret, \"closest\", selectors );\n\t},\n\t\n\t// Determine the position of an element within\n\t// the matched set of elements\n\tindex: function( elem ) {\n\t\tif ( !elem || typeof elem === \"string\" ) {\n\t\t\treturn jQuery.inArray( this[0],\n\t\t\t\t// If it receives a string, the selector is used\n\t\t\t\t// If it receives nothing, the siblings are used\n\t\t\t\telem ? jQuery( elem ) : this.parent().children() );\n\t\t}\n\t\t// Locate the position of the desired element\n\t\treturn jQuery.inArray(\n\t\t\t// If it receives a jQuery object, the first element is used\n\t\t\telem.jquery ? elem[0] : elem, this );\n\t},\n\n\tadd: function( selector, context ) {\n\t\tvar set = typeof selector === \"string\" ?\n\t\t\t\tjQuery( selector, context || this.context ) :\n\t\t\t\tjQuery.makeArray( selector ),\n\t\t\tall = jQuery.merge( this.get(), set );\n\n\t\treturn this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?\n\t\t\tall :\n\t\t\tjQuery.unique( all ) );\n\t},\n\n\tandSelf: function() {\n\t\treturn this.add( this.prevObject );\n\t}\n});\n\n// A painfully simple check to see if an element is disconnected\n// from a document (should be improved, where feasible).\nfunction isDisconnected( node ) {\n\treturn !node || !node.parentNode || node.parentNode.nodeType === 11;\n}\n\njQuery.each({\n\tparent: function( elem ) {\n\t\tvar parent = elem.parentNode;\n\t\treturn parent && parent.nodeType !== 11 ? parent : null;\n\t},\n\tparents: function( elem ) {\n\t\treturn jQuery.dir( elem, \"parentNode\" );\n\t},\n\tparentsUntil: function( elem, i, until ) {\n\t\treturn jQuery.dir( elem, \"parentNode\", until );\n\t},\n\tnext: function( elem ) {\n\t\treturn jQuery.nth( elem, 2, \"nextSibling\" );\n\t},\n\tprev: function( elem ) {\n\t\treturn jQuery.nth( elem, 2, \"previousSibling\" );\n\t},\n\tnextAll: function( elem ) {\n\t\treturn jQuery.dir( elem, \"nextSibling\" );\n\t},\n\tprevAll: function( elem ) {\n\t\treturn jQuery.dir( elem, \"previousSibling\" );\n\t},\n\tnextUntil: function( elem, i, until ) {\n\t\treturn jQuery.dir( elem, \"nextSibling\", until );\n\t},\n\tprevUntil: function( elem, i, until ) {\n\t\treturn jQuery.dir( elem, \"previousSibling\", until );\n\t},\n\tsiblings: function( elem ) {\n\t\treturn jQuery.sibling( elem.parentNode.firstChild, elem );\n\t},\n\tchildren: function( elem ) {\n\t\treturn jQuery.sibling( elem.firstChild );\n\t},\n\tcontents: function( elem ) {\n\t\treturn jQuery.nodeName( elem, \"iframe\" ) ?\n\t\t\telem.contentDocument || elem.contentWindow.document :\n\t\t\tjQuery.makeArray( elem.childNodes );\n\t}\n}, function( name, fn ) {\n\tjQuery.fn[ name ] = function( until, selector ) {\n\t\tvar ret = jQuery.map( this, fn, until );\n\t\t\n\t\tif ( !runtil.test( name ) ) {\n\t\t\tselector = until;\n\t\t}\n\n\t\tif ( selector && typeof selector === \"string\" ) {\n\t\t\tret = jQuery.filter( selector, ret );\n\t\t}\n\n\t\tret = this.length > 1 ? jQuery.unique( ret ) : ret;\n\n\t\tif ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {\n\t\t\tret = ret.reverse();\n\t\t}\n\n\t\treturn this.pushStack( ret, name, slice.call(arguments).join(\",\") );\n\t};\n});\n\njQuery.extend({\n\tfilter: function( expr, elems, not ) {\n\t\tif ( not ) {\n\t\t\texpr = \":not(\" + expr + \")\";\n\t\t}\n\n\t\treturn elems.length === 1 ?\n\t\t\tjQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :\n\t\t\tjQuery.find.matches(expr, elems);\n\t},\n\t\n\tdir: function( elem, dir, until ) {\n\t\tvar matched = [], cur = elem[dir];\n\t\twhile ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {\n\t\t\tif ( cur.nodeType === 1 ) {\n\t\t\t\tmatched.push( cur );\n\t\t\t}\n\t\t\tcur = cur[dir];\n\t\t}\n\t\treturn matched;\n\t},\n\n\tnth: function( cur, result, dir, elem ) {\n\t\tresult = result || 1;\n\t\tvar num = 0;\n\n\t\tfor ( ; cur; cur = cur[dir] ) {\n\t\t\tif ( cur.nodeType === 1 && ++num === result ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn cur;\n\t},\n\n\tsibling: function( n, elem ) {\n\t\tvar r = [];\n\n\t\tfor ( ; n; n = n.nextSibling ) {\n\t\t\tif ( n.nodeType === 1 && n !== elem ) {\n\t\t\t\tr.push( n );\n\t\t\t}\n\t\t}\n\n\t\treturn r;\n\t}\n});\n\njQuery.fn.extend({\n    text: function( text ) {\n            if ( jQuery.isFunction(text) ) {\n                    return this.each(function(i) {\n                            var self = jQuery(this);\n                            self.text( text.call(this, i, self.text()) );\n                    });\n            }\n            return jQuery.text( this );\n    }\n});\n\n\n// Implement the identical functionality for filter and not\nfunction winnow( elements, qualifier, keep ) {\n\tif ( jQuery.isFunction( qualifier ) ) {\n\t\treturn jQuery.grep(elements, function( elem, i ) {\n\t\t\tvar retVal = !!qualifier.call( elem, i, elem );\n\t\t\treturn retVal === keep;\n\t\t});\n\n\t} else if ( qualifier.nodeType ) {\n\t\treturn jQuery.grep(elements, function( elem, i ) {\n\t\t\treturn (elem === qualifier) === keep;\n\t\t});\n\n\t} else if ( typeof qualifier === \"string\" ) {\n\t\tvar filtered = jQuery.grep(elements, function( elem ) {\n\t\t\treturn elem.nodeType === 1;\n\t\t});\n\n\t\tif ( isSimple.test( qualifier ) ) {\n\t\t\treturn jQuery.filter(qualifier, filtered, !keep);\n\t\t} else {\n\t\t\tqualifier = jQuery.filter( qualifier, filtered );\n\t\t}\n\t}\n\n\treturn jQuery.grep(elements, function( elem, i ) {\n\t\treturn (jQuery.inArray( elem, qualifier ) >= 0) === keep;\n\t});\n}\n\n})( jQuery );\n})();\n"
  },
  {
    "path": "scripts/scanner/prelude/parseuri.js",
    "content": "// parseUri 1.2.2\n// (c) Steven Levithan <stevenlevithan.com>\n// MIT License\n\nfunction parseUri (str) {\n\tvar\to   = parseUri.options,\n\t\tm   = o.parser[o.strictMode ? \"strict\" : \"loose\"].exec(str),\n\t\turi = {},\n\t\ti   = 14;\n\n\twhile (i--) uri[o.key[i]] = m[i] || \"\";\n\n\turi[o.q.name] = {};\n\turi[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {\n\t\tif ($1) uri[o.q.name][$1] = $2;\n\t});\n\n\treturn uri;\n};\n\nparseUri.options = {\n\tstrictMode: false,\n\tkey: [\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"],\n\tq:   {\n\t\tname:   \"queryKey\",\n\t\tparser: /(?:^|&)([^&=]*)=?([^&]*)/g\n\t},\n\tparser: {\n\t\tstrict: /^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,\n\t\tloose:  /^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/\n\t}\n};\n"
  },
  {
    "path": "templates/footer.ftl",
    "content": "<hr>\n\n<div class=\"footer\" id=\"footer\">\n\n<a class=\"innerlinksmall\" href=\"#titlesection\">Top</a>\n\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "templates/header.ftl",
    "content": "<html>\n<head>\n<style type=\"text/css\">\n<#include \"style.ftl\" parse=true>\n</style>\n</head>\n<body>\n\n"
  },
  {
    "path": "templates/macros.ftl",
    "content": "<#ftl strip_text=true>\n<#escape x as x?html>\n\n<#function defined x>\n  <#return (x?is_string && x?length != 0) || (x?is_sequence && x?size != 0) >\n</#function>\n\n<#macro vegabanner bannerLogo>\n\t<div class=\"vegabanner\" id=\"vegabanner\">\n\t<#if defined (bannerLogo)>\n\t\t<img src=\"${bannerLogo}\" width=173px height=24px>\n\t\t<span> Open Source Web Security Platform </span>\n\t</#if>\n\t</div>\n</#macro>\n\n\n<#macro bgPattern bannerPattern>\n    <#if defined(bannerPattern)>\n\t\tbackground-image: url('${bannerPattern}');\n\t\tbackground-repeat: repeat;\n    </#if>\n</#macro>\n\n<#macro topsection title>\n  <div class=\"topsection\" id=\"titlesection\">\n  \t<span class=\"title\">${title}</span>\n  </div>\n</#macro>\n\n<#macro titleBgPattern titlePattern>\n\t<#if defined(titlePattern)>\n\t\tbackground-image: url('${titlePattern}');\n\t\tbackground-repeat: repeat;\n    </#if>\n</#macro>\n\n<#macro greyGradient sectionGradient>\n    <#if defined(sectionGradient)>\n\t\tbackground-image: url('${sectionGradient}');\n\t\tbackground-repeat: repeat-x;\n\t\tbackground-position: left bottom;\n    </#if>\n</#macro>\n\n<#macro sectionIcon redArrow>\n\t<#if defined (redArrow)>\n\t\tbackground-image:url('${redArrow}');\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: 5px 0px;\n\t</#if>\n</#macro>\n\n<#macro infobox class resource param methods detectiontype severity severityCSS>\n<div class=\"section\" id=\"infobox\">\n\t<h2>At a glance</h2>\n\t<div class=\"content\" id=\"sectioncontent\">\n\t\t<table>\n\t\t  <#if defined(class)>\n\t\t  <tr>\n    \t\t<td><div class=\"tablefield\">Classification</div></td><td><a class=\"innerlink\" href=\"#description\">${class}</a></td>\n  \t\t</tr>\n  \t\t</#if>\n  \n \t\t <#if defined(resource)>\n  \t\t<tr>\n  \t\t\t<td><div class=\"tablefield\">Resource</div></td><td><b>${resource}</b></td>\n  \t\t</tr>\n  \t\t</#if>\n\n\t        <#if defined(param)>\n                <tr>\n                        <td><div class=\"tablefield\">Parameter</div></td><td><b>${param}</b></td>\n                </tr>\n                </#if>\n\n \n                 <#if defined(methods)>\n                <tr>\n                        <td><div class=\"tablefield\">Method</div></td><td><b>${methods}</b></td>\n                </tr>\n                </#if>\n\n\n\t\t<#if defined(detectiontype)>\n\t\t<tr>\n\t\t\t<td><div class=\"tablefield\">Detection Type</div></td><td><b>${detectiontype}</b></td>\n\t\t</tr>\n\t\t</#if>\n\n  \t\t<#if defined(severity) && defined(severityCSS)>\n  \t\t\t<tr>\n  \t\t\t<td><div class=\"tablefield\">Risk</div></td><td><span class=\"${severityCSS}\">${severity}</span></td>\n  \t\t\t</tr>\n  \t\t</#if>\n  \t\t</table>\n\t</div>\n</div>\n\n</#macro>\n\n<#macro outputsection text>\n  <#if defined(text)>\n        <div class=\"section\" id=\"resourcecontentsection\">\n          <h2>Resource Content</h2>\n                <div class=\"content\" id=\"sectioncontent\">\n                  <table>\n                        <tr>\n                          <td><span class=\"resourcecontent\"><pre>${text}</pre></span></td>\n                        </tr>\n                  </table>\n                </div>\n        </div>\n  </#if>\n</#macro>\n\n\n<#macro impactsection impact>\n  <#if defined(impact)>\n\t<div class=\"section\" id = \"impactsection\">\n      <h2>Impact</h2>\n        <div class=\"content\" id=\"sectioncontent\">\n          <ul>\n            <#list impact as item>\n              <li>${item}</li>\n            </#list>\n    \t  </ul>\n        </div>\n    </div>\n  </#if>\n</#macro>\n\n<#macro remediationsection remediation>\n  <#if defined(remediation)>\n\t<div class=\"section\" id=\"remediationsection\">\n\t  <h2>Remediation</h2>\n\t\t<div class=\"content\" id=\"sectioncontent\">\n\t\t  <ul>\n  \t\t\t<#list remediation as item>\n    \t\t  <li>${item}</li>\n  \t\t\t</#list>\n\t\t  </ul>\n\t\t</div>\n\t</div>\n  </#if>\n</#macro>\n\n<#macro discussion text>\n  <#if defined(text)>\n\t<div class=\"section\" id=\"description\">\n\t  <h2>Discussion</h2>\n\t\t<div class=\"content\" id=\"sectioncontent\">\n\t\t  ${text}\n\t\t</div>\n\t</div>\n  </#if>\n</#macro>\n\n<#macro bullet bulletPoint>\n    <#if defined(bulletPoint)>\n\t\tlist-style-image: url('${bulletPoint}');\n    </#if>\n</#macro>\n\n<#macro linkBullet linkArrow>\n    <#if defined(linkArrow)>\n\t\tlist-style-image: url('${linkArrow}');\n    </#if>\n</#macro>\n\n</#escape>\n"
  },
  {
    "path": "templates/main.ftl",
    "content": "<#include \"header.ftl\">\n<#include \"macros.ftl\">\n\n<@vegabanner\n\tvars.bannerLogoURL ! \"\"\n/>\n\n<@topsection \n  doc.alert.title ! \"No title set.\" \n/>\n\n\n<@infobox \n  doc.alert.class ! \"No class set.\" \n  vars.resource ! \"\"\n  vars.param ! \"\"\n  vars.methods ! \"\" \n  vars.detectiontype ! \"\"\n  vars.severity ! \"\"\n  vars.severityCSS ! \"\"\n/>\n\n<#if vars.requestText??>\n  <div class=\"section\" id=\"requestlink\">\n        <h2>Request</h2>\n          <div class=\"content\" id=\"sectioncontent\">\n                <a href=\"#\" onclick=\"linkClick('${vars.requestId}');\"> ${vars.requestText} </a>\n          </div>\n  </div>\n</#if>\n\n<@outputsection\n  vars.output ! \"\"\n/>\n\n<@discussion\n  doc.alert.discussion\n/>\n\n<@impactsection \n  doc.alert.impact\n/>\n\n<@remediationsection\n  doc.alert.remediation\n/>\n\n<#if doc.alert.external?size != 0>\n  <div class=\"section\" id=\"remrefsection\">\n\t<h2>External Remediation Guidelines</h2>\n\t  <div class=\"content\" id=\"sectioncontent\">\n\t\tBelow are some links to third-party guidelines, tutorials and other documentation that may be useful in understanding and/or addressing this finding.\n\t\t<br>\n\t\t<br>\n\t\t<#list doc.alert.external.url as u>\n\t\t  <p><a class=\"reflink\" href=\"${u.@address?html}\">${u?html}</a></p>\n\t\t</#list>\n\t  </div>\n  </div>\n</#if>\n\n<#if doc.alert.references?size != 0>\n  <div class=\"section\" id=\"referencesection\">\n\t<h2>References</h2>\n\t  <div class=\"content\" id=\"sectioncontent\">\n\t\tSome additional links with relevant information published by third-parties:\n\t\t<br>\n\t\t<br>\n\t\t<#list doc.alert.references.url as u>\n\t\t  <ul><li><a class=\"reflink\" href=\"${u.@address?html}\">${u?html}</a></li></ul>\n\t\t</#list>\n\t  </div>\n  </div>\n</#if>\n\n<br>\n\n<#include \"footer.ftl\" parse=false>\n\n<br>\n<br>\n"
  },
  {
    "path": "templates/report-alert.ftl",
    "content": "<#include \"report-macros.ftl\">\n\n<div class=\"alert-body\">\n<a name=\"alert-${vars.num}\"></a>\n\n<@vegabanner\n\tvars.bannerLogoURL ! \"\"\n/>\n\n<@topsection \n  doc.alert.title ! \"No title set.\" \n/>\n\n<div class=alert-nav>\n<#if vars.prev??>\n  <a href=\"#alert-${vars.prev}\">Previous</a></span>\n</#if>\n<#if vars.next??>\n  <a href=\"#alert-${vars.next}\">Next</a>\n</#if>\n</div>\n\n\n<@infobox \n  doc.alert.class ! \"No class set.\" \n  vars.resource ! \"\"\n  vars.hostname ! \"\"\n  vars.param ! \"\"\n  vars.methods ! \"\" \n  vars.detectiontype ! \"\"\n  vars.severity ! \"\"\n  vars.severityCSS ! \"\"\n/>\n\n<#if vars.requestText??>\n  <div class=\"section\" id=\"requestlink\">\n        <h2>Request</h2>\n          <div class=\"content\" id=\"sectioncontent\">\n                ${vars.requestText}\n          </div>\n  </div>\n</#if>\n\n<@responsesection\n  vars.responseText ! \"\"\n/>\n\n<@outputsection\n  vars.output ! \"\"\n/>\n\n<@discussion\n  doc.alert.discussion\n/>\n\n<@impactsection \n  doc.alert.impact\n/>\n\n<@remediationsection\n  doc.alert.remediation\n/>\n\n<#if doc.alert.external?size != 0>\n  <div class=\"section\" id=\"remrefsection\">\n\t<h2>External Remediation Guidelines</h2>\n\t  <div class=\"content\" id=\"sectioncontent\">\n\t\tBelow are some links to third-party guidelines, tutorials and other documentation that may be useful in understanding and/or addressing this finding.\n\t\t<br>\n\t\t<br>\n\t\t<#list doc.alert.external.url as u>\n\t\t  <p><a class=\"reflink\" href=\"${u.@address?html}\">${u?html}</a></p>\n\t\t</#list>\n\t  </div>\n  </div>\n</#if>\n\n<#if doc.alert.references?size != 0>\n  <div class=\"section\" id=\"referencesection\">\n\t<h2>References</h2>\n\t  <div class=\"content\" id=\"sectioncontent\">\n\t\tSome additional links with relevant information published by third-parties:\n\t\t<br>\n\t\t<br>\n\t\t<#list doc.alert.references.url as u>\n\t\t  <ul><li><a class=\"reflink\" href=\"${u.@address?html}\">${u?html}</a></li></ul>\n\t\t</#list>\n\t  </div>\n  </div>\n</#if>\n<br />\n<br />\n<br />\n<hr>\n<div class=footer>\n  <a class=\"innerlinksmall\" href=\"#summary-page\">Top</a>\n</div>\n<span class=footertext>Report generated ${vars.datetime} by the Vega open source web application security testing framework.\n  <br />\n  <a href=\"https://subgraph.com\">https://subgraph.com</a><br />\n</div>\n\n"
  },
  {
    "path": "templates/report-macros.ftl",
    "content": "<#ftl strip_text=true>\n<#escape x as x?html>\n\n<#function defined x>\n  <#return (x?is_string && x?length != 0) || (x?is_sequence && x?size != 0) >\n</#function>\n\n<#macro vegabanner bannerLogo>\n        <div class=\"vegabanner\" id=\"vegabanner\">\n                <img class=bannerLogo width=173px height=24px>\n                <span> Open Source Web Security Platform </span>\n        </div>\n</#macro>\n\n<#macro bgPattern bannerPattern>\n\t\tbackground-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAaBJREFUeNqcxsl22jAUAFDpCcuSvQHcJoQEll31/7+j30DKcFKGbqynwc/qAmI4ISomd3X5rx8/X9FkHCZKdVmgkXcGkGjv/aNSSLTz7pj9VXbuRmBtcaaLGOPa4lyXx8x0GWNcXWRe3Ai0jI2l/BvCOTFWUh5CiFdp04GpUk2MW++6PGndxLi7yta7aTpQiMHGYiFElzKR8r8BJDqEMFEaiQ7Bf8je9w0s0UyVAsaWaKZKA2O/L/Ks+wYiY5XMDyFcxd8VmGrt2/YQ/CnePZ/iU9l/FijF4M1ZDeIUMThGCZGK/iyARIboe553MUSG6CFXhqjuHVigqaTMABZYH/P6noW5I8AZG8t85x1j/EM4Z1XvwEwXoW333s/fMzun7B/QQvxxrhQDLcSbs4UQxZcCNTXY0kOe19TYtn3MVd00ligVTARWiONMZgBLxNExFkcyT2WcCDDGhlm29Y4zNroVlg686KJlbGNtKuuLzNIBLcTG4jDLUhn1C9TUGKKJ0uc0XwmsEb/JfMB5l5XF6v4AcD7Msp33XQTno0QgnX8DADEePTrnlfl8AAAAAElFTkSuQmCC);\n\t\tbackground-repeat: repeat;\n</#macro>\n\n<#macro topsection title>\n  <div class=\"topsection\" id=\"titlesection\">\n  \t<span class=\"title\">${title}</span>\n  </div>\n</#macro>\n\n<#macro titleBgPattern titlePattern>\n\t\tbackground-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAABBCAIAAAB5BpL2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAARNJREFUeNpMkjt2HVAIA0ccqtRehKvsfxvZEOMC7oup7geEEMq/779shGYGEAI9CISMloIMElqYEJXUICIZbMiWITUOstcWACNSByWSnghRwNaQJWAPYIiR1jFkIhY5XJMeIIhAj58J0l6ShPIKUFvUA7maBKEN4cN6aS2dN4tCjbhHWLTVMJcWrs+KgbDzSAiUurRHChgUzKY9eu0nz/thedcvNrRirllNkC2k3S2C8tCipgaIs02BMeeDyS6HFX4b7X7ufaVSqGMwtxMhPb6SWHxCWmSVXkU58Z/fCJEek6dC+3RTCmfCkmrPhegD8LffNvrNQvBBo+/nfxqu4bBEzFqwgcmalxtOIOk/X1/XMvkZAKILDXEMaof/AAAAAElFTkSuQmCC);\n\t\tbackground-repeat: repeat;\n</#macro>\n\n<#macro greyGradient sectionGradient>\n\t\tbackground-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAABQCAYAAADGDi9oAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAEVJREFUeNrs1LENACAIRUE07r/ydwdpMDn61xyElST1OLsaIxaLR8Wn8QtoOxJgVkUbGG3atGnTFluV+KMjuQAAAP//AwA8ACKSl0uMsQAAAABJRU5ErkJggg==);\n\t\tbackground-repeat: repeat-x;\n\t\tbackground-position: left bottom;\n</#macro>\n\n<#macro sectionIcon redArrow>\n\t\tbackground-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAMdJREFUeNq00zEKwjAUBuA/VTo5dBcqOHTUzVu5C5lzAldP4S28QietiwpKaAqSNmkcWkGkSariG5P8H+/xCDHG4JcKug6XUWTy2SL8GgAAmqUyn/sRK8DiBPSQSl8ngeuSxUnTiQNxAiB+xA20C2ITO2IFRK2QawVRKwitsBpPQbNUvr8b2oBrVTYzwMAQgs3p2A7VEzhX1XMOvb1dBl1hN1BKACh3BQ9tYU8HstjL++g1vOa8/xb6hH1r9IYBgPzlN35SjwEAbbRZo8QjEkMAAAAASUVORK5CYII=);\n\t\tbackground-repeat: no-repeat;\n\t\tbackground-position: 5px 0px;\n</#macro>\n\n<#macro infobox class resource hostname param methods detectiontype severity severityCSS>\n<div class=\"section\" id=\"infobox\">\n\t<h2>At a glance</h2>\n\t<div class=\"content\" id=\"sectioncontent\">\n\t\t<table>\n\t\t  <#if defined(class)>\n\t\t  <tr>\n    \t\t<td><div class=\"tablefield\">Classification</div></td><td><a class=\"innerlink\" href=\"#description\">${class}</a></td>\n  \t\t</tr>\n  \t\t</#if>\n  \n \t\t<#if defined(resource)>\n  \t\t<tr>\n  \t\t\t<td><div class=\"tablefield\">Resource</div></td><td><b>${resource}</b></td>\n  \t\t</tr>\n  \t\t</#if>\n\n\t\t<#if defined(hostname)>\n\t\t<tr>\n\t\t\t<td><div class=\"tablefield\">Host</div></td><td><b>${hostname}</b></td>\n\t\t</tr>\n\t\t</#if>\n\n\t        <#if defined(param)>\n                <tr>\n                        <td><div class=\"tablefield\">Parameter</div></td><td><b>${param}</b></td>\n                </tr>\n                </#if>\n\n \n                 <#if defined(methods)>\n                <tr>\n                        <td><div class=\"tablefield\">Method</div></td><td><b>${methods}</b></td>\n                </tr>\n                </#if>\n\n\n\t\t<#if defined(detectiontype)>\n\t\t<tr>\n\t\t\t<td><div class=\"tablefield\">Detection Type</div></td><td><b>${detectiontype}</b></td>\n\t\t</tr>\n\t\t</#if>\n\n  \t\t<#if defined(severity) && defined(severityCSS)>\n  \t\t\t<tr>\n  \t\t\t<td><div class=\"tablefield\">Risk</div></td><td><span class=\"${severityCSS}\">${severity}</span></td>\n  \t\t\t</tr>\n  \t\t</#if>\n  \t\t</table>\n\t</div>\n</div>\n\n</#macro>\n\n<#macro outputsection text>\n  <#if defined(text)>\n        <div class=\"section\" id=\"resourcecontentsection\">\n          <h2>Resource Content</h2>\n                <div class=\"content\" id=\"sectioncontent\">\n                  <table>\n                        <tr>\n                          <td><span class=\"resourcecontent\"><pre>${text}</pre></span></td>\n                        </tr>\n                  </table>\n                </div>\n        </div>\n  </#if>\n</#macro>\n\n<#macro responsesection response>\n  <#if defined(response)>\n    <div class=\"section\" id=\"contentsection\">\n      <h2>Response</h2>\n       <div class=\"content\" id=\"sectioncontent\">\n\t  <table>\n\t    <tr>\n\t      <td><span class=\"responsecontent\"><pre>${response}</pre></span></td>\n\t    </tr>\n\t  </table>\n\t</div>\n   </div>\n  </#if>\n</#macro>             \n\n\n\n\n<#macro impactsection impact>\n  <#if defined(impact)>\n\t<div class=\"section\" id = \"impactsection\">\n      <h2>Impact</h2>\n        <div class=\"content\" id=\"sectioncontent\">\n          <ul>\n            <#list impact as item>\n              <li>${item}</li>\n            </#list>\n    \t  </ul>\n        </div>\n    </div>\n  </#if>\n</#macro>\n\n<#macro remediationsection remediation>\n  <#if defined(remediation)>\n\t<div class=\"section\" id=\"remediationsection\">\n\t  <h2>Remediation</h2>\n\t\t<div class=\"content\" id=\"sectioncontent\">\n\t\t  <ul>\n  \t\t\t<#list remediation as item>\n    \t\t  <li>${item}</li>\n  \t\t\t</#list>\n\t\t  </ul>\n\t\t</div>\n\t</div>\n  </#if>\n</#macro>\n\n<#macro discussion text>\n  <#if defined(text)>\n\t<div class=\"section\" id=\"description\">\n\t  <h2>Discussion</h2>\n\t\t<div class=\"content\" id=\"sectioncontent\">\n\t\t  ${text}\n\t\t</div>\n\t</div>\n  </#if>\n</#macro>\n\n<#macro bullet bulletPoint>\n\t\tlist-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAHBJREFUeNrUkjEOgCAMRR/GmV0Pwcj9Z0YOobsXqAsYqjVGBhM7wct/aUtwIkJPDXTW9+JYD1uICzD5nFy5Ayh213EG1i1EeWDmqEfQ53RhZQotWsEzA8TsWIJqr5YBzhTrA7UBiynxjQTg/vPl9gEA5xA3b+PDNsYAAAAASUVORK5CYII=);\n</#macro>\n\n<#macro linkBullet linkArrow>\n\t\tlist-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAE1JREFUeNpi/P//PwMlgImBQjBqwPA34KmFxf+nFhb/KXEBI5JBWBWwYLMVh2H/YQbiNQCLov84xInyAl7NDAwMDIwDnhsBAAAA//8DAABhE8Sx/kM4AAAAAElFTkSuQmCC);\n</#macro>\n\n</#escape>\n"
  },
  {
    "path": "templates/report-style.ftl",
    "content": "<#include \"report-macros.ftl\">\n\n::selection {\n\tbackground: #f46f5d;\n}\n\nbody {\n   font-size: 14px;\n   text-align: justify;\n   word-wrap: normal;\n   font-variant: normal;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   margin:-1px;\n}\n\nh1 {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-variant: normal;\n   color: #030371;\n   font-size: 24px;\n}\n\nh2 {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   color: #2f2f2f;\n   font-size: 13px;\n   text-transform: uppercase;\n}\n\n\nul {\n   margin-bottom: -1px;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 13px;\n   list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAHBJREFUeNrUkjEOgCAMRR/GmV0Pwcj9Z0YOobsXqAsYqjVGBhM7wct/aUtwIkJPDXTW9+JYD1uICzD5nFy5Ayh213EG1i1EeWDmqEfQ53RhZQotWsEzA8TsWIJqr5YBzhTrA7UBiynxjQTg/vPl9gEA5xA3b+PDNsYAAAAASUVORK5CYII=);\n}\n\ntable {\n   padding-top: 10px;\n   padding-bottom: 10px;\n   width: 85%;\n   border-spacing: 16px 2px;\n   background-color: #f3f3f3;\n   border-right-width: 1px;\n   border-bottom-width: 1px;\n   border-top-width: 1px;\n   border-left-width: 5px;\n   border-right-color: #6c0f0f;\n   border-bottom-color: #6c0f0f;\n   border-top-color: #6c0f0f;\n   border-left-color: #2f2f2f;\n   border-style: solid;\n   /* border-color: #6c0f0f; */\n   font-size: 13px;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   \n}\n\ntr {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   border-width: 1px;\n}\n\ntd {\n   border-width: 1px;\n}\n\nhr {\n   align: top;\n}\n\ndiv.summary-title-block {\n  text-align: center;\n  margin-top: 10%;\n}\n\ndiv.summary-table {\n  width: 50%;\n  margin-left: 25%;\n  margin-right: 25%;\n  margin-top: 10%;\n}\n \ndiv.summary-table table {\n  border-bottom-width: 1px;\n  border-left-width: 1px;\n  border-right-width: 1px;\n  border-top-width: 1px; \n  width: 100%;\n \n}\n\nspan.table-title {\n  display: table;\n  margin: 0 auto;\n  text-align: center;\n  font-size: 16px;\n  font-weight: heavy;  \n}\n\ntr.severity-row {\n  border-style: solid;\n  border-top-width: 1px;\n  border-bottom-width: 1px;\n  font-weight: bold;\n  background: #FFFFFF;\n}\n\ntd.severity-HIGH {\n   background-color: #ff0f06;\n   color: #ffffff;\n   font-weight: bold;\n   text-align: center;\n}\n\ntd.severity-MEDIUM {\n   background-color: #ff7c24;\n   color: #ffffff;\n   text-align: center;\n}\n\ntd.severity-LOW {\n   background-color: #61aa00;\n   color: #ffffff;\n   text-align: center;\n}\n\ntd.severity-INFO {\n   background-color: #535ad7;\n   color: #ffffff;\n   text-align: center;\n}\n\ntd.severity-UNKNOWN {\n   text-align: center;\n}\n\ntd.alert-count {\n   text-align: center;\n}\n\nspan.summary-bottom {\n   left: 0;\n   bottom: 0;\n   position: absolute;\n   margin-bottom: 1%;\n}\n\nspan.footertext {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 11px;\n} \n\ndiv.summary-page {\n  width 100%;\n  height: 100%;\n  overflow: auto;\n  font-family: Helvetica, Verdana, Arial, sans-serif;\n}\n\ndiv.summary-title-block  {\n  font-weight: bold;\n  text-align: center;\n}\n\ndiv.summary-title-block h1 {\n  font-size: 18px;\n  color: #000000;\n}\n\ndiv.summary-title-block h2 {\n  font-size: 16px;\n}\n\ndiv.alert-nav {\n   float: right;\n   padding-top: 2px;\n   padding-bottom: 2px;\n   padding-right: 2px;\n   left: -5px;\n}\n\ndiv.alert-body {\n   width: 100%;\n   overflow: auto;\n   height: 100%;\n}\n\ndiv.alert-nav a{\n   background-color: #c20006;\n   color: #ffffff;   \n   width: 60px;\n   pading-left: 2px;\n   padding-right: 2px;\n   border-top-width: 1px;\n   border-left-width: 1px;\n   border-right-width: 1px;\n   border-bottom-width: 1px;\n   border-style: solid;\n   border-color: #000000;\n   font-size: 13px;\n   font-family: Helvtica, Verdana, Arial, sans-serif;\n}\n\ndiv.detailed-findings {\n   background-color: #c20006;\n   color: #ffffff;\n   width: 20%;\n   margin-left: 40%;\n   margin-right: 40%;\n   margin-top: 10%;\n   pading-left: 2px;\n   padding-right: 2px;\n   border-top-width: 1px;\n   border-left-width: 1px;\n   border-right-width: 1px;\n   border-bottom-width: 1px;\n   border-style: solid;\n   border-color: #000000;\n   font-size: 16px;\n   font-family: Helvtica, Verdana, Arial, sans-serif;\n   text-align: center;\n}\n\ndiv.detailed-findings a{\n   color: #FFFFFF;\n}\n\ndiv.tablefield {\n   font-weight: bold;\n}\n\nspan.table-title {\n\n  width: 20%;\n  margin-left: 40%;\n  margin-right: 40%;\n  margin-bottom: 5%;\n  text-align: center;\n  \n}\n\nspan.attackstring {\n   font-family: monospace;\n}\n\nspan.resourcecontent {\n   font-family: monospace;\n}\n\nspan.responsecontent {\n   font-family: monospace;\n   height: 200px;\n   width: 40%;\n   overflow-y: scroll;\n   overflow-x: scroll;\n}\n\nspan.parameter {\n   font-style: italic;\n}\n\nspan.highrisk {\n   background-color: #ff0f06;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n   font-weight: bold;\n}\n\nspan.medrisk {\n   background-color: #ff7c24;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n}\n\nspan.lowrisk {\n   background-color: #61aa00;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n}\n\nspan.inforisk {\n   background-color: #535ad7;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n}\n\ndiv.reflink {\n   line-height: 28px;\n   text-transform: none;\n}\n\na {\n   text-decoration: none;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   color: #a20b0b;\n   font-variant: normal;\n   font-weight: bold;\n}\n\na.visited {\n   text-decoration: none;\n}\n\ndiv.section {\n   padding-left: 20px;\n   padding-bottom: 20px;\n   padding-top: 8px;\n   border-width: 1px;\n   border-style: none;\n\n   background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAABQCAYAAADGDi9oAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAEVJREFUeNrs1LENACAIRUE07r/ydwdpMDn61xyElST1OLsaIxaLR8Wn8QtoOxJgVkUbGG3atGnTFluV+KMjuQAAAP//AwA8ACKSl0uMsQAAAABJRU5ErkJggg==);\n\n   background-repeat: repeat-x;\n   background-position: left bottom;\n\n   font-size: 12px;\n}\n\ndiv.section h2{\n   padding-left: 25px;\n   <@sectionIcon\n       vars.redArrowURL ! \"\"\n   />\n}\n\ndiv.content#sectioncontent {\n   padding-left: 40px;\n   width: 85%;\n}\n\ndiv.vegabanner {\n   <@bgPattern\n     vars.bannerPatternURL ! \"\"\n   />\n   height: 25px;\n}\n\ndiv.vegabanner img {\n   float: left;\n   position: relative;\n   left: -2px;\n}\n\n\ndiv.vegabanner span {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 11px;\n   float: right;\n   position:relative;\n   top: 5px;\n   left: -5px;\n   color: #ffffff;\n   letter-spacing: 3px;\n}\n\ndiv.topsection {\n   border-style: none;\n   <@titleBgPattern\n       vars.titlePatternURL ! \"\"\n   />\n   position: relative;\n   height: 65px;\n   border-top-style: solid;\n   border-width: 1px;\n   border-color: #ffffff;\n}\n\ndiv.footer a{\n   background-color: #c20006;\n   color: #ffffff;\n   font-family:Helvetica, Verdana, Arial, sans-serif;\n   font-size: 10px;\n   float: right;\n   margin-right: 50px;\n   margin-bottom: 20px;\n   padding-right: 5px;\n   padding-left: 5px;\n   padding-top: 3px;\n   padding-bottom: 3px;\n}\n\nspan.title {\n   position: relative;\n   bottom: -40px;\n   left: 45px;\n   text-overflow: clip;\n   color: #ffffff;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 18px;\n   font-weight: lighter;\n   letter-spacing: 1px;\n}\n\ndiv.section#referencesection ul{\n     <@linkBullet\n     vars.linkArrowURL ! \"\"\n   />\n}\n\na.reflink {\n   font-size: 12px;\n   color: #4c00ff;\n   text-decoration: none;\n}\n\na.innerlink {\n   color: #5f2674;\n   text-decoration: none;\n}\n\na.innerlinksmall {\n   font-size: 12px;\n   color: #4c00ff;\n   text-decoration: none;\n}\n\n.bannerLogo {\n   content:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAK0AAAAYCAIAAAAHyurSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAH5lJREFUeNqc2GmsLOlBHuCv9r2qq7tr6f1091nuOmbs8XhjhCFeMDbIRIpxFpMFQ1AAESIilAghEIoSEREnxIkREQpChgCySBywjJ2QMbY1XhJ7vN25M/fcc3o93bV0dXfte1V+dPedO3dmwOb8evS+73e6+t/XBX35R95K4Fi3IZ5PDALHuk3xfGwSBNptiOcTc19NdYLAuo3q+dggcLTbrp1PTQJHu63q+dggCKzbqp5f6gSBddvV8wudIHeJQRBot1U9vzQJAu22aucj/VFcHnChEwTa7ij37mtkXnRV8XxikDjWaYjnU4PEsHZDvD81CAzrNB6qXo6xQRJYZ3ec2CcEjnaqwvm9BY6j7bpwsbQIBG3XhftLi8TQ1i5BDxW2r3bYJzXhQrMIDG1XhUvNwjG0XdujJfIXCx0DUANFL9cOgSItnrk44HLtEAjS4pnLzaMYbRwM3gN/lc0OTRi9b23LFFJJchoGOAQ/jFkYYC/Fyzd/JWBt7XbbYpAkO4RJqm/dbksM40TfuL1OJUxjfe32WmIYx7rl9NpikCXayul2qkGSaCun2xaDONYsp9sWg3CP3bjbrgVRqltOt1MN4lhb2XuYdrd9QKcahLFmbjudelCk+tbu9KUgjHXL6bQqYZIYG7fTqoRRbKzdbqsSxrGxcbqtShDHxsbptCpBHOtrp9OoBFGqr91OoxLEO1SDKNXWbqcphmVqRGG7xodRYmy9lsQHSWI4XkviwyQxHK9d58M40W2vVeeDODFsr13jwwdIEsP2WtX9uFUTgiTRHa9V48Mo0l2/KVdCqDT9sMnTQZaZftji6DDNHk5eBEcHaWb6UYunwyxbBeEeh2oVPNiETZbysmSVpi2WCvPcimOFJB/GOkn2SfIgeRQvP/UI4LMjGZRgdLU+6+9gnfZkqASj5YPkgPn6bCADFBlfrc+OFQDAaGqdHSugBKOZdTZUAARGc+tsqAAAj2ab06EKABjPV6fHCgBgPFudDXenVmfHCoDAaGqdnagAgkaz1emxWqLIeGyenrYAgY0W69MjGQAwXlinRzIowfhqvcd8fdqVQQ7GV+uT3sMVPL6yTo+UPfoKgMD4anXWkUBRjk375LgBYGhibk+aNQDAxNweN/4qGHuMje1xow4ANDHtoVoHoJya22O1BvJybG6Gag0g0NyPBjW+BGC69YZVvgRgau8xs71BlS9LMNt6gypfQmBue32RKyEws72+yBcAzGyvX+VLCMwcr185nBL5PM3mUTwQOZSEFlHYpZmyLB9gGYUdit6hSz1I9psHeOTUy4GqdU6z3Dwv1DqvrZyiLBt1Tlu7AEFbj78+kI4G31utiaw9mbDwVxqEvzRWRVE0ZH5pOnlZqDKvGc6D43leqnJFM+w8L1SZ10wnL0pVOkARNMMuilJVKpppF0WhyoKmb/OsUBo1be3lRdlQKkt9naOwWuM1y8mLUqly+totQKnUON1yi7JQJV5bOUVxeOa8UOsVzXTyYl/l5eF5ikKtcZrj5UWpNCr61CqKUhZY3faKolQqrL49YO3l5T7Ji2KPslQETre9oixlgTW2B9juDvp6m5elJDCG7RcwJFc4Y+0UJZAYyvTDoizrDGX6YV6UuyQvS4mhTC/MQSkxtOkHRfnSyg+Lh1CncMPxCxjUOWplBwACNRy3kqQoyz0AqOL4+mEcqvJlKF4daJrlC8M+7kpZli8M+6QvpUVu5cStD/4E8dqnCJKGURQASLyZiG97b3b+7Pb3/mu/Q6ZZudDt476UpvlC3x735TTPF5pz3JfTNF/o9slATtN8qW33yQ5ZsdDt44GcZvlCs4/70g7DIzmFwELbHA8aaZYvl/bwTE2ScqHbJ30pzfOFYR936rtHHXbraZYvTWfQldOsXJrOsCunebFc2cOunGb50rSHXSnN8qW+HbbrSZEtLGfYk9O8WDp+v11L8ny5dgdqNc1zbeMO1Gqa5trW7SvVNM+1rTtQamleaBtvoOw3faWaZvlyNy4O4yRdrt2jZjXNC932jiQxB5DuRUcVNitL3Q97Ir/DUYXPikL3wiORz4pS98IjkcuKwvDDXoXPilL3o16Fy4rS8KNehc3KXcWmSaZHUU/kMgToUdyr0FlcrpK4TVFZWa6SuHPAg6RFUVlZWi/Dw5uXAx5frXmW5FlyD4pccZ3X/MpvsG96R4FgCE5AMAIgCCEpCCfQ608+/isfrj31zvFyzfMkz5LjucVzFM+S4/mG50ie2yUkx5KTucXtsLB4nuR5ajJb8RzFc9RkZvEsyXPUZLriGYIT2cl0xXM0L1DjqclxFC+yE3PLcSRHk9PFhmdIjiGnyw3PkjzDTBZbnqV4hpws1hxL8Sw1WVgcS+4ThuTZXUVwDDExHI6hOIacXlkcTws1dm7aHEVwFDF7AMvmaIKjyNnK4SiSo4ipud1V09WWowmOJmY7UMR8ZXMkweH4dLVhaYIjiLnlcATBUcTc9TmGZHFsbnssjrE4Nt96LIaxODa3/X1ieyyBsTh25RwSx3sp8LnjMzjGIPDcDVgcZ3HsyglYEhdoUk8iBkEYBNWikEEQGkG1KKQfAvMqYP5SwLrl9hpVP9hdBque2Oz+5L+kGu3ts1+Yf/7pMs8ABAEAAAD2na+88N//EGV58t0fRG+8udeqe35ibqJev+H5qW463XbNC2LddLpd2U+KlRP1eqqf5OYm6vYUP8oMy+92ap4f66bTPVL8KDM3YaerelGqG3a3V3e9SNft3pHkebFue70jxfNi3XI7jZoXxLrldVTRC2NjvUsSw3J6jZoXxIbl9vYbp9esekGsr5yeWvWixFi73WbVC2LTcruNqlfmRhB26oIXJYbtd+qCF6WG7XfqFS9KDNvr1AQvSsxdFSem7bdrgh8lhuN3aoIfJabjt+sVP4oN22/Lgh8lK8dv1Xk/SkwnaDeqQZ6vgrDFs36SroKwxTMH7JKoxbF+srsM7pMmx/hJah2w8qMWx3hRYiVRU9jdHKNmlQmK3C5SlaR218MdNml6QPIIHmz+SqDDXh3BoPOL1bBbLykW//4PYBRVZqnw+JuqJAUAuPz4H0Lu5uj9Pya+7inu+uNllpZleeMf/kzw0V+98/mvnL3xddw7/qb5uc8O/RhBoPv3jOOTNvN971ttvMdubpluP7bDJ9+GUyRmWd4p8kkEDk2i8cSP/SCryNbaf/L7cPji/975i2cGAwWBYT1lrj1xG4bji0ttcNyAafzihatBW0IQ6HK+HnQkBEUvRleDTh1BoMu5OehICAJdXJr9dh1GoIuZOejUYQS6uDAHnRoEQxdLq9+twwg0ujCP2nUYAaO5NThSYAgdXZl9pQrDyEhfHckiBMMjc3WkiDAKj67MI6UKw/BIN4+UKgLDl7rZV0QYhkeG2ZNEGIIudauniDCEjFdWT6rAEDw2rV5dQDBs4gZdgUdgaGK53QqPwPDE2nYr3D4ROASBpmuvI3AIDE3XXncPdw/L7QoclOdT1+8IHAJB97deV2ARCLofBkcVFk2hkR+0KAoG4CoMmiR5AAUDMH8Iu823A7Qp8cuVW4JSqXFW89bg1uOJNoPlFoCK3LURlk+MBVeEeRKXcYziOIThyWZNiNX82lPJ018ushS9/oZB/3by3/7N1d27eVFQj72ZessP0neeBbZJvuEdTbD/awHga183C/7W3/kphCB3CQBgsbgsS9BoiBPNH3zgp2l7Mv6fv1eWZUMRteW2RGC1zmuWU5SlWue0lVuWQJUEzXTKsmxIgrZyyrJsyA+Sirayy6JsVPnl1isBpMoVzbSLEqiSoK/soizVlqiNrLIEu8tgWZaqyOlbryyLA4Ba4fStWx5ujmVZKhVO33i7U7vLoCJyhu2XAMgCa9i7DWtsvRJDZIHW7aAsgcxQhh+WAJIZ2vDDEgCZpQw/LMtSZinTC8vDrbA83C5LACSK0G2vhCCJJU0vKkEpMaTpRyUE6hxtrL0SgBpOWEl8QPIyxN8R0DjOdNM97ta3dsi//nsAAJjcKovi6vc/gvGC+t4PXPvxnwMAgLI0PvMn/gtfb77/p4mKCACgbr/x+LQzf+754A9+5/aP/uN08Br9s1+qVjn+qfdkYTD72G/TN56sJMmd3/3P/tXUcaOb1xpZlLf+0U8CCL74+B9cfvELFAq6fXVx55vDoeL7sZELr7n+mlQT1sFHh8NGHKf6yu6ftqI4Myxv0JbiNDfWzqAjxUn2MIYvTfSVM+jUoyQzNt6gKyVJZqzc/m5juf22FGeFGfj9Zi1OM9P2+0o1TvMDMnPr9RUxTjPD9vtK7VDV4jQ3Hf9IFuM40zdOT67EaW5u/W5diLN85QQ9SYyzYuUGR2otTTMriHoil+T5yg97lUfR3SGMurtNEO2TIOpWuDhOrCTuiGySFVYYdQU2yQsriLoCm0JgXWRtmk6KYp0kTYpKimKTHpDErT2SV8P6lQBPtQ3D4DxLXsxWXPeozDNQFBAMV1QZVnsQgobje+tvfRVAUKXT8zOozBIAQBYGhCjVhydJkulf/Gzu2ehrvkdQFbhznev0vdELkHYB0Swoi5o3je99hdCeyy+/HqrXMZqxPvunkz/8CDZ+tpEuF1/+PBp7PE9dTDa973kbgCBMPVIee4Lj6NnVmqFJvs7MLZuhcZ4j59qGoQmeI2c7sORM3zAUwbPkTNvQOyw3DInzNDHbnWLJ6WLNUDjPknNtw1AEz5Fzbc0ItCByV5ZDExhHkVeWfYBDEzjHkPONzVAYRxFXls2QGEfhhw1xtdrQFM4x5GLjMBTGMcRi7dAEzlH4Ym3TOMZR+MIPGRJjcWzh+DSGvgIIbOkGNIYy2B4sji1cn8ZQBoYWXkDjKIthSzegUJTFsaUbUBjK4tjSD2gCE1nciCMKQRgENeKIgg9A0B3IQ/VyUK8E2PHjbrPmBqkdxChB2M9+cf4X/wuCYe7t71Pe8n2Zu5399q996dd+Kbq6xIePXf/xnyeqknf/zsWf/FGZJSkt5kVBBYb2hacJuaW+/i3Vp94Foyj8rc84QZzGKYITyt/7+df96m+95V99RA8Q8eR65jnQ+FkYgCd/5he6/+zXb/zCvxt+93fbdhjgleHb350nCYCg9vf+gJ9CrhN2unXPi900azWrnh87ftRWRdePXD9qq1XXjx0vbKui48euF3bUqhvsIDpR4gZxu1lz/dj143az5gWJ60ctter5ietFLbXqQ7mbpq0a70WxE8bNmuBHsRvGrbrgRbEXxi1R8KLYi+JWVfCixI3iVlXwg9gJokZd8KPEC+OGyHtB6kVJo8p5UeqGSaPKe2HiJWlTFv0k9ZK0yTOvhgZHPww/yRoM5UaJl2cqx/hJ5iVZg6MfRYWJEBAUuUyQYZ4HeS4RxAMEeR7kuUyQQZ773zbgRp3HMOSFkV4XWVAWqNqpHp+CsnSvpqlrowwXENzg9a/D5XYaBsnaBKCEOVG+8RgEI/P5qtOqVgXyW5/4ROa7tff8ffXJp4LZRX75Dc30MQwGEATxNaYzQGqN6dUWI3AIKicTM0tzD2ExucP3zzCucufuVe+t70Rw4gsf/vXZ058k+jf1jFUbIoZj5/cWaquKcdS9ia5KPIYh52NDlQQMQ+6N9cYBqlQ5gEMx5HxqqpKAocj56MEpXa0LGIacj7Xd8fO52VArGIqeLyy1wuEosgOGIvcXlrKDZikCh6HI/aWlCByGwOcLQ6myGAJfaGtZYDEUvtQtWWAwBLnQLUVgMQS+0NeKwGIUPrJdiaEwGL7cOI9g9ABbR2IoDEF2QEEx2roSR2IwNNo6ErODKzEkBsGjjSvRJIbA48BvcBQGw9MwqOE4BsPT0N9hdsA0+A4ANyReMx0IgLrIxGuLbfeY3jCPo298+N9u/vzjAIK/6xc/dPbTvwxj+PzpTy5/59diy6TVlnjzcQAjobFsqkIU5+Y3v7J97msoKyA4Dr75tKZZAACCovI4/rN//lP/+0ffefdXf8LTFrF+hTBC9fYTNEt/+hd/7vxTfwoA2Ky2KUIdv+u9RZY1bt6k6gqA4NZb36W2JV3bAAhS1IruBABB1Bqvmy6AILXO66YDQZBaF/SVC++SlQNBQK3z+toBEKTKFd20AQRUSdBNGwJAqfO6aQMA7QFBaqduBAEEwO5+9wBgB+eAB9XGAQBIImvaPoCAJDDGxgcAknnWtH0IQLLAmHYAAUjmmZUXQRgms7ThhwAAmaWNIAQAyAxt+BEAkERTu0piKNMPAAASTep+BCGQxNBmEEIAkhjKDCKoPGA3DiIIgmSRXacJBEAVJ6wkBgB6BBC0vwN+O4CTLNdM57SvFEWx/OqXAQCZZyMk9cQ/+Vnq9FaRZ4mlx6tlWRaN69fr73o/WVcyzymy1L8ad5gkSXLbCY57tfnnPl2kabI2wuf+n2Y4zYYIAACgfOObb37XGx/zM/zGk7dnzzxdFsXRD/3t2+//gNA5IggMAGBo6/73vgOjGVAWR299R+X4WlkUyuufKti6pm1PTptJnOmr7cmNdpwX2so+6clJmu+R5drKPt4lpn3SkeKs0DbeyVBN0lxbuSd9JUlz3XSOj5QkzQ3rkKyck54c54Xhh8ftepLl+tY7btYehVpLsly3vWGjlqSZtnEGzVqSFabjD5VqkhWG4w+UapIXhuM9BDHJS8PxBs16BkOmHw2qfFrkDyHsi1xa5Ksg6ot8WuRmEPVFPo6SVRAdVfk0L1Z+fFThXoIgOqrsqrAn8ikM7DLtUHRaFOsk6R7QeRHMtw90urQ5luQY4v7EJJ758/4P/HDq+wjDkf1rJAAAAOeZP1teTm7+1L8gBzdJAEBZFoGLUMzmmU9XSOT80uAFSqpxX/rM/+m++/2U8cLkYsqxJIzhaV4gBFl73z8t0kSCkTJLPvmzH3zuj3735vv/AffOD7zn7X8XgmEAANcbHr37fWkYfOW//AZexPbWa73+zafv/mHktd/PffVrLEde3Nc4lmJr7MXXJzxDcQx5MTV5luIY8v7UeID9t7iyeJbmGPJibPAswTHk/bHBcRTLEpcTk2NJliEuJgbHkixDXkwNvspwLHMx1jiKYEniUrM4Cn8J9D0u5gZLEQyFj40NS+IMiY+MDUfjLImPjQ1HEiyJj/QdiJGxYQmCo4nLjcMSGINh463D4iiDY+P1HpOtx+IYg2OTrcviGI0g463LkjiDo4cKnWw9BscYYg96l2A4g6HTrcexBJWhV37AICiFIPMwoBGE/msB9cPo+rBhe1GWF+L6yvrcp6S/8UNlUTjPfy2HUfH0Jv/Gt2O3fBjFgvnIuZopr30jLre2z3+Tnn3VdkI/jK+fNcMgyYLQ+cwfx57uedHZifrCpRnd+RavqCWAsrzAMYQiMTSPzz/6m8lmJd58nK1V8ywDRQlQ3B5fWHe/wV19NUky/fkr/+IOXxUwmul06o4T+H50dtp0nNAvirNmzXFDP4jPBqrjh0GYHBCf9WQ7iP0oOTtu7jdD1XEjP0yuDRuOG/lBcjZQHC8KwuSsrzp+GATJ6UB1nShIs9NG3QniIE5PWrITxH6cnrUkJ4z9JD1rSE4Q+VF80pXcMA7i9Fit7dF4CcJkXx2QBFk+rAuuHwdpdlyruFEapPlxTfCSNEjTYVXwkixMs0FFcIM4yPOByHpJGqbZQOS9JA2zbCDyXpyGaTao8n6SRtmLVb/CRdsoLPIeRft5FhVFj6L9LIvyvEczr4gwz49eCahaFwgcvXN/2VYrJI5++T996E2iVH3tm3IIBXFYFgUuNXEJgLIM1haKQBCGb8/vbv7Hb9ah9FsTs6lWCBy9c/fq5FhhVy/cuXvVUAQCRzcrh/jyp+9ffGkyMSsCWxHoMEyOqmTGqF/94z8Qn/5ErSlNJkZTFTECv/Oxj944kVut2rPPXt56rOe64dP/+pdf94YzicOevztXGyJB4Xefn6tNkWDI5+9fqZJAEOhzF8uGLBA4+tzFUq3zBI4+N9Ybqkjg6N3zRUMWCAJ77v6yIQk4jt69v1QfBoHdvdgl2F1jqUgVHEXuzg21wuEo/Px8rVR4HEWenxpKhcNR5LnxQq5yOIreW6wUgcUx5N5iJQssjiL35nu8sKteCrnCESR+b2nJNIUj8PlqKzMUjsD3LVtiKBxBzi1bYigMKu65rsTRu2q/WdsPxjL7UILC9ze2zFA4hlzmcRUnMBgeeX5th+CvA1SucgvDhgCk1LiFYUORr//uvw8Xk+a7/haEILs3SAAAAEH1x54AABif//Tlx37negNbGDYEQbLEL7QtBEHHfVnbJbKg6duKSN+83tQNT60Qt24ouuHEdihVarobddq1G7c6ur6VK/i147qubys0LNXZ5XINQVCzIS4AkCpxjYGXizWAgCTzy8V695+Xiy2AYbnKLQ0bgoBc5ZamA0FArnALy4ZgWKrxS2MLQUCq8Ut9CwOwTwCQatzStPeVsQUQJFX5pbGFYEjuVLULAwJAElht4wIAJIHWNt7uMri0bADKukDrWxcCoMbT+taDAKjzjL71AATqu+SVIHGMsXUhDK4xlO6GAIAaTepeCEBZo0ndCyAAaiSu2x6AoCpNGH4IQaBKE0ZwwC6hCMMPIQCqFKF7exh+CBBYFiht60MAiBi2SuK/BODVAWd5MZpbJz0py4rJYv2aax0Sip758Ifu/8dfWj/zKV+7KssSABA7tv2NL+m//x++/lsf6glFlhejyepkID+KoZznxXi2OjlWAQTPF+vTkwaAwGxuHfflDIHGs9XxSQNA0GxmnZ61AACz2erkuJllxWhsHJ80sryYTs2za608K8YTY3jcyLNiMjGHx608K8YzY3i9lZVgvLCOe0qWg9GVNexIWVmMl+vhQM7LYjyzhj05z4vx3Br2lDwvJnNreCTnRTG9soY9JS+KyZU17Eq7ZNCVcghMbXvQqGd5PjE3A7WW5+XEXA+UWp7lE93qN2p5Xk7N7ZFSzfNitrKPFDEv8tnK7ktiXhQza4+pte3LL8Fs7fTVWg6Bue0eiVxe7CDkRXnleEcin6bZ3PN7VS4vyyvH71W4vCyv7AOcR7FwD3D8boWFaFSLozZFFwBo0aNYPoTOqwP5kUGDoYlGnb+cWwxDto572WNvHbzzPbXrt1OEhACAizT2nNxzCaQomKr62icqp7fm98dEETaUyuV4xTB4QxEvxwbDEA21cjk2GZpQlcpobDIMoSrCaGwyFKbI1dFyy7CE2qiORjrDkKoqji51hiXVxgEPJ6NdUhuNDIbZJQbLkGq7PrpcMgShSsJoZjIUptb5y6sVy1GqLIymJksRqiyMZiZLE6pcuZwZDE0osjCerWiKUCRhPF8xNLEb0xShysJ4ZjIsqXLMaLlmCFwRubGxYQhMEbixZlEkJovsxNwyBC4LzNS0aQKTBXZq2jSJyzwzNbc0gcsC+yJWDwHH5Qo7sWwaRmSGntkujWESQ81sl8bROkXM1g5N4nWWmts+haESQz4Ej0KxPbAXUafJ2S6hybkb0BBcgbFFFJIIUsOJh0F9e0BdP7p91rT9yPXjGyfqfDK9/Nyzp8eKHqajqXkykMMomy/W104acZzNFutrZw0HgoyZdftG23ZC1wtv3+jYbuB60e2buyS+faPjuKHrR7eutx03dN3w5nHbSRLXj27d6jlO4LrhrVs9xw5cN7x1+1HcfDE5cpzQ86KbNzuOF3pucPN2z3FCL85uHsmO57tBdHPYsL3QDdNbA9lxQ9ePb11rOX7k+vGts7bjh14Q3zxtOV7oBdGN05bjh64f3TxtOe6hckPPj2+ctpy170fJ9Y7s+JEXxje6shNEThBeO1LcMPGj5Fpb3uGsLblR7MXJtZbshrEXp9da0ot4UEWxF+2QBFl+WhXcMPaS9Jokeknqp9lZveL4kZdnp3XRixM/zU5rgpdkfpKd1nfIT+v8bnxaE7wk3VV+mvrpbpMGaXqi8JulH+T5gGH9LPtrAG7KAoajl3OrKQskja02/slQUSTedoLrp812s7r7RdBQKls3OBkqUo2bX62bagXDkMux2VRFDIMvx6tmQ8Qw9HK8aqoihiGjsdlQKxiOjCZmQ66gFDqaWY2miOHIaKTvMTYbrRqGIZeHZA8MG42MRquG4dh4rDdaIoZj40u90axhGDYa62q3hlHEaLbevU8cL9fNZgVD0dFs1VQrGIaOZmZz9+kzs6EIGI5M5itVrmAoOplZDVnEUGQ8XzVkYQdVFjAMmay2DaWCIfDE3KgijyHIaGkpIoehyMTcKhUWQ+CpuVUqHIYgU9NWKxyKwFPLVkQWQ5Dpyt69T5yutruXj5PVbgxPLVup8hiNzxxPYWkUhme2KzMUAsDc82SeRmF47vgyQ6EwPLc9mT2AoVAYnj0M9sUEg+G540sMhWKIUcZ1nEAhaBGFte8csCzzmuGgKCzLnGZ5CALLdU4z7AMcBIFliddMew/dQRBkBxRF9scRWFYETXfQ/cZGMUSu85puIzBcr3GaHSAIIquCpm8QDJVlUdNsBINlWdC0DYqisiJomo2iqKyIur5BUESWK5q+QVBYkgVN3yAILKmCpm1QBJEVUXN8BIOlCq1ZDoIjUp3XTRtBYanG66aNILBU5/WVjcCwVBN000EQRKoeqiqnm7uK100bReBdhWKI1BQN10dgWKowuuUgEKhXWcP2EBiq84xhewgM13j6JUDgOs8YrocgcL3CGLaPwEidpw3bR2H4ITCrMEIwpMaQph8iMFSlCN3xEQSu0uTKjxAIrtLEKogQCK5SxIuJHyHwoYLhKrVHbZ9Auwpn8AqOW0mCQJCIYa8I+NXx/wcAJLVB7X7G4x8AAAAASUVORK5CYII=);\n}\n"
  },
  {
    "path": "templates/style.ftl",
    "content": "<#include \"macros.ftl\">\n\n::selection {\n\tbackground: #f46f5d;\n}\n\nbody {\n   font-size: 14px;\n   text-align: justify;\n   word-wrap: normal;\n   font-variant: normal;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   margin:-1px;\n}\n\nh1 {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-variant: normal;\n   color: #030371;\n   font-size: 24px;\n}\n\nh2 {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   color: #2f2f2f;\n   font-size: 13px;\n   text-transform: uppercase;\n}\n\n\nul {\n   margin-bottom: -1px;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 13px;\n   <@bullet\n     vars.bulletPointURL ! \"\"\n   />\n}\n\ntable {\n   padding-top: 10px;\n   padding-bottom: 10px;\n   width: 85%;\n   border-spacing: 16px 2px;\n   background-color: #f3f3f3;\n   border-right-width: 1px;\n   border-bottom-width: 1px;\n   border-top-width: 1px;\n   border-left-width: 5px;\n   border-right-color: #6c0f0f;\n   border-bottom-color: #6c0f0f;\n   border-top-color: #6c0f0f;\n   border-left-color: #2f2f2f;\n   border-style: solid;\n   /* border-color: #6c0f0f; */\n   font-size: 13px;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   \n}\n\ntr {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   border-width: 1px;\n}\n\ntd {\n   border-width: 1px;\n}\n\ndiv.tablefield {\n   font-weight: bold;\n}\n\nspan.attackstring {\n   font-family: monospace;\n}\n\nspan.resourcecontent {\n   font-family: monospace;\n}\n\nspan.parameter {\n   font-style: italic;\n}\n\nspan.highrisk {\n   background-color: #ff0f06;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n   font-weight: bold;\n}\n\nspan.medrisk {\n   background-color: #ff7c24;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n}\n\nspan.lowrisk {\n   background-color: #61aa00;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n}\n\nspan.inforisk {\n   background-color: #535ad7;\n   color: #ffffff;\n   padding-left: 3px;\n   padding-right: 3px;\n   padding-top:2px;\n   padding-bottom: 2px;\n}\n\ndiv.reflink {\n   line-height: 28px;\n   text-transform: none;\n}\n\na {\n   text-decoration: none;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   color: #a20b0b;\n   font-variant: normal;\n   font-weight: bold;\n}\n\na.visited {\n   text-decoration: none;\n}\n\ndiv.section {\n   padding-left: 20px;\n   padding-bottom: 20px;\n   padding-top: 8px;\n   border-width: 1px;\n   border-style: none;\n   <@greyGradient\n     vars.sectionGradientURL ! \"\"\n   />\n   font-size: 12px;\n}\n\ndiv.section h2{\n   padding-left: 25px;\n   <@sectionIcon\n       vars.redArrowURL ! \"\"\n   />\n}\n\ndiv.content#sectioncontent {\n   padding-left: 40px;\n   width: 85%;\n}\n\ndiv.vegabanner {\n   <@bgPattern\n     vars.bannerPatternURL ! \"\"\n   />\n   height: 25px;\n}\n\ndiv.vegabanner img {\n   float: left;\n   position: relative;\n   left: -2px;\n}\n\n\ndiv.vegabanner span {\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 11px;\n   float: right;\n   position:relative;\n   top: 5px;\n   left: -5px;\n   color: #ffffff;\n   letter-spacing: 3px;\n}\n\ndiv.topsection {\n   border-style: none;\n   <@titleBgPattern\n       vars.titlePatternURL ! \"\"\n   />\n   position: relative;\n   height: 65px;\n   border-top-style: solid;\n   border-width: 1px;\n   border-color: #ffffff;\n}\n\ndiv.footer a{\n   background-color: #c20006;\n   color: #ffffff;\n   font-family:Helvetica, Verdana, Arial, sans-serif;\n   font-size: 10px;\n   float: right;\n   margin-right: 50px;\n   margin-bottom: 20px;\n   padding-right: 5px;\n   padding-left: 5px;\n   padding-top: 3px;\n   padding-bottom: 3px;\n}\n\nspan.title {\n   position: relative;\n   bottom: -40px;\n   left: 45px;\n   text-overflow: clip;\n   color: #ffffff;\n   font-family: Helvetica, Verdana, Arial, sans-serif;\n   font-size: 18px;\n   font-weight: lighter;\n   letter-spacing: 1px;\n}\n\ndiv.section#referencesection ul{\n     <@linkBullet\n     vars.linkArrowURL ! \"\"\n   />\n}\n\na.reflink {\n   font-size: 12px;\n   color: #4c00ff;\n   text-decoration: none;\n}\n\na.innerlink {\n   color: #5f2674;\n   text-decoration: none;\n}\n\na.innerlinksmall {\n   font-size: 12px;\n   color: #4c00ff;\n   text-decoration: none;\n}"
  },
  {
    "path": "xml/alerts/default.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Default Alert Template</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\n\t<discussion>\n\t\tThis alert template is displayed when the specified template could not be found.\n\t</discussion>\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/insecure-script-include.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>HTTP Script Include in HTTPS Website</title>\n\t\n\t<class>Environment</class>\n\n\t<severity>High</severity>\n\n\t<impact>Vega has detected script code included in HTTPS website over insecure channels.</impact>\n\t<impact>This could allow MITM attacks and compromise of the application or user data.</impact>\n\n\t<remediation>\n\t\tHTTPS websites should only include content, especially script code, over HTTPS.\n\t</remediation>\n\n\t<discussion>\n\t\tVega has detected that content served over HTTPS is including script content that will be fetched over HTTP. This is a serious vulnerability that undermines the security provided by HTTPS. Attackers observing the client interaction with the website could intercept the insecure communication and inject their own script code. If successful, this will run in the context of the DOM and have full access to resources otherwise protected by HTTPS.\n\t</discussion>\n\n\t<references>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-anonymous-dh.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Anonymous Diffie-Hellman Supported</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n\t<impact>Clients connecting with anonymous Diffie-Hellman are susceptible to MITM attacks.</impact>\n\n\t<remediation>\n\t\tFor deployments using OpenSSL, Anonymous Diffie-Hellman can be disabled by adding \"!ADH\" to the supported cipher list string.\n\t</remediation>\n\t<remediation>\n\t\tThe HTTPS server should be restarted after such a change.\n\t</remediation>\n\n\t<discussion>\n\t\tDiffie-Hellman is a key-agreement protocol that is used by clients and servers to mutually derive a session key for the HTTPS session. Anonymous Diffie-Hellman is a version without authentication. Vega detected support for anonymous Diffie-Hellman offered by the server.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://wiki.openssl.org/index.php/Diffie_Hellman\">Diffie-Hellman (OpenSSL)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-client-preference.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Client Ciphersuite Preference</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n\t<impact>User browsers may select less secure cipher suites creating opportunities for attack.</impact>\n\n\t<remediation>\n\t\tHTTPS server should be configured to enforce server ciphersuite preferences. How this is configured will vary by server.\n\t</remediation>\n\t<remediation>\n\t\tMozilla has included guidelines for configuring server ciphersuite preference for various implementations. See link below.\n\t</remediation>\n\n\t<discussion>\n\t\tThe server can override client ciphersuite prioritization during the TLS handshake. This is useful for enforcing better, more\n\t\tsecure ciphersuites for all visiting clients. Vega has detected that this is not configured in the server, potentially leaving\n\t\tolder clients at risk.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\"> Server Side TLS (Mozilla)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-compression.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>TLS Compression Support (CRIME attack)</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n\t<impact>Attackers may be able to exploit the CRIME attack to obtain session cookies or other sensitive data.</impact>\n\n\t<remediation>\n\t\tTLS Compression can be disabled in the server configuration. Consult documentation for the precise steps.\n\t</remediation>\n\t<remediation>\n\t\tThe Mozilla Server Side TLS configuration guide includes instructions for disabling TLS/SSL compression in server configuration (see link below).\n\t</remediation>\n\t<remediation> \n\t\tThe HTTPS server must likely be restarted for configuration changes to take effect.\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected that TLS compression is enabled by the server. This can be leveraged to carry out a chosen-plaintext attack through observing the compression ratio of data sent back from the server. If the attacker can induce a target user into making specific requests, it may be possible for them to obtain their session cookie.\n\t</discussion>\n\n\t<references>\n                <url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\"> Server Side TLS (Mozilla)</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/CRIME\">CRIME attack against TLS</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-export-ciphers.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Export Grade Ciphers Supported</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Low</severity>\n\n\t<impact>Export grade ciphers do not offer a strong level of security.</impact>\n\n\t<remediation>\n\t\tFor implemented using OpenSSL, \"!EXPORT\" can be added to the supported ciphersuites string to disable support for export grade ciphers.\n\t</remediation>\n        <remediation>\n                The Mozilla Server Side TLS configuration guide includes instructions for disabling spport for export grade ciphers in server configuration (see link below).\n        </remediation>\n\t<remediation>\n\t\tThe HTTPS server should be restarted after such a change is made.\n\t</remediation>\n\n\n\t<discussion>\n\t\tVega detected server support for weak (\"export grade\") cipher suites.\n\t</discussion>\n\n\t<references>\n                <url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\"> Server Side TLS (Mozilla)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-md5-cert.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Certificate signed using MD5</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>High</severity>\n\n\t<impact>Certificates may be forged.</impact>\n\t<impact>Forged certificatescan be used in MITM attacks against users.</impact>\n\n\t<remediation>\n\t\tObtain a new certificate signed with SHA-256.\n\t</remediation>\n\n\n\t<discussion>\n\t\tVega detected a certificate signed using MD5. MD5 is known to be insecure, and this has been demonstrated with known certificate forgery.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/MD5#Collision_vulnerabilities\">MD5 Collision Vulnerabilities (Wikipedia)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-no-pfs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Forward Secrecy Not Supported</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n        <impact>If a forward secret cipher is not used, the security of the session data is as secure as the server's long-term private key.</impact>\n\n        <remediation>\n                Server administrators should configure the server to prioritize forward secret cipher suites such as those using ECDHE (elliptic-curve DH ephemeral) and DHE (DH ephemeral).\n        </remediation>\n        <remediation>\n                Mozilla has made guielines available for securely configuring TLS servers. See the references section for a link.\n        </remediation>\n        <remediation>\n                The HTTPS server must likely be restarted for any configuration changes to take effect.\n        </remediation>\n\n        <discussion>\n                Vega detected that the server does not support or prioritize forward secret ciphers in the list of supported cipher suites.\n                Forward secret ciphers use algorithms such as Diffie-Hellman ephemeral to generate a single-use session key. This key\n                is not derived from the long-term private key, therefore the security of the data is not subject to decryption if that key\n                is compromised in the future.\n        </discussion>\n\n        <references>\n                <url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\">Security/Server Side TLS (Mozilla)</url>\n                <url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n        </references>\n\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-pfs-not-preferred.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Forward Secrecy Not Prioritized</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n\t<impact>If a forward secret cipher is not used, the security of the session data is as secure as the server's long-term private key.</impact>\n\n\t<remediation>\n\t\tServer administrators should configure the server to prioritize forward secret cipher suites such as those using ECDHE (elliptic-curve DH ephemeral) and DHE (DH ephemeral).\n\t</remediation>\n\t<remediation>\n\t\tMozilla has made guielines available for securely configuring TLS servers. See the references section for a link.\n\t</remediation>\n\t<remediation>\n\t\tThe HTTPS server must likely be restarted for any configuration changes to take effect.\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected that the server does not prioritize forward secret ciphers in the list of supported cipher suites.\n\t\tForward secret ciphers use algorithms such as Diffie-Hellman ephemeral to generate a single-use session key. This key\n\t\tis not derived from the long-term private key, therefore the security of the data is not subject to decryption if that key\n\t\tis compromised in the future. \n\t</discussion>\n\n\t<references>\n\t\t<url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\">Security/Server Side TLS (Mozilla)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-rc4-preference.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>RC4 Preferred Cipher</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n\t<impact>RC4 has known weaknesses and may be found to be broken in the future.</impact>\n\t<impact>Data confidentiality may be at risk.</impact>\n\n\t<remediation>\n\t\tRC4 should not be prioritized as the most preferred cipher by the server.\n\t</remediation>\n\t<remediation>\n\t\tThis can be changed in the server configuration settings. Mozilla has guidelines on server-side TLS configuration for a number of implementations. See link below.\n\t</remediation>\n\t<remediation>\n\t\tThe HTTPS server would likely need to be restarted for configuration changes to take effect.\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected RC4 as a cipher prioritized by the vendor. RC4 has known issues and it is suspected that even more severe vulnerabilities may be unknown publicly. It is recommended that more secure ciphers be prioritized by the server. Consult the guidance provided by Mozilla in their Server Side TLS configuration guide.\n\t</discussion>\n\n\t<references>\n                <url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\"> Server Side TLS (Mozilla)</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/RC4#Biased_outputs_of_the_RC4\">Biased outputs of the RC4 (Wikipedia)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-self-signed.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Self-Signed Certificate</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Info</severity>\n\n\t<impact>This is an informational finding.</impact>\n\n\t<remediation>\n\t\tN/A.\n\t</remediation>\n\n\n\t<discussion>\n\t\tVega detected a self-signed certificate.\n\t</discussion>\n\n\t<references>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-sha1-cert.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Certificate signed using SHA-1</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Medium</severity>\n\n\t<impact>Certificates can be forged by capable adversaries.</impact>\n\t<impact>Forged certificates can be used in MITM attacks against connecting clients.</impact>\n\n\t<remediation>\n\t\tRenew certificates with SHA-256 signatures.\n\t</remediation>\n\t<remediation>\n\t\tThis should be done before 2016.\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected a certificate signed using SHA-1. SHA-1 is a hash algorithm used in digital signatures. It is currently considered deprecated due to the increasing feasibility in breaking it. \n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/SHA-1\">SHA-1 (Wikipedia)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-small-key.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Small RSA Modulus</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>High</severity>\n\n\t<impact>Data security may be at risk.</impact>\n\t<impact>Users may be vulnerable to data decryption or MITM attacks.</impact>\n\n\t<remediation>\n\t\tDeploy with an RSA key with a larger modulus (2048 recommended).\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected a 1024 bit or smaller RSA public key. This is unacceptably small today and may be vulnerable to factorization.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/RSA_%28cryptosystem%29\">RSA Cryptosystem</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-v2-support.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>SSLv2 Support</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>High</severity>\n\n\t<impact>SSLv2 is vulnerable to many known attacks that can affect user security.</impact>\n\n\t<remediation>\n\t\tSupport for SSLv2 should be disabled as it is obsolete.\n\t</remediation>\n\t<remediation>\n                The Mozilla Server Side TLS configuration guide includes instructions for disabling SSLv2 in server configuration (see link below).\n        </remediation>\n\t<remediation>\n\t\tIt is likely that the HTTPS server must be restarted for configuration changes to take effect.\n\t</remediation>\n\n\t<discussion>\n\t\tVega discovered support for SSLv2. SSLv2 is known to have many serious vulnerabilities and should not be supported or used.\n\t</discussion>\n\n\t<references>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-v3-support.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>SSLv3 Supported (POODLE attack, others)</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>High</severity>\n\n\t<impact>Data security is at risk due to multiple known weaknesses in SSL 3.0.</impact>\n\t<impact>This includes the POODLE attack, which could allow decryption of sensitive data, such as session cookies.</impact>\n\t<impact>It should be noted that an attacker with MITM capabilities may be able to force clients to use SSL 3.0.</impact>\n\n\t<remediation>\n\t\tRemove support for SSLv3. \n\t</remediation>\n\t<remediation>\n\t\tMozilla has recommended settings for Apache, Nginx, Haproxy and others. These settings include explicitly supporting\n\t\tTLS (while excluding SSLv2, SSLv3). See guide below.\n\t</remediation>\n\t<remediation>\n\t\tIt is likely that the HTTPS server must be restarted for any configuration change to take effect.\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected server support for SSL 3.0. This version of the protocol has numerous known weaknesses \n\t\tand is considered deprecated in favor of newer versions of TLS. Some of the known weaknesses can result in a \n\t\tcompromise of sensitive data such as user session tokens.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"https://www.imperialviolet.org/2014/10/14/poodle.html\">POODLE Attacks on SSLv3 (ImperialViolet)</url>\n\t\t<url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\">Sever Side TLS (Mozilla)</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Transport_Layer_Security#SSL_3.0\">Transport Layer Security - SSL 3.0</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/ssl-weak-ciphers.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Weak Ciphers Supported</title>\n\t\n\t<class>Configuration</class>\n\n\t<severity>Low</severity>\n\n\t<impact>Data security may be at risk.</impact>\n\n\t<remediation>\n\t\tDisable support for weak ciphers.\n\t</remediation>\n\t<remediation>\n\t\tThe Mozilla Server Side TLS guide (link below) includes guidelines for disabling support for weak ciphers in many implementations.\n\t</remediation>\n\t<remediation>\n\t\tThe HTTPS server may need to be restarted following any configuration changes.\n\t</remediation>\n\n\t<discussion>\n\t\tVega discovered that the server supports weak ciphers. If used by a client these may put data security at risk.\n\t</discussion>\n\n\t<references>\n                <url address=\"https://wiki.mozilla.org/Security/Server_Side_TLS\"> Server Side TLS (Mozilla)</url>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/test.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Test vulnerability</title>\n\t\n\t<class>Example</class>\n\t<severity>High</severity>\t\t\n\t\n\t<impact> Could be used to demonstrate partially completed functionality of web application scanner.</impact>\n\t<impact> May cause boredom.</impact>\n\t\n\t<remediation>\n\t  There is currently no solution for this vulnerability.  Contact your vendor.  \n\t</remediation>\n\t\t\n\t<discussion>\n\t\tDiscuss it here.\n\t</discussion>\n\t\n\t<external>\n\t\t<url address=\"http://subgraph.com\">Subgraph security.</url>\n\t</external>\n\t\n\t<references>\n\t\t<url address=\"http://minecraft.net\">Minecraft is a good game.</url>\n\t\t<url address=\"http://en.wikipedia.com\">Learn stuff here</url>\n\t</references>\n\t\n</alert>\n"
  },
  {
    "path": "xml/alerts/vauthhttp.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Cleartext Password over HTTP</title>\n\t\n\t<class>Environment</class>\n\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a form that can cause a password submission over an insecure channel.</impact>\n\t<impact>This could result in disclosure of passwords to network eavesdroppers.</impact>\n\n\t<remediation>\n\t\tPasswords should never be sent over cleartext. The form should submit to an HTTPS target.\n\t</remediation>\n\n\n\t<discussion>\n    \tVega detected a form with a password input field that submits to an insecure (HTTP) target. Password values should never be sent in the clear across insecure channels. This vulnerability could result in unauthorized disclosure of passwords to passive network attackers.\n\t</discussion>\n\n\t<references>\n        \t<url address=\"http://en.wikipedia.org/wiki/HTTP_Secure\">HTTPS (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vautocomplete.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Form Password Field with Autocomplete Enabled</title>\n\t\n\t<class>Environment</class>\n\n\t<severity>Low</severity>\n\n\t<impact> A password value may be stored on the local filesystem of the client.</impact>\n\t<impact> Locally stored passwords could be retrieved by other users or malicious code.</impact>\n\n\t<remediation>\n\t  The form declaration should have an autocomplete attribute with its value set to \"off\".\n\t</remediation>\n\n\n\t<discussion>\n    \tVega detected a form that included a password input field.  The autocomplete attribute was not set to off.  This may result in some browsers storing values input by users locally, where they may be retrieved by third parties.\n\t</discussion>\n\n\t<references>\n        \t<url address=\"http://msdn.microsoft.com/en-us/library/ms533486(VS.85).aspx\">AUTOCOMPLETE attribute (MSDN)</url>\n    \t\t<url address=\"http://msdn.microsoft.com/en-us/library/ms533032(VS.85).aspx\">Using Autocomplete in HTML Forms (MSDN)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vdirlist.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Directory Listing Detected</title>\n\t\n\t<class>Configuration Error</class>\n\t<severity>Low</severity>\t\t\n\t\n\t<impact> The server is outputting the contents of directories.</impact>\n\t<impact> This could expose files not meant for user retrieval (old htaccess files, backups, source code).</impact>\n\t<impact> The directory listing may additionally provide useful information about the system layout and characteristics, such as naming conventions used by the developers and administrators.</impact>\n\t<impact> This information can increase the probability of success for blind attacks and brute force guessing.</impact>\n\n\t<discussion> Listing directory contents when no index file is present in a common misconfiguration. The directory contents can provide useful information to an attacker, especially if there are files that are not meant to be accessible, such as source code or backups.  The directory listing may also provide useful information about the habits of the server administration and/or web developers, such as file naming convention, that could be used to increase the probable success of brute-force or other attacks.\n\t</discussion>\n\n\t<remediation>\n\t  For Apache, do one of the following: add \"IndexIgnore *\" to the directory's .htaccess file, or alternatively remove \"Indexes\" from the line \"Options All Indexes FollowSymLinks MultiViews\" in your Apache configuration file.  </remediation>\n\t<remediation>For lighttpd, change \"dir-listing.activate = \"enable\"\" to \"dir-listing.activate = \"disable\"\" in your lighttpd configuration file.\n\t</remediation>\n\n\t<references>\n\t\t<url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n\t\t<url address=\"http://cwe.mitre.org/data/definitions/548.html\">CWE-548: Information Exposure through Directory Listing (Mitre)</url>\n\t\t<url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">Information Leakage (WASC)</url>\n\t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vfileupload.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Form File Upload Detected</title>\n\t\n\t<class>Environment</class>\n\n\t<severity>Info</severity>\n\n\t<impact>A form allowing file upload was detected by Vega.</impact>\n\t<impact>Vulnerabilities are commonly found in file upload functions.</impact>\n\n\t<remediation>\n\tThis alert is purely informational, there is no vulnerability that has been positively identified. It is recommended that the file upload function be examined and reviewed to ensure that it is implemented securely.\n\t</remediation>\n\n\n\t<discussion>\n\tFile uploads via FORM submissions are a common source of vulnerabilities. The most common attacks include uploading of script code (uploading a PHP file and then executing it remotely). Ensure that the location of the files uploaded is restricted, i.e., the uploaded file cannot be interpreted as server-side code. Care should also be taken to ensure that directory traversal vulnerabilities do not allow files to be uploaded in other areas.\n\t</discussion>\n\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vhttpauth.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>HTTP Authentication over Unencrypted HTTP</title>\n\t\n\t<class>Configuration Error</class>\n\t<severity>High</severity>\t\t\n\t\n\t<impact>Disclosure of credentials to network eavesdropper.</impact>\n\t<impact>Unauthorized access.</impact>\n\t\n\t<remediation>\n\t\tResources protected by HTTP authentication should only be accessible over HTTPS. \n\t</remediation>\n\t\t\n\t<discussion>\n\t\tVega detected a resource requiring HTTP authentication. This resource was available over HTTP. If a user were to authenticate to this resource over HTTP, the supplied credentials would be sent in cleatrtext and be vulnerable to eavesdropping. HTTPS will prevent unauthorized disclosure of HTTP authentication credentials.\n\t</discussion>\n\t\n\t<references>\n\t\t<url address=\"https://www.owasp.org/index.php/Top_10_2007-Insecure_Communications\">OWASP Top 10 - 2007: Insecure Communications</url>\n\t</references>\n\t\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-1918.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Internal Addresses Found</title>\n\t\n\t<class>Information</class>\n\t<severity>Low</severity>\n\n        <impact>May reveal internal network structure to outside attackers.</impact>\n\t<impact>Internal IP addresses that have been disclosed could be used as targets in otherwise blind attacks.</impact>\n\n\t<discussion>\n\tVega has discovered references to internal hosts or networks in publicly accessible content. These addresses may reveal information to an attacker about the internal network structure, increasing the likelihood of success for blind attacks involving other vulnerabilities.\n\t</discussion>\n\n\t<remediation>The cause may be related to the code, content, or due to the configuration of the server environment. </remediation>\n\t<remediation>It is recommended that the discovered page be inspected to determine where the exposed address originates. </remediation>\n\n\t<references>\n\t\t<url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">WASC: Information Leakage</url>\n\t</references>\t\n\t\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-ajax.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible AJAX code detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\n\n\t<impact>Vega has detected content the use of AJAX, indicating the existence of possible injection points where vulnerabilities may exist.</impact>\n\t<impact>The AJAX backend API should be manually inspected for vulnerabilities.</impact>\n\n\t<remediation>\n\tThis is not a vulnerability. This alert is only to flag that code associated with use of AJAX has been detected in scanned content. Backend AJAX interfaces can expose possible vulnerabilities and manual inspection should be included in any comprehensive security assessment.\n\t</remediation>\n\n\t<discussion>\n\tAJAX (Asynchronous Javascript and XML) refers to a collection of technologies used to make the user experience of web applications more interactive. AJAX functionality often involves the asynchronous sending of requests and processing of their responses using Javascript, without requiring page reloads. The endpoints on the server side often accept parameters, making them injection points where vulnerabilities could exist. \n\t</discussion>\n\t\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Ajax_(programming)\">AJAX (Wikipedia)</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/XMLHttpRequest\">XMLHttpRequest (Wikipedia)</url>\n\t</references>\t\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-bash-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Bash \"ShellShock\" Injection</title>\n\t\n\t<class>Information</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a possible command injection vulnerability.</impact>\n\t<impact>Attackers may be able to run commands on the server.</impact>\n\t<impact>Exploitation may lead to unauthorized remote access.</impact>\n\n\t<remediation>The bash shell should be upgraded on the affected host. This can often be done through the package management system, such as apt or yum.</remediation>\n\t<remediation>Developers should examine the code corresponding to the page in detail to determine if the vulnerability exists.</remediation>\n\t<remediation>Execution of system commands through a command interpreter, such as with system(), should be avoided.</remediation>\n\t<remediation>If absolutely necessary, the developer should take extra care with validating the input before it is passed to the interpreter.</remediation>\n\n\t<discussion>The issue Vega identified is due to a vulnerability in the Bash shell. This vulnerability may manifest itself remotely in web applications if user-supplied input is passed to the Bash shell environment, which can occur if header or parameter values are converted to local environment variables. If successfully exploited, this vulnerability may lead to command execution on the underlying host.</discussion>\n\n\t<references>\n\t\t<url address=\"https://access.redhat.com/articles/1200223\">Bash Code Injection Vulnerability via Specially Crafted Environment Variables (CVE-2014-6271, CVE-2014-7169) (Red Hat)</url>\n    <url address=\"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6271\">CVE-2014-6271</url>\n    <url address=\"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6278\">CVE-2014-6278</url>\n    <url address=\"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7169\">CVE-2014-7169</url>\n    <url address=\"https://www.owasp.org/index.php/Command_Injection\">Command Injection (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Reviewing_Code_for_OS_Injection\">Reviewing Code for OS Injection (OWASP)</url>\n    <url address=\"http://en.wikipedia.org/wiki/Code_injection#Shell_injection\">Shell Injection (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-blank.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Blank Body Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\n\n\t<discussion>\n\t    Vega has detected that requesting this URI returned a blank response body.\n\t</discussion>\n\n\t<impact>This may be indicative of an error condition and should be manually investigated further.</impact>\n\n\t<remediation>\n \tThe developer should investigate why this occurred and if there are any security implications. \n\t</remediation>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-code-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Eval Code Injection</title>\n        \n        <class>Information</class>\n        <severity>High</severity>\n\n        <impact>Vega has detected a code injection vulnerability.</impact>\n        <impact>Attackers may be able to run arbitrary code on the server.</impact>\n        <impact>Exploitation may lead to unauthorized remote access.</impact>\n\n        <remediation>Developers should examine the code corresponding to the page in detail to determine if the vulnerability exists.</remediation>\n        <remediation>Functions that evaluate code, such as eval(), should be avoided.</remediation>\n        <remediation>If absolutely necessary, the developer should take extra care with validating the input before it is passed to the interpreter.</remediation>\n\n        <discussion>Code injection vulnerabilities often occur when inadequately sanitized externally supplied data to a function that evaluates code such as eval(). Vulnerabilities such as these can be exploited by using shell metacharacters to run arbitrary code that was not intended to be executed by the application developer. The eval() function, and derivatives, are often responsible, and should be avoided unless absolutely necessary. These vulnerabilities can grant remote access to attackers, if exploited successfully.\n        </discussion>\n\n        <references>\n                <url address=\"https://www.owasp.org/index.php/Direct_Dynamic_Code_Evaluation_('Eval_Injection')\">Direct Dynamic Code Evaluation ('Eval Injection')</url>\n        </references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-comments.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Interesting HTML Comments Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\t\t\n\t\n\t<impact>Vega has detected comments in scanned content that may include sensitive information.</impact>\n\t<impact>Comments left by developers can include source code, usernames, passwords, or configuration settings.</impact>\n\t<impact>This information, while not visible on the rendered page, is still transmitted to the client.</impact>\n\t<impact>Disclosure of sensitive information could be used by an attacker to perform more intelligent attacks.</impact>\n\n\t<remediation>The developers should investigate the flagged link and manually confirm the presence of comments containing sensitive information. Any such comments should be removed.</remediation>\n\t\n\t<discussion>Programming and markup languages allow for arbitrary text or segments of code to be marked as comments, meaning that they are in the source code file but excluded from parsing and execution or rendering. HTML supports comments, and though they aren't rendered as part of a web page, they are transmitted with the rest of the document to remote clients. Developers sometimes comment out server-side application code that would never otherwise be seen by clients, as HTML comments. These cases, and others, where sensitive information is included in HTML comments, can result in security vulnerabilities.</discussion>\n\n\t<references>\n\t\t<url address=\"http://cwe.mitre.org/data/definitions/615.html\">CWE-615: Information Exposure through Comments (Mitre)</url>\n                <url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n                <url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">Information Leakage (WASC)</url>\n\t</references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-cookie-httponly.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Cookie HttpOnly Flag Not Set </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that this cookie was set without the HttpOnly flag. When this flag is not present, it is possible to access the cookie via client-side script code. The HttpOnly flag is a security measure that can help mitigate the risk of cross-site scripting attacks that target session cookies of the victim. If the HttpOnly flag is set and the browser supports this feature, attacker-supplied script code will not be able to access the cookie.\n</discussion>\n        <remediation>\n          When creating the cookie in the code, set the HttpOnly flag to true.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/HttpOnly\">HttpOnly OWASP Reference</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-cookie-scope.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Permissive Cookie Domain Scope</title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the domain scope for this cookie is too permissive. The cookie domain attribute determines which domains the browser will send to the cookie to. The issue is that a sub-domain has set a cookie domain attribute that is higher in the domain hierarchy (a parent domain). As a result, the browser will submit the cookie to the parent domain and its other child domains. This presents a security risk because the browser may transmit the cookie to unintended recipients in sub-domains. If a session identifier or other sensitive information is intercepted by a malicious party, they may be able gain unauthorized access to the application.\n</discussion>\n        <remediation>\n          Restrict the cookie domain scope to ensure that cookies are not sent to unintended sub-domains.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/Session_Management_Cheat_Sheet#Domain_and_Path_Attributes\">Domain and Path attributes OWASP Reference</url>\n        </references>\n</alert>\n\n\n"
  },
  {
    "path": "xml/alerts/vinfo-cookie-secure.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Cookie Secure Flag Not Set </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that this cookie was set without the Secure flag. When the Secure flag is set, the browser will only transmit the cookie back to the server over HTTPS. However, when this flag is not set, the cookie may be transmitted over unencrypted HTTP. This may allow the cookie to be observed in transit.\n</discussion>\n        <remediation>\n          When creating cookies, ensure the Secure flag is set.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/SecureFlag\">SecureFlag OWASP Reference</url>\n        </references>\n</alert>\n\n\n"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-aafd-domain-wildcard.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Wildcard Allow-Access-From Domain </title>\n\n<class>Information</class>\n<severity>High</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set the domain attribute for allow-access-from to a wildcard value. This means that there are no domain-based restrictions on cross-site requests. The affected resource will accept cross-site requests originating from any domain. If the affected cross-domain policy is the master policy for the whole domain then there will be no domain-based restrictions for any resources within the entire domain.\n</discussion>\n        <remediation>\n          Set a cross-domain policy that accepts requests only from specific trusted domains.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-aafd-domain-wildcardtld.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Wildcard TLD Allow-Access-From Domain </title>\n\n<class>Information</class>\n<severity>Low</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set Allow-Access-From domain attributes to wildcard values for entire top-level domains. This means that there are no domain-based restrictions on cross-site requests originating from these top-level domains. The affected resource will accept cross-site request from any sub-domain within the top-level domains specified in domain attributes. If the affected cross-domain policy is the master policy for the whole domain then this will affect any resources within the entire domain.\n</discussion>\n        <remediation>\n          Set a cross-domain policy that accepts requests only from specific trusted domains.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-aafd-secure-false.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Allow-Access-From Secure Flag False </title>\n\n<class>Information</class>\n<severity>Low</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set the allow-Access-from secure attribute to \"false\". This will permit HTTPS-based resources to accept cross-domain requests over unencrypted HTTP. This will eliminate any security benefits gained from using HTTPS, potentially facilitating man-in-the-middle attacks or eavesdropping of sensitive information.\n</discussion>\n        <remediation>\n          Set the secure attribute to \"true\" in the allow-access-from configuration setting of the policy file.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-ahrf-domain-wildcard.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Wildcard Allow-Http-Request-Headers-From Domain </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set the domain attribute for allow-http-request-headers-from to a wildcard value. This means that the resource does place domain-based restrictions on HTTP headers in cross-domain requests. \n</discussion>\n        <remediation>\n          Configure the cross-domain policy file to accept HTTP headers only from specific trusted domains.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-ahrf-domain-wildcardtld.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Wildcard TLD Allow-Http-Request-Headers-From Domain </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set domain attributes for allow-http-request-headers-from to wildcard top level domains. This means that the resource will accept HTTP headers from any sub-domains of the top level domains specified in the policy.\n</discussion>\n        <remediation>\n          Set a cross-domain policy that accepts requests only from specific trusted domains.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-ahrf-headers-wildcard.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Wildcard Allow-Http-Request-Headers-From Headers </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set the headers attribute for allow-http-request-headers-from to a wildcard value. This means that arbitrary headers will be accepted in cross-domain requests.\n</discussion>\n        <remediation>\n          Configure the cross-domain policy file to accept a limited range of safe headers such as \"SOAPAction\".\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n                <url address=\"http://helpx.adobe.com/flash-player/kb/arbitrary-headers-sent-flash-player.html\">Adobe Flash Player help =Arbitrary headers are not sent from Flash Player to a remote domain</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-ahrf-secure-false.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Allow-Http-Request-Headers-From Secure Flag False </title>\n\n<class>Information</class>\n<severity>Low</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain policy. The crossdomain.xml file has set the allow-http-request-headers-from secure attribute to \"false\". This will permit HTTPS-based resources to accept cross-domain requests over unencrypted HTTP. This will eliminate any security benefits gained from using HTTPS, potentially facilitating man-in-the-middle attacks or eavesdropping of sensitive information.\n</discussion>\n        <remediation>\n          Set the secure attribute to \"true\" in the allow-http-request-headers-from configuration setting of the policy file.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-crossdomain-sc-policies-all.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Flash Cross-Domain Permissive Site-Control Policy </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has specified an insecure Flash cross-domain site-control policy. The crossdomain.xml file has set the site-control permitted-cross-domain-policies attribute to \"all\". As a result, all cross-domain policy files on the domain are permitted and may override the master policy for specific resources, which can potentially lower cross-domain security settings.\n</discussion>\n        <remediation>\n          Assess the need for resource-specific cross-domain policies. If resource-specific policies are not absolutely required, configure a master policy file on the domain root path that specifies \"master-only\" as the value for the site-control permitted-cross-domain-policies attribute. This will enforce a single policy for the entire domain.\n        </remediation>\n        <references>\n                <url address=\"http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e08.html\">Adobe Flash Player security - Website controls (policy files)</url>\n        </references>\n</alert>"
  },
  {
    "path": "xml/alerts/vinfo-differential-lfi.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Page Fingerprint Differential Detected - Possible Local File Include</title>\n\t\n\t<class>Error Message</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a different response fingerprint in relation to a local file include injection attempt.</impact>\n\t<impact>This may indicate a local file include vulnerability, though this is not confirmed.</impact>\n\t<impact>If this is due to a local file include vulnerability, exploitation of local file include vulnerabilities can allow attackers to gain unauthorized access to files, which may also aid in other attacks.</impact>\n\t<impact>Differing responses may also indicate the presence of a file enumeration vulnerability, which instead of allowing the attacker to gain access to file contents, may allow them to determine if files exist on the system.</impact>\n\t\n\t<discussion>\n\tVega has detected a different response page fingerprint in relation to a local file include injection request. This means that the response page content returned by the web application has a different signature from that returned by an ordinary request, which may indicate the existence of a local file include vulnerability. Local file include vulnerabilities are present when externally-supplied input is used to specify the location of a local filesystem resource that is requested by the web application. The differing page fingerprint may include error messages or indicate a state change in the application in response to the local file include injection attempt made by Vega. Differing responses may also be indicative of a file enumeration vulnerability, which would allow an attacker to determine if specific files exist on the system. Developers should examine the response content and underlying code to verify whether or not a vulnerability is present. If the vulnerability exists and precautions are not taken, such a vulnerability could allow attackers to gain unauthorized access to sensitive information contained in local files, which may also be leveraged in further attacks on the web application.\n\t</discussion>\n\n\t<remediation>To prevent this type of vulnerability, the developer should canonicalize the path of any filesystem resource that has a path composed of externally-supplied input and then perform an authorization check prior to access.</remediation>\n\t<remediation>The realpath() library call will return the canonical path of the resource. It is implemented in PHP, Perl, and Python.</remediation>\n\t<remediation>For Ruby frameworks, File.expand_path can be used.</remediation>\n\t<remediation>GetFullPath() can be used on ASP.NET applications.</remediation>\n\t<remediation>getCanonicalPath() can be used in Java code.</remediation>\n\t<remediation>Additional protection against unauthorized access to filesystem resources can be obtained by using chroot() or similar mechanisms to limit filesystem access to the web application and http server process, although this can be difficult to manage.</remediation>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Directory_traversal\">Directory Traversal (Wikipedia)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Path_Traversal\">Path Traversal (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/File_System#Path_traversal\">Avoiding Path Traversal (OWASP)</url>\n\t</references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-differential-xpath.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Page Fingerprint Differential Detected - Possible XPath Injection</title>\n\t\n\t<class>Error Message</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a different response fingerprint in relation to an XPath injection attempt.</impact>\n\t<impact>This may indicate an XPath injection vulnerability, though this is not confirmed.</impact>\n\t<impact>If this is due to an XPath vulnerability, depending on the nature of the XPath query, exploitation could allow attackers to bypass authentication or gain unauthorized access to sensitive XML data.</impact>\n\t\n\t<discussion>\n\tVega has detected a different response page fingerprint in relation to an XPath injection request. This means that the response page content returned by the web application has a different signature from that returned by an ordinary request, which may indicate the existence of an XPath injection vulnerability. The differing page fingerprint may include error messages or indicate a state change in the application in response to the XPath injection attempt made by Vega. Developers should examine the response content and underlying code to verify whether or not a vulnerability is present. If the vulnerability exists and precautions are not taken, depending on the nature of the affected XPath query, such a vulnerability could allow attackers to bypass authentication or gain unauthorized access to sensitive XML data.</discussion>\n\n\t<remediation>To prevent this type of vulnerability, the developer should consider adopting the use of pre-compiled XPath statements or query parameterization options.</remediation>\n\t\n\t<references>\n\t\t<url address=\"https://www.owasp.org/index.php/XPATH_Injection\">XPATH Injection (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Blind_XPath_Injection\">Blind XPath Injection (OWASP)</url>\n\t</references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-emails.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Email Addresses Found</title>\n\t\n\t<class>Information</class>\n\t<severity>Low</severity>\n\n\t<impact>E-mail addresses exposed to the Internet will be scraped by spambots and added to spam lists.</impact>\n\t<impact>E-mail addresses can also be used in targeted and phishing attacks.</impact>\n\t<impact>E-mail addresses could be used to more accurately guess application usernames.</impact>\n\n\t<remediation>If the e-mail addresses are those of users, developers should investigate why they are being output and try to remove or obfuscate them.</remediation>\n\t<remediation>E-mail addresses embedded in user-supplied content should be filtered or obfuscated to prevent unintented disclosure.</remediation>\n\t<remediation>It is common that e-mail addresses may be automatically included in third-party components, such as Javascript libraries.</remediation>\n\t<remediation>Another possibility is that the server is automatically configured to include e-mail addresses. Tweaking configuration can usually remove these.</remediation>\n\t\n\t<discussion>\n\tVega has found patterns that resemble e-mail addresses in scanned content. These may be user the addresses of system users, addresses inserted in user-supplied content, or third-party addresses embedded in components of the application (such as Javascript libraries). Automatically scraping websites is one way that spammers and phishers collect e-mail addresses for their distribution lists. It is recommended that e-mail addresses not be displayed on exposed parts of the web application, directly or indirectly.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/E-mail_address_harvesting\">E-mail address harvesting (Wikipedia)</url>\n\t\t<url address=\"http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/\">Nine ways to obfuscate your e-mail address (Tilllate TechBlog)</url>\n\t</references>\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-asp.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>ASP/ASPX Error Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Low</severity>\t\t\n\t<discussion>Vega has detected an error message associated with the Microsoft ASP/ASP.NET framework. </discussion>\n  <impact>Verbose error output has been detected.</impact>\n  <impact>Data in this output could reveal sensitive information about the application that could aid more complex attacks.</impact>\n  <impact>The error itself may be indicative of a security vulnerability.</impact>\n\n  <remediation>The developer should investigate the error to determine its nature and ensure that it does not represent a vulnerability.</remediation>\n  <remediation>Disable error messages for remote users.</remediation>\n  <remediation>Configure the server and framework to display safe error messages that do not include sensitive information.</remediation>\n  <references>\n    <url address=\"http://msdn.microsoft.com/en-us/library/994a1482(v=vs.100).aspx\">MSDN - How to: Display Safe Error Messages</url>\n  </references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-cf.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>ColdFusion Debug Output Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Medium</severity>\t\t\n\n\t<impact>Vega has detected content that corresponds to verbose debugging output from a ColdFusion server.</impact>\n\t<impact>This output can contain sensitive information which could make other attacks easier.</impact>\n\t<impact>System configuration settings, absolute file paths, and other information may be disclosed.</impact>\n\t<impact>If Robust Exception Information is enabled, this data could include SQL statements and detailed information about the application error.</impact>\n\t<impact>The error itself may indicate a vulnerability.</impact> \n\n\t<remediation>ColdFusion can and should be configured to limit the output of debug data when errors occur.</remediation>\n\t<remediation>This is managed in the ColdFusion Administrator, the \"Debugging and Logging\" section.</remediation>\n\t<remediation>For production servers, the ColdFusion 9 Lockdown Guide recommends disabling \"Robust Exception Information\".</remediation>\n\t<remediation>For production servers, the ColdFusion 9 Lockdown Guide recommends disabling \"AJAX Debug Log Window\".</remediation>\n\t<remediation>For production servers, the ColdFusion 9 Lockdown Guide recommends disabling \"Request Debugging Output\".</remediation>\n\t<remediation>If absolutely necessary, ColdFusion can be configured to restrict debugging output to specific IP addresses.</remediation>\n\t<remediation>This can be also be managed from the ColdFusion Administrator, on the Debugging IP Addresses page.</remediation>\n\t<remediation>The developers should investigate the error to ensure that it is not linked to a security vulnerability.</remediation>\n\n\t<discussion>\n\tVega has detected content that matches the verbose error data output by servers running ColdFusion configured to send debug data to remote clients. The information in this output is sensitive: it can include absolute system paths, system configuration settings, information about the application code structure, system patchlevels, database queries, and database configuration settings. For production servers, it is strongly recommended that the debug output configuration options be disabled. The ColdFusion 9 lockdown guide recommends turning all of the settings off and provides instructions for doing so. The information obtained from this error page could increase the likelihood of success of another attack. Finally, the error itself should be investigated for security implications.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://www.adobe.com/products/coldfusion/whitepapers/pdf/91025512_cf9_lockdownguide_wp_ue.pdf\">ColdFusion 9 Lockdown Guide (Adobe)</url>\n\t\t<url address=\"http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf3638e6-7fe0.html\">Using the ColdFusion Administrator: Debugging and Logging section</url>\n                <url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n                <url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">Information Leakage (WASC)</url>\n\t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-django.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Django Debug Output Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Medium</severity>\t\t\n\n\t<impact>Vega has detected content that matches the verbose Django error output.</impact>\n\t<impact>The Django error output includes sensitive information that could increase the likelihood of other attacks.</impact>\n\t<impact>Disclosure of absolute system paths and filesystem layout.</impact>\n\t<impact>Disclosure of system configuration settings and software versions.</impact>\n\t<impact>Disclosure of database configuration settings.</impact>\n\t<impact>The application error itself may suggest a security vulnerability.</impact>\n\n\t<remediation>Verbose debug / error output should not be sent to remote clients on production systems.</remediation>\n\t<remediation>This can be disabled (and it is recommended to do so) by assigning the boolean DEBUG setting to False.</remediation>\n\t<remediation>This should be done in the settings file (e.g. settings.py).</remediation>\n\t<remediation>Users deploying with Apache and mod_python should also have PythonDebug Off in the Apache configuration files.</remediation>\n\t<remediation>The developers should investigate why the error occurred and whether or not there are security implications.</remediation>\n\n\t<discussion>Vega has detected content that matches the verbose error data output by servers running Django with the Django DEBUG setting set to True. The information in this output is sensitive: it includes absolute system paths, system configuration settings, information about the application code structure, system patchlevels, and database configuration. For production servers, it is strongly recommended that the DEBUG setting, a boolean value in the settings file, be set to False. The information obtained from this error page could increase the likelihood of success of another attack. Finally, the error itself should be investigated for security implications.</discussion>\n\n\t<references>\n\t\t<url address=\"http://www.djangobook.com/en/2.0/chapter20/\">Chapter 20: Security (Django Book)</url>\n\t\t<url address=\"http://docs.djangoproject.com/en/dev/ref/settings/\">Django Settings (Django documentation)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n\t\t<url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">Information Leakage (WASC)</url>\n\t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-http.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>HTTP Error Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\t\t\n\t\n  <impact>The error status code indicates an unidentified event on the server that may be associated with a vulnerability or configuration problem.</impact>\n\n  <remediation>The developer should investigate how or why this error occurred and ensure that there is no vulnerability present.</remediation>\n\n  <discussion>A request that Vega has sent has resulted in a HTTP response with an error status code. This should be investigated by inspecting both the request and response.</discussion>\n\n  <references>\n    <url address=\"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4\">RFC 2616: Section 10.4 (IETF)</url>\n  </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-java.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Java Debug Output Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Medium</severity>\t\t\n\t\n\t<impact>Verbose Java error output has been detected.</impact>\n\t<impact>Data in this output could reveal sensitive information about the application that could aid more complex attacks.</impact>\n\t<impact>The error itself may be indicative of a security vulnerability.</impact>\n\n\t<remediation>The administrator should configure a custom error page for production servers, with detailed error output being logged elsewhere.</remediation>\n\t<remediation>The nature of the error should be investigated.</remediation>\n\n\t<discussion>\n\t\tMany application servers can send verbose error output to clients, and some do this by default. This verbose error output can include stack traces and other detailed, sensitive information. This could be used by attackers to identify patchlevels, filesystem layout, configuration settings, or internal details about the application or database. Such output should never be sent to remote clients from production servers.</discussion>\n\n\t<references>\n\t\t<url address=\"https://www.owasp.org/index.php/Securing_tomcat\">Securing Tomcat (OWASP)</url>\n                <url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n                <url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">Information Leakage (WASC)</url>\n\t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-php.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>PHP Error Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Medium</severity>\t\t\n\t\n\t<impact>Vega has detected the signature of a PHP error page.</impact>\n\t<impact>Automatically generated error pages can leak sensitive information.</impact>\n\t<impact>The information leaked can include software patchlevels, configuration settings, and database or filesystem structure.</impact>\n\n\t<remediation>The PHP manual recommends disabling \"display_errors\" on servers exposed to the Internet. For PHP 5.2.4 and greater, the \"display_errors\" setting in the \"php.ini\" configuration file should be set to \"stderr\" (error output stream), rather than \"stdout\" (output stream sent to clients). For earlier versions, \"display_errors\" is a boolean type, and can be set to \"False\" for disabling. The setting can also be disabled at runtime using ini_set() from within a PHP script.</remediation>\n\n\t<references>\n\t\t<url address=\"http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors\">Turning off display-errors (php Manual)</url>\n\t</references>\n\n\t<discussion>Vega has detected signatures in scanned content that match common PHP error pages. These pages are automatically generated when an error occurs and can leak information useful in more sophisticated attacks. It is recommended that error output not be sent to the client on production systems.\n\t</discussion>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-errorpages-ruby.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Ruby on Rails Error Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Medium</severity>\t\t\n\t\n\t<impact>A Ruby on Rails error has been detected. This could indicate badly written code, and could disclose sensitive information.</impact>\n\n  <remediation>The developer should investigate the error to determine its nature and ensure that it does not represent a vulnerability.</remediation>\n  <remediation>Ensure that the application is running in a production environment.</remediation>\n\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-feeds.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>News Feed Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\t\t\n\t\n\t<impact>Vega has discovered an RSS-style news feed.</impact>\n\t<impact>This is a purely informational finding.</impact>\n\n\t<discussion>RSS (Really Simple Syndication) and related formats are methods for publishing regularly updated web content. RSS feeds are XML documents that are made available for client downloads and are often included with content managament systems, such as blogs.</discussion>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-format-string.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Format String Injection</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>High</severity>\n\n\t<discussion>\n    Vega has detected behavior indicative of a possible format string vulnerability. Format string vulnerabilities occur when untrustworthy input is used as or as part of the format string parameter passed to one of the printf() family of C library calls (and derivatives). Format string vulnerabilities can be used to overwrite memory, resulting in remote code execution.\n\t</discussion>\n\n  <impact>\n    If there is indeed a format string vulnerability present, the attacker could be able to overwrite memory of the target process.\n  </impact>\n  <impact>\n    Overwriting memory can allow for the execution of arbitrary code.\n  </impact>\n\n  <remediation>\n    The developer should investigate the code in question to determine if it is at all possible that a format string vulnerability could be present.\n  </remediation>\n  <remediation>\n    This can be fixed by ensuring that untrustworthy data is not passed to the printf() function.\n  </remediation>\n\n  <references>\n    <url address=\"http://en.wikipedia.org/wiki/Uncontrolled_format_string\">Uncontrolled format string (Wikipedia)</url>\n  </references>\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-header-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible HTTP Header Injection</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>Medium</severity>\n\n\t<impact>HTTP header injection vulnerabilities allow for attackers to forge request responses from servers.</impact>\n\t<impact>Attackers may be able to poison the caches of caching HTTP proxies.</impact>\n\n\t<remediation>Some languages/platforms offer some protection against this class of attacks. On versions of PHP4.4 and later, the header() function will only send one header at a time.</remediation>\n\t<remediation>If a safe function is not found, the externally supplied data used in header fields must have newlines sanitized before inclusion in the response header.</remediation>\n\n\t<discussion>\n\tHTTP Header injection vulnerabilities can occur when an application or server uses externally supplied input to construct the headers in the HTTP response. This can be a vulnerability in environments where multiple hosts are accessing HTTP servers through a proxy. Forged HTTP responses can be used to poison proxy caches.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/HTTP_header_injection\">HTTP Header Injection (Wikipedia)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/HTTP_Response_Splitting\">HTTP Response Splitting</url>\n\t\t<url address=\"https://www.owasp.org/index.php/HTTP_Request_Smuggling\">HTTP Request Smuggling</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-http-put.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible HTTP PUT File Upload</title>\n\t\n\t<class>Configuration</class>\n\t<severity>Medium</severity>\t\t\n\t\n\t<impact>Arbitrary file uploads could affect application or system integrity.</impact>\n\t<impact>This could occur if an attacker were to overwrite a resource pre-existing on the server.</impact>\n\t\n\t<remediation>\n\t\tThe server configuration settings should be reviewed to identify and disable the misconfiguration.\n\t</remediation>\n\t<remediation>\n\t\tApache allows for methods such as PUT and DELETE to be restricted using the LIMIT directive.\n\t</remediation>\n\t\t\n\t<discussion>\n\t\tThe HTTP PUT method was designed to allow HTTP clients to store resources on a HTTP server. In implementations, this has typically meant file upload capability. As the HTTP RFC states that a server should overwrite pre-existing resources located at the URI of a PUT request, a loss of system or application integrity could occur if such a request were made.\n\t</discussion>\n\t\n\t<references>\n\t\t<url address=\"http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html\">RFC 2616 - HTTP 1.1: Section 9 (IETF)</url>\n\t\t<url address=\"http://httpd.apache.org/docs/2.3/mod/core.html#limit\">Apache httpd Core Documentation: Limit Directive (Apache)</url>\n\t\t<url address=\"http://osvdb.org/show/osvdb/397\">OSVDB 397: Multiple Web Server Dangerous HTTP Method PUT (OSVDB)</url>\n\t</references>\n\t\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-http-trace.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>HTTP Trace Support Detected</title>\n\t\n\t<class>Configuration Error</class>\n\t<severity>Medium</severity>\n\n\t<impact>Allowing HTTP TRACE can permit cross-site tracing.</impact>\n\t<impact>Attackers may be able to use cross-site tracing with cross-site scripting retrieve the value of HttpOnly cookies.</impact>\n\n\t<remediation>For Apache based servers, the TraceEnable directive can be used to disable support for HTTP TRACE.</remediation>\n\t<remediation>For IIS based servers, the EnableTraceMethod registry setting controls support for HTTP TRACE..</remediation>\n\n\t<discussion>\n\t\tHTTP TRACE is an HTTP method that requests that the server echo the TRACE request back to the client. This includes headers that were sent along with the request. Support for HTTP TRACE can be abused in scenarios where a cross-site scripting vulnerability has been found, but cannot be exploited to retrieve cookie values because the target cookies are set with the HttpOnly flag. The HttpOnly flag instructs browsers not to permit access to the cookie by Javascript.\n\t\tIf a cross-site scripting vulnerability is found, but the session cookie is set HttpOnly, support for HTTP TRACE will open an oppportunity for cookie theft. An attacker can use the cross-site scripting vulnerability to have the target user's browser issue a TRACE request to the server via XMLHttpRequest (or a similar function) and then retrieve the cookie from the response, which will contain the request that was sent by the browser, including cookies.\n\t</discussion>\n\n\t<external>\n\t\t<url address=\"http://publib.boulder.ibm.com/httpserv/ihsdiag/http_trace.html\">IBM HTTP Server: Disabling the HTTP TRACE method</url>\n\t\t<url address=\"http://httpd.apache.org/docs/2.2/mod/core.html#traceenable\">Apache 2: TraceEnable Directive</url>\n                <url address=\"http://technet.microsoft.com/en-us/library/cc786149%28v=WS.10%29.aspx\">Windows Server 2012: WWW Service Registry Entries - EnableTraceMethod</url>\n\t\t<url address=\"http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d779ee4e-5cd1-4159-b098-66c10c5a3314.mspx?mfr=true\">W2K3 Server: WWW Service Registry Entries - Enable TraceMethod</url>\n\t</external>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Cross-site_tracing\">Wikipedia: Cross-site Tracing</url>\n\t\t<url address=\"http://www.kb.cert.org/vuls/id/867593\">CERT: Web servers enable HTTP TRACE method by default</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Cross_Site_Tracing\">OWASP: Cross Site Tracing</url>\n\t\t<url address=\"http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.8\">W3C: RFC 2616 - HTTP 1.1 - 9.8: TRACE</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-insecure-cors-ac.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Insecure Cross-Origin Resource Access Control </title>\n\n<class>Information</class>\n<severity>High</severity>\n<discussion>\nVega has detected that the resource has set an insecure Cross-Origin Resource Sharing (CORS) access control. CORS provides mechanisms that allow a server to restrict resource access for cross-site requests to certain trusted domains. The server in question has allowed resource from any origin by setting the value of the \"Access-Control-Allow-Origin\" response header to a wildcard value. This presents a security risk because any site can issue requests to access resources, regardless of origin.\n</discussion>\n        <remediation>\n          Set the \"Access-Control-Allow-Origin\" response header to allow access from trusted domains only. Do not allow access from arbitrary domains. \n        </remediation>\n        <references>\n                <url address=\"https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS\">HTTP access control (CORS)</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-integer-overflow.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Integer Overflow</title>\n\t\n\t<class>Boundary Condition Error</class>\n\t<severity>High</severity>\n\n\t<discussion>\n    Integer overflows occur when integer data types exceed their maximum value. When this occurs in programs written in languages such as C, the resulting behavior can have security implications. In these cases, unsigned integers will be reduced, wrapping back to a lower numeric value. The potential impact on security depends on how the integer value is used. If it is used as the size of a data buffer, forcing it to wrap to a lower value may result in bypassing of size checks, introducing possible buffer overflow conditions.\n\t</discussion>\n\n  <impact>\n    Integer overflow errors can have a variety of impacts, depending on the context and the purpose of the integer value.\n  </impact>\n  <impact>\n    Integers used to check the size of a data buffer, if reduced, can incorrectly represent the total amount of data, resulting in a possible buffer overflow.\n  </impact>\n\n  <remediation>\n    The developer should investigate the error and determine if a vulnerability is present.\n  </remediation>\n\n  <references>\n    <url address=\"https://www.owasp.org/index.php/Integer_overflow\">Integer overflow (OWASP)</url>\n    <url address=\"http://en.wikipedia.org/wiki/Integer_overflow\">Integer overflow (Wikipedia)</url>\n  </references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-lfi.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n\t<title>Local File Include</title>\n\t\n\t<class>Access Validation Error</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a local file include vulnerability.</impact>\n\t<impact>Local file include attacks may allow for unauthorized access to files on the local server, including files outside of the webroot.</impact>\n\t<impact>This could aid in an attacker obtaining unauthorized access to the server.</impact>\n\n\t<remediation>To prevent this type of vulnerability, the developer should canonicalize the path of any filesystem resource that has a path composed of externally-supplied input and then perform an authorization check prior to access.</remediation>\n\t<remediation>The realpath() library call will return the canonical path of the resource. It is implemented in PHP, Perl, and Python.</remediation>\n\t<remediation>For Ruby frameworks, File.expand_path can be used.</remediation>\n\t<remediation>GetFullPath() can be used on ASP.NET applications.</remediation>\n\t<remediation>getCanonicalPath() can be used in Java code.</remediation>\n\t<remediation>Additional protection against unauthorized access to filesystem resources can be obtained by using chroot() or similar mechanisms to limit filesystem access to the web application and http server process, although this can be difficult to manage.</remediation>\n\n\t<discussion>\n\tLocal file include is a type of vulnerability that occurs when the web application uses externally-supplied input to specify the location of a resource that it is requesting from the local filesystem. The vulnerability often manifests itself when malicious users embed path parts such as \"../\" (on UNIX systems) to refer to resources relative to a parent directory. This is commonly known as a \"directory traversal\" or \"path traversal\" vulnerability as the application uses the externally-supplied input to construct the path to the local filesystem resource. However, other variations exist that may allow an attacker to request the file by an absolute path or otherwise request files that were not intended to be exposed to users of the web application.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Directory_traversal\">Directory Traversal (Wikipedia)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Path_Traversal\">Path Traversal (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/File_System#Path_traversal\">Avoiding Path Traversal (OWASP)</url>\n\t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-metatags.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Interesting Meta Tags Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\t\t\n\n\t<remediation>The meta tags included in the content should be reviewed to ensure that there is nothing present that could aid an attacker.</remediation>\n\n\t<discussion>Vega has detected meta tags that may reveal sensitive information or warrant closer examination. These tags could include information such as platform or configuration characteristics. Interesting meta tags include those that contain: \"linux\", \"visual\", \"microsoft\". </discussion>\t\n\n\t<impact>Certain meta-tags, which may be intentionally or uninentionally included, may reveal information about the platform or configuration of the application.</impact>\n\t<impact>Information about the application unnecessarily revealed in page content may aid in the successful exploitation of more sophisticated attacks.</impact>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-missing-charset.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Character Set Not Specified </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has not specified a character set in the response. If the character set is not specified, the browser may make assumptions about the character set based on resource content. This may present a security concern if the affected resource contains dynamically-generated content that originates from users. In such a case, malicious users may potentially take advantage of how specific browsers interpret characters to cause malicious content to be rendered. For example, an attacker may be able to bypass a cross-site scripting filter by encoding their malicious payload in an alternate character set, which may be executed depending on how the browser interprets the encoded content.\n</discussion>\n        <remediation>\n          Specify a well-defined character set (such as UTF-8) within the response header content-type or the response body.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet\">OWASP Top Ten Cheat Sheet</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-mysql-error.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>MySQL Error Detected - Possible SQL Injection</title>\n\t\n\t<class>Error Message</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected known error output from a MySQL database server.</impact>\n\t<impact>This may indicate an SQL injection vulnerability, though this is not confirmed.</impact>\n\t<impact>If this is due to an SQL injection condition, exploitation of SQL injection vulnerabilities can also allow for attacks against the logic of the application.</impact>\n\t<impact>Attackers may be able to obtain unauthorized access to the server hosting the database.</impact>\n\n\t<discussion>\n\t\tVega has detected a SQL error string known to be output by MySQL. This can indicate a possible SQL injection vulnerability. These vulnerabilities are present when externally-supplied input is used to construct a SQL query. If precautions are not taken, the externally-supplied input (usually a GET or POST parameter) can modify the query string such that it performs unintented actions. These actions include gaining unauthorized read or write access to the data stored in the database, as well as modifying the logic of the application. \n\t</discussion>\n\n\n        <remediation>\n                SQL error messages should not be output to clients, as this may be useful information in exploiting any related vulnerability.\n        </remediation>\n  \t<remediation>\n\t\tThe developer should review the request and response against the code to manually verify whether or not a vulnerability is present.\n  \t</remediation>\n  \t<remediation>\n\t\tThe best defense against SQL injection vulnerabilities is to use parameterized statements.\n  \t</remediation>\n  \t<remediation>\n\t\tSanitizing input can prevent these vulnerabilities. Variables of string types should be filtered for escape characters, and numeric types should be checked to ensure that they are valid.\n  \t</remediation>\n  \t<remediation>\n\t\tUse of stored procedures can simplify complex queries and allow for tighter access control settings.\n  \t</remediation>\n  \t<remediation>\n\t\tConfiguring database access controls can limit the impact of exploited vulnerabilities. This is a mitigating strategy that can be employed in environments where the code is not modifiable.\n  \t</remediation>\n  \t<remediation>\n\t\tObject-relational mapping eliminates the need for SQL.\n  \t</remediation>\n\n  \t<references>\n\t\t<url address=\"http://cwe.mitre.org/data/definitions/209.html\">CWE-209: Information Exposure Through an Error Message</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/SQL_injection\">SQL Injection (Wikipedia)</url>\n\t\t<url address=\"http://php.net/manual/en/function.mysql-real-escape-string.php\"> mysql_real_escape_string() (PHP Manual)</url>\n\t\t<url address=\"http://guides.rubyonrails.org/security.html#sql-injection\">SQL Injection (Rails security guide)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet\">SQL Injection Prevention Cheat Sheet (OWASP)</url>\n  \t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-oracle.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Oracle Application Server Fingerprint</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\n\n\t<discussion>\n        Vega has detected that this resource is tagged with a string indicating that it may have been created by Oracle Application Server.\n\t</discussion>\n\n  <impact>\n    This resource contains a fingerprint that identifies the underlying platform to attackers.  This knowledge may make other attacks more reliable.\n  </impact>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-paths.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Local Filesystem Paths Found</title>\n\t\n\t<class>Information</class>\n\t<severity>Medium</severity>\n\n\t<impact>Vega has detected what may be absolute filesystem paths in scanned content.</impact>\n\t<impact>Disclosure of these paths reveals information about the filesystem layout.</impact>\n\t<impact>This information can be sensitive, its disclosure can increase the chances of success for other attacks.</impact>\n\n\t<remediation>Absolute paths are often found in error output.</remediation>\n\t<remediation>Both the system administrators and developers should be made aware, as the problem may be due to an application error or server misconfiguration.</remediation>\n\t<remediation>Error output containing sensitive information such as absolute system paths should not be sent to remote clients on production servers.</remediation>\n\t<remediation>This output should be sent to another output stream, such as an error log.</remediation>\n\n\n\t<discussion>\n\tVega has detected a possible absolute filesystem path (i.e. one that is not relative to the web root). This information is sensitive, as it may reveal things about the server environment to an attacker. Knowing filesystem layout can increase the chances of success for blind attacks. Full system paths are very often found in error output. This output should never be sent to clients on production systems. It should be redirected to another output channel (such as an error log) for analysis by developers and system administrators.\n\t</discussion>\n\t\n\t<references>\n\t\t<url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n\t</references>\t\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-rfi.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n\t<title>Remote File Include</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>High</severity>\n\n\t<impact>Possibility of server-side code execution if code from remote server is run.</impact>\n        <impact>Compromise of user sessions or data.</impact>\n        <impact>Phishing, social engineering.</impact>\n\n\t<remediation>The developer should investigate the reason why the server is fetching remote content and embedding it in the page.</remediation>\n        <remediation>In particular, the feasibility of server-side code execution should be determined.</remediation>\n\n\t<discussion>\n\tVega has determined that content from a client-specified location is being retrieved by the server and output. In some circumstances, code included in this content will be executed by the server. If this is possible, an attacker may be able to gain unauthorized access to the server. Minimally, the inclusion of content originating on a third-party server introduces the possibility of phishing or social engineering attacks.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Remote_file_inclusion\">Remote File Inclusion (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-securecookie-insecurechannel.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Secure Cookie Set Over Insecure Channel </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that this cookie was sent over an insecure channel when the Secure flag was set. This may allow eavesdroppers to observe the cookie while it is initially transmitted to the browser.\n</discussion>\n        <remediation>\n          When setting cookies with the Secure flag, ensure they are sent to the browser over HTTPS.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/SecureFlag\">SecureFlag OWASP Reference</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-sessioncookie-httponly.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Session Cookie Without HttpOnly Flag </title>\n\n<class>Information</class>\n<severity>High</severity>\n<discussion>\nVega has detected that a session cookie may have been set without the HttpOnly flag. When this flag is not present, it is possible to access the cookie via client-side script code. The HttpOnly flag is a security measure that can help mitigate the risk of cross-site scripting attacks that target session cookies of the victim. If the HttpOnly flag is set and the browser supports this feature, attacker-supplied script code will not be able to access the cookie.\n</discussion>\n        <remediation>\n          When creating the cookie in the code, set the HttpOnly flag to true.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/HttpOnly\">HttpOnly OWASP Reference</url>\n        </references>\n</alert>\n\n\n"
  },
  {
    "path": "xml/alerts/vinfo-sessioncookie-secure.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Session Cookie Without Secure Flag </title>\n\n<class>Information</class>\n<severity>High</severity>\n<discussion>\nVega has detected that a known session cookie may have been set without the secure flag.\n</discussion>\n        <impact>Cookies can be exposed to network eavesdroppers.</impact>\n        <impact>Session cookies are authentication credentials; attackers who obtain them can get unauthorized access to affected web applications.</impact>\n\n        <remediation>\n          When creating the cookie in the code, set the secure flag to true.\n        </remediation>\n\n        <references>\n                <url address=\"https://www.owasp.org/index.php/SecureFlag\">Secure Flag</url>\n                <url address=\"https://www.owasp.org/index.php/HttpOnly\">HttpOnly OWASP Reference</url>\n        </references>\n\n</alert>\n\n\n"
  },
  {
    "path": "xml/alerts/vinfo-shell-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Shell Injection</title>\n\t\n\t<class>Information</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a possible command injection vulnerability.</impact>\n\t<impact>Attackers may be able to run commands on the server.</impact>\n\t<impact>Exploitation may lead to unauthorized remote access.</impact>\n\n\t<remediation>Developers should examine the code corresponding to the page in detail to determine if the vulnerability exists.</remediation>\n\t<remediation>Execution of system commands through a command interpreter, such as with system(), should be avoided.</remediation>\n\t<remediation>If absolutely necessary, the developer should take extra care with validating the input before it is passed to the interpreter.</remediation>\n\n\t<discussion>Command injection vulnerabilities often occur when inadequately sanitized externally supplied data is as part of a system command executed through a command interpreter, or shell. Vulnerabilities such as these can be exploited by using shell metacharacters to run additional commands that were not intended to be executed by the application developer. The system() function, and derivatives, are often responsible, as these functions are very simple to use. These vulnerabilities can grant remote access to attackers, if exploited successfully.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"https://www.owasp.org/index.php/Command_Injection\">Command Injection (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/Reviewing_Code_for_OS_Injection\">Reviewing Code for OS Injection (OWASP)</url>\n                <url address=\"http://en.wikipedia.org/wiki/Code_injection#Shell_injection\">Shell Injection (Wikipedia)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-source.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible Source Code Disclosure</title>\n\t\n  <class>Information</class>\n\n  <severity>Medium</severity>\n\n  <impact>Could result in disclosure of sensitive information to attackers.</impact>\n  <impact>Source code fragments can include information about the design/structure of the application, including use of third-party components.</impact>\n  <impact>This information may not otherwise be easily known by an adversary.</impact>\n  <impact>Sometimes source code also contains highly sensitive information, such as passwords (database connection strings).</impact>\n\n  <remediation>The developer should verify that the output detected by Vega is in fact application source code.</remediation>\n  <remediation>The cause should be determined, and the material removed or prevented from being output.</remediation>\n\n  <discussion>\n    Vega has detected fragments of text that match signatures of application source code. Application source code unintentedly visible to remote clients can be a security vulnerability. This can occur in applications using technologies such as PHP and JSP, which allow for code to be mixed with static presentation content. For example, in-line code is sometimes commented using HTML comments, resulting in it being transmitted to remote clients. For an attacker, source code can reveal information about the nature of the application, such as its design or the use of third-party components. Sometimes sensitive information, such as a database connection string, can be included in source code.\n  </discussion>\n\n  <references>\n    <url address=\"https://www.owasp.org/index.php/Information_Leakage\">Information Leakage (OWASP)</url>\n    <url address=\"http://cwe.mitre.org/data/definitions/540.html\">CWE-540: Information Exposure through Source Code (Mitre)</url>\n    <url address=\"http://projects.webappsec.org/w/page/13246936/Information-Leakage\">Information Leakage (WASC)</url>\n  </references>\n\n\t\n\t\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-sql-error.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>SQL Error Detected - Possible SQL Injection</title>\n\t\n\t<class>Error Message</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected error output from a database server.</impact>\n\t<impact>This may indicate an SQL injection vulnerability, though this is not confirmed.</impact>\n\t<impact>If this is due to an SQL injection condition, exploitation of SQL injection vulnerabilities can also allow for attacks against the logic of the application.</impact>\n\t<impact>Attackers may be able to obtain unauthorized access to the server hosting the database.</impact>\n\n\t<discussion>\n\t\tVega has detected a known SQL error string. This can indicate a possible SQL injection vulnerability. These vulnerabilities are present when externally-supplied input is used to construct a SQL query. If precautions are not taken, the externally-supplied input (usually a GET or POST parameter) can modify the query string such that it performs unintented actions. These actions include gaining unauthorized read or write access to the data stored in the database, as well as modifying the logic of the application. \n\t</discussion>\n\n\n        <remediation>\n                SQL error messages should not be output to clients, as this may be useful information in exploiting any related vulnerability.\n        </remediation>\n  \t<remediation>\n\t\tThe developer should review the request and response against the code to manually verify whether or not a vulnerability is present.\n  \t</remediation>\n  \t<remediation>\n\t\tThe best defense against SQL injection vulnerabilities is to use parameterized statements.\n  \t</remediation>\n  \t<remediation>\n\t\tSanitizing input can prevent these vulnerabilities. Variables of string types should be filtered for escape characters, and numeric types should be checked to ensure that they are valid.\n  \t</remediation>\n  \t<remediation>\n\t\tUse of stored procedures can simplify complex queries and allow for tighter access control settings.\n  \t</remediation>\n  \t<remediation>\n\t\tConfiguring database access controls can limit the impact of exploited vulnerabilities. This is a mitigating strategy that can be employed in environments where the code is not modifiable.\n  \t</remediation>\n  \t<remediation>\n\t\tObject-relational mapping eliminates the need for SQL.\n  \t</remediation>\n\n  \t<references>\n\t\t<url address=\"http://cwe.mitre.org/data/definitions/209.html\">CWE-209: Information Exposure Through an Error Message</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/SQL_injection\">SQL Injection (Wikipedia)</url>\n\t\t<url address=\"http://php.net/manual/en/function.mysql-real-escape-string.php\"> mysql_real_escape_string() (PHP Manual)</url>\n\t\t<url address=\"http://guides.rubyonrails.org/security.html#sql-injection\">SQL Injection (Rails security guide)</url>\n\t\t<url address=\"http://msdn.microsoft.com/en-us/library/ff648339.aspx\">How To: Protect from SQL Injection in ASP.NET (MSDN)</url>\n\t\t<url address=\"http://blogs.msdn.com/b/raulga/archive/2007/01/04/dynamic-sql-sql-injection.aspx\">Dynamic SQL and SQL Injection (Raul Garcia's blog)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet\">SQL Injection Prevention Cheat Sheet (OWASP)</url>\n  \t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-sql-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>SQL Injection</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a possible SQL injection vulnerability.</impact>\n\t<impact>These vulnerabilities can be exploited by remote attackers to gain unauthorized read or write access to the underlying database.</impact>\n\t<impact>Exploitation of SQL injection vulnerabilities can also allow for attacks against the logic of the application.</impact>\n\t<impact>Attackers may be able to obtain unauthorized access to the server hosting the database.</impact>\n\n\t<discussion>\n\t\tVega has detected a possible SQL injection vulnerability. These vulnerabilities are present when externally-supplied input is used to construct a SQL query. If precautions are not taken, the externally-supplied input (usually a GET or POST parameter) can modify the query string such that it performs unintented actions. These actions include gaining unauthorized read or write access to the data stored in the database, as well as modifying the logic of the application. \n\t</discussion>\n\n\n  \t<remediation>\n\t\tThe developer should review the request and response against the code to manually verify whether or not a vulnerability is present.\n  \t</remediation>\n  \t<remediation>\n\t\tThe best defense against SQL injection vulnerabilities is to use parameterized statements.\n  \t</remediation>\n  \t<remediation>\n\t\tSanitizing input can prevent these vulnerabilities. Variables of string types should be filtered for escape characters, and numeric types should be checked to ensure that they are valid.\n  \t</remediation>\n  \t<remediation>\n\t\tUse of stored procedures can simplify complex queries and allow for tighter access control settings.\n  \t</remediation>\n  \t<remediation>\n\t\tConfiguring database access controls can limit the impact of exploited vulnerabilities. This is a mitigating strategy that can be employed in environments where the code is not modifiable.\n  \t</remediation>\n  \t<remediation>\n\t\tObject-relational mapping eliminates the need for SQL.\n  \t</remediation>\n\n  \t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/SQL_injection\">SQL Injection (Wikipedia)</url>\n\t\t<url address=\"http://php.net/manual/en/function.mysql-real-escape-string.php\"> mysql_real_escape_string() (PHP Manual)</url>\n\t\t<url address=\"http://guides.rubyonrails.org/security.html#sql-injection\">SQL Injection (Rails security guide)</url>\n\t\t<url address=\"http://msdn.microsoft.com/en-us/library/ff648339.aspx\">How To: Protect from SQL Injection in ASP.NET (MSDN)</url>\n\t\t<url address=\"http://blogs.msdn.com/b/raulga/archive/2007/01/04/dynamic-sql-sql-injection.aspx\">Dynamic SQL and SQL Injection (Raul Garcia's blog)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet\">SQL Injection Prevention Cheat Sheet (OWASP)</url>\n  \t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-sqlserver-error.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>SQLServer Error Detected - Possible SQL Injection</title>\n\t\n\t<class>Error Message</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected error output from an SQL Server database server.</impact>\n\t<impact>This may indicate an SQL injection vulnerability, though this is not confirmed.</impact>\n\t<impact>If this is due to an SQL injection condition, exploitation of SQL injection vulnerabilities can also allow for attacks against the logic of the application.</impact>\n\t<impact>Attackers may be able to obtain unauthorized access to the server hosting the database.</impact>\n\n\t<discussion>\n\t\tVega has detected an SQL error string known to be output by SQL Server. This can indicate a possible SQL injection vulnerability. These vulnerabilities are present when externally-supplied input is used to construct a SQL query. If precautions are not taken, the externally-supplied input (usually a GET or POST parameter) can modify the query string such that it performs unintented actions. These actions include gaining unauthorized read or write access to the data stored in the database, as well as modifying the logic of the application. \n\t</discussion>\n\n\n        <remediation>\n                SQL error messages should not be output to clients, as this may be useful information in exploiting any related vulnerability.\n        </remediation>\n  \t<remediation>\n\t\tThe developer should review the request and response against the code to manually verify whether or not a vulnerability is present.\n  \t</remediation>\n  \t<remediation>\n\t\tThe best defense against SQL injection vulnerabilities is to use parameterized statements.\n  \t</remediation>\n  \t<remediation>\n\t\tSanitizing input can prevent these vulnerabilities. Variables of string types should be filtered for escape characters, and numeric types should be checked to ensure that they are valid.\n  \t</remediation>\n  \t<remediation>\n\t\tUse of stored procedures can simplify complex queries and allow for tighter access control settings.\n  \t</remediation>\n  \t<remediation>\n\t\tConfiguring database access controls can limit the impact of exploited vulnerabilities. This is a mitigating strategy that can be employed in environments where the code is not modifiable.\n  \t</remediation>\n  \t<remediation>\n\t\tObject-relational mapping eliminates the need for SQL.\n  \t</remediation>\n\n  \t<references>\n\t\t<url address=\"http://cwe.mitre.org/data/definitions/209.html\">CWE-209: Information Exposure Through an Error Message</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/SQL_injection\">SQL Injection (Wikipedia)</url>\n\t\t<url address=\"http://guides.rubyonrails.org/security.html#sql-injection\">SQL Injection (Rails security guide)</url>\n\t\t<url address=\"http://msdn.microsoft.com/en-us/library/ff648339.aspx\">How To: Protect from SQL Injection in ASP.NET (MSDN)</url>\n\t\t<url address=\"http://blogs.msdn.com/b/raulga/archive/2007/01/04/dynamic-sql-sql-injection.aspx\">Dynamic SQL and SQL Injection (Raul Garcia's blog)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet\">SQL Injection Prevention Cheat Sheet (OWASP)</url>\n  \t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-unsafe-charset-body.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Unsafe Or Unrecognized Character Set In Response Body </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has specified an unsafe or unrecognized character set in the response body. This may cause unpredictable behavior depending on how the browser interprets the character set. This may present a security concern if the affected resource contains dynamically-generated content that originates from users. In such a case, malicious users may potentially take advantage of how specific browsers interpret characters to cause malicious content to be rendered. For example, an attacker may be able to bypass a cross-site scripting filter by encoding their malicious payload in an alternate character set, which may be executed depending on how the browser interprets the encoded content.\n</discussion>\n        <remediation>\n          Specify a well-defined character set (such as UTF-8) within the response header content-type or the response body.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet\">OWASP Top Ten Cheat Sheet</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-unsafe-charset-header.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Unsafe Or Unrecognized Character Set In Response Header </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has specified an unsafe or unrecognized character set in the response header. This may cause unpredictable behavior depending on how the browser interprets the character set. This may present a security concern if the affected resource contains dynamically-generated content that originates from users. In such a case, malicious users may potentially take advantage of how specific browsers interpret characters to cause malicious content to be rendered. For example, an attacker may be able to bypass a cross-site scripting filter by encoding their malicious payload in an alternate character set, which may be executed depending on how the browser interprets the encoded content.\n</discussion>\n        <remediation>\n          Specify a well-defined character set (such as UTF-8) within the response header content-type or the response body.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet\">OWASP Top Ten Cheat Sheet</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-url-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>URL Injection</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>Medium</severity>\n\n\t<impact>An externally supplied link has been used as an attribute (e.g. src, href, value) in a HTML tag.</impact>\n\t<impact>This can have have a variety of possible consequences, from benign, to serious, depending on the tag.</impact>\n\t<impact>Impacts can include automatic client fetching of remote malicious content.</impact>\n\t<impact>These could be used for phishing or, possibly, cross-domain attacks.</impact>\n\n\t<remediation>The developer should examine the tag and determine the possible security implications of the use of a remotely supplied URI.</remediation>\n\n\t<discussion>\n\tVega has determined that a HTML tag in the target page has an attribute (such as src, href, or value) that is a URI supplied by the scanner. There are a variety of security implications, depending on the tag. The most serious consequences include phishing attacks or possible cross-domain risks that can occur if the browser of the target user automatically fetches malicious content from these links. \n\t</discussion>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-wsdl.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>WSDL Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\t\t\n\t\n\t<impact>Vega has detected a possible WSDL definition.</impact>\n\t<impact>This may mean that there are web services interfaces that are worth further investigation.</impact>\n\t<impact>This finding does not constitute a vulnerability.</impact>\n\n\t<remediation>This is a purely informational finding.</remediation>\n\n\t<discussion>WSDL (Web Services Description Language) is an XML document that describes web services. The description includes the connection details and available operations. Web services clients can interpret the WSDL to understand the available services and how to use them. A WSDL is of interest because it may expose web service operations where vulnerabilities can be present. In some environments, the WSDL definition itself may constitute an unacceptable exposure.\n\t</discussion>\n\t\n\t<references>\n\t\t<url address=\"http://cwe.mitre.org/data/definitions/651.html\">CWE-651: Information Exposure through WSDL</url>\n\t\t<url address=\"http://www.w3.org/TR/wsdl\">WSDL (W3C)</url>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Web_Services_Description_Language\">Web Services Description Language</url>\n\t</references>\n\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-xframeoptions.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>X-Frame-Options Header Not Set </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has not set the X-Frame-Options HTTP response header. This header allows the resource to specify its policy with regards to whether it may be included in frames in other domains as well as which domains are allowed. When the header has been set, this may help to mitigate clickjacking attacks against browsers that support this feature. If the header has not been set, the affected resource may be used in clickjacking attacks.\n</discussion>\n        <remediation>\n          Set the X-Frame-Options header to DENY, SAMEORIGIN, or ALLOW-FROM according to policy.\n        </remediation>\n        <references>\n                <url address=\"https://www.owasp.org/index.php/Clickjacking\">OWASP Clickjacking</url>\n                <url address=\"https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet\">OWASP Clickjacking Defense Cheat Sheet</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-xml-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible XML Injection</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>Medium</severity>\n\n\t<impact>Vega has detected that it may be possible to corrupt the structure of a server-side XML document.</impact>\n\t<impact>This could affect the logic of the application, depending on how the XML document is used.</impact>\n\t<impact>An XML injection vulnerability can lead to a loss of integrity of the data used or stored by the application.</impact>\n\t<impact>XML may be an injection vector that bypasses content filters (e.g. including javascript in a CDATA section).</impact>\n\n\t<discussion>\n\tVega has detected a possible XML injection vulnerability. XML injection can occur when externally supplied data that has not been sufficiently validated is used to create an XML document. It is possible for this data to corrupt the structure of the documents. The possible consequences depend on the XML document and what it is used for.\n\t</discussion>\n\n  \t<remediation>\n\tDevelopers should investigate the code to manually verify that an XML injection vulnerability does exist.\t\n  \t</remediation>\n\t<remediation>\n\tCharacters that can be interpreted as XML should be filtered. \t\n\t</remediation>\n\n  <references>\n    <url address=\"https://www.owasp.org/index.php/Interpreter_Injection#XML_Injection\">XML Injection (OWASP)</url>\n    <url address=\"https://www.owasp.org/index.php/Testing_for_XML_Injection\">Testing for XML Injection (OWASP)</url>\n    <url address=\"http://projects.webappsec.org/w/page/13247004/XML-Injection\">XML Injection (WASC)</url>\n  </references>\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-xss-filter-disabled.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Internet Explorer Cross-site Scripting Filter Disabled </title>\n\n<class>Information</class>\n<severity>Info</severity>\n<discussion>\nVega has detected that the resource has disabled the Internet Explorer cross-site scripting filter. The cross-site scripting filter is a security feature in Internet Explorer 8 and later that is intended to mitigate some categories cross-site scripting attacks. It is enabled by default in supported versions of Internet Explorer but servers may disable the filter via the \"X-XSS-Protection\" response header. Disabling the filter presents a risk to users of browsers that support this feature as the filter will no longer protect them from certain cross-site scripting vulnerabilities in the website that has disabled the filter.\n</discussion>\n        <remediation>\n          Do not disable the cross-site scripting filter. If possible, proactively enable the filter by setting the following response header:\n          \"X-XSS-Protection: 1; mode=block\"\n        </remediation>\n        <references>\n                <url address=\"http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx\">Controlling the XSS Filter</url>\n        </references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vinfo-xss-inject.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Cross Site Scripting</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>High</severity>\n\n\t<impact>The precise impact depends greatly on the application.</impact>\n\t<impact>XSS is generally a threat to web applications which have authenticated users or are otherwise security sensitive.</impact>\n\t<impact>Malicious code may be able to manipulate the content of the site, changing its appearance and/or function for another user.</impact>\n\t<impact>This includes modifying the behavior of the web application (such as redirecting forms, etc).</impact>\n\t<impact>The code may also be able to perform actions within the application without user knowledge.</impact>\n\t<impact>Script code can also obtain and retransmit cookie values if they haven't been set HttpOnly.</impact>\n\n\t<remediation>The developer must identify how the untrustworthy data is being output to the client without adequate filtering.</remediation>\n\t<remediation>There are various language/platform specific techniques for filtering untrustworthy data.</remediation>\n\t<remediation>General rules for preventing XSS can be found in the recommended OWASP XSS Prevention Cheat Sheet (see references).</remediation>\t\n\n\t<discussion>Cross-site scripting (XSS) is a class of vulnerabilities affecting web applications that can result in security controls implemented in browsers being circumvented. When a browser visits a page on a website, script code originating in the website domain can access and manipulate the DOM (document object model), a representation of the page and its properties in the browser. Script code from another website can not. This is known as the \"same origin policy\", a critical control in the browser security model. Cross-site scripting vulnerabilities occur when a lack of input validation permits users to inject script code into the target website such that it runs in the browser of another user who is visiting the same website. This would circumvent the browser same-origin policy because the browser has no way to distinguish authentic script code from inauthentic, apart from its origin.</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Cross-site_scripting\">Cross-Site Scripting (Wikipedia)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/XSS\">Cross-Site Scripting (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet\">XSS Prevention Cheat Sheet</url>\n\t\t<url address=\"http://projects.webappsec.org/w/page/13246920/Cross-Site-Scripting\">Cross-Site Scripting (WASC)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vinfo-xss-stored.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Stored Cross Site Scripting</title>\n\t\n\t<class>Input Validation Error</class>\n\t<severity>High</severity>\n\n\t<impact>The precise impact depends greatly on the application.</impact>\n\t<impact>XSS is generally a threat to web applications which have authenticated users or are otherwise security sensitive.</impact>\n\t<impact>Malicious code may be able to manipulate the content of the site, changing its appearance and/or function for another user.</impact>\n\t<impact>This includes modifying the behavior of the web application (such as redirecting forms, etc).</impact>\n\t<impact>The code may also be able to perform actions within the application without user knowledge.</impact>\n\t<impact>Script code can also obtain and retransmit cookie values if they haven't been set HttpOnly.</impact>\n\n\t<remediation>The developer must identify how the untrustworthy data is being output to the client without adequate filtering.</remediation>\n\t<remediation>There are various language/platform specific techniques for filtering untrustworthy data.</remediation>\n\t<remediation>General rules for preventing XSS can be found in the recommended OWASP XSS Prevention Cheat Sheet (see references).</remediation>\t\n\n\t<discussion>Cross-site scripting (XSS) is a class of vulnerabilities affecting web applications that can result in security controls implemented in browsers being circumvented. When a browser visits a page on a website, script code originating in the website domain can access and manipulate the DOM (document object model), a representation of the page and its properties in the browser. Script code from another website can not. This is known as the \"same origin policy\", a critical control in the browser security model. Cross-site scripting vulnerabilities occur when a lack of input validation permits users to inject script code into the target website such that it runs in the browser of another user who is visiting the same website. This would circumvent the browser same-origin policy because the browser has no way to distinguish authentic script code from inauthentic, apart from its origin.</discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Cross-site_scripting\">Cross-Site Scripting (Wikipedia)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/XSS\">Cross-Site Scripting (OWASP)</url>\n\t\t<url address=\"https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet\">XSS Prevention Cheat Sheet</url>\n\t\t<url address=\"http://projects.webappsec.org/w/page/13246920/Cross-Site-Scripting\">Cross-Site Scripting (WASC)</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vpii-cc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible Credit Card Data Detected</title>\n\t\n\t<class>Personally Identifiable Information (PII)</class>\n\t<severity>High</severity>\n\n\t<impact>Vega has detected a string of digits that have some of the properties of credit card numbers.</impact>\n        <impact>Unauthorized disclosure of this information could lead to fraud, or identity theft.</impact>\n        <impact>Unauthorized disclosure could also lead to regulatory penalties.</impact>\n\n\t<remediation>This should be investigated to identify the nature of the data matching the detection pattern. The root cause of a disclosure could be test data, a flat file database, or the triggering of some unexpected vulnerability. </remediation>\n\n\t<discussion>Vega has detected a string of digits that have similar characteristics to credit card numbers. This should be reviewed carefully (which can be done by examining the server response). </discussion>\n\n\t<references>\n\t\t<url address=\"http://www.merriampark.com/anatomycc.htm\">Anatomy of a Credit Card Number</url>\n\t</references>\n\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/vpii-ssnsin-sin.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible Social Insurance Number Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>High</severity>\t\t\n\n        <impact>Unauthorized disclosure of this information could lead to fraud, or identity theft.</impact>\n        <impact>Unauthorized disclosure could also lead to regulatory penalties.</impact>\n\n        <remediation>This should be investigated to identify the nature of the data matching the detection pattern. The root cause of a disclosure could be test data, a flat file database, or the triggering of some unexpected vulnerability. </remediation>\n\n        <discussion>Vega has detected a numerical pattern matching the structure of a social insurance number in scanned content. This could be a false positive against a pattern with the same characteristics. </discussion>\n\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Social_Insurance_Number\">Social Insurance Number (Wikipedia)</url>\n\t</references>\t\n</alert>\n"
  },
  {
    "path": "xml/alerts/vpii-ssnsin-ssn.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Possible Social Security Number Detected</title>\n\t\n\t<class>Information</class>\n\t<severity>High</severity>\t\t\n\t\n\t<impact>Unauthorized disclosure of this information could lead to fraud, or identity theft.</impact>\n\t<impact>Unauthorized disclosure could also lead to regulatory penalties.</impact>\n\n\t<remediation>This should be investigated to identify the nature of the data matching the detection pattern. The root cause of a disclosure could be test data, a flat file database, or the triggering of some unexpected vulnerability. </remediation>\n\n\t<discussion>Vega has detected a numerical pattern matching the structure of a social security number in scanned content. This could be a false positive against a pattern with the same characteristics.</discussion>\n\t\n\t<references>\n\t\t<url address=\"http://en.wikipedia.org/wiki/Social_Security_number\">Social Security Number (Wikipedia)</url>\n\t</references>\n</alert>\n"
  },
  {
    "path": "xml/alerts/vvcs-users.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Version Control String Found</title>\n\t\n\t<class>Information</class>\n\t<severity>Info</severity>\n\t<impact>Vega has detected a version control string in scanned content.</impact>\n\t<impact>These strings can contain developer usernames or reveal other sensitive information about the application.</impact>\n\t<impact>This information can be used to help make brute-force or other attacks more likely to succeed.</impact>\n\n\t<remediation>Developers should ensure that this information is not included in content that is deployed on production servers. These strings should be also removed from third-party static content if left there by the developer, as it unnecessarily aids application or patchlevel fingerprinting.</remediation>\n\n\t<discussion>\n\tVersion control systems (VCSs) are tools for tracking changes to files over time. Some of these systems tag each file with a string indicating the current revision, the username, the last change, and a timestamp. This information may be sensitive and care should be taken that it not be inadvertently exposed on production servers exposed to potentially hostile clients.\n\t</discussion>\n\t\n\t\n</alert>\n\n"
  },
  {
    "path": "xml/alerts/xs-script-include.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<alert>\n<title>Cross-Site Script Include</title>\n\t\n\t<class>Environment</class>\n\n\t<severity>High</severity>\n\n\t<impact>Vega has detected that script code is being included from an unrelated domain.</impact>\n\t<impact>This gives the operator of the server where the code originates control over the DOM, and the web application .</impact>\n        <impact>Even if the source is trusted, there are implications if the website hosting the script code is ever compromised. </impact>\n\n\t<remediation>\n\t\tServers should host their own Javascript, especially for critical applications.\n\t</remediation>\n\n\t<discussion>\n\t\tVega detected that content on a server is including Javascript content from an unrelated domain. When this script code is fetched by a user browser and loaded into the DOM, it will have complete control over the DOM, bypassing the protection offered by the same-origin policy. Even if the source of the script code is trusted by the website operator,  malicious code could be introduced if the server is ever compromised. It is strongly recommended that sensitive applications host all included Javascript locally.\n\t</discussion>\n\n\t<references>\n\t\t<url address=\"http://www.subgraph.com/kb/websecurity/https\">Wikipedia: Same-Origin Policy</url>\n\t</references>\n\n</alert>\n\n"
  }
]