Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 25FC2200BC9 for ; Sat, 12 Nov 2016 00:22:51 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 24939160B01; Fri, 11 Nov 2016 23:22:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 16ABA160AF6 for ; Sat, 12 Nov 2016 00:22:49 +0100 (CET) Received: (qmail 91798 invoked by uid 500); 11 Nov 2016 23:22:49 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 91789 invoked by uid 99); 11 Nov 2016 23:22:49 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Nov 2016 23:22:49 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id CA5651A8C00 for ; Fri, 11 Nov 2016 23:22:48 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id LzD2k_VTXZr7 for ; Fri, 11 Nov 2016 23:22:46 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id DDE6C5F1E9 for ; Fri, 11 Nov 2016 23:22:45 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id CDAD0E10A5 for ; Fri, 11 Nov 2016 23:22:44 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 6DC863A19F6 for ; Fri, 11 Nov 2016 23:22:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1769363 [2/2] - in /poi/trunk/src: examples/src/org/apache/poi/crypt/examples/ examples/src/org/apache/poi/examples/util/ examples/src/org/apache/poi/xssf/eventusermodel/examples/ examples/src/org/apache/poi/xssf/streaming/examples/ exampl... Date: Fri, 11 Nov 2016 23:22:43 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20161111232244.6DC863A19F6@svn01-us-west.apache.org> archived-at: Fri, 11 Nov 2016 23:22:51 -0000 Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java?rev=1769363&r1=1769362&r2=1769363&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java Fri Nov 11 23:22:43 2016 @@ -27,31 +27,19 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.nio.charset.Charset; import java.security.GeneralSecurityException; -import java.security.SecureRandom; import java.util.List; -import javax.crypto.Cipher; -import javax.crypto.CipherInputStream; -import javax.crypto.CipherOutputStream; -import javax.crypto.spec.SecretKeySpec; - import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.util.ZipEntrySource; -import org.apache.poi.poifs.crypt.AesZipFileZipEntrySource; -import org.apache.poi.poifs.crypt.ChainingMode; -import org.apache.poi.poifs.crypt.CipherAlgorithm; -import org.apache.poi.poifs.crypt.CryptoFunctions; +import org.apache.poi.poifs.crypt.temp.AesZipFileZipEntrySource; +import org.apache.poi.poifs.crypt.temp.EncryptedTempData; +import org.apache.poi.poifs.crypt.temp.SXSSFWorkbookWithCustomZipEntrySource; import org.apache.poi.util.IOUtils; -import org.apache.poi.util.POILogFactory; -import org.apache.poi.util.POILogger; -import org.apache.poi.util.TempFile; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; @@ -145,104 +133,4 @@ public final class TestSXSSFWorkbookWith workbook.dispose(); assertFalse("tempFile deleted after dispose?", tempFile.exists()); } - - static class SXSSFWorkbookWithCustomZipEntrySource extends SXSSFWorkbook { - - private static final POILogger logger = POILogFactory.getLogger(SXSSFWorkbookWithCustomZipEntrySource.class); - - @Override - public void write(OutputStream stream) throws IOException { - flushSheets(); - EncryptedTempData tempData = new EncryptedTempData(); - OutputStream os = tempData.getOutputStream(); - getXSSFWorkbook().write(os); - os.close(); - ZipEntrySource source = null; - try { - // provide ZipEntrySource to poi which decrypts on the fly - source = AesZipFileZipEntrySource.createZipEntrySource(tempData.getInputStream()); - injectData(source, stream); - } catch (GeneralSecurityException e) { - throw new IOException(e); - } finally { - tempData.dispose(); - IOUtils.closeQuietly(source); - } - } - - @Override - protected SheetDataWriter createSheetDataWriter() throws IOException { - //log values to ensure these values are accessible to subclasses - logger.log(POILogger.INFO, "isCompressTempFiles: " + isCompressTempFiles()); - logger.log(POILogger.INFO, "SharedStringSource: " + getSharedStringSource()); - return new SheetDataWriterWithDecorator(); - } - } - - static class SheetDataWriterWithDecorator extends SheetDataWriter { - final static CipherAlgorithm cipherAlgorithm = CipherAlgorithm.aes128; - SecretKeySpec skeySpec; - byte[] ivBytes; - - public SheetDataWriterWithDecorator() throws IOException { - super(); - } - - void init() { - if(skeySpec == null) { - SecureRandom sr = new SecureRandom(); - ivBytes = new byte[16]; - byte[] keyBytes = new byte[16]; - sr.nextBytes(ivBytes); - sr.nextBytes(keyBytes); - skeySpec = new SecretKeySpec(keyBytes, cipherAlgorithm.jceId); - } - } - - @Override - protected OutputStream decorateOutputStream(FileOutputStream fos) { - init(); - Cipher ciEnc = CryptoFunctions.getCipher(skeySpec, cipherAlgorithm, ChainingMode.cbc, ivBytes, Cipher.ENCRYPT_MODE, "PKCS5Padding"); - return new CipherOutputStream(fos, ciEnc); - } - - @Override - protected InputStream decorateInputStream(FileInputStream fis) { - Cipher ciDec = CryptoFunctions.getCipher(skeySpec, cipherAlgorithm, ChainingMode.cbc, ivBytes, Cipher.DECRYPT_MODE, "PKCS5Padding"); - return new CipherInputStream(fis, ciDec); - } - } - - // a class to save and read an AES-encrypted workbook - static class EncryptedTempData { - final static CipherAlgorithm cipherAlgorithm = CipherAlgorithm.aes128; - final SecretKeySpec skeySpec; - final byte[] ivBytes; - final File tempFile; - - EncryptedTempData() throws IOException { - SecureRandom sr = new SecureRandom(); - ivBytes = new byte[16]; - byte[] keyBytes = new byte[16]; - sr.nextBytes(ivBytes); - sr.nextBytes(keyBytes); - skeySpec = new SecretKeySpec(keyBytes, cipherAlgorithm.jceId); - tempFile = TempFile.createTempFile("poi-temp-data", ".tmp"); - } - - OutputStream getOutputStream() throws IOException { - Cipher ciEnc = CryptoFunctions.getCipher(skeySpec, cipherAlgorithm, ChainingMode.cbc, ivBytes, Cipher.ENCRYPT_MODE, null); - return new CipherOutputStream(new FileOutputStream(tempFile), ciEnc); - } - - InputStream getInputStream() throws IOException { - Cipher ciDec = CryptoFunctions.getCipher(skeySpec, cipherAlgorithm, ChainingMode.cbc, ivBytes, Cipher.DECRYPT_MODE, null); - return new CipherInputStream(new FileInputStream(tempFile), ciDec); - } - - void dispose() { - assertTrue("Could not delete tempfile " + tempFile + ": " + tempFile.exists(), - !tempFile.exists() || tempFile.delete()); - } - } -} +} \ No newline at end of file Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/pointers/PointerV5.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/pointers/PointerV5.java?rev=1769363&r1=1769362&r2=1769363&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/pointers/PointerV5.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/pointers/PointerV5.java Fri Nov 11 23:22:43 2016 @@ -28,14 +28,24 @@ public final class PointerV5 extends Poi return (0x40 <= format && format < 0x50); } public boolean destinationHasPointers() { - if(type == 20) return true; - if(type == 22) return false; - if(format == 0x1d || format == 0x1e) return true; + if(type == 20) { + return true; + } + if(type == 22) { + return false; + } + if(format == 0x1d || format == 0x1e) { + return true; + } return (0x50 <= format && format < 0x60); } public boolean destinationHasChunks() { - if (type == 21) return true; - if (type == 24) return true; + if (type == 21) { + return true; + } + if (type == 24) { + return true; + } return (0xd0 <= format && format < 0xdf); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java?rev=1769363&r1=1769362&r2=1769363&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java Fri Nov 11 23:22:43 2016 @@ -33,7 +33,7 @@ import org.apache.poi.util.Units; * Represents Macintosh PICT picture data. */ public final class PICT extends Metafile { - private static POILogger LOG = POILogFactory.getLogger(PICT.class); + private static final POILogger LOG = POILogFactory.getLogger(PICT.class); public static class NativeHeader { /** Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java?rev=1769363&r1=1769362&r2=1769363&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java Fri Nov 11 23:22:43 2016 @@ -346,7 +346,9 @@ public final class HSLFFreeformShape ext } private void fillPoint(byte xyMaster[], double xyPoints[]) { - if (xyMaster == null || xyPoints == null || (xyMaster.length != 4 && xyMaster.length != 8) || xyPoints.length != 2) { + int masterCnt = (xyMaster == null) ? 0 : xyMaster.length; + int pointCnt = (xyPoints == null) ? 0 : xyPoints.length; + if ((masterCnt != 4 && masterCnt != 8) || pointCnt != 2) { logger.log(POILogger.WARN, "Invalid number of master bytes for a single point - ignore point"); return; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org