private static RecordInputStream convertToInputStream(DrawingRecord r) { byte[] data = r.serialize(); RecordInputStream rinp = new RecordInputStream( new ByteArrayInputStream(data) ); rinp.nextRecord(); return rinp; }
/** * Clone the current record, via a call to serialize * it, and another to create a new record from the * bytes. * May only be used for classes which don't have * internal counts / ids in them. For those which * do, a full model-aware cloning is needed, which * allocates new ids / counts as needed. * * @return the cloned current record */ public Record cloneViaReserialise() { // Do it via a re-serialization // It's a cheat, but it works... byte[] b = serialize(); RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b)); rinp.nextRecord(); Record[] r = RecordFactory.createRecord(rinp); if(r.length != 1) { throw new IllegalStateException("Re-serialised a record to clone it, but got " + r.length + " records back!"); } return r[0]; } }
private void open(DirectoryNode directory) throws IOException { DocumentNode book; try { book = (DocumentNode)directory.getEntry(OLD_WORKBOOK_DIR_ENTRY_NAME); } catch (FileNotFoundException e) { // some files have "Workbook" instead book = (DocumentNode)directory.getEntry(WORKBOOK_DIR_ENTRY_NAMES[0]); } if (book == null) { throw new IOException("No Excel 5/95 Book stream found"); } ris = new RecordInputStream(directory.createDocumentInputStream(book)); prepare(); }
public void run() throws IOException { try (POIFSFileSystem fs = new POIFSFileSystem(new File(file), true); InputStream din = BiffViewer.getPOIFSInputStream(fs)) { RecordInputStream rinp = new RecordInputStream(din); while (rinp.hasNextRecord()) { int sid = rinp.getNextSid(); rinp.nextRecord(); int size = rinp.available(); Class<? extends Record> clz = RecordFactory.getRecordClass(sid); System.out.print( formatSID(sid) + " - " + formatSize(size) + " bytes" ); if (clz != null) { System.out.print(" \t"); System.out.print(clz.getName().replace("org.apache.poi.hssf.record.", "")); } System.out.println(); byte[] data = rinp.readRemainder(); if (data.length > 0) { System.out.print(" "); System.out.println(formatData(data)); } } } }
RecordInputStream rs = new RecordInputStream(in); List<Record> records = new ArrayList<>(); StreamEncryptionInfo sei = new StreamEncryptionInfo(rs, records);
private void open(InputStream biffStream) throws IOException { BufferedInputStream bis = (biffStream instanceof BufferedInputStream) ? (BufferedInputStream)biffStream : new BufferedInputStream(biffStream, 8); if (FileMagic.valueOf(bis) == FileMagic.OLE2) { POIFSFileSystem poifs = new POIFSFileSystem(bis); try { open(poifs); toClose = poifs; // Fixed by GR, we should not close it here } finally { if (toClose == null) { poifs.close(); } } } else { ris = new RecordInputStream(bis); toClose = bis; prepare(); } }
public RecordInputStream createDecryptingStream(InputStream original) { String userPassword = Biff8EncryptionKey.getCurrentUserPassword(); if (userPassword == null) { userPassword = Decryptor.DEFAULT_PASSWORD; } EncryptionInfo info = _filePassRec.getEncryptionInfo(); try { if (!info.getDecryptor().verifyPassword(userPassword)) { throw new EncryptedDocumentException( (Decryptor.DEFAULT_PASSWORD.equals(userPassword) ? "Default" : "Supplied") + " password is invalid for salt/verifier/verifierHash"); } } catch (GeneralSecurityException e) { throw new EncryptedDocumentException(e); } return new RecordInputStream(original, info, _initialRecordsSize); }
RecordInputStream recStream = new RecordInputStream(is); while (true) { boolean hasNext;
Record last_record = null; RecordInputStream recStream = new RecordInputStream(in);
private static RecordInputStream convertToInputStream(DrawingRecord r) { byte[] data = r.serialize(); RecordInputStream rinp = new RecordInputStream( new ByteArrayInputStream(data) ); rinp.nextRecord(); return rinp; }
private static RecordInputStream convertToInputStream(DrawingRecord r) { byte[] data = r.serialize(); RecordInputStream rinp = new RecordInputStream( new ByteArrayInputStream(data) ); rinp.nextRecord(); return rinp; }
private static RecordInputStream convertToInputStream(DrawingRecord r) { byte[] data = r.serialize(); RecordInputStream rinp = new RecordInputStream( new ByteArrayInputStream(data) ); rinp.nextRecord(); return rinp; }
/** * Clone the current record, via a call to serialize * it, and another to create a new record from the * bytes. * May only be used for classes which don't have * internal counts / ids in them. For those which * do, a full model-aware cloning is needed, which * allocates new ids / counts as needed. */ public Record cloneViaReserialise() { // Do it via a re-serialization // It's a cheat, but it works... byte[] b = serialize(); RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b)); rinp.nextRecord(); Record[] r = RecordFactory.createRecord(rinp); if(r.length != 1) { throw new IllegalStateException("Re-serialised a record to clone it, but got " + r.length + " records back!"); } return r[0]; } }
/** * Clone the current record, via a call to serialize * it, and another to create a new record from the * bytes. * May only be used for classes which don't have * internal counts / ids in them. For those which * do, a full model-aware cloning is needed, which * allocates new ids / counts as needed. */ public Record cloneViaReserialise() { // Do it via a re-serialization // It's a cheat, but it works... byte[] b = serialize(); RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b)); rinp.nextRecord(); Record[] r = RecordFactory.createRecord(rinp); if(r.length != 1) { throw new IllegalStateException("Re-serialised a record to clone it, but got " + r.length + " records back!"); } return r[0]; } }
/** * Clone the current record, via a call to serialize * it, and another to create a new record from the * bytes. * May only be used for classes which don't have * internal counts / ids in them. For those which * do, a full model-aware cloning is needed, which * allocates new ids / counts as needed. * * @return the cloned current record */ public Record cloneViaReserialise() { // Do it via a re-serialization // It's a cheat, but it works... byte[] b = serialize(); RecordInputStream rinp = new RecordInputStream(new ByteArrayInputStream(b)); rinp.nextRecord(); Record[] r = RecordFactory.createRecord(rinp); if(r.length != 1) { throw new IllegalStateException("Re-serialised a record to clone it, but got " + r.length + " records back!"); } return r[0]; } }
private void open(DirectoryNode directory) throws IOException { DocumentNode book; try { book = (DocumentNode)directory.getEntry(OLD_WORKBOOK_DIR_ENTRY_NAME); } catch (FileNotFoundException e) { // some files have "Workbook" instead book = (DocumentNode)directory.getEntry(WORKBOOK_DIR_ENTRY_NAMES[0]); } if (book == null) { throw new IOException("No Excel 5/95 Book stream found"); } ris = new RecordInputStream(directory.createDocumentInputStream(book)); prepare(); }
private void open(InputStream biffStream) throws IOException { BufferedInputStream bis = (biffStream instanceof BufferedInputStream) ? (BufferedInputStream)biffStream : new BufferedInputStream(biffStream, 8); if (FileMagic.valueOf(bis) == FileMagic.OLE2) { POIFSFileSystem poifs = new POIFSFileSystem(bis); try { open(poifs); toClose = poifs; // Fixed by GR, we should not close it here } finally { if (toClose == null) { poifs.close(); } } } else { ris = new RecordInputStream(bis); toClose = bis; prepare(); } }
public RecordInputStream createDecryptingStream(InputStream original) { String userPassword = Biff8EncryptionKey.getCurrentUserPassword(); if (userPassword == null) { userPassword = Decryptor.DEFAULT_PASSWORD; } EncryptionInfo info = _filePassRec.getEncryptionInfo(); try { if (!info.getDecryptor().verifyPassword(userPassword)) { throw new EncryptedDocumentException( (Decryptor.DEFAULT_PASSWORD.equals(userPassword) ? "Default" : "Supplied") + " password is invalid for salt/verifier/verifierHash"); } } catch (GeneralSecurityException e) { throw new EncryptedDocumentException(e); } return new RecordInputStream(original, info, _initialRecordsSize); }
public RecordInputStream createDecryptingStream(InputStream original) { FilePassRecord fpr = _filePassRec; String userPassword = Biff8EncryptionKey.getCurrentUserPassword(); Biff8EncryptionKey key; if (userPassword == null) { key = Biff8EncryptionKey.create(fpr.getDocId()); } else { key = Biff8EncryptionKey.create(userPassword, fpr.getDocId()); } if (!key.validate(fpr.getSaltData(), fpr.getSaltHash())) { throw new EncryptedDocumentException( (userPassword == null ? "Default" : "Supplied") + " password is invalid for docId/saltData/saltHash"); } return new RecordInputStream(original, key, _initialRecordsSize); }
public RecordInputStream createDecryptingStream(InputStream original) { FilePassRecord fpr = _filePassRec; String userPassword = Biff8EncryptionKey.getCurrentUserPassword(); Biff8EncryptionKey key; if (userPassword == null) { key = Biff8EncryptionKey.create(fpr.getDocId()); } else { key = Biff8EncryptionKey.create(userPassword, fpr.getDocId()); } if (!key.validate(fpr.getSaltData(), fpr.getSaltHash())) { throw new EncryptedDocumentException( (userPassword == null ? "Default" : "Supplied") + " password is invalid for docId/saltData/saltHash"); } return new RecordInputStream(original, key, _initialRecordsSize); }