Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public List<ChecksumAlgorithmFactory> selectList( Collection<String> algorithmNa
.collect( toList() );
}

@Override
public boolean isChecksumExtension( String extension )
{
throw new RuntimeException( "not implemented" );
}

private static class MessageDigestChecksumAlgorithmFactory
extends ChecksumAlgorithmFactorySupport
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepo
}

return new Maven2RepositoryLayout(
new ArrayList<>( checksumAlgorithmFactorySelector.getChecksumAlgorithmFactories() ),
checksumAlgorithmFactorySelector,
checksumsAlgorithms,
omitChecksumsForExtensions
);
Expand All @@ -143,17 +143,17 @@ public RepositoryLayout newInstance( RepositorySystemSession session, RemoteRepo
private static class Maven2RepositoryLayout
implements RepositoryLayout
{
private final List<ChecksumAlgorithmFactory> allChecksumAlgorithms;
private final ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector;

private final List<ChecksumAlgorithmFactory> configuredChecksumAlgorithms;

private final Set<String> extensionsWithoutChecksums;

private Maven2RepositoryLayout( List<ChecksumAlgorithmFactory> allChecksumAlgorithms,
private Maven2RepositoryLayout( ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector,
List<ChecksumAlgorithmFactory> configuredChecksumAlgorithms,
Set<String> extensionsWithoutChecksums )
{
this.allChecksumAlgorithms = Collections.unmodifiableList( allChecksumAlgorithms );
this.checksumAlgorithmFactorySelector = requireNonNull( checksumAlgorithmFactorySelector );
this.configuredChecksumAlgorithms = Collections.unmodifiableList( configuredChecksumAlgorithms );
this.extensionsWithoutChecksums = requireNonNull( extensionsWithoutChecksums );
}
Expand Down Expand Up @@ -269,7 +269,7 @@ private List<ChecksumLocation> getChecksumLocations( URI location )

private boolean isChecksum( String extension )
{
return allChecksumAlgorithms.stream().anyMatch( a -> extension.endsWith( "." + a.getFileExtension() ) );
return checksumAlgorithmFactorySelector.isChecksumExtension( extension );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import javax.inject.Named;
import javax.inject.Singleton;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -94,8 +94,22 @@ public List<ChecksumAlgorithmFactory> selectList( Collection<String> algorithmNa
}

@Override
public List<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories()
public Collection<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories()
{
return new ArrayList<>( factories.values() );
return Collections.unmodifiableCollection( factories.values() );
}

@Override
public boolean isChecksumExtension( String extension )
{
requireNonNull( extension );
if ( extension.contains( "." ) )
{
return factories.values().stream().anyMatch( a -> extension.endsWith( "." + a.getFileExtension() ) );
}
else
{
return factories.values().stream().anyMatch( a -> extension.equals( a.getFileExtension() ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public Collection<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories()
{
return Collections.singletonList( checksumAlgorithmFactory );
}

@Override
public boolean isChecksumExtension( String extension )
{
throw new RuntimeException( "not implemented" );
}
};
subject = new TrustedChecksumsArtifactResolverPostProcessor( selector,
Collections.singletonMap( TRUSTED_SOURCE_NAME, this ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public interface ChecksumAlgorithmFactory
/**
* Returns the file extension to be used for given checksum file (without leading dot), never {@code null}. The
* extension should be file and URL path friendly, and may differ from value returned by {@link #getName()}.
* The checksum extension SHOULD NOT contain dot (".") character.
* Example: "sha1".
*/
String getFileExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public interface ChecksumAlgorithmFactorySelector
ChecksumAlgorithmFactory select( String algorithmName );

/**
* Returns a list of factories for given algorithm names in order as collection is ordered, or throws if any of the
* Returns a list of factories in same order as algorithm names are ordered, or throws if any of the
* algorithm name is not supported. The returned list has equal count of elements as passed in collection of names,
* and if names contains duplicated elements, the returned list of algorithms will have duplicates as well.
*
Expand All @@ -52,10 +52,19 @@ public interface ChecksumAlgorithmFactorySelector
List<ChecksumAlgorithmFactory> selectList( Collection<String> algorithmNames );

/**
* Returns a collection of supported algorithms. This set represents ALL the algorithms supported by Resolver,
* and is NOT in any relation to given repository layout used checksums, returned by method {@link
* Returns immutable collection of all supported algorithms. This set represents ALL the algorithms supported by
* Resolver, and is NOT in any relation to given repository layout used checksums, returned by method {@link
* org.eclipse.aether.spi.connector.layout.RepositoryLayout#getChecksumAlgorithmFactories()} (in fact, is super set
* of it).
*/
Collection<ChecksumAlgorithmFactory> getChecksumAlgorithmFactories();

/**
* Returns {@code true} if passed in extension matches any known checksum extension. The extension string may
* start or contain dot ("."), but does not have to. In former case "ends with" is checked (i.e. "jar.sha1" -> true;
* ".sha1" -> true) while in latter equality (i.e. "sha1" -> true).
*
* @since 1.9.3
*/
boolean isChecksumExtension( String extension );
}