Пример #1
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();
  }
Пример #2
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;
  }