public void write(LittleEndianByteArrayOutputStream bos) { writeUnicodeLPP4(bos, featureIdentifier); bos.writeShort(readerVersionMajor); bos.writeShort(readerVersionMinor); bos.writeShort(updaterVersionMajor); bos.writeShort(updaterVersionMinor); bos.writeShort(writerVersionMajor); bos.writeShort(writerVersionMinor); } }
public void write(LittleEndianByteArrayOutputStream bos) { int start = bos.getWriteIndex(); LittleEndianOutput sizeOut = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(transformType); writeUnicodeLPP4(bos, transformerId); sizeOut.writeInt(bos.getWriteIndex()-start); writeUnicodeLPP4(bos, transformerName); bos.writeShort(readerVersionMajor); bos.writeShort(readerVersionMinor); bos.writeShort(updaterVersionMajor); bos.writeShort(updaterVersionMinor); bos.writeShort(writerVersionMajor); bos.writeShort(writerVersionMinor); } }
@Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); header.write(bos); verifier.write(bos); } };
@Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); bos.writeInt(info.getEncryptionFlags()); header.write(bos); verifier.write(bos); } };
/** * Write the data content of this BIFF record including the sid and record length. * <p> * The subclass must write the exact number of bytes as reported by * {@link org.apache.poi.hssf.record.Record#getRecordSize()}} */ @Override public final int serialize(int offset, byte[] data) { int dataSize = getDataSize(); int recSize = 4 + dataSize; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); out.writeShort(getSid()); out.writeShort(dataSize); serialize(out); if (out.getWriteIndex() - offset != recSize) { throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): " + "Incorrect number of bytes written - expected " + recSize + " but got " + (out.getWriteIndex() - offset)); } return recSize; }
@Override public void write(LittleEndianByteArrayOutputStream bos) { // EncryptionVersionInfo (4 bytes): A Version structure (section 2.1.4), where // Version.vMajor MUST be 0x0004 and Version.vMinor MUST be 0x0004 bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); // Reserved (4 bytes): A value that MUST be 0x00000040 bos.writeInt(info.getEncryptionFlags()); EncryptionDocument ed = createEncryptionDocument(); marshallEncryptionDocument(ed, bos); } };
@Override public int serialize(int offset, byte[] data) { int recSize = getRecordSize(); int dataSize = recSize - 4; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); // NOSONAR out.writeShort(sid); out.writeShort(dataSize); if (_uninterpretedData == null) { for (int i = 0; i < subrecords.size(); i++) { SubRecord record = subrecords.get(i); record.serialize(out); } int expectedEndIx = offset+dataSize; // padding while (out.getWriteIndex() < expectedEndIx) { out.writeByte(0); } } else { out.write(_uninterpretedData); } return recSize; }
/** * serializes the header */ @Override public void write(LittleEndianByteArrayOutputStream bos) { int startIdx = bos.getWriteIndex(); LittleEndianOutput sizeOutput = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(getFlags()); bos.writeInt(0); // size extra bos.writeInt(getCipherAlgorithm().ecmaId); bos.writeInt(getHashAlgorithm().ecmaId); bos.writeInt(getKeySize()); bos.writeInt(getCipherProvider().ecmaId); bos.writeInt(0); // reserved1 bos.writeInt(0); // reserved2 String cspName = getCspName(); if (cspName == null) { cspName = getCipherProvider().cipherProviderName; } bos.write(StringUtil.getToUnicodeLE(cspName)); bos.writeShort(0); int headerSize = bos.getWriteIndex()-startIdx-LittleEndianConsts.INT_SIZE; sizeOutput.writeInt(headerSize); }
public void write(LittleEndianByteArrayOutputStream bos) { writeUnicodeLPP4(bos, featureIdentifier); bos.writeShort(readerVersionMajor); bos.writeShort(readerVersionMinor); bos.writeShort(updaterVersionMajor); bos.writeShort(updaterVersionMinor); bos.writeShort(writerVersionMajor); bos.writeShort(writerVersionMinor); } }
public void write(LittleEndianByteArrayOutputStream bos) { int start = bos.getWriteIndex(); LittleEndianOutput sizeOut = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(transformType); writeUnicodeLPP4(bos, transformerId); sizeOut.writeInt(bos.getWriteIndex()-start); writeUnicodeLPP4(bos, transformerName); bos.writeShort(readerVersionMajor); bos.writeShort(readerVersionMinor); bos.writeShort(updaterVersionMajor); bos.writeShort(updaterVersionMinor); bos.writeShort(writerVersionMajor); bos.writeShort(writerVersionMinor); } }
@Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); header.write(bos); verifier.write(bos); } };
public int serialize(int offset, byte[] data) { int recSize = getRecordSize(); int dataSize = recSize - 4; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); out.writeShort(sid); out.writeShort(dataSize); if (_uninterpretedData == null) { for (int i = 0; i < subrecords.size(); i++) { SubRecord record = subrecords.get(i); record.serialize(out); } int expectedEndIx = offset+dataSize; // padding while (out.getWriteIndex() < expectedEndIx) { out.writeByte(0); } } else { out.write(_uninterpretedData); } return recSize; }
public int serialize(int offset, byte[] data) { int recSize = getRecordSize(); int dataSize = recSize - 4; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); out.writeShort(sid); out.writeShort(dataSize); if (_uninterpretedData == null) { for (int i = 0; i < subrecords.size(); i++) { SubRecord record = subrecords.get(i); record.serialize(out); } int expectedEndIx = offset+dataSize; // padding while (out.getWriteIndex() < expectedEndIx) { out.writeByte(0); } } else { out.write(_uninterpretedData); } return recSize; }
@Override public void write(LittleEndianByteArrayOutputStream bos) { // EncryptionVersionInfo (4 bytes): A Version structure (section 2.1.4), where // Version.vMajor MUST be 0x0004 and Version.vMinor MUST be 0x0004 bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); // Reserved (4 bytes): A value that MUST be 0x00000040 bos.writeInt(info.getEncryptionFlags()); EncryptionDocument ed = createEncryptionDocument(); marshallEncryptionDocument(ed, bos); } };
/** * Write the data content of this BIFF record including the sid and record length. * <p> * The subclass must write the exact number of bytes as reported by * {@link org.apache.poi.hssf.record.Record#getRecordSize()}} */ @Override public final int serialize(int offset, byte[] data) { int dataSize = getDataSize(); int recSize = 4 + dataSize; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); out.writeShort(getSid()); out.writeShort(dataSize); serialize(out); if (out.getWriteIndex() - offset != recSize) { throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): " + "Incorrect number of bytes written - expected " + recSize + " but got " + (out.getWriteIndex() - offset)); } return recSize; }
@Override public void write(LittleEndianByteArrayOutputStream bos) { bos.writeShort(info.getVersionMajor()); bos.writeShort(info.getVersionMinor()); bos.writeInt(info.getEncryptionFlags()); header.write(bos); verifier.write(bos); } };
/** * Write the data content of this BIFF record including the sid and record length.<br/> * * The subclass must write the exact number of bytes as reported by * {@link org.apache.poi.hssf.record.Record#getRecordSize()}} */ @Override public final int serialize(int offset, byte[] data) { int dataSize = getDataSize(); int recSize = 4 + dataSize; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); out.writeShort(getSid()); out.writeShort(dataSize); serialize(out); if (out.getWriteIndex() - offset != recSize) { throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): " + "Incorrect number of bytes written - expected " + recSize + " but got " + (out.getWriteIndex() - offset)); } return recSize; }
/** * Write the data content of this BIFF record including the sid and record length.<br/> * * The subclass must write the exact number of bytes as reported by * {@link org.apache.poi.hssf.record.Record#getRecordSize()}} */ @Override public final int serialize(int offset, byte[] data) { int dataSize = getDataSize(); int recSize = 4 + dataSize; LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize); out.writeShort(getSid()); out.writeShort(dataSize); serialize(out); if (out.getWriteIndex() - offset != recSize) { throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): " + "Incorrect number of bytes written - expected " + recSize + " but got " + (out.getWriteIndex() - offset)); } return recSize; }
/** * Write the contents of the record back, so it can be written * to disk */ public void writeOut(OutputStream out) throws IOException { // Data byte data[] = new byte[1024]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(data, 0); bos.writeShort(ei.getVersionMajor()); bos.writeShort(ei.getVersionMinor()); bos.writeInt(ei.getEncryptionFlags()); ((CryptoAPIEncryptionHeader)ei.getHeader()).write(bos); ((CryptoAPIEncryptionVerifier)ei.getVerifier()).write(bos); // Header LittleEndian.putInt(_header, 4, bos.getWriteIndex()); out.write(_header); out.write(data, 0, bos.getWriteIndex()); bos.close(); }
/** * serializes the header */ @Override public void write(LittleEndianByteArrayOutputStream bos) { int startIdx = bos.getWriteIndex(); LittleEndianOutput sizeOutput = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(getFlags()); bos.writeInt(0); // size extra bos.writeInt(getCipherAlgorithm().ecmaId); bos.writeInt(getHashAlgorithm().ecmaId); bos.writeInt(getKeySize()); bos.writeInt(getCipherProvider().ecmaId); bos.writeInt(0); // reserved1 bos.writeInt(0); // reserved2 String cspName = getCspName(); if (cspName == null) { cspName = getCipherProvider().cipherProviderName; } bos.write(StringUtil.getToUnicodeLE(cspName)); bos.writeShort(0); int headerSize = bos.getWriteIndex()-startIdx-LittleEndianConsts.INT_SIZE; sizeOutput.writeInt(headerSize); }