1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.eclipse.aether.spi.checksums;
20
21 import java.util.List;
22 import java.util.Map;
23
24 import org.eclipse.aether.RepositorySystemSession;
25 import org.eclipse.aether.repository.RemoteRepository;
26 import org.eclipse.aether.spi.connector.ArtifactDownload;
27 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
28 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicy;
29
30 /**
31 * Component able to provide (expected) checksums to connector beforehand the download happens. Checksum provided by
32 * this component are of kind {@link ChecksumPolicy.ChecksumKind#PROVIDED}. Resolver by default provides one
33 * implementation: an adapter, that makes {@link TrustedChecksumsSource} into {@link ProvidedChecksumsSource}. Users
34 * are encouraged to rely on this adapter, and do not create their own implementations.
35 *
36 * @since 1.9.14
37 */
38 public interface ProvidedChecksumsSource {
39 /**
40 * May return the provided checksums (for given artifact transfer) from source other than remote repository, or
41 * {@code null} if it have no checksums available for given transfer. Provided checksums are "opt-in" for
42 * transfer, in a way IF they are available upfront, they will be enforced according to checksum policy
43 * in effect. Otherwise, provided checksum verification is completely left out.
44 * <p>
45 * For enabled provided checksum source is completely acceptable to return {@code null} values, as that carries
46 * the meaning "nothing to add here", as there are no checksums to be provided upfront transfer. Semantically, this
47 * is equivalent to returning empty map, but signals the intent better.
48 *
49 * @param session The current session.
50 * @param transfer The transfer that is about to be executed.
51 * @param remoteRepository The remote repository connector is about to contact.
52 * @param checksumAlgorithmFactories The checksum algorithms that are expected.
53 * @return Map of expected checksums, or {@code null}.
54 */
55 Map<String, String> getProvidedArtifactChecksums(
56 RepositorySystemSession session,
57 ArtifactDownload transfer,
58 RemoteRepository remoteRepository,
59 List<ChecksumAlgorithmFactory> checksumAlgorithmFactories);
60 }