private final Record _lastRecord;
private final boolean _hasBOFRecord;
- private static POILogger log = POILogFactory.getLogger(StreamEncryptionInfo.class);
-
public StreamEncryptionInfo(RecordInputStream rs, List<Record> outputRecs) {
Record rec;
rs.nextRecord();
if (password != null) {
Biff8EncryptionKey.setCurrentUserPassword(password);
}
- Workbook wb = new HSSFWorkbook(root, true);
- Biff8EncryptionKey.setCurrentUserPassword(null);
- return wb;
+ try {
+ return new HSSFWorkbook(root, true);
+ } finally {
+ Biff8EncryptionKey.setCurrentUserPassword(null);
+ }
}
/**
import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader;\r
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;\r
import org.apache.poi.poifs.filesystem.POIFSFileSystem;\r
+import org.junit.After;\r
import org.junit.Before;\r
import org.junit.Test;\r
\r
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();\r
\r
@Before\r
+ @After // also afterwards to not affect other tests running in the same JVM\r
public void resetPassword() {\r
Biff8EncryptionKey.setCurrentUserPassword(null);\r
}\r
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.After;
/**
* Testing for {@link HSSFEventFactory}
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
}
+ // to not affect other tests running in the same JVM
+ @After
+ public void resetPassword() {
+ Biff8EncryptionKey.setCurrentUserPassword(null);
+ }
+
public void testWithMissingRecords() throws Exception {
HSSFRequest req = new HSSFRequest();
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LocaleUtil;
+import org.junit.After;
import org.junit.Test;
/**
*
*/
public final class TestExcelExtractor {
+ // to not affect other tests running in the same JVM
+ @After
+ public void resetPassword() {
+ Biff8EncryptionKey.setCurrentUserPassword(null);
+ }
@SuppressWarnings("resource")
private static ExcelExtractor createExtractor(String sampleFileName) throws IOException {
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.util.HexRead;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
* @author Josh Micich
*/
public final class TestRecordFactoryInputStream {
+ // to not affect other tests running in the same JVM
+ @After
+ public void resetPassword() {
+ Biff8EncryptionKey.setCurrentUserPassword(null);
+ }
/**
* Hex dump of a BOF record and most of a FILEPASS record.
import org.apache.poi.poifs.crypt.CryptoFunctions;\r
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;\r
import org.apache.poi.util.HexRead;\r
+import org.junit.After;\r
import org.junit.Test;\r
\r
public class TestXorEncryption {\r
\r
private static HSSFTestDataSamples samples = new HSSFTestDataSamples();\r
\r
+ // to not affect other tests running in the same JVM\r
+ @After\r
+ public void resetPassword() {\r
+ Biff8EncryptionKey.setCurrentUserPassword(null);\r
+ }\r
+\r
@Test\r
public void testXorEncryption() throws Exception {\r
// Xor-Password: abc\r
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.LocaleUtil;
+import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
* define the test in the base class {@link BaseTestBugzillaIssues}</b>
*/
public final class TestBugs extends BaseTestBugzillaIssues {
+ // to not affect other tests running in the same JVM
+ @After
+ public void resetPassword() {
+ Biff8EncryptionKey.setCurrentUserPassword(null);
+ }
public TestBugs() {
super(HSSFITestDataProvider.instance);