@Override protected void post(final Path file, final MessageDigest digest, final BaseB2Response response) throws BackgroundException { this.verify(file, digest, Checksum.parse(StringUtils.removeStart(((B2FileResponse) response).getContentSha1(), "unverified:"))); }
@Override protected void post(final Path file, final MessageDigest digest, final StorageObject part) throws BackgroundException { if(null != part.getServerSideEncryptionAlgorithm()) { log.warn(String.format("Skip checksum verification for %s with server side encryption enabled", file)); return; } this.verify(file, digest, Checksum.parse(part.getETag())); }
@Override protected void post(final Path file, final MessageDigest digest, final StorageObject response) throws BackgroundException { this.verify(file, digest, Checksum.parse(response.getMd5sum())); } }
@Override protected void verify(final Path file, final MessageDigest digest, final Checksum checksum) throws ChecksumException { if(null == digest) { log.debug(String.format("Digest verification disabled for file %s", file)); return; } if(file.getType().contains(Path.Type.encrypted)) { log.warn(String.format("Skip checksum verification for %s with client side encryption enabled", file)); return; } final String expected = Hex.encodeHexString(digest.digest()); if(!checksum.equals(Checksum.parse(expected))) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", checksum.algorithm.toString(), expected, checksum.hash)); } }
protected void verify(final Path file, final MessageDigest digest, final Checksum checksum) throws ChecksumException { if(file.getType().contains(Path.Type.encrypted)) { log.warn(String.format("Skip checksum verification for %s with client side encryption enabled", file)); return; } if(null == digest) { log.debug(String.format("Digest disabled for file %s", file)); return; } if(null == checksum) { log.warn("ETag returned by server is unknown checksum algorithm"); return; } if(!checksum.algorithm.equals(HashAlgorithm.md5)) { log.warn(String.format("ETag %s returned by server is %s but expected MD5", checksum.hash, checksum.algorithm)); return; } // Obtain locally-calculated MD5 hash. final String expected = Hex.encodeHexString(digest.digest()); // Compare our locally-calculated hash with the ETag returned by S3. if(!checksum.equals(Checksum.parse(expected))) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format("Mismatch between MD5 hash {0} of uploaded data and ETag {1} returned by the server", expected, checksum.hash)); } }
protected PathAttributes toAttributes(final B2FileResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(response.getContentLength()); if(response.getFileInfo().containsKey(X_BZ_INFO_LARGE_FILE_SHA1)) { attributes.setChecksum(Checksum.parse(response.getFileInfo().get(X_BZ_INFO_LARGE_FILE_SHA1))); } else { attributes.setChecksum(Checksum.parse(StringUtils.removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:"))); } final Map<String, String> metadata = new HashMap<>(); for(Map.Entry<String, String> entry : response.getFileInfo().entrySet()) { metadata.put(entry.getKey(), entry.getValue()); } attributes.setMetadata(metadata); attributes.setVersionId(response.getFileId()); if(response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate(Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } return attributes; }
protected PathAttributes toAttributes(final StorageObject object) { final PathAttributes attributes = new PathAttributes(); if(StringUtils.isNotBlank(object.getMd5sum())) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.parse(object.getMd5sum())); } attributes.setSize(object.getSize()); final String lastModified = object.getLastModified(); if(lastModified != null) { try { attributes.setModificationDate(iso8601DateParser.parse(lastModified).getTime()); } catch(InvalidDateException e) { log.warn(String.format("%s is not ISO 8601 format %s", lastModified, e.getMessage())); try { attributes.setModificationDate(rfc1123DateFormatter.parse(lastModified).getTime()); } catch(InvalidDateException f) { log.warn(String.format("%s is not RFC 1123 format %s", lastModified, f.getMessage())); } } } return attributes; }
protected PathAttributes toAttributes(final ObjectMetadata metadata) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(Long.valueOf(metadata.getContentLength())); final String lastModified = metadata.getLastModified(); try { attributes.setModificationDate(rfc1123DateFormatter.parse(lastModified).getTime()); } catch(InvalidDateException e) { log.warn(String.format("%s is not RFC 1123 format %s", lastModified, e.getMessage())); } if(StringUtils.isNotBlank(metadata.getETag())) { final String etag = StringUtils.removePattern(metadata.getETag(), "\""); attributes.setETag(etag); if(metadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.NONE); } else { attributes.setChecksum(Checksum.parse(etag)); } } return attributes; } }
public PathAttributes toAttributes(final Node node) throws BackgroundException { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(String.valueOf(node.getId())); attributes.setRevision(node.getBranchVersion()); attributes.setChecksum(Checksum.parse(node.getHash())); attributes.setCreationDate(node.getCreatedAt() != null ? node.getCreatedAt().getMillis() : -1L); attributes.setModificationDate(node.getUpdatedAt() != null ? node.getUpdatedAt().getMillis() : -1L); attributes.setSize(node.getSize()); attributes.setPermission(this.toPermission(node)); attributes.setAcl(this.toAcl(node)); final Map<String, String> custom = new HashMap<>(); if(null != node.getCntDownloadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_DOWNLOADSHARES, String.valueOf(node.getCntDownloadShares())); } if(null != node.getCntUploadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_UPLOADSHARES, String.valueOf(node.getCntUploadShares())); } custom.put(SDSAttributesFinderFeature.KEY_ENCRYPTED, String.valueOf(node.getIsEncrypted())); attributes.setCustom(custom); return attributes; }
attributes.setChecksum(Checksum.parse(headers.get(HttpHeaders.CONTENT_MD5)));
attributes.setChecksum(Checksum.parse(object.getETag()));
segment.attributes().setChecksum(Checksum.parse(s.getMd5sum()));
attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone());
/** * @param response List filenames response from server * @return Null when respone filename is not child of working directory directory */ protected PathAttributes parse(final B2FileInfoResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setChecksum( Checksum.parse(StringUtils.removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:")) ); final long timestamp = response.getUploadTimestamp(); if(response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate(Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } else { attributes.setModificationDate(timestamp); } attributes.setVersionId(response.getFileId()); switch(response.getAction()) { case hide: // File version marking the file as hidden, so that it will not show up in b2_list_file_names case start: // Large file has been started, but not finished or canceled attributes.setDuplicate(true); attributes.setSize(-1L); break; default: attributes.setSize(response.getSize()); } return attributes; }
attributes.setCreationDate(f.getCreatedTime().getValue()); attributes.setChecksum(Checksum.parse(f.getMd5Checksum())); if(StringUtils.isNotBlank(f.getWebViewLink())) { attributes.setLink(new DescriptiveUrl(URI.create(f.getWebViewLink()),
attributes.setETag(blob.getProperties().getEtag()); if(StringUtils.isNotBlank(blob.getProperties().getContentMD5())) { attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(blob.getProperties().getContentMD5()))));
@Override public PathAttributes find(final Path file) throws BackgroundException { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if(!f.exists()) { throw new NotfoundException(file.getAbsolute()); } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(f.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); return attributes; } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } }
attributes.setAcl(new AclDictionary().deserialize(aclObj)); attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum"))); attributes.setVersionId(dict.stringForKey("Version")); final String duplicateObj = dict.stringForKey("Duplicate");
.getDataObjectChecksumUtilitiesAO(fs.getIRODSAccount()); final ChecksumValue value = checksum.computeChecksumOnDataObject(f); final Checksum fingerprint = Checksum.parse(value.getChecksumStringValue()); if(null == fingerprint) { log.warn(String.format("Unsupported checksum algorithm %s", value.getChecksumEncoding()));
attributes.setModificationDate(properties.getLastModified().getTime()); if(StringUtils.isNotBlank(properties.getContentMD5())) { attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(properties.getContentMD5()))));