throws IOException { EncryptionInfo info = new EncryptionInfo(root); Decryptor d = Decryptor.getInstance(info);
private OOXMLPasswordsTry(POIFSFileSystem fs) throws IOException { info = new EncryptionInfo(fs); d = Decryptor.getInstance(info); this.fs = fs; } private OOXMLPasswordsTry(File file) throws IOException {
private InputStream getProtectedInputStreamForXlsx() { try { final POIFSFileSystem fileSystem = new POIFSFileSystem(new FileInputStream(this.spreadsheetFile)); final EncryptionInfo encryptionInfo = new EncryptionInfo(fileSystem); final Decryptor decryptor = Decryptor.getInstance(encryptionInfo); decryptor.verifyPassword(this.password); return decryptor.getDataStream(fileSystem); } catch (Exception e) { final String message = "Failed to open file with the given password: " + e.getMessage(); LOGGER.error(message); throw new RuntimeException(message); } }
public static InputStream decrypt(final InputStream inputStream, final String pwd) throws Exception { try { POIFSFileSystem fs = new POIFSFileSystem(inputStream); EncryptionInfo info = new EncryptionInfo(fs); Decryptor d = Decryptor.getInstance(info); if (!d.verifyPassword(pwd)) { throw new RuntimeException("incorrect password"); } return d.getDataStream(fs); } finally { IOUtils.closeQuietly(inputStream); } } }
case ENCRYPTED: EncryptionInfo info = new EncryptionInfo(root); Decryptor d = Decryptor.getInstance(info);
throws IOException { EncryptionInfo info = new EncryptionInfo(root); Decryptor d = Decryptor.getInstance(info);
Decryptor d = Decryptor.getInstance(info); d.verifyPassword(builder.getPassword()); pkg = OPCPackage.open(d.getDataStream(poifs));
Decryptor d = Decryptor.getInstance(info); d.verifyPassword(password); pkg = OPCPackage.open(d.getDataStream(poifs));
EncryptionInfo info = new EncryptionInfo(poifs); Decryptor d = Decryptor.getInstance(info);
Decryptor d = Decryptor.getInstance(info);
public void init(File f) { try { if (builder.getPassword() != null) { // Based on: https://poi.apache.org/encryption.html POIFSFileSystem poifs = new POIFSFileSystem(f); EncryptionInfo info = new EncryptionInfo(poifs); Decryptor d = Decryptor.getInstance(info); d.verifyPassword(builder.getPassword()); pkg = OPCPackage.open(d.getDataStream(poifs)); } else { pkg = OPCPackage.open(f); } XSSFReader reader = new XSSFReader(pkg); SharedStringsTable sst = reader.getSharedStringsTable(); StylesTable styles = reader.getStylesTable(); loadSheets(reader, sst, styles, builder.getRowCacheSize()); } catch (IOException e) { throw new OpenException("Failed to open file", e); } catch (OpenXML4JException | XMLStreamException e) { throw new ReadException("Unable to read workbook", e); } catch (GeneralSecurityException e) { throw new ReadException("Unable to read workbook - Decryption failed", e); } }
public void init(File f) { try { if (builder.getPassword() != null) { // Based on: https://poi.apache.org/encryption.html POIFSFileSystem poifs = new POIFSFileSystem(f); EncryptionInfo info = new EncryptionInfo(poifs); Decryptor d = Decryptor.getInstance(info); d.verifyPassword(builder.getPassword()); pkg = OPCPackage.open(d.getDataStream(poifs)); } else { pkg = OPCPackage.open(f); } XSSFReader reader = new XSSFReader(pkg); SharedStringsTable sst = reader.getSharedStringsTable(); StylesTable styles = reader.getStylesTable(); loadSheets(reader, sst, styles, builder.getRowCacheSize()); } catch (IOException e) { throw new OpenException("Failed to open file", e); } catch (OpenXML4JException | XMLStreamException e) { throw new ReadException("Unable to read workbook", e); } catch (GeneralSecurityException e) { throw new ReadException("Unable to read workbook - Decryption failed", e); } }
case ENCRYPTED: EncryptionInfo info = new EncryptionInfo(root); Decryptor d = Decryptor.getInstance(info);
case ENCRYPTED: EncryptionInfo info = new EncryptionInfo(root); Decryptor d = Decryptor.getInstance(info);