Exemplo n.º 1
0
  /** Print the HTML tag. */
  public static void printTag(PrintStream out, Hashtable atts) {
    out.print("<applet");

    String v = (String) atts.get("codebase");
    if (v != null) {
      out.print(" codebase=\"" + v + "\"");
    }

    v = (String) atts.get("code");
    if (v == null) {
      v = "applet.class";
    }
    out.print(" code=\"" + v + "\"");
    v = (String) atts.get("width");
    if (v == null) {
      v = "150";
    }
    out.print(" width=" + v);

    v = (String) atts.get("height");
    if (v == null) {
      v = "100";
    }
    out.print(" height=" + v);

    v = (String) atts.get("name");
    if (v != null) {
      out.print(" name=\"" + v + "\"");
    }
    out.println(">");

    // A very slow sorting algorithm
    int len = atts.size();
    String params[] = new String[len];
    len = 0;
    for (Enumeration e = atts.keys(); e.hasMoreElements(); ) {
      String param = (String) e.nextElement();
      int i = 0;
      for (; i < len; i++) {
        if (params[i].compareTo(param) >= 0) {
          break;
        }
      }
      System.arraycopy(params, i, params, i + 1, len - i);
      params[i] = param;
      len++;
    }

    for (int i = 0; i < len; i++) {
      String param = params[i];
      if (systemParam.get(param) == null) {
        out.println("<param name=" + param + " value=\"" + atts.get(param) + "\">");
      }
    }
    out.println("</applet>");
  }
Exemplo n.º 2
0
 private static void checkConnect(URL url) {
   SecurityManager security = System.getSecurityManager();
   if (security != null) {
     try {
       j86.java.security.Permission perm = url.openConnection().getPermission();
       if (perm != null) security.checkPermission(perm);
       else security.checkConnect(url.getHost(), url.getPort());
     } catch (j86.java.io.IOException ioe) {
       security.checkConnect(url.getHost(), url.getPort());
     }
   }
 }
Exemplo n.º 3
0
  /** Return an enumeration of all the accessible applets on this page. */
  public Enumeration getApplets() {
    AppletSecurity security = (AppletSecurity) System.getSecurityManager();
    Vector v = new Vector();
    SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect");

    for (Enumeration e = appletPanels.elements(); e.hasMoreElements(); ) {
      AppletPanel p = (AppletPanel) e.nextElement();
      if (p.getDocumentBase().equals(panel.getDocumentBase())) {

        SocketPermission sp = new SocketPermission(p.getCodeBase().getHost(), "connect");
        if (panelSp.implies(sp)) {
          v.addElement(p.applet);
        }
      }
    }
    return v.elements();
  }
Exemplo n.º 4
0
  /** Get an applet by name. */
  public Applet getApplet(String name) {
    AppletSecurity security = (AppletSecurity) System.getSecurityManager();
    name = name.toLowerCase();
    SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect");
    for (Enumeration e = appletPanels.elements(); e.hasMoreElements(); ) {
      AppletPanel p = (AppletPanel) e.nextElement();
      String param = p.getParameter("name");
      if (param != null) {
        param = param.toLowerCase();
      }
      if (name.equals(param) && p.getDocumentBase().equals(panel.getDocumentBase())) {

        SocketPermission sp = new SocketPermission(p.getCodeBase().getHost(), "connect");

        if (panelSp.implies(sp)) {
          return p.applet;
        }
      }
    }
    return null;
  }
Exemplo n.º 5
0
  /**
   * Send the initial set of events to the appletviewer event queue. On start-up the current
   * behaviour is to load the applet and call Applet.init() and Applet.start().
   */
  private void initEventQueue() {
    // appletviewer.send.event is an undocumented and unsupported system
    // property which is used exclusively for testing purposes.
    String eventList = System.getProperty("appletviewer.send.event");

    if (eventList == null) {
      // Add the standard events onto the event queue.
      panel.sendEvent(AppletPanel.APPLET_LOAD);
      panel.sendEvent(AppletPanel.APPLET_INIT);
      panel.sendEvent(AppletPanel.APPLET_START);
    } else {
      // We're testing AppletViewer.  Force the specified set of events
      // onto the event queue, wait for the events to be processed, and
      // exit.

      // The list of events that will be executed is provided as a
      // ","-separated list.  No error-checking will be done on the list.
      String[] events = splitSeparator(",", eventList);

      for (int i = 0; i < events.length; i++) {
        System.out.println("Adding event to queue: " + events[i]);
        if (events[i].equals("dispose")) panel.sendEvent(AppletPanel.APPLET_DISPOSE);
        else if (events[i].equals("load")) panel.sendEvent(AppletPanel.APPLET_LOAD);
        else if (events[i].equals("init")) panel.sendEvent(AppletPanel.APPLET_INIT);
        else if (events[i].equals("start")) panel.sendEvent(AppletPanel.APPLET_START);
        else if (events[i].equals("stop")) panel.sendEvent(AppletPanel.APPLET_STOP);
        else if (events[i].equals("destroy")) panel.sendEvent(AppletPanel.APPLET_DESTROY);
        else if (events[i].equals("quit")) panel.sendEvent(AppletPanel.APPLET_QUIT);
        else if (events[i].equals("error")) panel.sendEvent(AppletPanel.APPLET_ERROR);
        else
          // non-fatal error if we get an unrecognized event
          System.out.println("Unrecognized event name: " + events[i]);
      }

      while (!panel.emptyEventQueue()) ;
      appletSystemExit();
    }
  }
Exemplo n.º 6
0
 /** Exit the program. Exit from the program (if not stand alone) - do no clean-up */
 private void appletSystemExit() {
   if (factory.isStandalone()) System.exit(0);
 }