Class SummaryFileTrustedChecksumsSource
- java.lang.Object
-
- org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
-
- org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource
-
- All Implemented Interfaces:
org.eclipse.aether.spi.checksums.TrustedChecksumsSource
@Singleton @Named("summaryFile") public final class SummaryFileTrustedChecksumsSource extends FileTrustedChecksumsSourceSupportCompact fileFileTrustedChecksumsSourceSupportimplementation 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 GNUsha1sumis (for BSD derivatives same file can be used with-rswitch).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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCHECKSUMS_FILE_PREFIXstatic java.lang.StringCONFIG_PROP_BASEDIRThe basedir where checksums are.static java.lang.StringCONFIG_PROP_ENABLEDIs checksum source enabled?static java.lang.StringCONFIG_PROP_ORIGIN_AWAREIs source origin aware?static java.lang.StringLOCAL_REPO_PREFIX_DIRstatic java.lang.StringNAME-
Fields inherited from class org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
CONFIG_PROP_REPOSITORY_KEY_FUNCTION, DEFAULT_REPOSITORY_KEY_FUNCTION
-
-
Constructor Summary
Constructors Constructor Description SummaryFileTrustedChecksumsSource(org.eclipse.aether.spi.remoterepo.RepositoryKeyFunctionFactory repoKeyFunctionFactory, LocalPathComposer localPathComposer, RepositorySystemLifecycle repositorySystemLifecycle, org.eclipse.aether.spi.io.PathProcessor pathProcessor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,java.lang.String>doGetTrustedArtifactChecksums(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.repository.ArtifactRepository artifactRepository, java.util.List<org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory> checksumAlgorithmFactories)Implementors MUST NOT returnnullat this point, as this source is enabled.protected org.eclipse.aether.spi.checksums.TrustedChecksumsSource.WriterdoGetTrustedArtifactChecksumsWriter(org.eclipse.aether.RepositorySystemSession session)Implementors may override this method and returnTrustedChecksumsSource.Writerinstance.protected booleanisEnabled(org.eclipse.aether.RepositorySystemSession session)Returnstrueif session configuration marks this instance as enabled.-
Methods inherited from class org.eclipse.aether.internal.impl.checksum.FileTrustedChecksumsSourceSupport
getBasedir, getTrustedArtifactChecksums, getTrustedArtifactChecksumsWriter, repositoryKey
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
CONFIG_PROP_ENABLED
public static final java.lang.String CONFIG_PROP_ENABLED
Is checksum source enabled?- See Also:
- Constant Field Values
-
CONFIG_PROP_BASEDIR
public static final java.lang.String CONFIG_PROP_BASEDIR
The basedir where checksums are. If relative, is resolved from local repository root.- See Also:
- Constant Field Values
-
LOCAL_REPO_PREFIX_DIR
public static final java.lang.String LOCAL_REPO_PREFIX_DIR
- See Also:
- Constant Field Values
-
CONFIG_PROP_ORIGIN_AWARE
public static final java.lang.String CONFIG_PROP_ORIGIN_AWARE
Is source origin aware?- See Also:
- Constant Field Values
-
CHECKSUMS_FILE_PREFIX
public static final java.lang.String CHECKSUMS_FILE_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SummaryFileTrustedChecksumsSource
@Inject public SummaryFileTrustedChecksumsSource(org.eclipse.aether.spi.remoterepo.RepositoryKeyFunctionFactory repoKeyFunctionFactory, LocalPathComposer localPathComposer, RepositorySystemLifecycle repositorySystemLifecycle, org.eclipse.aether.spi.io.PathProcessor pathProcessor)
-
-
Method Detail
-
isEnabled
protected boolean isEnabled(org.eclipse.aether.RepositorySystemSession session)
Description copied from class:FileTrustedChecksumsSourceSupportReturnstrueif session configuration marks this instance as enabled.Default value is
false.- Specified by:
isEnabledin classFileTrustedChecksumsSourceSupport
-
doGetTrustedArtifactChecksums
protected java.util.Map<java.lang.String,java.lang.String> doGetTrustedArtifactChecksums(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.repository.ArtifactRepository artifactRepository, java.util.List<org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory> checksumAlgorithmFactories)
Description copied from class:FileTrustedChecksumsSourceSupportImplementors MUST NOT returnnullat this point, as this source is enabled.- Specified by:
doGetTrustedArtifactChecksumsin classFileTrustedChecksumsSourceSupport
-
doGetTrustedArtifactChecksumsWriter
protected org.eclipse.aether.spi.checksums.TrustedChecksumsSource.Writer doGetTrustedArtifactChecksumsWriter(org.eclipse.aether.RepositorySystemSession session)
Description copied from class:FileTrustedChecksumsSourceSupportImplementors may override this method and returnTrustedChecksumsSource.Writerinstance.- Overrides:
doGetTrustedArtifactChecksumsWriterin classFileTrustedChecksumsSourceSupport
-
-