Search in sources :

Example 11 with ChecksumType

use of org.dcache.util.ChecksumType in project dcache by dCache.

the class RemoteHttpDataTransferProtocol method checkChecksums.

private void checkChecksums(RemoteHttpDataTransferProtocolInfo info, String rfc3230, Optional<Set<Checksum>> knownChecksums) throws ThirdPartyTransferFailedCacheException {
    Map<ChecksumType, Checksum> checksums = uniqueIndex(Checksums.decodeRfc3230(rfc3230), Checksum::getType);
    boolean verified = false;
    if (knownChecksums.isPresent()) {
        for (Checksum ourChecksum : knownChecksums.get()) {
            ChecksumType type = ourChecksum.getType();
            if (checksums.containsKey(type)) {
                checkChecksumEqual(ourChecksum, checksums.get(type));
                verified = true;
            }
        }
    }
    if (info.isVerificationRequired() && !verified) {
        throw new ThirdPartyTransferFailedCacheException("no useful checksum in HEAD response: " + (rfc3230 == null ? "(none sent)" : rfc3230));
    }
}
Also used : Checksum(org.dcache.util.Checksum) ChecksumType(org.dcache.util.ChecksumType) ThirdPartyTransferFailedCacheException(diskCacheV111.util.ThirdPartyTransferFailedCacheException)

Aggregations

ChecksumType (org.dcache.util.ChecksumType)11 Checksum (org.dcache.util.Checksum)9 CacheException (diskCacheV111.util.CacheException)3 IOException (java.io.IOException)3 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)2 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)2 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)2 FsPath (diskCacheV111.util.FsPath)2 NotDirCacheException (diskCacheV111.util.NotDirCacheException)2 NotFileCacheException (diskCacheV111.util.NotFileCacheException)2 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)2 CellEndpoint (dmg.cells.nucleus.CellEndpoint)2 MessageDigest (java.security.MessageDigest)2 RepositoryChannel (org.dcache.pool.repository.RepositoryChannel)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Strings.nullToEmpty (com.google.common.base.Strings.nullToEmpty)1 ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1