abstract class FileTrustedChecksumsSourceSupport extends java.lang.Object implements TrustedChecksumsSource
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 enabled
aether.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.
TrustedChecksumsSource.Writer
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CONF_NAME_BASEDIR |
private static java.lang.String |
CONF_NAME_ORIGIN_AWARE |
private static java.lang.String |
CONFIG_PROP_PREFIX |
(package private) static java.lang.String |
LOCAL_REPO_PREFIX_DIR
Visible for testing.
|
private java.lang.String |
name |
Constructor and Description |
---|
FileTrustedChecksumsSourceSupport(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
configPropKey(java.lang.String name)
To be used by underlying implementations to form configuration property keys properly scoped.
|
protected abstract java.util.Map<java.lang.String,java.lang.String> |
doGetTrustedArtifactChecksums(RepositorySystemSession session,
Artifact artifact,
ArtifactRepository artifactRepository,
java.util.List<ChecksumAlgorithmFactory> checksumAlgorithmFactories)
Implementors MUST NOT return
null at this point, as this source is enabled. |
protected TrustedChecksumsSource.Writer |
doGetTrustedArtifactChecksumsWriter(RepositorySystemSession session)
Implementors may override this method and return
Writer instance. |
protected java.nio.file.Path |
getBasedir(RepositorySystemSession session,
boolean mayCreate)
Uses utility
DirectoryUtils.resolveDirectory(RepositorySystemSession, String, String, boolean) to
calculate (and maybe create) basedir for this implementation, never returns null . |
java.util.Map<java.lang.String,java.lang.String> |
getTrustedArtifactChecksums(RepositorySystemSession session,
Artifact artifact,
ArtifactRepository artifactRepository,
java.util.List<ChecksumAlgorithmFactory> checksumAlgorithmFactories)
This implementation will call into underlying code only if enabled, and will enforce non-
null return
value. |
TrustedChecksumsSource.Writer |
getTrustedArtifactChecksumsWriter(RepositorySystemSession session)
This implementation will call into underlying code only if enabled.
|
protected boolean |
isEnabled(RepositorySystemSession session)
Returns
true if session configuration marks this instance as enabled. |
protected boolean |
isOriginAware(RepositorySystemSession session)
Returns
true if session configuration marks this instance as origin aware. |
private static final java.lang.String CONFIG_PROP_PREFIX
private static final java.lang.String CONF_NAME_BASEDIR
private static final java.lang.String CONF_NAME_ORIGIN_AWARE
static final java.lang.String LOCAL_REPO_PREFIX_DIR
private final java.lang.String name
FileTrustedChecksumsSourceSupport(java.lang.String name)
public java.util.Map<java.lang.String,java.lang.String> getTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, java.util.List<ChecksumAlgorithmFactory> checksumAlgorithmFactories)
null
return
value. In worst case, empty map should be returned, meaning "no trusted checksums available".getTrustedArtifactChecksums
in interface TrustedChecksumsSource
session
- The repository system session, never null
.artifact
- The artifact we want checksums for, never null
.artifactRepository
- The origin repository: local, workspace, remote repository, never null
.checksumAlgorithmFactories
- The checksum algorithms that are expected, never null
.null
if not enabled.public TrustedChecksumsSource.Writer getTrustedArtifactChecksumsWriter(RepositorySystemSession session)
null
.getTrustedArtifactChecksumsWriter
in interface TrustedChecksumsSource
protected abstract java.util.Map<java.lang.String,java.lang.String> doGetTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, java.util.List<ChecksumAlgorithmFactory> checksumAlgorithmFactories)
null
at this point, as this source is enabled.protected TrustedChecksumsSource.Writer doGetTrustedArtifactChecksumsWriter(RepositorySystemSession session)
Writer
instance.protected java.lang.String configPropKey(java.lang.String name)
protected boolean isEnabled(RepositorySystemSession session)
true
if session configuration marks this instance as enabled.
Default value is false
.
protected boolean isOriginAware(RepositorySystemSession session)
true
if session configuration marks this instance as origin aware.
Default value is true
.
protected java.nio.file.Path getBasedir(RepositorySystemSession session, boolean mayCreate)
DirectoryUtils.resolveDirectory(RepositorySystemSession, String, String, boolean)
to
calculate (and maybe create) basedir for this implementation, never returns null
. The returned
Path
may not exist, if invoked with mayCreate
being false
.
Default value is ${LOCAL_REPOSITORY}/.checksums
.
Path
of basedir, never null
.