default String etag() { return sha256Hex(Integer.toString(hashCode())); } }
private String getConfigFileMd5(File configFile) { String newMd5; try (FileInputStream inputStream = new FileInputStream(configFile)) { newMd5 = CachedDigestUtils.md5Hex(inputStream); } catch (IOException e) { throw new RuntimeException(e); } return newMd5; }
public static String md5Hex(String string) { return compute(string, DigestObjectPools.MD_5); }
public String md5ForEntity(PipelineGroups pipelineGroups) { List<String> md5s = new ArrayList<>(); for (PipelineConfigs pipelineConfigs : pipelineGroups) { md5s.add(md5ForEntity(pipelineConfigs)); } return CachedDigestUtils.md5Hex(StringUtils.join(md5s, "/")); }
private String etagFor(Object entity) { return sha256Hex(Integer.toString(entity.hashCode())); }
public static String sha256Hex(String string) { if (shaDigestCache.containsKey(string)) { return shaDigestCache.get(string); } String digest = compute(string, DigestObjectPools.SHA_256); shaDigestCache.putIfAbsent(string, digest); return digest; }
public String md5ForEntity(RolesConfig roles) { List<String> md5s = new ArrayList<>(); for (Role role : roles) { md5s.add(md5ForEntity(role)); } return CachedDigestUtils.md5Hex(StringUtils.join(md5s, "/")); }
private String generateFingerprintFromCriteria(Map<String, Object> sqlCriteria) { List<String> list = new ArrayList<>(); for (Map.Entry<String, Object> criteria : sqlCriteria.entrySet()) { list.add(new StringBuilder().append(criteria.getKey()).append("=").append(criteria.getValue()).toString()); } String fingerprint = StringUtils.join(list, FINGERPRINT_DELIMITER); // CAREFUL! the hash algorithm has to be same as the one used in 47_create_new_materials.sql return CachedDigestUtils.sha256Hex(fingerprint); }
private Properties computeChecksumForContentsOfDirectory(File directory, String destPath) throws IOException { Collection<File> fileStructure = FileUtils.listFiles(directory, null, true); Properties checksumProperties = new Properties(); for (File file : fileStructure) { String filePath = removeStart(file.getAbsolutePath(), directory.getParentFile().getAbsolutePath()); try (FileInputStream inputStream = new FileInputStream(file)) { checksumProperties.setProperty(getEffectiveFileName(destPath, FilenameUtils.separatorsToUnix(filePath)), md5Hex(inputStream)); } } return checksumProperties; }
private String generateFingerprintFromCriteria(Map<String, Object> sqlCriteria) { List<String> list = new ArrayList<>(); for (Map.Entry<String, Object> criteria : sqlCriteria.entrySet()) { list.add(new StringBuilder().append(criteria.getKey()).append("=").append(criteria.getValue()).toString()); } String fingerprint = StringUtils.join(list, FINGERPRINT_DELIMITER); // CAREFUL! the hash algorithm has to be same as the one used in 47_create_new_materials.sql return CachedDigestUtils.sha256Hex(fingerprint); }
private Properties computeChecksumForContentsOfDirectory(File directory, String destPath) throws IOException { Collection<File> fileStructure = FileUtils.listFiles(directory, null, true); Properties checksumProperties = new Properties(); for (File file : fileStructure) { String filePath = removeStart(file.getAbsolutePath(), directory.getParentFile().getAbsolutePath()); try (FileInputStream inputStream = new FileInputStream(file)) { checksumProperties.setProperty(getEffectiveFileName(destPath, FilenameUtils.separatorsToUnix(filePath)), md5Hex(inputStream)); } } return checksumProperties; }
public String etagForExport(PipelineConfig pipelineConfig, String groupName) { return sha256Hex(Integer.toString(Objects.hash(pipelineConfig, groupName, crExtension.pluginDescriptorFor(pluginId)))); } }
private Properties artifactChecksums(File source, String destPath) throws IOException { if (source.isDirectory()) { return computeChecksumForContentsOfDirectory(source, destPath); } Properties properties; try (FileInputStream inputStream = new FileInputStream(source)) { properties = computeChecksumForFile(source.getName(), md5Hex(inputStream), destPath); } return properties; }
public String getProcessNamespace(String fingerprint) { return CachedDigestUtils.sha256Hex(fingerprint + agentIdentifier.getUuid() + workingDirectory); }
private String getFromCache(String cacheKey, Object dbObject) { String cachedMD5 = getFromCache(cacheKey); if (cachedMD5 != null) { return cachedMD5; } String md5 = CachedDigestUtils.md5Hex(new GsonBuilder().create().toJson(dbObject)); goCache.put(ETAG_CACHE_KEY, cacheKey, md5); return md5; }
public String getProcessNamespace(String fingerprint) { return CachedDigestUtils.sha256Hex(goConfigService.getServerId() + fingerprint);//memoize if necessary(for gc reasons) -jj }
private Properties artifactChecksums(File source, String destPath) throws IOException { if (source.isDirectory()) { return computeChecksumForContentsOfDirectory(source, destPath); } Properties properties = null; try (FileInputStream inputStream = new FileInputStream(source)) { properties = computeChecksumForFile(source.getName(), md5Hex(inputStream), destPath); } return properties; }
public String getFingerprint() { List<String> list = new ArrayList<>(); list.add(format("%s=%s", "plugin-id", getPluginId())); handleSCMProperties(list); String fingerprint = StringUtils.join(list, AbstractMaterialConfig.FINGERPRINT_DELIMITER); // CAREFUL! the hash algorithm has to be same as the one used in 47_create_new_materials.sql return CachedDigestUtils.sha256Hex(fingerprint); }
public void handle(InputStream stream) throws IOException { ZipInputStream zipInputStream = new ZipInputStream(stream); LOG.info("[Agent Fetch Artifact] Downloading from '{}' to '{}'. Will read from Socket stream to compute MD5 and write to file", srcFile, destOnAgent.getAbsolutePath()); long before = System.currentTimeMillis(); new ZipUtil((entry, stream1) -> { LOG.info("[Agent Fetch Artifact] Downloading a directory from '{}' to '{}'. Handling the entry: '{}'", srcFile, destOnAgent.getAbsolutePath(), entry.getName()); new ChecksumValidator(artifactMd5Checksums).validate(getSrcFilePath(entry), md5Hex(stream1), checksumValidationPublisher); }).unzip(zipInputStream, destOnAgent); LOG.info("[Agent Fetch Artifact] Downloading a directory from '{}' to '{}'. Took: {}ms", srcFile, destOnAgent.getAbsolutePath(), System.currentTimeMillis() - before); }
public String getFingerprint(String fingerprintDelimiter) { List<String> list = new ArrayList<>(); list.add(format("%s=%s", "plugin-id", pluginId())); handlePackageDefinitionProperties(list); handlePackageRepositoryProperties(list); String fingerprint = StringUtils.join(list, fingerprintDelimiter); // CAREFUL! the hash algorithm has to be same as the one used in 47_create_new_materials.sql return CachedDigestUtils.sha256Hex(fingerprint); }