home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 February / Game.EXE_02_2001.iso / Utilities / Opera 5.01 / Opera501_final_nonjava.exe / OPERA.JAR / opera / CertificateHandler.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-12-07  |  1.6 KB  |  70 lines

  1. package opera;
  2.  
  3. import java.security.CodeSource;
  4. import java.security.Principal;
  5. import java.security.cert.Certificate;
  6. import java.security.cert.CertificateEncodingException;
  7. import java.security.cert.X509Certificate;
  8.  
  9. class CertificateHandler {
  10.    protected static boolean checkCertificates(CodeSource var0) {
  11.       try {
  12.          Certificate[] var1 = var0.getCertificates();
  13.          if (var1.length == 0) {
  14.             return false;
  15.          } else {
  16.             int var2 = 0;
  17.  
  18.             for(int var3 = 0; var3 < var1.length; var2 = var3) {
  19.                int var4;
  20.                for(var4 = var2; var4 + 1 < var1.length && var1[var4] instanceof X509Certificate && var1[var4 + 1] instanceof X509Certificate && isIssuerOf((X509Certificate)var1[var4], (X509Certificate)var1[var4 + 1]); ++var4) {
  21.                }
  22.  
  23.                var3 = var4 + 1;
  24.                byte[][] var5 = makeChain(var1, var2, var3);
  25.                if (var5 != null) {
  26.                   int[] var6 = new int[var5.length];
  27.  
  28.                   for(int var7 = 0; var7 < var5.length; ++var7) {
  29.                      var6[var7] = var5[var7].length;
  30.                   }
  31.  
  32.                   synchronized(var0) {
  33.                      if (acceptCertificateChain(var0, var0.getLocation().toString(), var5, var6, var5.length)) {
  34.                         boolean var9 = true;
  35.                         return var9;
  36.                      }
  37.                   }
  38.                }
  39.             }
  40.  
  41.             return false;
  42.          }
  43.       } catch (CertificateEncodingException var12) {
  44.          return false;
  45.       }
  46.    }
  47.  
  48.    private static boolean isIssuerOf(X509Certificate var0, X509Certificate var1) {
  49.       Principal var2 = var0.getIssuerDN();
  50.       Principal var3 = var1.getSubjectDN();
  51.       return var2.equals(var3);
  52.    }
  53.  
  54.    private static byte[][] makeChain(Certificate[] var0, int var1, int var2) throws CertificateEncodingException {
  55.       if (var1 == var2) {
  56.          return null;
  57.       } else {
  58.          byte[][] var3 = new byte[var2 - var1][];
  59.  
  60.          for(int var4 = var1; var4 < var2; ++var4) {
  61.             var3[var4 - var1] = var0[var4].getEncoded();
  62.          }
  63.  
  64.          return var3;
  65.       }
  66.    }
  67.  
  68.    private static native boolean acceptCertificateChain(CodeSource var0, String var1, byte[][] var2, int[] var3, int var4);
  69. }
  70.