Class FileTrustedChecksumsSourceSupport
java.lang.Object
org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
- All Implemented Interfaces:
TrustedChecksumsSource
- Direct Known Subclasses:
SparseDirectoryTrustedChecksumsSource
,SummaryFileTrustedChecksumsSource
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
configPropKey
(String name) To be used by underlying implementations to form configuration property keys properly scoped.doGetTrustedArtifactChecksums
(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) Implementors MUST NOT returnnull
at this point, as this source is enabled.protected TrustedChecksumsSource.Writer
Implementors may override this method and returnTrustedChecksumsSource.Writer
instance.protected Path
getBasedir
(RepositorySystemSession session, 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-null
return value.This implementation will call into underlying code only if enabled.protected boolean
isEnabled
(RepositorySystemSession session) Returnstrue
if session configuration marks this instance as enabled.protected boolean
isOriginAware
(RepositorySystemSession session) Returnstrue
if session configuration marks this instance as origin aware.
-
Field Details
-
CONFIG_PROP_PREFIX
- See Also:
-
CONF_NAME_BASEDIR
- See Also:
-
CONF_NAME_ORIGIN_AWARE
- See Also:
-
LOCAL_REPO_PREFIX_DIR
Visible for testing.- See Also:
-
name
-
-
Constructor Details
-
FileTrustedChecksumsSourceSupport
FileTrustedChecksumsSourceSupport(String name)
-
-
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-null
return value. In worst case, empty map should be returned, meaning "no trusted checksums available".- Specified by:
getTrustedArtifactChecksums
in 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
null
if not enabled.
-
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:
getTrustedArtifactChecksumsWriter
in interfaceTrustedChecksumsSource
-
doGetTrustedArtifactChecksums
protected abstract Map<String,String> doGetTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, List<ChecksumAlgorithmFactory> checksumAlgorithmFactories) Implementors MUST NOT returnnull
at this point, as this source is enabled. -
doGetTrustedArtifactChecksumsWriter
protected TrustedChecksumsSource.Writer doGetTrustedArtifactChecksumsWriter(RepositorySystemSession session) Implementors may override this method and returnTrustedChecksumsSource.Writer
instance. -
configPropKey
To be used by underlying implementations to form configuration property keys properly scoped. -
isEnabled
Returnstrue
if session configuration marks this instance as enabled.Default value is
false
. -
isOriginAware
Returnstrue
if session configuration marks this instance as origin aware.Default value is
true
. -
getBasedir
Uses utilityDirectoryUtils.resolveDirectory(RepositorySystemSession, String, String, boolean)
to calculate (and maybe create) basedir for this implementation, never returnsnull
. The returnedPath
may not exist, if invoked withmayCreate
beingfalse
.Default value is
${LOCAL_REPOSITORY}/.checksums
.- Returns:
- The
Path
of basedir, nevernull
.
-