View Javadoc
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.connector.checksum;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.eclipse.aether.RepositorySystemSession;
25  import org.eclipse.aether.spi.connector.ArtifactDownload;
26  
27  /**
28   * Component able to provide (expected) checksums to connector beforehand the download happens. Checksum provided by
29   * this component are of kind {@link org.eclipse.aether.spi.connector.checksum.ChecksumPolicy.ChecksumKind#PROVIDED}.
30   *
31   * @since 1.8.0
32   */
33  public interface ProvidedChecksumsSource {
34      /**
35       * May return the provided checksums (for given artifact transfer) from source other than remote repository, or
36       * {@code null} if it have no checksums available for given transfer. Provided checksums are "opt-in" for
37       * transfer, in a way IF they are available upfront, they will be enforced according to checksum policy
38       * in effect. Otherwise, provided checksum verification is completely left out.
39       * <p>
40       * For enabled provided checksum source is completely acceptable to return {@code null} values, as that carries
41       * the meaning "nothing to add here", as there are no checksums to be provided upfront transfer. Semantically, this
42       * is equivalent to returning empty map, but signals the intent better.
43       *
44       * @param transfer                   The transfer that is about to be executed.
45       * @param checksumAlgorithmFactories The checksum algorithms that are expected.
46       * @return Map of expected checksums, or {@code null}.
47       */
48      Map<String, String> getProvidedArtifactChecksums(
49              RepositorySystemSession session,
50              ArtifactDownload transfer,
51              List<ChecksumAlgorithmFactory> checksumAlgorithmFactories);
52  }