Class FileTrustedChecksumsSourceSupport
java.lang.Object
org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
- All Implemented Interfaces:
TrustedChecksumsSource
- Direct Known Subclasses:
SparseDirectoryTrustedChecksumsSource,SummaryFileTrustedChecksumsSource
public abstract class FileTrustedChecksumsSourceSupport
extends Object
implements TrustedChecksumsSource
Support class for implementing
TrustedChecksumsSource backed by local filesystem. It implements basic support
like basedir calculation, "enabled" flag and "originAware" flag.
The configuration keys supported:
aether.trustedChecksumsSource.${name}(boolean) must be explicitly set to "true" to become enabledaether.trustedChecksumsSource.${name}.basedir(string, path) directory from where implementation can use files. May be relative path (then is resolved against local repository basedir) or absolute. If unset, default value is ".checksums" and is resolved against local repository basedir.aether.trustedChecksumsSource.${name}.originAware(boolean) whether to make implementation "originAware", to factor in origin repository ID as well or not.
This implementation ensures that implementations have "name" property, used in configuration properties above.
- Since:
- 1.9.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.aether.spi.checksums.TrustedChecksumsSource
TrustedChecksumsSource.Writer -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFileTrustedChecksumsSourceSupport(RepositoryKeyFunctionFactory repositoryKeyFunctionFactory) -
Method Summary
Modifier and TypeMethodDescriptiondoGetTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) Implementors MUST NOT returnnullat this point, as this source is enabled.protected TrustedChecksumsSource.WriterImplementors may override this method and returnTrustedChecksumsSource.Writerinstance.doGetTrustedMetadataChecksums(RepositorySystemSession session, Metadata metadata, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) Implementors MUST NOT returnnullat this point, as this source is enabled.protected PathgetBasedir(RepositorySystemSession session, String defaultValue, String configPropKey, boolean mayCreate) Uses utilityDirectoryUtils.resolveDirectory(RepositorySystemSession, String, String, boolean)to calculate (and maybe create) basedir for this implementation, never returnsnull.getTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) This implementation will call into underlying code only if enabled, and will enforce non-nullreturn value.This implementation will call into underlying code only if enabled.getTrustedMetadataChecksums(RepositorySystemSession session, Metadata metadata, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) This implementation will call into underlying code only if enabled, and will enforce non-nullreturn value.protected abstract booleanisEnabled(RepositorySystemSession session) Returnstrueif session configuration marks this instance as enabled.repositoryKey(RepositorySystemSession session, ArtifactRepository artifactRepository) Returns repository keys to be used on file system layout.
-
Field Details
-
CONFIG_PROPS_PREFIX
- See Also:
-
logger
-
-
Constructor Details
-
FileTrustedChecksumsSourceSupport
protected FileTrustedChecksumsSourceSupport(RepositoryKeyFunctionFactory repositoryKeyFunctionFactory)
-
-
Method Details
-
getTrustedArtifactChecksums
public Map<String,String> getTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) This implementation will call into underlying code only if enabled, and will enforce non-nullreturn value. In worst case, empty map should be returned, meaning "no trusted checksums available".- Specified by:
getTrustedArtifactChecksumsin interfaceTrustedChecksumsSource- Parameters:
session- The repository system session, nevernull.artifact- The artifact we want checksums for, nevernull.artifactRepository- The origin repository: local, workspace, remote repository, nevernull.checksumAlgorithmFactories- The checksum algorithms that are expected, nevernull.- Returns:
- Map of expected checksums, or
nullif not enabled.
-
getTrustedMetadataChecksums
public Map<String,String> getTrustedMetadataChecksums(RepositorySystemSession session, Metadata metadata, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) This implementation will call into underlying code only if enabled, and will enforce non-nullreturn value. In worst case, empty map should be returned, meaning "no trusted checksums available".- Specified by:
getTrustedMetadataChecksumsin interfaceTrustedChecksumsSource- Parameters:
session- The repository system session, nevernull.metadata- The metadata we want checksums for, nevernull.artifactRepository- The origin repository: local, workspace, remote repository, nevernull.checksumAlgorithmFactories- The checksum algorithms that are expected, nevernull.- Returns:
- Map of expected checksums, or
null. - Since:
- 2.0.23
-
getTrustedArtifactChecksumsWriter
public TrustedChecksumsSource.Writer getTrustedArtifactChecksumsWriter(RepositorySystemSession session) This implementation will call into underlying code only if enabled. Underlying implementation may still choose to returnnull.- Specified by:
getTrustedArtifactChecksumsWriterin interfaceTrustedChecksumsSource
-
doGetTrustedArtifactChecksums
protected abstract Map<String,String> doGetTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) Implementors MUST NOT returnnullat this point, as this source is enabled. -
doGetTrustedMetadataChecksums
protected abstract Map<String,String> doGetTrustedMetadataChecksums(RepositorySystemSession session, Metadata metadata, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) Implementors MUST NOT returnnullat this point, as this source is enabled. Metadata checksums are looked up using the same file conventions as artifact checksums, with the metadata path composed from the origin repository key (for exampleg/a/v/maven-metadata-central.xml).- Since:
- 2.0.23
-
doGetTrustedArtifactChecksumsWriter
protected TrustedChecksumsSource.Writer doGetTrustedArtifactChecksumsWriter(RepositorySystemSession session) Implementors may override this method and returnTrustedChecksumsSource.Writerinstance. -
isEnabled
Returnstrueif session configuration marks this instance as enabled.Default value is
false. -
getBasedir
protected Path getBasedir(RepositorySystemSession session, String defaultValue, String configPropKey, boolean mayCreate) Uses utilityDirectoryUtils.resolveDirectory(RepositorySystemSession, String, String, boolean)to calculate (and maybe create) basedir for this implementation, never returnsnull. The returnedPathmay not exist, if invoked withmayCreatebeingfalse.Default value is
${LOCAL_REPOSITORY}/.checksums.- Returns:
- The
Pathof basedir, nevernull.
-
repositoryKey
protected List<String> repositoryKey(RepositorySystemSession session, ArtifactRepository artifactRepository) Returns repository keys to be used on file system layout. Always returns a list with at least one element. Elements are sorted from "most specific" to "least specific" keys.- Since:
- 2.0.14
-