1

I've created a java traceroute applet and it works fine in the eclipse appletviewer, but when I execute it in my browser I get the following error:

error in actionPerformed(): java.lang.SecurityException: class "Controller" does not match trust level of other classes in the same package

I have signed my jar file and tried a lot of changes in my manifest file but it still doesn't work. I am using java jdk1.7.0_45.

CONTROLLER CLASS:

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.ArrayList;

public class Controller {

    public Controller(GUI gui) {
        this.gui = gui;
    }

    private final String os = System.getProperty("os.name");
    private GUI gui;

    public void displayHopsOnConsole(final InputStream stream) {
        gui.clearConsole();
        Thread thread = new Thread() {
            public void run() {
                BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); //create BufferedReader to read the inputstream easily
                ArrayList <String> hops = new ArrayList <String> ();
                ArrayList <String> hopCoordinates = new ArrayList <String> ();
                String hop;
                String IP;
                int i = 0;
                try {
                    while ((hop = reader.readLine()) != null) { // while the input is not NULL, read every line separately
                        if (i >= 5 && hop.length() > 25) {
                            IP = getIpFromHop(hop); //Filter the hop and get the ip back
                            hops.add(IP); //put this ip in a arraylist
                            hopCoordinates.add(new Post(IP).getResponse());
                        }
                        gui.setConsoleOutput(hop);
                        System.out.println(hop);
                        i++;

                    }
                    reader.close(); //close buffer because finished
                    gui.setConsoleOutput("\n");
                    int c=2;
                    for(String str:hopCoordinates){
                         gui.setConsoleOutput(c + ": " + str);
                         c++;
                    }

                } 
                catch (Exception ex) {
                    System.out.println("Error in displayHopsOnConsole" + ex);
                }
            }
        };
        thread.start(); //start thread  
    }

    public void traceRoute(InetAddress address) {
        try {
            Process traceRt;
            if (os.contains("Win") || os.contains("win")) {
                traceRt = Runtime.getRuntime().exec("tracert " + address.getHostAddress());
            } 
            else {
                traceRt = Runtime.getRuntime().exec("traceroute " + address.getHostAddress());
            }
            displayHopsOnConsole(traceRt.getInputStream());
        } 
        catch (Exception ex) {
            System.out.println("error while performing trace route command, see traceRoute() " + ex);
        }
    }

    public String getIpFromHop(String routeLine) {
        String resultString = routeLine.substring(31, routeLine.length() - 1);
        if (resultString.contains("[")) {
            String[] splitString = resultString.split("\\[");
            resultString = splitString[1].substring(0, splitString[1].length() - 1);
            return resultString;
        } 
        else {
            if (!resultString.contains("-")) {
                return resultString.replaceAll("\\s", "");
            } 
            else {
                return "Timeout!";
            }
        }
    }
}

GUI CLASS ACTION PERFORMED METHOD:

public void actionPerformed(ActionEvent e) {
        if(e.getSource()==submitButton) {
            try{
                new Controller(this).traceRoute(InetAddress.getByName(targetField.getText())); //call traceRoute method to start traceroute on given target address 
            }
            catch (Exception ex) {
                System.out.println("error in actionPerformed(): " + ex);
            }
        }
    }

MY MANIFEST FILE:

Manifest-Version: 1.0 Codebase: * Permissions: all-permissions Application-Library-Allowable-Codebase: * Caller-Allowable-Codebase: * Application-Name: GUI

Engin
  • 135
  • 1
  • 10
  • possible duplicate of [Java 7u4 webstart security exception: Class does not match trust level](http://stackoverflow.com/questions/10905790/java-7u4-webstart-security-exception-class-does-not-match-trust-level) – alex2410 Jan 09 '14 at 14:27
  • 1
    I've read that question but I could not find a solution. – Engin Jan 09 '14 at 14:28
  • Please help me its a project for school so I have to fix this before monday :( – Engin Jan 09 '14 at 14:38

0 Answers0