Class SummaryFileTrustedChecksumsSource
- java.lang.Object
-
- org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
-
- org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource
-
- All Implemented Interfaces:
TrustedChecksumsSource
@Singleton @Named("summaryFile") public final class SummaryFileTrustedChecksumsSource extends FileTrustedChecksumsSourceSupport
Compact fileFileTrustedChecksumsSourceSupport
implementation that use specified directory as base directory, where it expects a "summary" file named as "checksums.${checksumExt}" for each checksum algorithm. File format is GNU Coreutils compatible: each line holds checksum followed by two spaces and artifact relative path (from local repository root, without leading "./"). This means that trusted checksums summary file can be used to validate artifacts or generate it using standard GNU tools like GNUsha1sum
is (for BSD derivatives same file can be used with-r
switch).The format supports comments "#" (hash) and empty lines for easier structuring the file content, and both are ignored. Also, their presence makes the summary file incompatible with GNU Coreutils format. On save of the summary file, the comments and empty lines are lost, and file is sorted by path names for easier diffing (2nd column in file).
The source by default is "origin aware", and it will factor in origin repository ID as well into summary file name, for example "checksums-central.sha256".
Example commands for managing summary file (in examples will use repository ID "central"):
- To create summary file:
find * -not -name "checksums-central.sha256" -type f -print0 | xargs -0 sha256sum | sort -k 2 > checksums-central.sha256
- To verify artifacts using summary file:
sha256sum --quiet -c checksums-central.sha256
The checksums summary file is lazily loaded and remains cached during lifetime of the component, so file changes during lifecycle of the component are not picked up. This implementation can be simultaneously used to lookup and also record checksums. The recorded checksums will become visible for every session, and will be flushed at repository system shutdown, merged with existing ones on disk.
The name of this implementation is "summaryFile".
- Since:
- 1.9.0
- See Also:
- sha1sum man page, GNU Coreutils: md5sum
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SummaryFileTrustedChecksumsSource.SummaryFileWriter
-
Nested classes/interfaces inherited from interface org.eclipse.aether.spi.checksums.TrustedChecksumsSource
TrustedChecksumsSource.Writer
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.lang.Boolean>
changedChecksums
private java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String>>
checksums
private static java.lang.String
CHECKSUMS_FILE_PREFIX
private LocalPathComposer
localPathComposer
private static org.slf4j.Logger
LOGGER
static java.lang.String
NAME
private java.util.concurrent.atomic.AtomicBoolean
onShutdownHandlerRegistered
private RepositorySystemLifecycle
repositorySystemLifecycle
-
Fields inherited from class org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
LOCAL_REPO_PREFIX_DIR
-
-
Constructor Summary
Constructors Constructor Description SummaryFileTrustedChecksumsSource(LocalPathComposer localPathComposer, RepositorySystemLifecycle repositorySystemLifecycle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,java.lang.String>
doGetTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, java.util.List<ChecksumAlgorithmFactory> checksumAlgorithmFactories)
Implementors MUST NOT returnnull
at this point, as this source is enabled.protected SummaryFileTrustedChecksumsSource.SummaryFileWriter
doGetTrustedArtifactChecksumsWriter(RepositorySystemSession session)
Implementors may override this method and returnTrustedChecksumsSource.Writer
instance.private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String>
loadProvidedChecksums(java.nio.file.Path summaryFile)
private void
saveRecordedLines()
On-close handler that saves recorded checksums, if any.private java.nio.file.Path
summaryFile(java.nio.file.Path basedir, boolean originAware, java.lang.String repositoryId, java.lang.String checksumExtension)
Returns the summary file path.-
Methods inherited from class org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
configPropKey, getBasedir, getTrustedArtifactChecksums, getTrustedArtifactChecksumsWriter, isEnabled, isOriginAware
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
CHECKSUMS_FILE_PREFIX
private static final java.lang.String CHECKSUMS_FILE_PREFIX
- See Also:
- Constant Field Values
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
localPathComposer
private final LocalPathComposer localPathComposer
-
repositorySystemLifecycle
private final RepositorySystemLifecycle repositorySystemLifecycle
-
checksums
private final java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String>> checksums
-
changedChecksums
private final java.util.concurrent.ConcurrentHashMap<java.nio.file.Path,java.lang.Boolean> changedChecksums
-
onShutdownHandlerRegistered
private final java.util.concurrent.atomic.AtomicBoolean onShutdownHandlerRegistered
-
-
Constructor Detail
-
SummaryFileTrustedChecksumsSource
@Inject public SummaryFileTrustedChecksumsSource(LocalPathComposer localPathComposer, RepositorySystemLifecycle repositorySystemLifecycle)
-
-
Method Detail
-
doGetTrustedArtifactChecksums
protected java.util.Map<java.lang.String,java.lang.String> doGetTrustedArtifactChecksums(RepositorySystemSession session, Artifact artifact, ArtifactRepository artifactRepository, java.util.List<ChecksumAlgorithmFactory> checksumAlgorithmFactories)
Description copied from class:FileTrustedChecksumsSourceSupport
Implementors MUST NOT returnnull
at this point, as this source is enabled.- Specified by:
doGetTrustedArtifactChecksums
in classFileTrustedChecksumsSourceSupport
-
doGetTrustedArtifactChecksumsWriter
protected SummaryFileTrustedChecksumsSource.SummaryFileWriter doGetTrustedArtifactChecksumsWriter(RepositorySystemSession session)
Description copied from class:FileTrustedChecksumsSourceSupport
Implementors may override this method and returnTrustedChecksumsSource.Writer
instance.- Overrides:
doGetTrustedArtifactChecksumsWriter
in classFileTrustedChecksumsSourceSupport
-
summaryFile
private java.nio.file.Path summaryFile(java.nio.file.Path basedir, boolean originAware, java.lang.String repositoryId, java.lang.String checksumExtension)
Returns the summary file path. The file itself and its parent directories may not exist, this method merely calculate the path.
-
loadProvidedChecksums
private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String> loadProvidedChecksums(java.nio.file.Path summaryFile)
-
saveRecordedLines
private void saveRecordedLines()
On-close handler that saves recorded checksums, if any.
-
-