public virtual CodeSigner[] GetCodeSigners(JarFile jar, JarEntry entry) { String name = entry.Name; if (EagerValidation_Renamed && SigFileSigners.Get(name) != null) { /* * Force a read of the entry data to generate the * verification hash. */ try { InputStream s = jar.GetInputStream(entry); sbyte[] buffer = new sbyte[1024]; int n = buffer.Length; while (n != -1) { n = s.Read(buffer, 0, buffer.Length); } s.Close(); } catch (IOException) { } } return(GetCodeSigners(name)); }
public JarEntryIterator(JarFile outerInstance) { this.OuterInstance = outerInstance; if (!InstanceFieldsInitialized) { InitializeInstanceFields(); InstanceFieldsInitialized = true; } }
/* * Like entries() but screens out internal JAR mechanism entries * and includes signed entries with no ZIP data. */ //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: //ORIGINAL LINE: public java.util.Iterator<JarEntry> entries2(final JarFile jar, java.util.Iterator<? extends java.util.zip.ZipEntry> e) public virtual IEnumerator <JarEntry> Entries2(JarFile jar, IEnumerator <T1> e) where T1 : java.util.zip.ZipEntry { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Map<String, CodeSigner[]> map = new HashMap<>(); Map <String, CodeSigner[]> map = new HashMap <String, CodeSigner[]>(); map.PutAll(SignerMap()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Iterator<? extends java.util.zip.ZipEntry> enum_ = e; //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: IEnumerator <?> enum_ = e; return(new IteratorAnonymousInnerClassHelper2(this, jar, map, enum_)); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: //ORIGINAL LINE: public synchronized java.util.Iterator<String> entryNames(JarFile jar, final CodeSource[] cs) public virtual IEnumerator <String> EntryNames(JarFile jar, CodeSource[] cs) { lock (this) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Map<String, CodeSigner[]> map = signerMap(); Map <String, CodeSigner[]> map = SignerMap(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Iterator<Map_Entry<String, CodeSigner[]>> itor = map.entrySet().iterator(); Iterator <Map_Entry <String, CodeSigner[]> > itor = map.EntrySet().Iterator(); bool matchUnsigned = false; /* * Grab a single copy of the CodeSigner arrays. Check * to see if we can optimize CodeSigner equality test. */ List <CodeSigner[]> req = new List <CodeSigner[]>(cs.Length); for (int i = 0; i < cs.Length; i++) { CodeSigner[] match = FindMatchingSigners(cs[i]); if (match != null) { if (match.Length > 0) { req.Add(match); } else { matchUnsigned = true; } } else { matchUnsigned = true; } } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final List<CodeSigner[]> signersReq = req; List <CodeSigner[]> signersReq = req; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Iterator<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration; IEnumerator <String> enum2 = (matchUnsigned) ? UnsignedEntryNames(jar) : emptyEnumeration; return(new IteratorAnonymousInnerClassHelper(this, itor, signersReq, enum2)); } }
private static string GetMainClassFromJarManifest(string mainClass) { JarFile jf = new JarFile(mainClass); try { Manifest manifest = jf.getManifest(); if (manifest == null) { Console.Error.WriteLine("Jar file doesn't contain manifest"); return null; } mainClass = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS); } finally { jf.close(); } if (mainClass == null) { Console.Error.WriteLine("Manifest doesn't contain a Main-Class."); return null; } return mainClass.Replace('/', '.'); }
public virtual java.security.cert.Certificate[] GetCerts(JarFile jar, JarEntry entry) { return(MapSignersToCertArray(GetCodeSigners(jar, entry))); }
public virtual IList <Object> GetManifestDigests(JarFile jar) { return(jar.ManifestDigests); }
public virtual void SetEagerValidation(JarFile jar, bool eager) { jar.EagerValidation = eager; }
public virtual IEnumerator <JarEntry> Entries2(JarFile jar) { return(jar.Entries2()); }
public virtual IEnumerator <String> EntryNames(JarFile jar, CodeSource[] cs) { return(jar.EntryNames(cs)); }
public virtual CodeSource GetCodeSource(JarFile jar, URL url, String name) { return(jar.GetCodeSource(url, name)); }
public virtual CodeSource[] GetCodeSources(JarFile jar, URL url) { return(jar.GetCodeSources(url)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public boolean jarFileHasClassPathAttribute(JarFile jar) throws java.io.IOException public virtual bool JarFileHasClassPathAttribute(JarFile jar) { return(jar.HasClassPathAttribute()); }
public static void findExtensions(ProgressMonitor monitor, int min, int max) { monitor.setNote("Loading Extensions"); File file1 = new File("./extensions"); File file2 = new File("./lib"); File file3 = new File("./extensions/lib"); URLClassLoader urlClassLoader1 = (URLClassLoader) ClassLoader.getSystemClassLoader(FileSniffer.__\u003CGetCallerID\u003E()); Class class1 = (Class) ClassLiteral<URLClassLoader>.Value; Method declaredMethod; Exception exception1; try { Class class2 = class1; string str = "addURL"; Class[] classArray = new Class[1]; int index = 0; // ISSUE: variable of the null type __Null local = ClassLiteral<URL>.Value; classArray[index] = (Class) local; CallerID callerId = FileSniffer.__\u003CGetCallerID\u003E(); declaredMethod = class2.getDeclaredMethod(str, classArray, callerId); ((AccessibleObject) declaredMethod).setAccessible(true); goto label_6; } catch (Exception ex) { int num = 0; M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num); if (m0 == null) throw; else exception1 = (Exception) m0; } Throwable.instancehelper_printStackTrace((Exception) exception1); monitor.setProgress(max); return; label_6: File[] fileArray1 = new File[3]; int index1 = 0; File file4 = file2; fileArray1[index1] = file4; int index2 = 1; File file5 = file3; fileArray1[index2] = file5; int index3 = 2; File file6 = file1; fileArray1[index3] = file6; File[] fileArray2 = fileArray1; int length1 = fileArray2.Length; for (int index4 = 0; index4 < length1; ++index4) { File file7 = fileArray2[index4]; if (!file7.exists()) { monitor.setProgress(min + (max - min) / 5); } else { System.get_out().println(new StringBuilder().append("Searching Folder:").append((object) file7).toString()); monitor.setNote(new StringBuilder().append("Searching Folder:").append((object) file7).toString()); File[] fileArray3 = file7.listFiles((FilenameFilter) new FileSniffer\u00241()); if (fileArray3 == null) { monitor.setProgress(min + (max - min) / 5); } else { File[] fileArray4 = fileArray3; int length2 = fileArray4.Length; for (int index5 = 0; index5 < length2; ++index5) { File file8 = fileArray4[index5]; System.get_out().println(new StringBuilder().append("Adding Jar:").append((object) file8).toString()); Exception exception2; try { Method method = declaredMethod; URLClassLoader urlClassLoader2 = urlClassLoader1; object[] objArray = new object[1]; int index6 = 0; URL url = file8.toURI().toURL(); objArray[index6] = (object) url; CallerID callerId = FileSniffer.__\u003CGetCallerID\u003E(); method.invoke((object) urlClassLoader2, objArray, callerId); continue; } catch (Exception ex) { int num = 0; M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num); if (m0 == null) throw; else exception2 = (Exception) m0; } Throwable.instancehelper_printStackTrace((Exception) exception2); } monitor.setProgress(min + (max - min) / 5); } } } if (!file1.exists()) { System.get_out().println("No Extension Folder"); monitor.setProgress(max); } else { File[] fileArray3 = file1.listFiles((FilenameFilter) new FileSniffer\u00242()); double num1 = 0.0; File[] fileArray4 = fileArray3; int length2 = fileArray4.Length; label_26: for (int index4 = 0; index4 < length2; ++index4) { File file7 = fileArray4[index4]; System.get_out().println(new StringBuilder().append("Searching Jar:").append((object) file7).toString()); monitor.setProgress(ByteCodeHelper.d2i((double) (min + max) / 2.0 * (1.0 + num1++ / (double) fileArray3.Length))); monitor.setNote(new StringBuilder().append("Searching Jar:").append((object) file7).toString()); Enumeration enumeration; Exception exception2; try { enumeration = new JarFile(file7).entries(); goto label_31; } catch (Exception ex) { int num2 = 0; exception2 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2); } Exception exception3 = exception2; goto label_52; label_31: Exception exception4; Exception exception5; while (true) { Class class2; try { string name; do { if (enumeration.hasMoreElements()) name = ((ZipEntry) enumeration.nextElement()).getName(); else goto label_26; } while (!String.instancehelper_endsWith(name, ".class")); class2 = (Class) null; try { try { try { class2 = Class.forName(String.instancehelper_replaceAll(String.instancehelper_substring(name, 0, String.instancehelper_length(name) - 6), "/", "."), false, (ClassLoader) urlClassLoader1, FileSniffer.__\u003CGetCallerID\u003E()); DisplayElementRegistry.registerWidget(class2.asSubclass((Class) ClassLiteral<Widget>.Value)); System.get_out().println(new StringBuilder().append("Custom Widget:").append(class2.getSimpleName()).toString()); continue; } catch (Exception ex) { int num2 = 2; if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num2) == null) throw; } } catch (ClassNotFoundException ex) { goto label_42; } } catch (Exception ex) { int num2 = 2; if (ByteCodeHelper.MapException<NoClassDefFoundError>(ex, (ByteCodeHelper.MapFlags) num2) == null) throw; else goto label_43; } } catch (Exception ex) { int num2 = 0; exception4 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2); break; } try { try { DisplayElementRegistry.registerStaticWidget(class2.asSubclass((Class) ClassLiteral<StaticWidget>.Value)); System.get_out().println(new StringBuilder().append("Custom Static Widget:").append(class2.getSimpleName()).toString()); } catch (Exception ex) { int num2 = 2; if (ByteCodeHelper.MapException<ClassCastException>(ex, (ByteCodeHelper.MapFlags) num2) == null) throw; } } catch (Exception ex) { int num2 = 0; exception5 = (Exception) ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2); goto label_51; } continue; label_42: continue; label_43:; } exception3 = exception4; goto label_52; label_51: exception3 = exception5; label_52: Throwable.instancehelper_printStackTrace(exception3); System.get_out().println("Error, could not add URL to system classloader"); } monitor.setProgress(max); } }