com.github.junrar.Archive.isEncrypted()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中com.github.junrar.Archive.isEncrypted()方法的一些代码示例,展示了Archive.isEncrypted()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Archive.isEncrypted()方法的具体详情如下:
包路径:com.github.junrar.Archive
类名称:Archive
方法名:isEncrypted

Archive.isEncrypted介绍

暂无

代码示例

代码示例来源:origin: apache/tika

rar = new Archive(new FileVolumeManager(tis.getFile()));
if (rar.isEncrypted()) {
  throw new EncryptedDocumentException();

代码示例来源:origin: com.github.junrar/junrar

private static List<File> extractArchiveTo(final Archive arch, final ExtractDestination destination) throws IOException, RarException {
  if (arch.isEncrypted()) {
    logger.warn("archive is encrypted cannot extract");
    arch.close();
    return new ArrayList<File>();
  }
  final List<File> extractedFiles = new ArrayList<File>();
  try{
    for(final FileHeader fh : arch ) {
      try {
        final File file = tryToExtract(logger, destination, arch, fh);
        if (file != null) {
          extractedFiles.add(file);
        }
      } catch (final IOException e) {
        logger.error("error extracting the file", e);
        throw e;
      } catch (final RarException e) {
        logger.error("error extraction the file", e);
        throw e;
      }
    }
  }finally {
    arch.close();
  }
  return extractedFiles;
}

代码示例来源:origin: com.github.junrar/junrar

public static List<ContentDescription> getContentsDescription(final File rar) throws RarException, IOException {
  validateRarPath(rar);
  final Archive arch = createArchiveOrThrowException(logger, rar);
  final List<ContentDescription> contents = new ArrayList<ContentDescription>();
  try{
    if (arch.isEncrypted()) {
      logger.warn("archive is encrypted cannot extract");
      return new ArrayList<ContentDescription>();
    }
    for(final FileHeader fileHeader : arch ) {
      contents.add(new ContentDescription(fileHeader.getFileNameString(), fileHeader.getUnpSize()));
    }
  }finally {
    arch.close();
  }
  return contents;
}

代码示例来源:origin: uk.gov.nationalarchives/droid-core-interfaces

@Override
public void handle(IdentificationRequest request) throws IOException {
  if (request.getClass().isAssignableFrom(FileSystemIdentificationRequest.class)) {
    FileSystemIdentificationRequest req = (FileSystemIdentificationRequest) request;
    FileVolumeManager fileVolumeManager = new FileVolumeManager(req.getFile());
    try {
      try (Archive archive = new Archive(fileVolumeManager)) {
        if (archive.isEncrypted()) {
          throw new RuntimeException("Encrypted archive");
        }
        RarWalker walker = new RarWalker(archive, req.getIdentifier());
        walker.walk(archive.getFileHeaders());
      }
    } catch (RarException ex) {
      throw new RuntimeException("Rar procesing failed :", ex);
    }
  } else {
    log.info("Identification request for RAR archive ignored due to limited support.");
  }
}

代码示例来源:origin: digital-preservation/droid

@Override
public void handle(IdentificationRequest request) throws IOException {
  VolumeManager readerVolume = new RarReader(request.getWindowReader());
  try {
    try (Archive archive = new Archive(readerVolume)) {
      if (archive.isEncrypted()) {
        throw new RuntimeException("Encrypted archive");
      }
      RarWalker walker = new RarWalker(archive, request.getIdentifier());
      walker.walk(archive.getFileHeaders());
    }
  } catch (RarException ex) {
    throw new RuntimeException("Rar processing failed :", ex);
  }
}

代码示例来源:origin: digital-preservation/droid

/**
 * @param uri to identify
 * @param request identification request. Only FileSystemIdentificationRequest is supported.
 * @throws CommandExecutionException ex.
 */
public void identify(final URI uri, final IdentificationRequest request) throws CommandExecutionException {
  final String newPath = makeContainerURI("rar", request.getFileName());
  setSlash1("");
  if (request.getClass().isAssignableFrom(FileSystemIdentificationRequest.class)) {
    FileSystemIdentificationRequest req = (FileSystemIdentificationRequest) request;
    FileVolumeManager fileVolumeManager = new FileVolumeManager(req.getFile().toFile());
    try {
      try (Archive archive = new Archive(fileVolumeManager)) {
        if (archive.isEncrypted()) {
          log.info("encrypted rar");
        } else {
          for (FileHeader entry : archive.getFileHeaders()) {
            processEntry(entry, archive, uri, newPath);
          }
        }
      }
    } catch (IOException e) {
      throw new CommandExecutionException("IO error in RARFileSystem", e);
    } catch (RarException ex) {
      throw new CommandExecutionException("Rar exception in RARFileSystem", ex);
    }
  } else {
    log.info("Identification request for RAR archive ignored due to limited support.");
  }
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-parsers

rar = new Archive(tis.getFile());
if (rar.isEncrypted()) {
  throw new EncryptedDocumentException();

代码示例来源:origin: org.apache.tika/tika-parsers

rar = new Archive(new FileVolumeManager(tis.getFile()));
if (rar.isEncrypted()) {
  throw new EncryptedDocumentException();

相关文章