summaryrefslogtreecommitdiffstats
path: root/Master/Agile Software Development/TestApp/src/testapp
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Agile Software Development/TestApp/src/testapp
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Agile Software Development/TestApp/src/testapp')
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/App.java60
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/AppFrame.java172
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/DOTGenerator.java54
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/GraphGenerator.java81
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/ImageComponent.java46
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/ItemGenerator.java92
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/Locate.java90
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ExternalCssItem.java58
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ExternalJavascriptItem.java56
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/FrameItem.java51
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/GraphConstants.java44
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/IframeItem.java51
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ImageItem.java102
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/Item.java413
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ItemClassification.java14
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ItemPlace.java14
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ItemType.java14
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/LinkItem.java50
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/PageItem.java48
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/ScriptItem.java62
-rw-r--r--Master/Agile Software Development/TestApp/src/testapp/data/StyleItem.java47
21 files changed, 1619 insertions, 0 deletions
diff --git a/Master/Agile Software Development/TestApp/src/testapp/App.java b/Master/Agile Software Development/TestApp/src/testapp/App.java
new file mode 100644
index 0000000..d0e1a55
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/App.java
@@ -0,0 +1,60 @@
+/*
+ * Main
+ */
+
+package testapp;
+
+import java.io.IOException;
+import javax.swing.JFrame;
+import javax.swing.UIManager;
+import java.util.logging.*;
+
+/**
+ *
+ * @author eisenhauer
+ */
+public class App {
+
+ private static App theInstance = null;
+ private JFrame mainFrame = null;
+ private String appPath = "";
+ private App() {
+ try {
+ this.appPath = Locate.getClassLocation(this.getClass()).getParent();
+ // to run from Netbeans
+ if (appPath.contains("build")) {
+ appPath = appPath.replace("build", "dist");
+ }
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ public static App getInstance() {
+ if (theInstance == null) {
+ theInstance = new App();
+ }
+ return theInstance;
+ }
+ private void startApplication() {
+ // Setup Look and Feel
+ try {
+ //UIManager.setLookAndFeel(new com.jgoodies.looks.windows.WindowsLookAndFeel());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ mainFrame = new AppFrame("Webspinne");
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+ public String getAppPath() {
+ return appPath;
+ }
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ App.getInstance().startApplication();
+ }
+
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/AppFrame.java b/Master/Agile Software Development/TestApp/src/testapp/AppFrame.java
new file mode 100644
index 0000000..ab025c4
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/AppFrame.java
@@ -0,0 +1,172 @@
+/*
+ * GUI
+ */
+package testapp;
+
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import java.util.logging.*;
+import javax.swing.JProgressBar;
+
+/**
+ *
+ * @author eisenhauer
+ */
+public class AppFrame extends JFrame {
+
+ private static final Logger logger = Logger.getLogger(AppFrame.class.getName());
+
+ private JPanel taskPanel;
+ private JTextField urlTxf;
+ private JButton loadBtn;
+ private ImageComponent imgComp;
+ private JScrollPane imgScroll;
+ private static AppFrame theInstance = null;
+ private JPanel progressPanel;
+
+ public AppFrame(String title) {
+ super(title);
+ theInstance = this;
+ initUI();
+
+
+ }
+
+ public static AppFrame getInstance() {
+ return theInstance;
+ }
+
+ private void initUI() {
+ this.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ if (imgComp != null) {
+ if (imgComp.getFile() != null) {
+ // TODO
+ //imgComp.getFile().delete();
+ }
+ }
+ System.exit(0);
+ }
+ });
+ Container cont = this.getContentPane();
+ ButtonListener bl = new ButtonListener();
+ CellConstraints cc = new CellConstraints();
+ setLayout(new BorderLayout());
+ taskPanel = new JPanel();
+ String colSpec = "5dlu,p,5dlu,200dlu,5dlu,p,5dlu";
+ String rowSpec = "5dlu,p,5dlu,p,5dlu";
+ taskPanel.setLayout(new FormLayout(colSpec, rowSpec));
+ int row = 2;
+ JLabel urlLabel = new JLabel("URL:");
+ taskPanel.add(urlLabel, cc.xy(2, row));
+ urlTxf = new JTextField("");
+ taskPanel.add(urlTxf, cc.xy(4, row));
+ loadBtn = new JButton("Analyze");
+ loadBtn.setActionCommand("LOADURL");
+ loadBtn.addActionListener(bl);
+ urlTxf.addKeyListener(bl);
+ taskPanel.add(loadBtn, cc.xy(6, row));
+ imgComp = new ImageComponent();
+ imgScroll = new JScrollPane(imgComp);
+ imgScroll.setPreferredSize(new Dimension(200, 200));
+
+ JProgressBar progressBar = new JProgressBar();
+ progressBar.setIndeterminate(true);
+ progressPanel = new JPanel();
+ progressPanel.setVisible(false);
+ progressBar.setPreferredSize(new Dimension (500,25));
+
+ imgScroll.setForeground(Color.white);
+
+ progressBar.setBackground(Color.black);
+ progressBar.setForeground(Color.red);
+
+
+ progressPanel.add(progressBar);
+
+
+ cont.add(progressPanel, BorderLayout.SOUTH);
+ cont.add(taskPanel, BorderLayout.NORTH);
+ cont.add(imgScroll, BorderLayout.CENTER);
+ }
+
+ public void endProgressBar ()
+ {
+ progressPanel.setVisible(false);
+ }
+
+ private void onLoad() {
+ String url = urlTxf.getText();
+
+ if (!url.startsWith("http://"))
+ url = "http://" + url;
+
+ ItemGenerator ig = new ItemGenerator(url, progressPanel);
+
+ progressPanel.setVisible(true);
+
+ ig.execute();
+ }
+
+ public void setImage(File img) {
+ if (!img.canRead()) {
+ logger.log(Level.SEVERE,"Cannot read File");
+ return;
+ }
+ if (imgComp.getFile() != null) {
+ //TODO
+ //imgComp.getFile().delete();
+ }
+ imgComp.setImage(img);
+ imgScroll.revalidate();
+ progressPanel.setVisible(false);
+ }
+
+ public File getImageFile() {
+ return imgComp.getFile();
+ }
+
+ public class ButtonListener implements ActionListener, KeyListener {
+
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+ if (cmd.equals("LOADURL")) {
+ onLoad();
+ }
+ }
+
+ public void keyTyped(KeyEvent e) {
+ }
+
+ public void keyPressed(KeyEvent e) {
+ int key = e.getKeyCode();
+ if (key == KeyEvent.VK_ENTER) {
+ onLoad();
+ }
+ }
+
+ public void keyReleased(KeyEvent e) {
+ }
+ }
+
+
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/DOTGenerator.java b/Master/Agile Software Development/TestApp/src/testapp/DOTGenerator.java
new file mode 100644
index 0000000..679c339
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/DOTGenerator.java
@@ -0,0 +1,54 @@
+/*
+ * Class to write the .dot file
+ */
+
+package testapp;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import javax.swing.SwingWorker;
+import testapp.data.Item;
+import java.util.logging.*;
+/**
+ *
+ * @author sven
+ */
+public class DOTGenerator extends SwingWorker<File,Object>{
+ private Item startItem;
+
+ private static final Logger logger = Logger.getLogger(DOTGenerator.class.getName());
+
+ public DOTGenerator(Item startItem) {
+ this.startItem = startItem;
+ }
+
+ @Override
+ protected File doInBackground() throws Exception {
+ File tmpDotFile = null;
+ try {
+ tmpDotFile = File.createTempFile("tmp", ".gv");
+ FileWriter fw = new FileWriter(tmpDotFile);
+ logger.log(Level.INFO, "Path: "+tmpDotFile.getAbsolutePath());
+ fw.write(startItem.toDOT());
+ fw.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ return tmpDotFile;
+ }
+
+ @Override
+ protected void done() {
+ try {
+ GraphGenerator gen = new GraphGenerator(get());
+ gen.execute();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ } catch (ExecutionException ee) {
+ ee.printStackTrace();
+ }
+ }
+
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/GraphGenerator.java b/Master/Agile Software Development/TestApp/src/testapp/GraphGenerator.java
new file mode 100644
index 0000000..06645d2
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/GraphGenerator.java
@@ -0,0 +1,81 @@
+/*
+ * Class to generate the graphic out of the .dot file
+ */
+package testapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import javax.swing.SwingWorker;
+import java.util.logging.*;
+/**
+ *
+ * @author eisenhauer
+ */
+public class GraphGenerator extends SwingWorker<File,Object> {
+ int retVal=-1;
+ Process proc;
+ File dotFile = null;
+ public GraphGenerator(File dotFile) {
+ super();
+ this.dotFile = dotFile;
+ }
+
+ @Override
+ protected File doInBackground() throws Exception {
+ return getImageFileForGraph();
+ }
+
+ @Override
+ protected void done() {
+ try {
+ if (retVal == 0) {
+ AppFrame af = AppFrame.getInstance();
+ if (af != null) {
+ af.setImage(get());
+ //TODO
+ //dotFile.delete();
+ }
+ }
+ return;
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ } catch (ExecutionException ee) {
+ ee.printStackTrace();
+ }
+ }
+
+ //Convert the .dot file to a .png grafic
+ public File getImageFileForGraph(File dotFile) {
+ File tmpFile = null;
+ if (!dotFile.canRead()) {
+ return null;
+ }
+ try {
+ tmpFile = File.createTempFile("tmp", ".png");
+ File dotPath = new File(App.getInstance().getAppPath() + "/lib/graphviz/bin/");
+ File dotExe = new File(dotPath.toString()+"/dot.exe");
+ String dotArgType = "-Tpng";
+ String dotArgOutfile = "-o"+tmpFile.toString();
+ String dotArgInfile = dotFile.toString();
+ String graphvizCmd = dotExe.toString();
+ String[] cmd = new String[]
+ {graphvizCmd,dotArgType,dotArgOutfile,dotArgInfile};
+ ProcessBuilder procBuilder = new ProcessBuilder(cmd);
+ procBuilder.redirectErrorStream(true);
+ proc = procBuilder.start();
+ try {
+ retVal = proc.waitFor();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ return tmpFile;
+ }
+ public File getImageFileForGraph() {
+ //File dotFile = new File(System.getProperty("user.dir")+"/dist/resource/test.dot");
+ return getImageFileForGraph(dotFile);
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/ImageComponent.java b/Master/Agile Software Development/TestApp/src/testapp/ImageComponent.java
new file mode 100644
index 0000000..359bf10
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/ImageComponent.java
@@ -0,0 +1,46 @@
+/*
+ * Class for image drawing.
+ */
+package testapp;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+import javax.swing.JComponent;
+import java.util.logging.*;
+
+/**
+ *
+ * @author eisenhauer
+ */
+public class ImageComponent extends JComponent {
+
+ private BufferedImage image;
+ private File file;
+
+ public void setImage(File file) {
+ this.file = file;
+ try {
+ if ((image = ImageIO.read(this.file)) != null) {
+ setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
+ repaint();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ if (image != null) {
+ g.drawImage(image, 0, 0, this);
+ }
+ }
+
+ public File getFile() {
+ return file;
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/ItemGenerator.java b/Master/Agile Software Development/TestApp/src/testapp/ItemGenerator.java
new file mode 100644
index 0000000..9a8855f
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/ItemGenerator.java
@@ -0,0 +1,92 @@
+/*
+ * Class to use the html parser and generate items.
+ */
+
+package testapp;
+
+import Parser.HtmlParser;
+import Parser.UrlAnalyzer;
+import java.util.concurrent.ExecutionException;
+import javax.swing.SwingWorker;
+import testapp.data.IframeItem;
+import testapp.data.ImageItem;
+import testapp.data.Item;
+import testapp.data.ItemClassification;
+import testapp.data.PageItem;
+import java.util.logging.*;
+import javax.swing.JPanel;
+/**
+ *
+ * @author sven
+ */
+public class ItemGenerator extends SwingWorker<Item,Object> {
+ private static final Logger logger = Logger.getLogger(ItemGenerator.class.getName());
+
+ private String url;
+ private JPanel progressBar;
+
+ public ItemGenerator(String url, JPanel ProgressBar) {
+ this.url = url;
+ this.progressBar = ProgressBar;
+ }
+
+ @Override
+ protected Item doInBackground() throws Exception {
+ // Call Parser for URL
+ PageItem pi =null;
+ if(UrlAnalyzer.validateURL(url))
+ {
+ progressBar.setVisible(true);
+ String rest = UrlAnalyzer.stripProtocol(url);
+ if (!rest.contains(UrlAnalyzer.PATH_SEPARATOR)) {
+ url += "/";
+ }
+ pi = new PageItem(url,null);
+ HtmlParser htmlParser=new HtmlParser();
+ htmlParser.parse(pi);
+
+ /*
+ PageItem pi = new PageItem(url);
+ pi.setClassification(ItemClassification.SUSPICIOUS);
+ pi.add(new ImageItem(url+"image1").setClassification(ItemClassification.HARMLESS));
+ pi.add(new ImageItem(url+"image2").setClassification(ItemClassification.CRITICAL));
+ pi.add(new IframeItem(url+"if1")
+ .add(new ImageItem(url+"if1img1").setClassification(ItemClassification.SUSPICIOUS))
+ .add(new ImageItem(url+"if1img2").setClassification(ItemClassification.SUSPICIOUS))
+ );
+ pi.add(new IframeItem("NEWIFRAME").setClassification(ItemClassification.UNKNOWN));
+ */
+ //
+ // start analyse here!!!
+ //
+ //pi.analyse();
+ }
+ else
+ {
+ //throw new Exception("Wrong URL format.");
+ }
+ return pi;
+ }
+
+ @Override
+ protected void done() {
+ try {
+ Item rootItem = get();
+ rootItem.urlToValidUrl(true);
+ ItemClassification ic = rootItem.analyse();
+ DOTGenerator dotGenerator = new DOTGenerator(rootItem);
+ dotGenerator.execute();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ } catch (ExecutionException ee) {
+ ee.printStackTrace();
+ } catch (Exception ex)
+ {
+ logger.log(Level.SEVERE, ex.toString());
+ }
+ finally
+ {
+ progressBar.setVisible(false);
+ }
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/Locate.java b/Master/Agile Software Development/TestApp/src/testapp/Locate.java
new file mode 100644
index 0000000..49f96a9
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/Locate.java
@@ -0,0 +1,90 @@
+/*
+ *
+ */
+
+package testapp;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.logging.*;
+
+/**@author McDowell*/
+public class Locate {
+
+ /**
+ * Returns the URL of a given class.
+ * @param c a non-null class
+ * @return the URL for that class
+ */
+ public static URL getUrlOfClass(Class c) {
+ if(c==null) {
+ throw new NullPointerException();
+ }
+ String className = c.getName();
+ String resourceName = className.replace('.', '/') + ".class";
+ ClassLoader classLoader = c.getClassLoader();
+ if(classLoader==null) {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
+ URL url = classLoader.getResource(resourceName);
+ return url;
+ }
+
+ /**
+ * Finds the location of a given class file on the file system.
+ * Throws an IOException if the class cannot be found.
+ * <br>
+ * If the class is in an archive (JAR, ZIP), then the returned object
+ * will point to the archive file.
+ * <br>
+ * If the class is in a directory, the base directory will be returned
+ * with the package directory removed.
+ * <br>
+ * The <code>File.isDirectory()</code> method can be used to
+ * determine which is the case.
+ * <br>
+ * @param c a given class
+ * @return a File object
+ * @throws IOException
+ */
+ public static File getClassLocation(Class c) throws IOException, FileNotFoundException {
+ if(c==null) {
+ throw new NullPointerException();
+ }
+
+ String className = c.getName();
+ String resourceName = className.replace('.', '/') + ".class";
+ ClassLoader classLoader = c.getClassLoader();
+ if(classLoader==null) {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
+ URL url = classLoader.getResource(resourceName);
+
+ String szUrl = url.toString();
+ if(szUrl.startsWith("jar:file:")) {
+ try {
+ szUrl = szUrl.substring("jar:".length(), szUrl.lastIndexOf("!"));
+ URI uri = new URI(szUrl);
+ return new File(uri);
+ } catch(URISyntaxException e) {
+ throw new IOException(e.toString());
+ }
+ } else if(szUrl.startsWith("file:")) {
+ try {
+ szUrl = szUrl.substring(0, szUrl.length() - resourceName.length());
+ URI uri = new URI(szUrl);
+ return new File(uri);
+ } catch(URISyntaxException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ throw new FileNotFoundException(szUrl);
+ }
+
+}
+
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ExternalCssItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/ExternalCssItem.java
new file mode 100644
index 0000000..9f8025a
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ExternalCssItem.java
@@ -0,0 +1,58 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+import java.util.HashMap;
+import java.util.logging.*;
+
+/**
+ *
+ * @author sven
+ */
+public class ExternalCssItem extends Item {
+ private Boolean suspiciousCode=false;
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public ExternalCssItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.EXTERNALCSS;
+ }
+
+// public ExternalCssItem(String url) {
+// super(url);
+// itemType = ItemType.EXTERNALCSS;
+// }
+
+ public void setSuspiciousCode() {
+ suspiciousCode=true;
+ }
+
+ public Boolean getSuspiciousCode() {
+ return suspiciousCode;
+ }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ attributes.put("shape", "septagon");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+
+ @Override
+ protected String getGraphNodetext() {
+ return "Ext. CSS: "+this.url;
+ }
+
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ExternalJavascriptItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/ExternalJavascriptItem.java
new file mode 100644
index 0000000..9c23f88
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ExternalJavascriptItem.java
@@ -0,0 +1,56 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package testapp.data;
+
+import java.util.HashMap;
+import java.util.logging.*;
+/**
+ *
+ * @author sven
+ */
+public class ExternalJavascriptItem extends Item {
+
+ private Boolean suspiciousCode = false;
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public ExternalJavascriptItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.EXTERNALJAVASCRIPT;
+ }
+
+// public ExternalJavascriptItem(String url) {
+// super(url);
+// itemType = ItemType.EXTERNALJAVASCRIPT;
+// }
+
+ public void setSuspiciousCode() {
+ suspiciousCode = true;
+ }
+
+ public Boolean getSuspiciousCode() {
+ return suspiciousCode;
+ }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String, String>();
+ }
+ attributes.put("shape", "ellipse");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+
+ @Override
+ protected String getGraphNodetext() {
+ return "Ext. SCRIPT: " + this.url;
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/FrameItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/FrameItem.java
new file mode 100644
index 0000000..84c982d
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/FrameItem.java
@@ -0,0 +1,51 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+import java.util.HashMap;
+import java.util.logging.*;
+/**
+ *
+ * @author sven
+ */
+public class FrameItem extends Item {
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public FrameItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.FRAME;
+ }
+
+// public FrameItem(String url) {
+// super(url);
+// itemType = ItemType.FRAME;
+// }
+
+ @Override
+
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ attributes.put("shape", "doubleoctagon");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+
+ @Override
+ protected String getGraphNodetext() {
+ if (this.filename.compareTo("")!=0)
+ return this.filename;
+ else
+ return this.getUrl();
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/GraphConstants.java b/Master/Agile Software Development/TestApp/src/testapp/data/GraphConstants.java
new file mode 100644
index 0000000..6edf288
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/GraphConstants.java
@@ -0,0 +1,44 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+/**
+ *
+ * @author sven
+ */
+public class GraphConstants {
+ public static String getDOTStart() {
+// return "digraph G {\r\n\tgraph [rankdir = \"LR\"];\r\n";
+ return "digraph G {\r\n\tgraph[rankdir = \"LR\"];\r\n";
+ }
+ public static String getDOTEnd() {
+ return "\r\n}";
+ }
+ public final static String getDotLegend() {
+ StringBuilder res = new StringBuilder("\t/* Legend */\r\n");
+
+ res.append("\tsubgraph cluster_1 { \r\n");
+ res.append("\t\tfontname=Verdana;\r\n");
+ res.append("\t\tlabel = \"Legende\";\r\n");
+ res.append("\t\tcolor=lightgrey;\r\n");
+ res.append("\t\tstyle=filled;\r\n");
+ res.append("\t\tHOME [style=filled,fontname=verdana,fontsize=10,color=white,shape=house,rank=0];\r\n");
+ res.append("\t\tLink [style=filled,fontname=verdana,fontsize=10,color=white,shape=box,rank=0];\r\n");
+ res.append("\t\tImage [style=filled,fontname=verdana,fontsize=10,color=white,shape=octagon,rank=0];\r\n");
+ res.append("\t\tScript [style=filled,fontname=verdana,fontsize=10,color=white,shape=ellipse,rank=0];\r\n");
+ res.append("\t\tCSS [style=filled,fontname=verdana,fontsize=10,color=white,shape=septagon,rank=0];\r\n");
+ res.append("\t\tIframe [style=filled,fontname=verdana,fontsize=10,color=white,shape=doubleoctagon,rank=0];\r\n");
+
+ res.append("\t\tSuspicious [style=filled,fontname=verdana,fontsize=10,color=orange,shape=ellipse,rank=1];\r\n");
+ res.append("\t\tCritical [style=filled,fontname=verdana,fontsize=10,color=red2,shape=ellipse,rank=1];\r\n");
+ res.append("\t\tUnknown [style=filled,fontname=verdana,fontsize=10,color=slateblue1,shape=ellipse,rank=1];\r\n");
+ res.append("\t}\r\n");
+
+ return res.toString();
+ }
+ public static final String getEmptyMessage() {
+ return "\"Keine kritischen Elemente gefunden\" [style=filled,color=limegreen];\r\n";
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/IframeItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/IframeItem.java
new file mode 100644
index 0000000..5a6537b
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/IframeItem.java
@@ -0,0 +1,51 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+import java.util.logging.*;
+import java.util.HashMap;
+
+/**
+ *
+ * @author sven
+ */
+public class IframeItem extends Item {
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public IframeItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.IFRAME;
+ attributes = getAttributes();
+ }
+
+// public IframeItem(String url) {
+// super(url);
+// itemType = ItemType.IFRAME;
+// attributes = getAttributes();
+// }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ attributes.put("shape", "doubleoctagon");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+ @Override
+ protected String getGraphNodetext() {
+ if (this.filename.compareTo("")!=0)
+ return this.filename;
+ else
+ return this.getUrl();
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ImageItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/ImageItem.java
new file mode 100644
index 0000000..0014b81
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ImageItem.java
@@ -0,0 +1,102 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+import java.awt.Image;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.logging.*;
+import javax.imageio.ImageIO;
+
+
+
+/**
+ *
+ * @author sven
+ */
+public class ImageItem extends Item{
+
+ private static final Logger logger = Logger.getLogger(ImageItem.class.getName());
+
+ public ImageItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.IMAGE;
+ }
+
+// public ImageItem(String url) {
+// super(url);
+// itemType = ItemType.IMAGE;
+// }
+
+ @Override
+ public ItemClassification analyse() {
+
+ // if (!url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("ftp://"))
+ // url="http://"+url;
+ doAnalyse();
+
+ try {
+
+ // Bild auf Größe abfragen, wenn kleiner als 5x5 Pixel --> Critical
+ // Wenn größer und von fremden Server --> Suspicous
+ // Wenn lokal, dann ist auch die Größe egal --> Harmless
+ logger.log(Level.INFO, this.url.toString());
+ URL imgUrl = new URL(this.url);
+ logger.log(Level.INFO, imgUrl.toString());
+ Image image=null;
+ try {
+ image = ImageIO.read(imgUrl);
+ } catch(Exception exception) {
+ logger.log(Level.WARNING, "Couldn't verify image "+imgUrl);
+ setClassification(ItemClassification.SUSPICIOUS);
+ }
+
+ //System.out.println("Höhe "+image.getHeight(null)+" Breite "+image.getWidth(null));
+ if (image != null) {
+ if ( (image.getHeight(null) <= 5) && (image.getWidth(null) <= 5) && (itemPlace != ItemPlace.LOCAL) ) {
+ setClassification(ItemClassification.CRITICAL);
+ }
+ else if (itemPlace == ItemPlace.REMOTE)
+ {
+ setClassification(ItemClassification.SUSPICIOUS);
+ }
+ else if (itemPlace == ItemPlace.LOCAL)
+ {
+ setClassification(ItemClassification.HARMLESS);
+ }
+ } else {
+ setClassification(ItemClassification.UNKNOWN);
+ }
+ } catch (IOException ex) {
+ logger.log(Level.SEVERE, ex.toString());
+ }
+
+ logger.log(Level.INFO, "Place: " + this.itemPlace);
+ return itemClassification;
+ }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ attributes.put("shape", "octagon");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+
+ @Override
+ protected String getGraphNodetext() {
+ if (this.filename.compareTo("")!=0)
+ return this.filename;
+ else
+ return this.getUrl();
+ }
+
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/Item.java b/Master/Agile Software Development/TestApp/src/testapp/data/Item.java
new file mode 100644
index 0000000..08f17a6
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/Item.java
@@ -0,0 +1,413 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package testapp.data;
+
+import Parser.UrlAnalyzer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.logging.*;
+
+/**
+ *
+ * @author sven
+ * Abstract which all Items implement
+ * This is the Component of the composite pattern
+ */
+public abstract class Item {
+
+ private static final Logger logger = Logger.getLogger(ImageItem.class.getName());
+ protected List<Item> childItems = new ArrayList<Item>();
+ protected String url;
+ protected String protocol;
+ protected String hostname;
+ protected String path;
+ protected String filename;
+ protected String labelExtension;
+ protected HashMap<String, String> httpParams;
+ protected String urlAnchor;
+ protected Item parent;
+ protected ItemType itemType;
+ protected ItemClassification itemClassification;
+ protected HashMap<String, String> attributes = new HashMap();
+ protected ItemPlace itemPlace;
+
+// public Item(String url) {
+// this.url = url;
+// this.itemClassification = ItemClassification.NEW;
+// }
+ public Item(String url, Item parent) {
+ this.parent = parent;
+ this.url = url;
+ this.itemClassification = ItemClassification.NEW;
+ urlToValidUrl(false);
+ }
+
+ /**
+ * method to let Item analyse itself
+ * and let all it's children analyse themselfs
+ *
+ * MUST call doAnalyse as return
+ *
+ */
+ public abstract ItemClassification analyse();
+
+ public final ItemClassification doAnalyse() {
+ checkPlace();
+ if (!itemType.equals(ItemType.LINK)) {
+ if (itemPlace == ItemPlace.REMOTE) {
+ setClassification(ItemClassification.CRITICAL);
+ } else if (itemPlace == ItemPlace.LOCAL) {
+ setClassification(ItemClassification.HARMLESS);
+ }
+ }
+ ItemClassification childClassification = ItemClassification.UNKNOWN;
+ ItemClassification ownClassification = itemClassification;
+ for (Item child : childItems) {
+ childClassification = child.analyse();
+ if ((ownClassification.compareTo(childClassification) < 0)) {
+ ownClassification = childClassification;
+ }
+ }
+
+ setClassification(ownClassification);
+ return ownClassification;
+
+ }
+
+ /**
+ * get DOT Graph representation of this Item and all
+ * of its children
+ * @return DOT String representation
+ * see DOT documentation for syntax
+ */
+ public final String toDOT() {
+ StringBuilder sb = new StringBuilder();
+ if (isRoot()) {
+ sb.append(GraphConstants.getDOTStart());
+ if (!hasDrawable()) {
+ sb.append(GraphConstants.getEmptyMessage());
+ } else {
+ sb.append(GraphConstants.getDotLegend());
+ }
+ sb.append("\r\n\t/*Node definitions*/\r\n");
+ sb.append(getAsDotNode());
+ sb.append("\r\n\t/*Tree definition*/\r\n");
+ }
+
+ if (isLeaf()) {
+ sb.append("\"" + getGraphNodetext() + "\";\r\n");
+ } else {
+ if (isDrawable()) {
+ sb.append(getChildrenAsDOT());
+ }
+ }
+ if (isRoot()) {
+ sb.append(GraphConstants.getDOTEnd());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * is this Item a Leaf of the tree?
+ * @return true if it has no children,
+ * false if it has children
+ */
+ public final boolean isLeaf() {
+ return (childItems.size() > 0) ? false : true;
+ }
+
+ /**
+ * is this Item the root of the tree?
+ * @return true if it has no parent Item
+ * false if it has a parent Item
+ */
+ protected final boolean isRoot() {
+ return (parent == null) ? true : false;
+ }
+
+ /**
+ * Add a child Item to this Item
+ * @param child
+ * @return the Item
+ */
+ public final Item add(Item child) {
+ child.setParent(this);
+ childItems.add(child);
+ return this;
+ }
+
+ /**
+ * set the parent Item of this Item
+ * @param parent
+ */
+ public final void setParent(Item parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * ste the URL of this Item
+ * @param url
+ */
+ public final void setUrl(String url) {
+ this.url = url;
+ }
+
+ /**
+ * get the URL of this Item
+ */
+ public final String getUrl() {
+ return this.url;
+ }
+
+ protected final String getChildrenAsDOT() {
+ StringBuilder sb = new StringBuilder();
+ if (isDrawable()) {
+ for (Item child : childItems) {
+ if (child.isDrawable()) {
+ sb.append(isRoot() ? "\t" : "");
+ sb.append("\"" + getGraphNodetext() + "\"");
+ sb.append(" -> ");
+ sb.append(child.toDOT());
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+ protected abstract String getGraphNodetext();
+
+ public final boolean isDrawable() {
+ if (itemClassification.compareTo(ItemClassification.HARMLESS) > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return String: DOT Node reprensetation plus addiditonal attributes
+ */
+ protected final String getAsDotNode() {
+ if (!isDrawable()) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append("\t\"");
+ sb.append(getGraphNodetext());
+ sb.append("\" [");
+ int i = 0;
+ for (String keyStr : attributes.keySet()) {
+ if (i > 0) {
+ sb.append(",");
+ }
+ sb.append(keyStr + "=" + attributes.get(keyStr));
+ i++;
+ }
+
+ labelExtension = "<<table border=\"0\" cellborder=\"0\" cellpadding=\"3\" bgcolor=\"white\"><tr>test</tr></table>>";
+
+ if (this.labelExtension.compareTo("") != 0) {
+ // sb.append(",label="+this.labelExtension);
+ }
+
+ logger.log(Level.INFO, labelExtension);
+
+ sb.append("];\r\n");
+ for (Item item : childItems) {
+ sb.append(item.getAsDotNode());
+ }
+ return sb.toString();
+ }
+
+ protected abstract HashMap<String, String> getAttributes();
+
+ private boolean hasDrawable() {
+ boolean res = isDrawable();
+ if (!res) {
+ for (Item child : childItems) {
+ res = child.hasDrawable();
+ if (res) {
+ return res;
+ }
+ }
+ }
+ return res;
+ }
+
+ private final void setAttribute(String key, String value) {
+ getAttributes().put(key, value);
+ }
+
+ private final void setColor() {
+ switch (itemClassification) {
+ case CRITICAL:
+ setAttribute("color", "red2");
+ break;
+ case HARMLESS:
+ setAttribute("color", "limegreen");
+ break;
+ case SUSPICIOUS:
+ setAttribute("color", "orange");
+ break;
+ case UNKNOWN:
+ setAttribute("color", "slateblue1");
+ break;
+ case NEW:
+ setAttribute("color", "ivory3");
+ break;
+ }
+ }
+
+ /**
+ * check and validate the URL of this item and and its children
+ * CAUTION run after parsing completed, otherwise we can not be sure to
+ * have a valid parent item. This is important if we only have a relative url
+ */
+ public final void urlToValidUrl(boolean recursive) {
+ /*if (!url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("ftp://"))
+ url="http://"+url;
+
+ return url;*/
+ if (this.url == null) {
+ this.url = this.parent.getFullUrl();
+// return;
+ }
+ if (isRoot()) {
+ if (!this.url.contains(UrlAnalyzer.PROTOCOL_SEPARATOR)) {
+ this.url = UrlAnalyzer.PROTOCOL_HTTP + UrlAnalyzer.PROTOCOL_SEPARATOR + this.url;
+ }
+ }
+ this.protocol = UrlAnalyzer.getProtocol(this.url);
+ if (this.protocol.equals(UrlAnalyzer.NO_PROTOCOL)) {
+ this.protocol = this.parent.getProtocol();
+ }
+ this.hostname = UrlAnalyzer.getHostname(url);
+ if (this.hostname.equals(UrlAnalyzer.NO_HOST)) {
+ this.hostname = this.parent.hostname;
+ }
+ this.path = UrlAnalyzer.getPath(url);
+ if (this.path.equals(UrlAnalyzer.NO_VALID_PATH)) {
+ this.path = this.parent.path;
+ } else if (this.path != null && this.parent != null && !this.path.startsWith(String.valueOf(UrlAnalyzer.PATH_SEPARATOR))) {
+ this.path = this.parent.path + this.path;
+ }
+ this.filename = UrlAnalyzer.getFilename(this.url);
+ if (this.filename.equals(UrlAnalyzer.NO_VALID_FILE)) {
+ this.filename = this.parent.filename;
+ }
+
+
+ if (UrlAnalyzer.hasParams(this.url)) {
+ this.httpParams = UrlAnalyzer.getParams(this.url);
+ }
+ if (UrlAnalyzer.hasAnchor(this.url)) {
+ this.urlAnchor = UrlAnalyzer.getAnchor(this.url);
+ }
+
+ this.url = getFullUrl();
+ //System.out.println("Full Url: " + this.url);
+ if (recursive) {
+ for (Item child : childItems) {
+ child.urlToValidUrl(recursive);
+ }
+ }
+ }
+
+ public final String getProtocol() {
+ if (this.protocol == null) {
+ urlToValidUrl(false);
+ this.protocol = this.parent.getProtocol();
+ }
+ return this.protocol;
+ }
+
+ public Item setClassification(ItemClassification it) {
+ itemClassification = it;
+ setColor();
+ return this;
+ }
+
+ protected Item getRoot() {
+ // Festellen, ob von eigener Seite
+
+ Item parentIt = this.parent;
+ Item root = null;
+
+ if (parentIt != null) {
+ while (parentIt.parent != null) {
+ parentIt = parentIt.parent;
+ }
+ root = parentIt;
+ } else {
+ return this;
+ }
+
+ return root;
+ }
+
+ /*protected String getHostname ()
+ {
+
+ try {
+
+ String host = (new URL(url)).getHost();
+ return host;
+
+ } catch (MalformedURLException ex) {
+ Logger.getLogger(ImageItem.class.getName()).log(Level.SEVERE, null, ex);
+ return null;
+ }
+
+
+ }*/
+ protected final void checkPlace() {
+ if (this.hostname != null) {
+ //System.out.println("Root: " + this.getRoot().getHostname() + " this: " + this.getHostname());
+ //System.out.println("Root: " + this.getRoot().hostname + " this: " + this.hostname);
+ if (!this.hostname.equals(this.getRoot().hostname)) {
+ this.itemPlace = ItemPlace.REMOTE;
+ } else {
+ this.itemPlace = ItemPlace.LOCAL;
+ }
+ } else {
+ this.itemPlace = ItemPlace.LOCAL;
+ }
+ }
+
+ public final String getFullUrl() {
+// if (this.protocol == null) {
+// urlToValidUrl();
+// }
+ String res = protocol + UrlAnalyzer.PROTOCOL_SEPARATOR + hostname + path + filename;
+ res += (urlAnchor != null) ? UrlAnalyzer.ANCHOR + urlAnchor : "";
+ res += httpParamsToString();
+ return res;
+ }
+
+ public final String getFullpath() {
+ return protocol + UrlAnalyzer.PROTOCOL_SEPARATOR + hostname + path;
+ }
+
+ private final String httpParamsToString() {
+ String res = "";
+ if (this.httpParams != null) {
+ res += UrlAnalyzer.PARAMS_INDICATOR;
+ int n = 0;
+ for (String paramName : httpParams.keySet()) {
+ if (n > 0) {
+ res += UrlAnalyzer.PARAMS_SEPARATOR;
+ }
+ res += paramName;
+ String paramValue = httpParams.get(paramName);
+ if (paramValue != null) {
+ res += UrlAnalyzer.PARAMS_ASSIGN + paramValue;
+ }
+ n++;
+ }
+ }
+ return res;
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ItemClassification.java b/Master/Agile Software Development/TestApp/src/testapp/data/ItemClassification.java
new file mode 100644
index 0000000..217ac51
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ItemClassification.java
@@ -0,0 +1,14 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+/**
+ *
+ * @author sven
+ */
+public enum ItemClassification {
+ NEW,HARMLESS,UNKNOWN,SUSPICIOUS,CRITICAL;
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ItemPlace.java b/Master/Agile Software Development/TestApp/src/testapp/data/ItemPlace.java
new file mode 100644
index 0000000..78b762b
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ItemPlace.java
@@ -0,0 +1,14 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+/**
+ *
+ * @author widbstudi
+ */
+public enum ItemPlace {
+ UNKNOWN,LOCAL,REMOTE
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ItemType.java b/Master/Agile Software Development/TestApp/src/testapp/data/ItemType.java
new file mode 100644
index 0000000..d6901ad
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ItemType.java
@@ -0,0 +1,14 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+/**
+ *
+ * @author sven
+ */
+public enum ItemType {
+ IMAGE,IFRAME,FRAME,PAGE,LINK,STYLE,SCRIPT,EXTERNALJAVASCRIPT,EXTERNALCSS
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/LinkItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/LinkItem.java
new file mode 100644
index 0000000..600163d
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/LinkItem.java
@@ -0,0 +1,50 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+
+import java.util.HashMap;
+import java.util.logging.*;
+
+/**
+ *
+ * @author sven
+ */
+public class LinkItem extends Item {
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public LinkItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.LINK;
+ }
+// public LinkItem(String url) {
+// super(url);
+// itemType = ItemType.LINK;
+// }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ attributes.put("shape", "box");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+ @Override
+ protected String getGraphNodetext() {
+ //return this.filename;
+ if (this.filename.compareTo("")!=0)
+ return "link to: "+this.filename;
+ else
+ return "link to: "+this.getUrl();
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/PageItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/PageItem.java
new file mode 100644
index 0000000..071539a
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/PageItem.java
@@ -0,0 +1,48 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package testapp.data;
+
+import java.util.HashMap;
+import java.util.logging.*;
+
+/**
+ *
+ * @author sven
+ */
+public class PageItem extends Item {
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public PageItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.PAGE;
+ attributes = getAttributes();
+ }
+
+// public PageItem(String url) {
+// super(url);
+// itemType = ItemType.PAGE;
+// attributes = getAttributes();
+// }
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String, String>();
+ }
+ attributes.put("shape", "house");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+
+ @Override
+ protected String getGraphNodetext() {
+ return getFullUrl();
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/ScriptItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/ScriptItem.java
new file mode 100644
index 0000000..1764f3a
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/ScriptItem.java
@@ -0,0 +1,62 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package testapp.data;
+
+import java.util.HashMap;
+import java.util.logging.*;
+/**
+ *
+ * @author sven
+ */
+public class ScriptItem extends Item {
+
+ @Override
+ public ItemClassification analyse() {
+ setClassification(ItemClassification.HARMLESS);
+
+ checkPlace();
+ if (itemPlace == ItemPlace.REMOTE) {
+ setClassification(ItemClassification.CRITICAL);
+ } else if (itemPlace == ItemPlace.LOCAL) {
+ setClassification(ItemClassification.HARMLESS);
+ }
+/* TODO: Take Child classifcation
+ for (Item child : childItems) {
+ childClassification = child.analyse();
+ }
+ if ((itemClassification.compareTo(childClassification) > 0)) {
+ setClassification(childClassification);
+ }
+*/
+ return doAnalyse();
+ }
+
+ public ScriptItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.SCRIPT;
+ }
+
+// public ScriptItem(String url) {
+// super(url);
+// itemType = ItemType.SCRIPT;
+// }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String, String>();
+ }
+ attributes.put("shape", "ellipse");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+
+ @Override
+ protected String getGraphNodetext() {
+ return "SCRIPT: "+this.url;
+ }
+}
diff --git a/Master/Agile Software Development/TestApp/src/testapp/data/StyleItem.java b/Master/Agile Software Development/TestApp/src/testapp/data/StyleItem.java
new file mode 100644
index 0000000..4bb8ff3
--- /dev/null
+++ b/Master/Agile Software Development/TestApp/src/testapp/data/StyleItem.java
@@ -0,0 +1,47 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package testapp.data;
+import java.util.logging.*;
+import java.util.HashMap;
+
+/**
+ *
+ * @author sven
+ */
+public class StyleItem extends Item {
+
+ @Override
+ public ItemClassification analyse() {
+ return doAnalyse();
+ }
+
+ public StyleItem(String url, Item parent) {
+ super(url, parent);
+ itemType = ItemType.STYLE;
+ }
+
+// public StyleItem(String url) {
+// super(url);
+// itemType = ItemType.STYLE;
+// }
+
+ @Override
+ protected HashMap<String, String> getAttributes() {
+ if (attributes == null) {
+ attributes = new HashMap<String,String>();
+ }
+ attributes.put("shape", "septagon");
+ attributes.put("style", "filled");
+ attributes.put("fontname", "Verdana");
+ attributes.put("fontsize", "10");
+ return attributes;
+ }
+ @Override
+ protected String getGraphNodetext() {
+ //return this.filename;
+ return "CSS STYLE "+this.url;
+ }
+}