home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 July / PCO_07_97.ISO / NET_COM / cc32e40.exe / nav40.z / java40.jar / netscape / applet / AppletClassLoader.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-07  |  12.7 KB  |  773 lines

  1. package netscape.applet;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10. import java.net.URLConnection;
  11. import java.util.Enumeration;
  12. import java.util.Hashtable;
  13. import java.util.Vector;
  14. import java.util.zip.ZipEntry;
  15. import java.util.zip.ZipFile;
  16. import netscape.misc.WeakLink;
  17. import netscape.security.AppletSecurity;
  18. import netscape.security.AppletSecurityException;
  19. import netscape.security.Principal;
  20. import netscape.security.PrivilegeManager;
  21. import netscape.security.Target;
  22.  
  23. public class AppletClassLoader extends ClassLoader {
  24.    URL codeBaseURL;
  25.    URL archiveURL;
  26.    MozillaAppletContext context;
  27.    static boolean wantTiming;
  28.    long loaderTime;
  29.    boolean _mayScript;
  30.    boolean isReusable;
  31.    Principal codeBasePrincipal;
  32.    Principal[] matchPrincipalAry;
  33.    public static final String MANIFEST_FILENAME = "META-INF/manifest.mf";
  34.    private String archiveFile;
  35.    private boolean capturedArchive;
  36.    private int nativeArchive;
  37.    private int nativeZig;
  38.    byte[] inputBuf;
  39.    static Vector classloaders = new Vector(10);
  40.    private static boolean capturingClasses;
  41.    private static final boolean MARIMBA_ENABLED = true;
  42.    private CastanetChannelInfo channelInfo;
  43.    private Hashtable codebaseEnv;
  44.  
  45.    String grabArchiveFile() throws IOException {
  46.       String var1 = this.archiveURL.getFile();
  47.       if (!var1.endsWith(".jar") && !var1.endsWith(".zip")) {
  48.          return null;
  49.       } else {
  50.          String var2;
  51.          if (capturingClasses) {
  52.             int var3 = var1.lastIndexOf(47);
  53.             String var4 = var1.substring(var3 + 1);
  54.             var2 = this.getCaptureDir() + "/" + var4;
  55.          } else {
  56.             var2 = this.getTempName();
  57.          }
  58.  
  59.          SecurityManager.enablePrivilege("UniversalFileAccess");
  60.          SecurityManager.enablePrivilege("UniversalConnect");
  61.          FileOutputStream var14 = new FileOutputStream(var2);
  62.          long var15 = 0L;
  63.          if (wantTiming) {
  64.             var15 = System.currentTimeMillis();
  65.          }
  66.  
  67.          InputStream var6 = null;
  68.  
  69.          try {
  70.             URLConnection var9 = this.archiveURL.openConnection();
  71.             var9.setAllowUserInteraction(false);
  72.             var6 = var9.getInputStream();
  73.             if (this.inputBuf == null) {
  74.                this.inputBuf = new byte[4096];
  75.             }
  76.  
  77.             Thread var11 = Thread.currentThread();
  78.  
  79.             int var10;
  80.             while((var10 = var6.read(this.inputBuf)) >= 0 && !var11.isInterrupted()) {
  81.                var14.write(this.inputBuf, 0, var10);
  82.             }
  83.  
  84.             if (var11.isInterrupted()) {
  85.                throw new IOException("interrupted: " + this);
  86.             }
  87.          } finally {
  88.             if (var6 != null) {
  89.                var6.close();
  90.             }
  91.  
  92.             if (var14 != null) {
  93.                var14.close();
  94.             }
  95.  
  96.          }
  97.  
  98.          SecurityManager.revertPrivilege();
  99.          if (wantTiming) {
  100.             long var7 = System.currentTimeMillis();
  101.             long var16 = var7 - var15;
  102.             this.loaderTime += var16;
  103.             System.err.println("# Archive download time: " + this.archiveURL + ": " + var16 + " (total = " + this.loaderTime + ")");
  104.          }
  105.  
  106.          if (capturingClasses) {
  107.             System.err.println("#\tCaptured archive " + var2);
  108.             this.capturedArchive = true;
  109.          } else if (this.context != null && MozillaAppletContext.debug >= 2) {
  110.             System.err.println("# Loading classes from downloaded archive file: " + this.archiveURL);
  111.          }
  112.  
  113.          return var2;
  114.       }
  115.    }
  116.  
  117.    native String getTempName();
  118.  
  119.    private native int openArchive0(String var1) throws IOException;
  120.  
  121.    private native byte[] loadFromArchive0(int var1, String var2) throws IOException;
  122.  
  123.    private native void closeArchive0(int var1) throws IOException;
  124.  
  125.    void openArchive() {
  126.       try {
  127.          this.archiveFile = this.grabArchiveFile();
  128.          if (this.archiveFile == null) {
  129.             return;
  130.          }
  131.  
  132.          this.nativeArchive = this.openArchive0(this.archiveFile);
  133.          if (this.nativeArchive != 0) {
  134.             this.nativeZig = this.setupZignature();
  135.             if (this.nativeZig != 0) {
  136.                if (!this.loadManifest(this.nativeArchive, this.nativeZig, this.codeBaseURL.getFile()) || this.loadSignatures(this.nativeArchive, this.nativeZig, this.codeBaseURL.getFile()) <= 0) {
  137.                   this.nativeZig = 0;
  138.                }
  139.  
  140.                return;
  141.             }
  142.          }
  143.       } catch (IOException var2) {
  144.          ((Throwable)var2).printStackTrace();
  145.          System.err.println("# Unable to load archive " + this.archiveURL + ": " + var2);
  146.          this.nativeZig = 0;
  147.       }
  148.  
  149.    }
  150.  
  151.    byte[] loadFromArchive(String var1) throws IOException {
  152.       return this.nativeArchive != 0 ? this.loadFromArchive0(this.nativeArchive, var1) : null;
  153.    }
  154.  
  155.    void closeArchive() {
  156.       if (this.nativeArchive != 0) {
  157.          try {
  158.             this.closeArchive0(this.nativeArchive);
  159.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  160.                System.err.println("# Closed downloaded archive: " + this.archiveURL);
  161.             }
  162.          } catch (IOException var3) {
  163.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  164.                System.err.println("# Failed to close downloaded archive: " + this.archiveURL);
  165.             }
  166.          }
  167.  
  168.          this.nativeArchive = 0;
  169.          if (!this.capturedArchive) {
  170.             File var1 = new File(this.archiveFile);
  171.             SecurityManager.enablePrivilege("UniversalFileRead");
  172.             SecurityManager.enablePrivilege("UniversalFileDelete");
  173.             boolean var2 = var1.delete();
  174.             SecurityManager.revertPrivilege();
  175.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  176.                if (var2) {
  177.                   System.err.println("# Deleted downloaded archive: " + this.archiveFile);
  178.                   return;
  179.                }
  180.  
  181.                System.err.println("# Failed to delete downloaded archive: " + this.archiveFile);
  182.             }
  183.          }
  184.       }
  185.  
  186.    }
  187.  
  188.    static synchronized AppletClassLoader getClassLoader(MozillaAppletContext var0, URL var1, URL var2, boolean var3, boolean var4) {
  189.       boolean var5 = false;
  190.       AppletClassLoader var6 = null;
  191.       SecurityManager.enablePrivilege("UniversalConnect");
  192.  
  193.       for(int var8 = 0; var8 < classloaders.size(); ++var8) {
  194.          WeakLink var9 = (WeakLink)classloaders.elementAt(var8);
  195.          AppletClassLoader var10 = (AppletClassLoader)var9.get();
  196.          if (var10 == null) {
  197.             var5 = true;
  198.          } else {
  199.             String var11 = var1.getFile();
  200.             int var12 = var11.lastIndexOf(47);
  201.             URL var7 = var1;
  202.             if (var12 > 0 && var12 < var11.length() - 1) {
  203.                try {
  204.                   var7 = new URL(var1, var11.substring(0, var12 + 1));
  205.                } catch (MalformedURLException var13) {
  206.                }
  207.             }
  208.  
  209.             if (var7.equals(var10.codeBaseURL)) {
  210.                label78: {
  211.                   boolean var10000;
  212.                   if (var2 == null) {
  213.                      if (var10.archiveURL == null) {
  214.                         break label78;
  215.                      }
  216.  
  217.                      var10000 = false;
  218.                   } else {
  219.                      var10000 = var2.equals(var10.archiveURL);
  220.                   }
  221.  
  222.                   if (!var10000) {
  223.                      continue;
  224.                   }
  225.                }
  226.  
  227.                if (var3 == var10._mayScript && (!var3 || var0 == var10.context) && var10.isReusable) {
  228.                   if (!var4) {
  229.                      var6 = var10;
  230.                      if (MozillaAppletContext.debug >= 8) {
  231.                         System.err.println("#   reusing class loader " + var10 + "\n" + "#\tcontext = " + var0 + "\n" + "#\tcodebase = " + var7 + "\n" + "#\tarchive = " + var2 + "\n" + "#\tmayscript = " + var3);
  232.                      }
  233.                      break;
  234.                   }
  235.  
  236.                   if (MozillaAppletContext.debug >= 8) {
  237.                      System.err.println("#   preventing reuse of " + var10);
  238.                   }
  239.  
  240.                   var10.isReusable = false;
  241.                }
  242.             }
  243.          }
  244.       }
  245.  
  246.       SecurityManager.revertPrivilege();
  247.       if (var6 == null) {
  248.          var6 = new AppletClassLoader(var0, var1, var2);
  249.          var6._mayScript = var3;
  250.          classloaders.addElement(new WeakLink(var6));
  251.       }
  252.  
  253.       if (var5) {
  254.          for(int var14 = classloaders.size() - 1; var14 >= 0; --var14) {
  255.             WeakLink var15 = (WeakLink)classloaders.elementAt(var14);
  256.             if (var15.get() == null) {
  257.                classloaders.removeElementAt(var14);
  258.             }
  259.  
  260.             if (MozillaAppletContext.debug >= 8) {
  261.                System.err.println("#   classloader was removed");
  262.             }
  263.          }
  264.       }
  265.  
  266.       return var6;
  267.    }
  268.  
  269.    synchronized void releaseClassLoader() {
  270.    }
  271.  
  272.    AppletClassLoader(MozillaAppletContext var1, URL var2, URL var3) {
  273.       this.capturedArchive = false;
  274.       this._mayScript = false;
  275.       this.isReusable = true;
  276.       this.codeBasePrincipal = new Principal(var2);
  277.       String var4 = var2.getFile();
  278.       int var5 = var4.lastIndexOf(47);
  279.       if (var5 > 0 && var5 < var4.length() - 1) {
  280.          try {
  281.             var2 = new URL(var2, var4.substring(0, var5 + 1));
  282.          } catch (MalformedURLException var6) {
  283.          }
  284.       }
  285.  
  286.       this.codeBaseURL = var2;
  287.       this.archiveURL = var3;
  288.       this.context = var1;
  289.       if (MozillaAppletContext.debug > 5) {
  290.          System.err.println("#   new class loader " + this + "\n" + "#\tcontext = " + var1 + "\n" + "#\tcodebase = " + var2 + "\n" + "#\tarchive = " + var3);
  291.       }
  292.  
  293.       if (this.archiveURL != null) {
  294.          this.openArchive();
  295.       }
  296.  
  297.    }
  298.  
  299.    void close() {
  300.       if (this.archiveURL != null) {
  301.          this.closeArchive();
  302.       }
  303.  
  304.       if (this.channelInfo != null) {
  305.          this.channelInfo.closeZips();
  306.       }
  307.  
  308.    }
  309.  
  310.    protected void finalize() {
  311.       this.close();
  312.       if (MozillaAppletContext.debug >= 8) {
  313.          System.err.println("# finalized: " + this);
  314.       }
  315.  
  316.    }
  317.  
  318.    protected AppletClassLoader(URL var1) {
  319.       this((MozillaAppletContext)null, var1, (URL)null);
  320.    }
  321.  
  322.    boolean mayScript() {
  323.       return this._mayScript;
  324.    }
  325.  
  326.    public URL getCodeBase() {
  327.       return this.codeBaseURL;
  328.    }
  329.  
  330.    private Class loadClass(String var1, URL var2, String var3) throws IOException {
  331.       SecurityManager.enablePrivilege("UniversalConnect");
  332.       byte[] var4 = var2.getData();
  333.       SecurityManager.revertPrivilege();
  334.       if (capturingClasses) {
  335.          this.captureClassFile(var1, var4);
  336.       }
  337.  
  338.       return ((ClassLoader)this).defineClass(var1, var4, 0, var4.length, this.nativeZig, var3);
  339.    }
  340.  
  341.    public Class loadClass(String var1) throws ClassNotFoundException {
  342.       return this.loadClass(var1, true);
  343.    }
  344.  
  345.    protected final Class loadClass(String var1, boolean var2) throws ClassNotFoundException {
  346.       Class var3;
  347.       if (wantTiming) {
  348.          long var4 = System.currentTimeMillis();
  349.          var3 = this.loadClass1(var1, var2);
  350.          long var6 = System.currentTimeMillis();
  351.          long var8 = var6 - var4;
  352.          this.loaderTime += var8;
  353.          System.err.println("# Class load time: " + var1 + ": " + var8 + " (total = " + this.loaderTime + ")");
  354.       } else {
  355.          var3 = this.loadClass1(var1, var2);
  356.       }
  357.  
  358.       return var3;
  359.    }
  360.  
  361.    private Class loadClass1(String var1, boolean var2) throws ClassNotFoundException {
  362.       Class var3 = ((ClassLoader)this).findLoadedClass(var1);
  363.       if (var3 == null) {
  364.          SecurityManager var4 = System.getSecurityManager();
  365.          if (var4 != null) {
  366.             int var5 = var1.lastIndexOf(46);
  367.             if (var5 >= 0) {
  368.                var4.checkPackageAccess(var1.substring(0, var5));
  369.             }
  370.          }
  371.  
  372.          try {
  373.             return ((ClassLoader)this).findSystemClass(var1);
  374.          } catch (NoClassDefFoundError var8) {
  375.             if (this.channelInfo == null) {
  376.                throw var8;
  377.             }
  378.          } catch (ClassNotFoundException var9) {
  379.          }
  380.  
  381.          var3 = this.findClass(var1);
  382.       }
  383.  
  384.       if (var3 == null) {
  385.          throw new ClassNotFoundException(var1);
  386.       } else {
  387.          if (this.nativeArchive != 0) {
  388.             System.getSecurityManager().checkURLConnect(this.codeBaseURL, this.archiveURL);
  389.          }
  390.  
  391.          if (var2) {
  392.             try {
  393.                ((ClassLoader)this).resolveClass(var3);
  394.             } catch (NoClassDefFoundError var6) {
  395.                if (this.channelInfo == null) {
  396.                   throw var6;
  397.                }
  398.  
  399.                throw new ClassNotFoundException(var1);
  400.             } catch (UnknownError var7) {
  401.                if (this.channelInfo == null) {
  402.                   throw var7;
  403.                }
  404.  
  405.                throw new ClassNotFoundException(var1);
  406.             }
  407.          }
  408.  
  409.          return var3;
  410.       }
  411.    }
  412.  
  413.    private synchronized Class findClass(String var1) throws ClassNotFoundException {
  414.       boolean var2 = true;
  415.       Class var3 = ((ClassLoader)this).findLoadedClass(var1);
  416.       if (var3 != null) {
  417.          return var3;
  418.       } else {
  419.          if (MozillaAppletContext.debug >= 2) {
  420.             System.err.println("# Loading class " + var1);
  421.          }
  422.  
  423.          SecurityManager var4 = System.getSecurityManager();
  424.          if (var4 != null) {
  425.             int var5 = var1.lastIndexOf(46);
  426.             if (var5 >= 0) {
  427.                var4.checkPackageDefinition(var1.substring(0, var5));
  428.             }
  429.          }
  430.  
  431.          String var14 = var1.replace('.', '/') + ".class";
  432.          if (this.nativeArchive != 0) {
  433.             try {
  434.                byte[] var6 = this.loadFromArchive(var14);
  435.                if (var6 != null) {
  436.                   var3 = ((ClassLoader)this).defineClass(var1, var6, 0, var6.length, this.nativeZig, var14);
  437.                   if (var3 != null && this.context != null && MozillaAppletContext.debug >= 2) {
  438.                      System.err.println("# Loaded " + var14 + " from " + this.archiveURL);
  439.                   }
  440.  
  441.                   var2 = false;
  442.                }
  443.             } catch (IOException var12) {
  444.                if (MozillaAppletContext.debug >= 2) {
  445.                   System.err.println("# Failed to load " + var14 + " from " + this.archiveURL);
  446.                }
  447.             }
  448.          }
  449.  
  450.          if (var3 == null) {
  451.             URL var15;
  452.             try {
  453.                var15 = new URL(this.codeBaseURL, var14);
  454.             } catch (MalformedURLException var9) {
  455.                throw new ClassNotFoundException(var1);
  456.             }
  457.  
  458.             if (this.context != null && MozillaAppletContext.debug >= 5) {
  459.                System.err.println("# Fetching " + var15);
  460.             }
  461.  
  462.             try {
  463.                var3 = this.loadClass(var1, var15, var14);
  464.                var2 = false;
  465.             } catch (IOException var10) {
  466.                if (this.channelInfo != null) {
  467.                   try {
  468.                      var3 = this.marimbaLoad(var1);
  469.                      var2 = false;
  470.                   } catch (IOException var8) {
  471.                   }
  472.                }
  473.  
  474.                if (var3 == null) {
  475.                   throw new ClassNotFoundException(var1);
  476.                }
  477.             } catch (SecurityException var11) {
  478.                if (this.context != null && MozillaAppletContext.debug >= 5) {
  479.                   System.err.println("# Exception while loading " + var14 + " from downloaded archive " + var15.toString() + "\n#   Exception: " + ((Throwable)var11).toString());
  480.                }
  481.  
  482.                throw var11;
  483.             }
  484.          }
  485.  
  486.          if (!var1.equals(var3.getName())) {
  487.             Class var16 = var3;
  488.             Object var13 = null;
  489.             throw new ClassFormatError(var1 + " != " + var16.getName());
  490.          } else {
  491.             if (!var2) {
  492.                this.setPrincipalAry(var3, var14);
  493.             }
  494.  
  495.             return var3;
  496.          }
  497.       }
  498.    }
  499.  
  500.    static boolean getCaptureClassFiles() {
  501.       return capturingClasses;
  502.    }
  503.  
  504.    static void setCaptureClassFiles(boolean var0) {
  505.       capturingClasses = var0;
  506.    }
  507.  
  508.    String getCaptureDir() throws IOException {
  509.       String var1 = this.codeBaseURL.toString();
  510.       if (var1.startsWith("http://")) {
  511.          var1 = var1.substring(7);
  512.       }
  513.  
  514.       if (var1.endsWith("/")) {
  515.          var1 = var1.substring(0, var1.length() - 1);
  516.       }
  517.  
  518.       var1 = var1.replace('/', '_').replace(':', '_');
  519.       SecurityManager.enablePrivilege("UniversalFileRead");
  520.       SecurityManager.enablePrivilege("UniversalFileWrite");
  521.       File var2 = new File(var1);
  522.       if ((!var2.exists() || !var2.isDirectory()) && !var2.mkdir()) {
  523.          throw new IOException(var2 + " is not a directory");
  524.       } else {
  525.          return var1;
  526.       }
  527.    }
  528.  
  529.    void captureClassFile(String var1, byte[] var2) {
  530.       try {
  531.          String var3 = this.getCaptureDir();
  532.          SecurityManager.enablePrivilege("UniversalFileWrite");
  533.          File var4 = new File(var3 + "/" + var1 + ".class");
  534.          FileOutputStream var5 = new FileOutputStream(var4);
  535.          var5.write(var2, 0, var2.length);
  536.          System.err.println("#\tCaptured class " + var4);
  537.          var5.close();
  538.       } catch (SecurityException var6) {
  539.          System.err.println("#\tCan't capture class: " + var6);
  540.       } catch (IOException var7) {
  541.          System.err.println("#\tCan't capture class: " + var7);
  542.       }
  543.    }
  544.  
  545.    byte[] getResource(URL var1) {
  546.       byte[] var2 = null;
  547.       String var3 = var1.getFile();
  548.       String var4 = this.codeBaseURL.getFile();
  549.       if (!var3.startsWith(var4)) {
  550.          return null;
  551.       } else {
  552.          String var5 = var3.substring(var4.length());
  553.  
  554.          try {
  555.             var2 = this.loadFromArchive(var5);
  556.             if (var2 != null && this.context != null && MozillaAppletContext.debug >= 5) {
  557.                System.err.println("# Loaded " + var5 + " from " + this.archiveURL);
  558.             }
  559.          } catch (IOException var6) {
  560.             if (MozillaAppletContext.debug >= 5) {
  561.                System.err.println("# Failed to load " + var5 + " from " + this.archiveURL);
  562.             }
  563.          }
  564.  
  565.          return var2;
  566.       }
  567.    }
  568.  
  569.    private boolean setPrincipalAry(Class var1, String var2) {
  570.       Object var3 = null;
  571.       int var4 = 1;
  572.       Object[] var5 = getCertificates(this.nativeZig, var2);
  573.       if (var5 != null) {
  574.          var4 += var5.length;
  575.       }
  576.  
  577.       Principal[] var12 = new Principal[var4];
  578.  
  579.       for(int var6 = var4 - 1; var6-- > 0; var12[var6] = new Principal(14, (byte[])var5[var6], var1)) {
  580.       }
  581.  
  582.       var12[var4 - 1] = this.codeBasePrincipal;
  583.  
  584.       try {
  585.          if (this.matchPrincipalAry != null) {
  586.             PrivilegeManager var9 = AppletSecurity.getPrivilegeManager();
  587.             if (var9 != null && var9.comparePrincipalArray(var12, this.matchPrincipalAry) == 1) {
  588.                var12 = new Principal[]{this.codeBasePrincipal};
  589.                throw new AppletSecurityException("mismatch of principals");
  590.             }
  591.          }
  592.       } finally {
  593.          this.setPrincipals(var1, var12);
  594.       }
  595.  
  596.       return true;
  597.    }
  598.  
  599.    public boolean checkMatchPrincipalAlways(int var1) {
  600.       PrivilegeManager var5 = AppletSecurity.getPrivilegeManager();
  601.       if (var5 == null) {
  602.          return true;
  603.       } else {
  604.          this.matchPrincipalAry = var5.getClassPrincipalsFromStack(var1 + 1);
  605.          Enumeration var2 = ((ClassLoader)this).getClassNames();
  606.  
  607.          while(var2.hasMoreElements()) {
  608.             String var4 = (String)var2.nextElement();
  609.             Class var3 = ((ClassLoader)this).findLoadedClass(var4);
  610.             if (var3 != null && !var5.checkMatchPrincipal(var3, var1 + 1)) {
  611.                return false;
  612.             }
  613.          }
  614.  
  615.          return true;
  616.       }
  617.    }
  618.  
  619.    private native int setupZignature();
  620.  
  621.    private native int destroyZignature(int var1);
  622.  
  623.    private native boolean loadManifest(int var1, int var2, String var3);
  624.  
  625.    private native int loadSignatures(int var1, int var2, String var3);
  626.  
  627.    private native boolean verifySignature(int var1, Class var2, String var3);
  628.  
  629.    private static native Object[] getCertificates(int var0, String var1);
  630.  
  631.    private native void setPrincipals(Class var1, Principal[] var2);
  632.  
  633.    public AppletClassLoader(URL var1, CastanetChannelInfo var2) {
  634.       this((MozillaAppletContext)null, var1, (URL)null);
  635.       this.channelInfo = var2;
  636.    }
  637.  
  638.    public Class classFromBytes(byte[] var1, String var2) {
  639.       if (this.channelInfo == null) {
  640.          return null;
  641.       } else {
  642.          Class var3 = ((ClassLoader)this).findLoadedClass(var2);
  643.          if (var3 != null) {
  644.             return var3;
  645.          } else {
  646.             try {
  647.                var3 = ((ClassLoader)this).findSystemClass(var2);
  648.                if (var3 != null) {
  649.                   return var3;
  650.                }
  651.             } catch (NoClassDefFoundError var8) {
  652.             } catch (ClassNotFoundException var9) {
  653.             }
  654.  
  655.             SecurityManager var4 = System.getSecurityManager();
  656.             if (var4 != null) {
  657.                int var5 = var2.lastIndexOf(46);
  658.                if (var5 >= 0) {
  659.                   var4.checkPackageDefinition(var2.substring(0, var5));
  660.                }
  661.             }
  662.  
  663.             PrivilegeManager var12 = PrivilegeManager.getPrivilegeManager();
  664.             if (var12 != null) {
  665.                Target var6 = Target.findTarget("MarimbaInternalTarget");
  666.                if (var6 == null) {
  667.                   throw new AppletSecurityException("classFromBytes call denied");
  668.                }
  669.  
  670.                var12.checkPrivilegeEnabled(var6);
  671.             }
  672.  
  673.             try {
  674.                var3 = ((ClassLoader)this).defineClass(var2, var1, 0, var1.length);
  675.                return var3;
  676.             } catch (NoClassDefFoundError var7) {
  677.                return null;
  678.             }
  679.          }
  680.       }
  681.    }
  682.  
  683.    private Class marimbaLoad(String var1) throws IOException, ClassNotFoundException {
  684.       if (this.channelInfo == null) {
  685.          return null;
  686.       } else {
  687.          Class var2 = null;
  688.          int var3 = this.channelInfo.getPathlen();
  689.          if (var3 != 0) {
  690.             String var4 = var1.replace('.', '/') + ".class";
  691.  
  692.             for(int var5 = 0; var5 < var3; ++var5) {
  693.                URL var6 = this.channelInfo.getURL(var5);
  694.                if (var6 != null) {
  695.                   try {
  696.                      var2 = this.loadClass(var1, new URL(var6, var4), var4);
  697.                      if (var2 != null) {
  698.                         return var2;
  699.                      }
  700.                   } catch (NoClassDefFoundError var14) {
  701.                   } catch (MalformedURLException var15) {
  702.                   } catch (FileNotFoundException var16) {
  703.                   }
  704.                }
  705.  
  706.                ZipFile var7 = this.channelInfo.getZip(var5);
  707.                if (var7 != null) {
  708.                   ZipEntry var8 = var7.getEntry(var4);
  709.                   if (var8 != null) {
  710.                      int var9 = (int)var8.getSize();
  711.                      byte[] var10 = new byte[var9];
  712.                      InputStream var11 = var7.getInputStream(var8);
  713.  
  714.                      for(int var12 = 0; var12 < var9; var12 += var11.read(var10, var12, var9 - var12)) {
  715.                      }
  716.  
  717.                      var11.close();
  718.  
  719.                      try {
  720.                         var2 = ((ClassLoader)this).defineClass(var1, var10, 0, var10.length);
  721.                      } catch (NoClassDefFoundError var13) {
  722.                      }
  723.  
  724.                      if (var2 != null) {
  725.                         return var2;
  726.                      }
  727.                   }
  728.                }
  729.             }
  730.          }
  731.  
  732.          return null;
  733.       }
  734.    }
  735.  
  736.    public boolean marimbaCheckRead(String var1, boolean var2) {
  737.       return this.channelInfo != null ? this.channelInfo.checkRead(var1, var2) : false;
  738.    }
  739.  
  740.    public boolean marimbaCheckWrite(String var1, boolean var2) {
  741.       return this.channelInfo != null ? this.channelInfo.checkWrite(var1, var2) : false;
  742.    }
  743.  
  744.    public String marimbaGetHost() {
  745.       return this.channelInfo != null ? this.channelInfo.getHost() : null;
  746.    }
  747.  
  748.    boolean marimbaCheckThreadGroup(ThreadGroup var1) {
  749.       return this.channelInfo == null ? false : this.channelInfo.checkThreadGroup(var1);
  750.    }
  751.  
  752.    void marimbaCheckTopLevelWindow(Object var1) {
  753.       if (this.channelInfo != null) {
  754.          this.channelInfo.checkTopLevelWindow(var1);
  755.       }
  756.    }
  757.  
  758.    Hashtable getCodebaseEnv() {
  759.       if (this.codebaseEnv == null) {
  760.          this.initCodebaseEnv();
  761.       }
  762.  
  763.       return this.codebaseEnv;
  764.    }
  765.  
  766.    synchronized void initCodebaseEnv() {
  767.       if (this.codebaseEnv == null) {
  768.          this.codebaseEnv = new Hashtable();
  769.       }
  770.  
  771.    }
  772. }
  773.