class MavenContentValidator extends ComponentSupport implements ContentValidator {

  @Nonnull
  @Override
  public String determineContentType(boolean strictContentTypeValidation,
                                     Supplier<InputStream> contentSupplier,
                                     @Nullable MimeRulesSource mimeRulesSource,
                                     @Nullable String contentName,
                                     @Nullable String declaredContentType) throws IOException
  {
    if (contentName != null) {
      if (contentName.endsWith(".pom")) {
        // Note: this is due fact that Tika has glob "*.pom" extension enlisted at text/plain
        return defaultContentValidator.determineContentType(
            strictContentTypeValidation, contentSupplier, mimeRulesSource, contentName + ".xml", declaredContentType
        );
      }
      else if (contentName.endsWith(".sha1") || contentName.endsWith(".md5")) {
        if (strictContentTypeValidation) {
          // hashes are small/simple, do it directly
          try (InputStream is = contentSupplier.get()) {
            final String digestCandidate = DigestExtractor.extract(is);
            if (!DigestExtractor.isDigest(digestCandidate)) {
              throw new InvalidContentException("Not a Maven2 digest: " + contentName);
            }
          }
        }

        if (declaredContentType != null) {
          return declaredContentType;
        }
      }
    }
    // everything else goes to default for now
    return defaultContentValidator.determineContentType(
        strictContentTypeValidation, contentSupplier, mimeRulesSource, contentName, declaredContentType
    );
  }

  @Inject public  MavenContentValidator(final DefaultContentValidator defaultContentValidator);

}