package org.apache.poi.hssf.record;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.LittleEndianOutputStream;
/**
* Title: File Pass Record (0x002F) <p>
private static final int ENCRYPTION_XOR = 0;
private static final int ENCRYPTION_OTHER = 1;
- private int encryptionType;
+ private final int encryptionType;
private EncryptionInfo encryptionInfo;
- private int dataLength;
private FilePassRecord(FilePassRecord other) {
- dataLength = other.dataLength;
encryptionType = other.encryptionType;
try {
encryptionInfo = other.encryptionInfo.clone();
}
public FilePassRecord(RecordInputStream in) {
- dataLength = in.remaining();
encryptionType = in.readUShort();
EncryptionMode preferredMode;
}
}
- public void serialize(LittleEndianOutput out) {
+ @Override
+ public void serialize(LittleEndianOutput out) {
out.writeShort(encryptionType);
byte data[] = new byte[1024];
case cryptoAPI:
out.writeShort(encryptionInfo.getVersionMajor());
out.writeShort(encryptionInfo.getVersionMinor());
+ out.writeInt(encryptionInfo.getEncryptionFlags());
((CryptoAPIEncryptionHeader)encryptionInfo.getHeader()).write(bos);
((CryptoAPIEncryptionVerifier)encryptionInfo.getVerifier()).write(bos);
break;
out.write(data, 0, bos.getWriteIndex());
}
- protected int getDataSize() {
- return dataLength;
+ @Override
+ @SuppressWarnings("resource")
+ protected int getDataSize() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ LittleEndianOutputStream leos = new LittleEndianOutputStream(bos);
+ serialize(leos);
+ return bos.size();
}
public EncryptionInfo getEncryptionInfo() {
return encryptionInfo;
}
+ @Override
public short getSid() {
return sid;
}
return new FilePassRecord(this);
}
- public String toString() {
+ @Override
+ public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[FILEPASS]\n");