1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl.transport.http;
20
21 import javax.inject.Named;
22 import javax.inject.Singleton;
23
24 import java.util.Collections;
25 import java.util.Map;
26 import java.util.function.Function;
27
28 import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory;
29 import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractorStrategy;
30 import org.eclipse.aether.spi.connector.transport.http.HttpConstants;
31
32
33
34
35 @Singleton
36 @Named(Nx2ChecksumExtractor.NAME)
37 public final class Nx2ChecksumExtractor extends ChecksumExtractorStrategy {
38 public static final String NAME = "nx2";
39
40 @Override
41 public Map<String, String> extractChecksums(Function<String, String> headerGetter) {
42
43 String etag = headerGetter.apply(HttpConstants.ETAG);
44 if (etag != null) {
45 int start = etag.indexOf("SHA1{"), end = etag.indexOf("}", start + 5);
46 if (start >= 0 && end > start) {
47 return Collections.singletonMap(Sha1ChecksumAlgorithmFactory.NAME, etag.substring(start + 5, end));
48 }
49 }
50 return null;
51 }
52 }