示例#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>");
  }
示例#2
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();
  }
示例#3
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;
  }