@Override public ChecksumCompute checksum(final Path file) { return ChecksumComputeFactory.get(HashAlgorithm.md5); } }
@Override public ChecksumCompute checksum(final Path file) { return ChecksumComputeFactory.get(HashAlgorithm.md5); } }
@Override public ChecksumCompute checksum(final Path file) { return ChecksumComputeFactory.get(HashAlgorithm.sha256); } }
@Override public ChecksumCompute checksum(final Path file) { return ChecksumComputeFactory.get(HashAlgorithm.sha1); }
@Override public ChecksumCompute checksum(final Path file) { return ChecksumComputeFactory.get(HashAlgorithm.md5); }
/** * The fingerprint of a public key consists of the output of the MD5 * message-digest algorithm [RFC-1321]. The input to the algorithm is * the public key blob as described in [SSH-TRANS]. The output of the * algorithm is presented to the user as a sequence of 16 octets printed * as hexadecimal with lowercase letters and separated by colons. * <p> * For example: "4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21" * * @param in Public key blob * @return The fingerprint is the MD5 of the Base64-encoded public key */ public String fingerprint(final InputStream in) throws ChecksumException { final String undelimited = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(in, new TransferStatus()).hash; final StringBuilder fp = new StringBuilder(undelimited.substring(0, 2)); for(int i = 2; i <= undelimited.length() - 2; i += 2) { fp.append(":").append(undelimited.substring(i, i + 2)); } return fp.toString(); } }
@Override public void cleanup(final Transfer download) { // Save checksum before edit try { checksum = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus()); } catch(BackgroundException e) { log.warn(String.format("Error computing checksum for %s. %s", local, e.getDetail())); } } };
current = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(file.getInputStream(), new TransferStatus()); if(log.isDebugEnabled()) { log.debug(String.format("Current checksum for %s is %s", file, current));
listener.message(MessageFormat.format( LocaleFactory.localizedString("Compute MD5 hash of {0}", "Status"), local.getName())); current = ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), new TransferStatus());
if(append.size == local.attributes().getSize()) { if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) {
@Override public B2UploadPartResponse call() throws BackgroundException { final TransferStatus status = new TransferStatus().length(len); final ByteArrayEntity entity = new ByteArrayEntity(content, off, len); final Checksum checksum = ChecksumComputeFactory.get(HashAlgorithm.sha1) .compute(new ByteArrayInputStream(content, off, len), status); try { return session.getClient().uploadLargeFilePart(version.id, segment, entity, checksum.hash); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Upload {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Upload {0} failed", e, file); } } }, new DisabledProgressListener(), new TransferBackgroundActionState(overall)).call());
ChecksumComputeFactory.get(HashAlgorithm.md5).compute(concat.toString(), new TransferStatus()), completed.size()); final String reference; if(complete.getEtag().startsWith("\"") && complete.getEtag().endsWith("\"")) {
if(local.attributes().getSize() == attributes.getSize()) { if(Checksum.NONE != attributes.getChecksum()) { final ChecksumCompute compute = ChecksumComputeFactory.get(attributes.getChecksum().algorithm); if(compute.compute(local.getInputStream(), parent).equals(attributes.getChecksum())) { if(log.isInfoEnabled()) {
ChecksumComputeFactory.get(HashAlgorithm.md5).compute(concat.toString(), new TransferStatus()), completed.size()); final String reference; if(complete.getEtag().startsWith("\"") && complete.getEtag().endsWith("\"")) {
switch(session.getSignatureVersion()) { case AWS4HMACSHA256: status.setChecksum(ChecksumComputeFactory.get(HashAlgorithm.sha256) .compute(new ByteArrayInputStream(content, off, len), status) );
final Checksum checksum = status.getChecksum(); if(Checksum.NONE != checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(checksum.algorithm); listener.message(MessageFormat.format(LocaleFactory.localizedString("Calculate checksum for {0}", "Status"), file.getName()));
@Override public StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { // The client-side checksum is passed to the BlackPearl gateway by supplying the applicable CRC HTTP header. // If this is done, the BlackPearl gateway verifies that the data received matches the checksum provided. // End-to-end data protection requires that the client provide the CRC when uploading the object and then // verify the CRC after downloading the object at a later time (see Get Object). The BlackPearl gateway also // verifies the CRC when reading from physical data stores so the gateway can identify problems before // transmitting data to the client. status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status)); } // Make sure file is available in cache final List<TransferStatus> chunks = bulk.query(Transfer.Type.upload, file, status); StorageObject stored = null; for(TransferStatus chunk : chunks) { chunk.setChecksum(ChecksumComputeFactory.get(HashAlgorithm.md5).compute(local.getInputStream(), chunk)); stored = super.upload(file, local, throttle, listener, chunk, callback); } return stored; }
final Checksum expected = ChecksumComputeFactory.get(fingerprint.algorithm).compute(local.getInputStream(), copy); if(!expected.equals(fingerprint)) { throw new ChecksumException(MessageFormat.format(LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()),
local.attributes().setChecksum(ChecksumComputeFactory.get(attributes.getChecksum().algorithm) .compute(local.getInputStream(), new TransferStatus())); switch(checksum.compare(attributes, local.attributes())) {