@Override public int hashCode(){ return this.getSHA1().hashCode(); }
private synchronized String getShaFromCachedJarAnalyzer(URL _jar_url) { // Build the JarAnalyzer (if possible) and put it into the cache if(!this.jarAnalyzersCache.containsKey(_jar_url)) { JarAnalyzer ja = null; try { final URI uri = _jar_url.toURI(); final File file = Paths.get(uri).toFile(); ja = new JarAnalyzer(); ja.analyze(file); } catch (InvalidPathException ex) { log.error("Invalid path [" + _jar_url + "]: " + ex.getMessage(), ex); } catch (FileAnalysisException ex) { log.error("Error analyzing the JAR at [" + _jar_url + "]: " + ex.getMessage(), ex); } catch(java.nio.file.FileSystemNotFoundException fsnfe) { log.error("File system not found for [" + _jar_url + "]: " + fsnfe.getMessage(), fsnfe); } catch (URISyntaxException e) { log.error("URI syntax exception for [" + _jar_url + "]: " + e.getMessage(), e); } this.jarAnalyzersCache.put(_jar_url, ja); // ja can be null } // Return the digest or null (if the JarAnalyzer could not be built) final JarAnalyzer ja = this.jarAnalyzersCache.get(_jar_url); if(ja!=null) return ja.getSHA1(); else return null; } }
public JsonObject toJSON(){ final JsonObject rootObj = new JsonObject(); rootObj.addProperty("direction", this.direction.toString()); rootObj.add("from", this.caller.toGSON()); rootObj.add("to", this.callee.toGSON()); // Add the archive SHA1 of the OSS (not needed for the application archive, if any) if(this.getJarAnalyzerOfOss()!=null) rootObj.addProperty("archiveId", this.getJarAnalyzerOfOss().getSHA1()); // Callee arguments /*if(this.calleeArgs != null && this.calleeArgs.size()>0){ final JsonArray myArray = new JsonArray(); for(Entry<String, Serializable> entry : this.calleeArgs.entrySet()){ if (entry.getKey().contains("arg_value_")) { String argNumber = entry.getKey().substring(entry.getKey().lastIndexOf('_')+1); JsonObject jo = new JsonObject(); jo.addProperty(this.calleeArgs.get("arg_type_"+argNumber), entry.getValue().toString()); myArray.add(jo); } } rootObj.add("endPointArguments", myArray); }*/ rootObj.addProperty("source", "X2C"); return rootObj; }
/** * This method is called by {@link JarAnalysisManager}. */ public void run() { try { this.getSHA1(); this.getConstructIds(); this.getChilds(true); if(this.instrument) { try { this.createInstrumentedArchive(); } catch(JarAnalysisException jae) { JarAnalyzer.log.error(this.toString() + ": " + jae.getMessage()); } } } catch(Exception e) { JarAnalyzer.log.error(this.toString() + ": Error during analysis: " + e.getMessage()); // for(StackTraceElement el: e.getStackTrace()) // JarAnalyzer.log.error(" " + el.toString()); } }
TouchPoint ase = iter.next(); if(ase.getJarAnalyzerOfOss()!=null) { String archiveId = ase.getJarAnalyzerOfOss().getSHA1(); if(!touchPointByArchiveId.containsKey(archiveId)){ touchPointByArchiveId.put(archiveId, new LinkedList<TouchPoint>());
/** * Returns a {@link Library} representing the analyzed Java archive. * @return * @throws FileAnalysisException */ public Library getLibrary() throws FileAnalysisException { final Library lib = new Library(this.getSHA1()); lib.setDigestAlgorithm(DigestAlgorithm.SHA1); lib.setConstructs(this.getSharedConstructs()); lib.setLibraryId(this.libraryId); final Set<Property> p = new HashSet<Property>(); if(this.jarWriter.getOriginalManifest()!=null) { for(Object key: this.jarWriter.getOriginalManifest().getMainAttributes().keySet()) { p.add(new Property(PropertySource.JAVA_MANIFEST, key.toString(), this.jarWriter.getOriginalManifest().getMainAttributes().get(key).toString())); } } lib.setProperties(p); return lib; }
if(jar_path!=null && this.jarFiles.containsKey(jar_path)) { ja = this.jarFiles.get(jar_path); json.append(",\"lib\":\"").append(ja.getSHA1()).append("\"");
cv.setOriginalArchiveDigest(this.getSHA1()); cv.setAppContext(JarAnalyzer.getAppContext()); if(cv.isInstrumented())