Browse Source

Code-style: Unify how arrays are specified from C-style to normal Java-style

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1849716 13f79535-47bb-0310-9956-ffa450edef68
pull/140/head
centic 5 years ago
parent
commit
2bd8838fd8
100 changed files with 431 additions and 424 deletions
  1. 1
    1
      src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java
  2. 1
    1
      src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java
  3. 1
    1
      src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java
  4. 1
    1
      src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java
  5. 1
    1
      src/java/org/apache/poi/ddf/EscherBitmapBlip.java
  6. 1
    1
      src/java/org/apache/poi/ddf/EscherRecord.java
  7. 3
    3
      src/java/org/apache/poi/hpsf/Section.java
  8. 41
    41
      src/java/org/apache/poi/hpsf/Variant.java
  9. 1
    1
      src/java/org/apache/poi/hssf/dev/BiffViewer.java
  10. 1
    1
      src/java/org/apache/poi/hssf/dev/FormulaViewer.java
  11. 3
    3
      src/java/org/apache/poi/hssf/model/InternalWorkbook.java
  12. 1
    1
      src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
  13. 1
    1
      src/java/org/apache/poi/hssf/record/FilePassRecord.java
  14. 1
    1
      src/java/org/apache/poi/hssf/record/WSBoolRecord.java
  15. 3
    3
      src/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java
  16. 6
    6
      src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java
  17. 4
    4
      src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java
  18. 1
    1
      src/java/org/apache/poi/hssf/usermodel/FontDetails.java
  19. 1
    1
      src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java
  20. 7
    7
      src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
  21. 1
    1
      src/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java
  22. 2
    2
      src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
  23. 2
    2
      src/java/org/apache/poi/poifs/crypt/CipherAlgorithm.java
  24. 32
    32
      src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
  25. 14
    14
      src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
  26. 1
    1
      src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
  27. 1
    1
      src/java/org/apache/poi/poifs/crypt/Encryptor.java
  28. 9
    9
      src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java
  29. 9
    9
      src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java
  30. 8
    8
      src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Encryptor.java
  31. 9
    9
      src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
  32. 3
    3
      src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentInputStream.java
  33. 1
    1
      src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java
  34. 3
    3
      src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java
  35. 10
    10
      src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java
  36. 8
    8
      src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
  37. 10
    10
      src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java
  38. 5
    5
      src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java
  39. 5
    5
      src/java/org/apache/poi/poifs/crypt/xor/XORDecryptor.java
  40. 2
    2
      src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java
  41. 9
    9
      src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
  42. 1
    1
      src/java/org/apache/poi/poifs/dev/POIFSLister.java
  43. 1
    1
      src/java/org/apache/poi/poifs/dev/POIFSViewer.java
  44. 1
    1
      src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java
  45. 1
    1
      src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
  46. 1
    1
      src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
  47. 1
    1
      src/java/org/apache/poi/poifs/filesystem/POIFSStream.java
  48. 1
    1
      src/java/org/apache/poi/poifs/macros/VBAMacroExtractor.java
  49. 1
    1
      src/java/org/apache/poi/sl/draw/BitmapImageRenderer.java
  50. 1
    1
      src/java/org/apache/poi/sl/draw/DrawFactory.java
  51. 1
    1
      src/java/org/apache/poi/sl/draw/DrawFontManagerDefault.java
  52. 2
    2
      src/java/org/apache/poi/sl/draw/DrawShape.java
  53. 4
    4
      src/java/org/apache/poi/sl/draw/DrawTableShape.java
  54. 1
    1
      src/java/org/apache/poi/sl/draw/ImageRenderer.java
  55. 1
    1
      src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java
  56. 1
    1
      src/java/org/apache/poi/sl/image/ImageHeaderEMF.java
  57. 8
    8
      src/java/org/apache/poi/sl/image/ImageHeaderPICT.java
  58. 26
    26
      src/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java
  59. 1
    1
      src/java/org/apache/poi/sl/usermodel/PresetColor.java
  60. 2
    2
      src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java
  61. 1
    1
      src/java/org/apache/poi/sl/usermodel/StrokeStyle.java
  62. 2
    2
      src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java
  63. 2
    2
      src/java/org/apache/poi/ss/format/CellNumberFormatter.java
  64. 2
    2
      src/java/org/apache/poi/ss/formula/CacheAreaEval.java
  65. 2
    2
      src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
  66. 3
    3
      src/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java
  67. 3
    3
      src/java/org/apache/poi/ss/formula/functions/Days360.java
  68. 21
    18
      src/java/org/apache/poi/ss/formula/functions/MatrixFunction.java
  69. 2
    2
      src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java
  70. 1
    2
      src/java/org/apache/poi/ss/util/CellUtil.java
  71. 1
    1
      src/java/org/apache/poi/util/IOUtils.java
  72. 4
    4
      src/java/org/apache/poi/util/LittleEndianInputStream.java
  73. 8
    4
      src/java/org/apache/poi/util/POILogger.java
  74. 2
    2
      src/java/org/apache/poi/util/StringUtil.java
  75. 1
    1
      src/ooxml/java/org/apache/poi/openxml4j/opc/StreamHelper.java
  76. 1
    1
      src/ooxml/java/org/apache/poi/openxml4j/util/ZipArchiveThresholdInputStream.java
  77. 14
    14
      src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java
  78. 3
    2
      src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java
  79. 5
    5
      src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java
  80. 17
    17
      src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
  81. 6
    6
      src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java
  82. 4
    4
      src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java
  83. 1
    1
      src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
  84. 1
    1
      src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java
  85. 2
    2
      src/ooxml/java/org/apache/poi/poifs/crypt/temp/AesZipFileZipEntrySource.java
  86. 2
    2
      src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
  87. 1
    1
      src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java
  88. 1
    1
      src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java
  89. 2
    2
      src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
  90. 2
    2
      src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
  91. 1
    1
      src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
  92. 7
    7
      src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPasswordHelper.java
  93. 5
    5
      src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
  94. 6
    6
      src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java
  95. 1
    1
      src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java
  96. 1
    1
      src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLiteAgent.java
  97. 7
    7
      src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java
  98. 1
    1
      src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java
  99. 5
    5
      src/ooxml/testcases/org/apache/poi/poifs/crypt/TestAgileEncryptionParameters.java
  100. 0
    0
      src/ooxml/testcases/org/apache/poi/poifs/crypt/TestCertificateEncryption.java

+ 1
- 1
src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java View File

@@ -39,7 +39,7 @@ import org.apache.poi.hwpf.usermodel.Range;
*/
public final class DataExtraction {

public static void main(String args[]) throws Exception {
public static void main(String[] args) throws Exception {

if (args.length == 0) {
usage();

+ 1
- 1
src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java View File

@@ -92,7 +92,7 @@ public class ExcelComparator {
List<String> listOfDifferences = new ArrayList<>();

public static void main(String args[]) throws Exception {
public static void main(String[] args) throws Exception {
if (args.length != 2 || !(new File(args[0]).exists()) || !(new File(args[1]).exists())) {
System.err.println("java -cp <classpath> "+ExcelComparator.class.getCanonicalName()+" <workbook1.xls/x> <workbook2.xls/x");
System.exit(-1);

+ 1
- 1
src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java View File

@@ -33,7 +33,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
*/
public final class DataExtraction {

public static void main(String args[]) throws IOException, OpenXML4JException {
public static void main(String[] args) throws IOException, OpenXML4JException {

PrintStream out = System.out;


+ 1
- 1
src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java View File

@@ -27,7 +27,7 @@ import java.io.FileOutputStream;
*/
public final class MergePresentations {

public static void main(String args[]) throws Exception {
public static void main(String[] args) throws Exception {
try (XMLSlideShow ppt = new XMLSlideShow()) {
for (String arg : args) {
try (FileInputStream is = new FileInputStream(arg);

+ 1
- 1
src/java/org/apache/poi/ddf/EscherBitmapBlip.java View File

@@ -53,7 +53,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {

System.arraycopy( field_1_UID, 0, data, pos, 16 );
data[pos + 16] = field_2_marker;
byte pd[] = getPicturedata();
byte[] pd = getPicturedata();
System.arraycopy( pd, 0, data, pos + 17, pd.length );

listener.afterRecordSerialize(offset + getRecordSize(), getRecordId(), getRecordSize(), this);

+ 1
- 1
src/java/org/apache/poi/ddf/EscherRecord.java View File

@@ -93,7 +93,7 @@ public abstract class EscherRecord implements Cloneable {
* @param offset the offset to start reading from
* @return value of instance part of options field
*/
protected static short readInstance( byte data[], int offset ) {
protected static short readInstance(byte[] data, int offset ) {
final short options = LittleEndian.getShort( data, offset );
return fInstance.getShortValue( options );
}

+ 3
- 3
src/java/org/apache/poi/hpsf/Section.java View File

@@ -831,7 +831,7 @@ public class Section {
}

try {
byte buf[] = IOUtils.safelyAllocate(nrBytes, MAX_RECORD_LENGTH);
byte[] buf = IOUtils.safelyAllocate(nrBytes, MAX_RECORD_LENGTH);
leis.readFully(buf, 0, nrBytes);
final String str = CodePageUtil.getStringFromCodePage(buf, 0, nrBytes, cp);

@@ -862,7 +862,7 @@ public class Section {
*/
private void writeDictionary(final OutputStream out, final int codepage)
throws IOException {
final byte padding[] = new byte[4];
final byte[] padding = new byte[4];
final Map<Long,String> dic = getDictionary();

LittleEndian.putUInt(dic.size(), out);
@@ -873,7 +873,7 @@ public class Section {
length += LittleEndianConsts.INT_SIZE;

final String value = ls.getValue()+"\0";
final byte bytes[] = CodePageUtil.getBytesInCodePage(value, codepage);
final byte[] bytes = CodePageUtil.getBytesInCodePage(value, codepage);
final int len = (codepage == CodePageUtil.CP_UNICODE) ? value.length() : bytes.length;

LittleEndian.putUInt( len, out );

+ 41
- 41
src/java/org/apache/poi/hpsf/Variant.java View File

@@ -342,47 +342,47 @@ public class Variant
*/
public static final Integer LENGTH_8 = 8;

private static final Object NUMBER_TO_NAME_LIST[][] = {
{ 0L, "VT_EMPTY", LENGTH_0 },
{ 1L, "VT_NULL", LENGTH_UNKNOWN },
{ 2L, "VT_I2", LENGTH_2 },
{ 3L, "VT_I4", LENGTH_4 },
{ 4L, "VT_R4", LENGTH_4 },
{ 5L, "VT_R8", LENGTH_8 },
{ 6L, "VT_CY", LENGTH_UNKNOWN },
{ 7L, "VT_DATE", LENGTH_UNKNOWN },
{ 8L, "VT_BSTR", LENGTH_UNKNOWN },
{ 9L, "VT_DISPATCH", LENGTH_UNKNOWN },
{ 10L, "VT_ERROR", LENGTH_UNKNOWN },
{ 11L, "VT_BOOL", LENGTH_UNKNOWN },
{ 12L, "VT_VARIANT", LENGTH_UNKNOWN },
{ 13L, "VT_UNKNOWN", LENGTH_UNKNOWN },
{ 14L, "VT_DECIMAL", LENGTH_UNKNOWN },
{ 16L, "VT_I1", LENGTH_UNKNOWN },
{ 17L, "VT_UI1", LENGTH_UNKNOWN },
{ 18L, "VT_UI2", LENGTH_UNKNOWN },
{ 19L, "VT_UI4", LENGTH_UNKNOWN },
{ 20L, "VT_I8", LENGTH_UNKNOWN },
{ 21L, "VT_UI8", LENGTH_UNKNOWN },
{ 22L, "VT_INT", LENGTH_UNKNOWN },
{ 23L, "VT_UINT", LENGTH_UNKNOWN },
{ 24L, "VT_VOID", LENGTH_UNKNOWN },
{ 25L, "VT_HRESULT", LENGTH_UNKNOWN },
{ 26L, "VT_PTR", LENGTH_UNKNOWN },
{ 27L, "VT_SAFEARRAY", LENGTH_UNKNOWN },
{ 28L, "VT_CARRAY", LENGTH_UNKNOWN },
{ 29L, "VT_USERDEFINED", LENGTH_UNKNOWN },
{ 30L, "VT_LPSTR", LENGTH_VARIABLE },
{ 31L, "VT_LPWSTR", LENGTH_UNKNOWN },
{ 64L, "VT_FILETIME", LENGTH_8 },
{ 65L, "VT_BLOB", LENGTH_UNKNOWN },
{ 66L, "VT_STREAM", LENGTH_UNKNOWN },
{ 67L, "VT_STORAGE", LENGTH_UNKNOWN },
{ 68L, "VT_STREAMED_OBJECT", LENGTH_UNKNOWN },
{ 69L, "VT_STORED_OBJECT", LENGTH_UNKNOWN },
{ 70L, "VT_BLOB_OBJECT", LENGTH_UNKNOWN },
{ 71L, "VT_CF", LENGTH_UNKNOWN },
{ 72L, "VT_CLSID", LENGTH_UNKNOWN }
private static final Object[][] NUMBER_TO_NAME_LIST = {
{0L, "VT_EMPTY", LENGTH_0},
{1L, "VT_NULL", LENGTH_UNKNOWN},
{2L, "VT_I2", LENGTH_2},
{3L, "VT_I4", LENGTH_4},
{4L, "VT_R4", LENGTH_4},
{5L, "VT_R8", LENGTH_8},
{6L, "VT_CY", LENGTH_UNKNOWN},
{7L, "VT_DATE", LENGTH_UNKNOWN},
{8L, "VT_BSTR", LENGTH_UNKNOWN},
{9L, "VT_DISPATCH", LENGTH_UNKNOWN},
{10L, "VT_ERROR", LENGTH_UNKNOWN},
{11L, "VT_BOOL", LENGTH_UNKNOWN},
{12L, "VT_VARIANT", LENGTH_UNKNOWN},
{13L, "VT_UNKNOWN", LENGTH_UNKNOWN},
{14L, "VT_DECIMAL", LENGTH_UNKNOWN},
{16L, "VT_I1", LENGTH_UNKNOWN},
{17L, "VT_UI1", LENGTH_UNKNOWN},
{18L, "VT_UI2", LENGTH_UNKNOWN},
{19L, "VT_UI4", LENGTH_UNKNOWN},
{20L, "VT_I8", LENGTH_UNKNOWN},
{21L, "VT_UI8", LENGTH_UNKNOWN},
{22L, "VT_INT", LENGTH_UNKNOWN},
{23L, "VT_UINT", LENGTH_UNKNOWN},
{24L, "VT_VOID", LENGTH_UNKNOWN},
{25L, "VT_HRESULT", LENGTH_UNKNOWN},
{26L, "VT_PTR", LENGTH_UNKNOWN},
{27L, "VT_SAFEARRAY", LENGTH_UNKNOWN},
{28L, "VT_CARRAY", LENGTH_UNKNOWN},
{29L, "VT_USERDEFINED", LENGTH_UNKNOWN},
{30L, "VT_LPSTR", LENGTH_VARIABLE},
{31L, "VT_LPWSTR", LENGTH_UNKNOWN},
{64L, "VT_FILETIME", LENGTH_8},
{65L, "VT_BLOB", LENGTH_UNKNOWN},
{66L, "VT_STREAM", LENGTH_UNKNOWN},
{67L, "VT_STORAGE", LENGTH_UNKNOWN},
{68L, "VT_STREAMED_OBJECT", LENGTH_UNKNOWN},
{69L, "VT_STORED_OBJECT", LENGTH_UNKNOWN},
{70L, "VT_BLOB_OBJECT", LENGTH_UNKNOWN},
{71L, "VT_CF", LENGTH_UNKNOWN},
{72L, "VT_CLSID", LENGTH_UNKNOWN}
};

/* Initialize the number-to-name and number-to-length map: */

+ 1
- 1
src/java/org/apache/poi/hssf/dev/BiffViewer.java View File

@@ -699,7 +699,7 @@ public final class BiffViewer {
return ib;
}

private static void writeHex(char buf[], int startInBuf, int value, int nDigits) {
private static void writeHex(char[] buf, int startInBuf, int value, int nDigits) {
int acc = value;
for(int i=nDigits-1; i>=0; i--) {
int digit = acc & 0x0F;

+ 1
- 1
src/java/org/apache/poi/hssf/dev/FormulaViewer.java View File

@@ -210,7 +210,7 @@ public class FormulaViewer
* @param args pass one argument with the filename or --help
* @throws IOException if the file can't be read or contained errors
*/
public static void main(String args[]) throws IOException
public static void main(String[] args) throws IOException
{
if ((args == null) || (args.length >2 )
|| args[ 0 ].equals("--help"))

+ 3
- 3
src/java/org/apache/poi/hssf/model/InternalWorkbook.java View File

@@ -1338,7 +1338,7 @@ public final class InternalWorkbook {
*/
private static FormatRecord createFormat(int id) {
// we'll need multiple editions for the different formats
final int mappings[] = { 5, 6, 7, 8, 0x2a, 0x29, 0x2c, 0x2b };
final int[] mappings = {5, 6, 7, 8, 0x2a, 0x29, 0x2c, 0x2b};
if (id < 0 || id >= mappings.length) {
throw new IllegalArgumentException("Unexpected id " + id);
}
@@ -1433,8 +1433,8 @@ public final class InternalWorkbook {
*/
private static StyleRecord createStyle(int id) {
// we'll need multiple editions
final int mappings[][] = {
{ 0x010, 3 }, { 0x011, 6 }, { 0x012, 4 }, { 0x013, 7 }, { 0x000, 0 }, { 0x014, 5 }
final int[][] mappings = {
{0x010, 3}, {0x011, 6}, {0x012, 4}, {0x013, 7}, {0x000, 0}, {0x014, 5}
};
if (id < 0 || id >= mappings.length) {
throw new IllegalArgumentException("Unexpected style id " + id);

+ 1
- 1
src/java/org/apache/poi/hssf/record/BoundSheetRecord.java View File

@@ -62,7 +62,7 @@ public final class BoundSheetRecord extends StandardRecord {
* @param in the record stream to read from
*/
public BoundSheetRecord(RecordInputStream in) {
byte buf[] = new byte[LittleEndianConsts.INT_SIZE];
byte[] buf = new byte[LittleEndianConsts.INT_SIZE];
in.readPlain(buf, 0, buf.length);
field_1_position_of_BOF = LittleEndian.getInt(buf);
field_2_option_flags = in.readUShort();

+ 1
- 1
src/java/org/apache/poi/hssf/record/FilePassRecord.java View File

@@ -88,7 +88,7 @@ public final class FilePassRecord extends StandardRecord implements Cloneable {
public void serialize(LittleEndianOutput out) {
out.writeShort(encryptionType);

byte data[] = new byte[1024];
byte[] data = new byte[1024];
LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(data, 0); // NOSONAR

switch (encryptionInfo.getEncryptionMode()) {

+ 1
- 1
src/java/org/apache/poi/hssf/record/WSBoolRecord.java View File

@@ -55,7 +55,7 @@ public final class WSBoolRecord extends StandardRecord {

public WSBoolRecord(RecordInputStream in)
{
byte data[] = in.readRemainder();
byte[] data = in.readRemainder();
field_1_wsbool =
data[ 1 ]; // backwards because theoretically this is one short field
field_2_wsbool =

+ 3
- 3
src/java/org/apache/poi/hssf/record/crypto/Biff8DecryptingStream.java View File

@@ -41,12 +41,12 @@ public final class Biff8DecryptingStream implements BiffHeaderInput, LittleEndia
private static final int MAX_RECORD_LENGTH = 100_000;

private ChunkedCipherInputStream ccis;
private final byte buffer[] = new byte[LittleEndianConsts.LONG_SIZE];
private final byte[] buffer = new byte[LittleEndianConsts.LONG_SIZE];
private boolean shouldSkipEncryptionOnCurrentRecord;

public Biff8DecryptingStream(InputStream in, int initialOffset, EncryptionInfo info) throws RecordFormatException {
try {
byte initialBuf[] = IOUtils.safelyAllocate(initialOffset, MAX_RECORD_LENGTH);
byte[] initialBuf = IOUtils.safelyAllocate(initialOffset, MAX_RECORD_LENGTH);
InputStream stream;
if (initialOffset == 0) {
stream = in;
@@ -207,7 +207,7 @@ public final class Biff8DecryptingStream implements BiffHeaderInput, LittleEndia
}

@Override
public void readPlain(byte b[], int off, int len) {
public void readPlain(byte[] b, int off, int len) {
ccis.readPlain(b, off, len);
}


+ 6
- 6
src/java/org/apache/poi/hssf/usermodel/EscherGraphics.java View File

@@ -244,8 +244,8 @@ public class EscherGraphics extends Graphics
}

@Override
public void drawPolygon(int xPoints[], int yPoints[],
int nPoints)
public void drawPolygon(int[] xPoints, int[] yPoints,
int nPoints)
{
int right = findBiggest(xPoints);
int bottom = findBiggest(yPoints);
@@ -269,8 +269,8 @@ public class EscherGraphics extends Graphics

@Override
@NotImplemented
public void drawPolyline(int xPoints[], int yPoints[],
int nPoints)
public void drawPolyline(int[] xPoints, int[] yPoints,
int nPoints)
{
if (logger.check( POILogger.WARN ))
logger.log(POILogger.WARN,"drawPolyline not supported");
@@ -401,8 +401,8 @@ public class EscherGraphics extends Graphics
* @see java.awt.Graphics#drawPolygon(int[], int[], int)
*/
@Override
public void fillPolygon(int xPoints[], int yPoints[],
int nPoints)
public void fillPolygon(int[] xPoints, int[] yPoints,
int nPoints)
{
int right = findBiggest(xPoints);
int bottom = findBiggest(yPoints);

+ 4
- 4
src/java/org/apache/poi/hssf/usermodel/EscherGraphics2d.java View File

@@ -243,13 +243,13 @@ public final class EscherGraphics2d extends Graphics2D {
// draw(new java.awt.geom.Ellipse2D.Float(x, y, width, height));
}

public void drawPolygon(int xPoints[], int yPoints[],
int nPoints)
public void drawPolygon(int[] xPoints, int[] yPoints,
int nPoints)
{
getEscherGraphics().drawPolygon(xPoints, yPoints, nPoints);
}

public void drawPolyline(int xPoints[], int yPoints[], int nPoints)
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
{
if(nPoints > 0)
{
@@ -343,7 +343,7 @@ public final class EscherGraphics2d extends Graphics2D {
* @param nPoints the total number of points in the polygon.
* @see java.awt.Graphics#drawPolygon(int[], int[], int)
*/
public void fillPolygon(int xPoints[], int yPoints[], int nPoints)
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
{
_escherGraphics.fillPolygon(xPoints, yPoints, nPoints);
}

+ 1
- 1
src/java/org/apache/poi/hssf/usermodel/FontDetails.java View File

@@ -151,7 +151,7 @@ public class FontDetails
int listSize = tok.countTokens();
if(max != -1 && listSize > max)
listSize = max;
String list[] = new String[listSize];
String[] list = new String[listSize];
for(int i = 0; tok.hasMoreTokens(); i++)
{
if(max != -1 && i == listSize - 1)

+ 1
- 1
src/java/org/apache/poi/hssf/usermodel/HSSFPicture.java View File

@@ -256,7 +256,7 @@ public class HSSFPicture extends HSSFSimpleShape implements Picture {
public void setFileName(String data){
// TODO: add trailing \u0000?
byte bytes[] = StringUtil.getToUnicodeLE(data);
byte[] bytes = StringUtil.getToUnicodeLE(data);
EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, true, bytes);
setPropertyValue(prop);
}

+ 7
- 7
src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java View File

@@ -1508,7 +1508,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
}

@SuppressWarnings("resource")
void encryptBytes(byte buf[]) {
void encryptBytes(byte[] buf) {
EncryptionInfo ei = getEncryptionInfo();
if (ei == null) {
return;
@@ -1518,7 +1518,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
LittleEndianByteArrayInputStream plain = new LittleEndianByteArrayInputStream(buf, 0); // NOSONAR
LittleEndianByteArrayOutputStream leos = new LittleEndianByteArrayOutputStream(buf, 0); // NOSONAR
enc.setChunkSize(Biff8DecryptingStream.RC4_REKEYING_INTERVAL);
byte tmp[] = new byte[1024];
byte[] tmp = new byte[1024];
try {
ChunkedCipherOutputStream os = enc.getDataStream(leos, initialOffset);
int totalBytes = 0;
@@ -1532,7 +1532,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
if (sid == BoundSheetRecord.sid) {
// special case for the field_1_position_of_BOF (=lbPlyPos) field of
// the BoundSheet8 record which must be unencrypted
byte bsrBuf[] = IOUtils.safelyAllocate(len, MAX_RECORD_LENGTH);
byte[] bsrBuf = IOUtils.safelyAllocate(len, MAX_RECORD_LENGTH);
plain.readFully(bsrBuf);
os.writePlain(bsrBuf, 0, 4);
os.write(bsrBuf, 4, len-4);
@@ -1877,7 +1877,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
// remove first 22 bytes if file starts with magic bytes D7-CD-C6-9A
// see also http://de.wikipedia.org/wiki/Windows_Metafile#Hinweise_zur_WMF-Spezifikation
if (LittleEndian.getInt(pictureData) == 0x9AC6CDD7) {
byte picDataNoHeader[] = new byte[pictureData.length-22];
byte[] picDataNoHeader = new byte[pictureData.length - 22];
System.arraycopy(pictureData, 22, picDataNoHeader, 0, pictureData.length-22);
pictureData = picDataNoHeader;
}
@@ -2260,15 +2260,15 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
// check if the password has been changed
EncryptionInfo ei = fpr.getEncryptionInfo();
EncryptionVerifier ver = ei.getVerifier();
byte encVer[] = ver.getEncryptedVerifier();
byte[] encVer = ver.getEncryptedVerifier();
Decryptor dec = ei.getDecryptor();
Encryptor enc = ei.getEncryptor();
try {
if (encVer == null || !dec.verifyPassword(password)) {
enc.confirmPassword(password);
} else {
byte verifier[] = dec.getVerifier();
byte salt[] = ver.getSalt();
byte[] verifier = dec.getVerifier();
byte[] salt = ver.getSalt();
enc.confirmPassword(password, null, null, verifier, salt, null);
}
} catch (GeneralSecurityException e) {

+ 1
- 1
src/java/org/apache/poi/poifs/crypt/ChunkedCipherInputStream.java View File

@@ -226,7 +226,7 @@ public abstract class ChunkedCipherInputStream extends LittleEndianInputStream {
*
*/
@Override
public void readPlain(byte b[], int off, int len) {
public void readPlain(byte[] b, int off, int len) {
if (len <= 0) {
return;
}

+ 2
- 2
src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java View File

@@ -220,7 +220,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
* @throws ShortBufferException
*/
protected int invokeCipher(int posInChunk, boolean doFinal) throws GeneralSecurityException, IOException {
byte plain[] = (plainByteFlags.isEmpty()) ? null : chunk.clone();
byte[] plain = (plainByteFlags.isEmpty()) ? null : chunk.clone();

int ciLen = (doFinal)
? cipher.doFinal(chunk, 0, posInChunk, chunk)
@@ -316,7 +316,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
// encrypted within the EncryptedData field, not including the size of the StreamSize field.
// Note that the actual size of the \EncryptedPackage stream (1) can be larger than this
// value, depending on the block size of the chosen encryption algorithm
byte buf[] = new byte[LittleEndianConsts.LONG_SIZE];
byte[] buf = new byte[LittleEndianConsts.LONG_SIZE];
LittleEndian.putLong(buf, 0, pos);
os.write(buf);


+ 2
- 2
src/java/org/apache/poi/poifs/crypt/CipherAlgorithm.java View File

@@ -41,13 +41,13 @@ public enum CipherAlgorithm {
public final String jceId;
public final int ecmaId;
public final int defaultKeySize;
public final int allowedKeySize[];
public final int[] allowedKeySize;
public final int blockSize;
public final int encryptedVerifierHashLength;
public final String xmlId;
public final boolean needsBouncyCastle;
CipherAlgorithm(CipherProvider provider, String jceId, int ecmaId, int defaultKeySize, int allowedKeySize[], int blockSize, int encryptedVerifierHashLength, String xmlId, boolean needsBouncyCastle) {
CipherAlgorithm(CipherProvider provider, String jceId, int ecmaId, int defaultKeySize, int[] allowedKeySize, int blockSize, int encryptedVerifierHashLength, String xmlId, boolean needsBouncyCastle) {
this.provider = provider;
this.jceId = jceId;
this.ecmaId = ecmaId;

+ 32
- 32
src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java View File

@@ -84,7 +84,7 @@ public class CryptoFunctions {
* @param spinCount
* @return the hashed password
*/
public static byte[] hashPassword(String password, HashAlgorithm hashAlgorithm, byte salt[], int spinCount) {
public static byte[] hashPassword(String password, HashAlgorithm hashAlgorithm, byte[] salt, int spinCount) {
return hashPassword(password, hashAlgorithm, salt, spinCount, true);
}
@@ -101,7 +101,7 @@ public class CryptoFunctions {
* if false the n-1 hash value is applied first
* @return the hashed password
*/
public static byte[] hashPassword(String password, HashAlgorithm hashAlgorithm, byte salt[], int spinCount, boolean iteratorFirst) {
public static byte[] hashPassword(String password, HashAlgorithm hashAlgorithm, byte[] salt, int spinCount, boolean iteratorFirst) {
// If no password was given, use the default
if (password == null) {
password = Decryptor.DEFAULT_PASSWORD;
@@ -149,7 +149,7 @@ public class CryptoFunctions {
* </ul>
**/
public static byte[] generateIv(HashAlgorithm hashAlgorithm, byte[] salt, byte[] blockKey, int blockSize) {
byte iv[] = salt;
byte[] iv = salt;
if (blockKey != null) {
MessageDigest hashAlgo = getMessageDigest(hashAlgorithm);
hashAlgo.update(salt);
@@ -333,34 +333,34 @@ public class CryptoFunctions {
}
}

private static final int INITIAL_CODE_ARRAY[] = {
0xE1F0, 0x1D0F, 0xCC9C, 0x84C0, 0x110C, 0x0E10, 0xF1CE,
0x313E, 0x1872, 0xE139, 0xD40F, 0x84F9, 0x280C, 0xA96A,
0x4EC3
private static final int[] INITIAL_CODE_ARRAY = {
0xE1F0, 0x1D0F, 0xCC9C, 0x84C0, 0x110C, 0x0E10, 0xF1CE,
0x313E, 0x1872, 0xE139, 0xD40F, 0x84F9, 0x280C, 0xA96A,
0x4EC3
};

private static final byte PAD_ARRAY[] = {
(byte)0xBB, (byte)0xFF, (byte)0xFF, (byte)0xBA, (byte)0xFF,
(byte)0xFF, (byte)0xB9, (byte)0x80, (byte)0x00, (byte)0xBE,
(byte)0x0F, (byte)0x00, (byte)0xBF, (byte)0x0F, (byte)0x00
private static final byte[] PAD_ARRAY = {
(byte) 0xBB, (byte) 0xFF, (byte) 0xFF, (byte) 0xBA, (byte) 0xFF,
(byte) 0xFF, (byte) 0xB9, (byte) 0x80, (byte) 0x00, (byte) 0xBE,
(byte) 0x0F, (byte) 0x00, (byte) 0xBF, (byte) 0x0F, (byte) 0x00
};
private static final int ENCRYPTION_MATRIX[][] = {
/* char 1 */ {0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09},
/* char 2 */ {0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF},
/* char 3 */ {0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0},
/* char 4 */ {0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40},
/* char 5 */ {0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5},
/* char 6 */ {0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A},
/* char 7 */ {0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9},
/* char 8 */ {0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0},
/* char 9 */ {0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC},
/* char 10 */ {0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10},
/* char 11 */ {0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168},
/* char 12 */ {0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C},
/* char 13 */ {0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD},
/* char 14 */ {0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC},
/* char 15 */ {0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4}
private static final int[][] ENCRYPTION_MATRIX = {
/* char 1 */ {0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09},
/* char 2 */ {0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF},
/* char 3 */ {0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0},
/* char 4 */ {0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40},
/* char 5 */ {0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5},
/* char 6 */ {0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A},
/* char 7 */ {0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9},
/* char 8 */ {0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0},
/* char 9 */ {0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC},
/* char 10 */ {0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10},
/* char 11 */ {0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168},
/* char 12 */ {0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C},
/* char 13 */ {0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD},
/* char 14 */ {0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC},
/* char 15 */ {0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4}
};

/**
@@ -514,11 +514,11 @@ public class CryptoFunctions {
if (password.length() > 15) {
password = password.substring(0, 15);
}
byte passBytes[] = password.getBytes(Charset.forName("ASCII"));
byte[] passBytes = password.getBytes(Charset.forName("ASCII"));
// this code is based on the libre office implementation.
// The MS-OFFCRYPTO misses some infos about the various rotation sizes
byte obfuscationArray[] = new byte[16];
byte[] obfuscationArray = new byte[16];
System.arraycopy(passBytes, 0, obfuscationArray, 0, passBytes.length);
System.arraycopy(PAD_ARRAY, 0, obfuscationArray, passBytes.length, PAD_ARRAY.length-passBytes.length+1);
@@ -526,8 +526,8 @@ public class CryptoFunctions {
// rotation of key values is application dependent - Excel = 2 / Word = 7
int nRotateSize = 2;
byte baseKeyLE[] = { (byte)(xorKey & 0xFF), (byte)((xorKey >>> 8) & 0xFF) };
byte[] baseKeyLE = {(byte) (xorKey & 0xFF), (byte) ((xorKey >>> 8) & 0xFF)};
for (int i=0; i<obfuscationArray.length; i++) {
obfuscationArray[i] ^= baseKeyLE[i&1];
obfuscationArray[i] = rotateLeft(obfuscationArray[i], nRotateSize);

+ 14
- 14
src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java View File

@@ -64,14 +64,14 @@ public class DataSpaceMapUtils {
}
public static DocumentEntry createEncryptionEntry(DirectoryEntry dir, String path, EncryptionRecord out) throws IOException {
String parts[] = path.split("/");
String[] parts = path.split("/");
for (int i=0; i<parts.length-1; i++) {
dir = dir.hasEntry(parts[i])
? (DirectoryEntry)dir.getEntry(parts[i])
: dir.createDirectory(parts[i]);
}
final byte buf[] = new byte[5000];
final byte[] buf = new byte[5000];
LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0);
out.write(bos);
@@ -93,9 +93,9 @@ public class DataSpaceMapUtils {
}
public static class DataSpaceMap implements EncryptionRecord {
DataSpaceMapEntry entries[];
DataSpaceMapEntry[] entries;
public DataSpaceMap(DataSpaceMapEntry entries[]) {
public DataSpaceMap(DataSpaceMapEntry[] entries) {
this.entries = entries.clone();
}
@@ -118,11 +118,11 @@ public class DataSpaceMapUtils {
}
public static class DataSpaceMapEntry implements EncryptionRecord {
final int referenceComponentType[];
final String referenceComponent[];
final int[] referenceComponentType;
final String[] referenceComponent;
final String dataSpaceName;
public DataSpaceMapEntry(int referenceComponentType[], String referenceComponent[], String dataSpaceName) {
public DataSpaceMapEntry(int[] referenceComponentType, String[] referenceComponent, String dataSpaceName) {
this.referenceComponentType = referenceComponentType.clone();
this.referenceComponent = referenceComponent.clone();
this.dataSpaceName = dataSpaceName;
@@ -154,9 +154,9 @@ public class DataSpaceMapUtils {
}
public static class DataSpaceDefinition implements EncryptionRecord {
String transformer[];
String[] transformer;
public DataSpaceDefinition(String transformer[]) {
public DataSpaceDefinition(String[] transformer) {
this.transformer = transformer.clone();
}
@@ -322,7 +322,7 @@ public class DataSpaceMapUtils {
}
public static void writeUnicodeLPP4(LittleEndianOutput os, String string) {
byte buf[] = StringUtil.getToUnicodeLE(string);
byte[] buf = StringUtil.getToUnicodeLE(string);
os.writeInt(buf.length);
os.write(buf);
if (buf.length%4==2) {
@@ -336,8 +336,8 @@ public class DataSpaceMapUtils {
/* int skip = */ is.readInt();
return length == 0 ? null : "";
}
byte data[] = IOUtils.safelyAllocate(length, MAX_RECORD_LENGTH);
byte[] data = IOUtils.safelyAllocate(length, MAX_RECORD_LENGTH);
is.readFully(data);

// Padding (variable): A set of bytes that MUST be of correct size such that the size of the UTF-8-LP-P4
@@ -360,7 +360,7 @@ public class DataSpaceMapUtils {
os.writeInt(str == null ? 0 : 4);
os.writeInt(0);
} else {
byte buf[] = str.getBytes(StandardCharsets.UTF_8);
byte[] buf = str.getBytes(StandardCharsets.UTF_8);
os.writeInt(buf.length);
os.write(buf);
int scratchBytes = buf.length%4;

+ 1
- 1
src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java View File

@@ -130,7 +130,7 @@ public abstract class EncryptionHeader implements Cloneable {
return keySalt;
}
protected void setKeySalt(byte salt[]) {
protected void setKeySalt(byte[] salt) {
this.keySalt = (salt == null) ? null : salt.clone();
}


+ 1
- 1
src/java/org/apache/poi/poifs/crypt/Encryptor.java View File

@@ -42,7 +42,7 @@ public abstract class Encryptor implements Cloneable {
throws IOException, GeneralSecurityException;

// for tests
public abstract void confirmPassword(String password, byte keySpec[], byte keySalt[], byte verifier[], byte verifierSalt[], byte integritySalt[]);
public abstract void confirmPassword(String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt);
public abstract void confirmPassword(String password);

+ 9
- 9
src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java View File

@@ -66,15 +66,15 @@ public class BinaryRC4Decryptor extends Decryptor implements Cloneable {
SecretKey skey = generateSecretKey(password, ver);
try {
Cipher cipher = initCipherForBlock(null, 0, getEncryptionInfo(), skey, Cipher.DECRYPT_MODE);
byte encryptedVerifier[] = ver.getEncryptedVerifier();
byte verifier[] = new byte[encryptedVerifier.length];
byte[] encryptedVerifier = ver.getEncryptedVerifier();
byte[] verifier = new byte[encryptedVerifier.length];
cipher.update(encryptedVerifier, 0, encryptedVerifier.length, verifier);
setVerifier(verifier);
byte encryptedVerifierHash[] = ver.getEncryptedVerifierHash();
byte verifierHash[] = cipher.doFinal(encryptedVerifierHash);
byte[] encryptedVerifierHash = ver.getEncryptedVerifierHash();
byte[] verifierHash = cipher.doFinal(encryptedVerifierHash);
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte calcVerifierHash[] = hashAlg.digest(verifier);
byte[] calcVerifierHash = hashAlg.digest(verifier);
if (Arrays.equals(calcVerifierHash, verifierHash)) {
setSecretKey(skey);
return true;
@@ -96,9 +96,9 @@ public class BinaryRC4Decryptor extends Decryptor implements Cloneable {
throws GeneralSecurityException {
EncryptionVerifier ver = encryptionInfo.getVerifier();
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
byte blockKey[] = new byte[4];
byte[] blockKey = new byte[4];
LittleEndian.putUInt(blockKey, 0, block);
byte encKey[] = CryptoFunctions.generateKey(skey.getEncoded(), hashAlgo, blockKey, 16);
byte[] encKey = CryptoFunctions.generateKey(skey.getEncoded(), hashAlgo, blockKey, 16);
SecretKey key = new SecretKeySpec(encKey, skey.getAlgorithm());
if (cipher == null) {
EncryptionHeader em = encryptionInfo.getHeader();
@@ -115,8 +115,8 @@ public class BinaryRC4Decryptor extends Decryptor implements Cloneable {
}
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password));
byte salt[] = ver.getSalt();
byte[] hash = hashAlg.digest(StringUtil.getToUnicodeLE(password));
byte[] salt = ver.getSalt();
hashAlg.reset();
for (int i = 0; i < 16; i++) {
hashAlg.update(hash, 0, 5);

+ 9
- 9
src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java View File

@@ -34,13 +34,13 @@ public class BinaryRC4EncryptionVerifier extends EncryptionVerifier implements E
}

protected BinaryRC4EncryptionVerifier(LittleEndianInput is) {
byte salt[] = new byte[16];
byte[] salt = new byte[16];
is.readFully(salt);
setSalt(salt);
byte encryptedVerifier[] = new byte[16];
byte[] encryptedVerifier = new byte[16];
is.readFully(encryptedVerifier);
setEncryptedVerifier(encryptedVerifier);
byte encryptedVerifierHash[] = new byte[16];
byte[] encryptedVerifierHash = new byte[16];
is.readFully(encryptedVerifierHash);
setEncryptedVerifierHash(encryptedVerifierHash);
setSpinCount(-1);
@@ -51,7 +51,7 @@ public class BinaryRC4EncryptionVerifier extends EncryptionVerifier implements E
}

@Override
protected void setSalt(byte salt[]) {
protected void setSalt(byte[] salt) {
if (salt == null || salt.length != 16) {
throw new EncryptedDocumentException("invalid verifier salt");
}
@@ -60,24 +60,24 @@ public class BinaryRC4EncryptionVerifier extends EncryptionVerifier implements E
}

@Override
protected void setEncryptedVerifier(byte encryptedVerifier[]) {
protected void setEncryptedVerifier(byte[] encryptedVerifier) {
super.setEncryptedVerifier(encryptedVerifier);
}

@Override
protected void setEncryptedVerifierHash(byte encryptedVerifierHash[]) {
protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) {
super.setEncryptedVerifierHash(encryptedVerifierHash);
}

@Override
public void write(LittleEndianByteArrayOutputStream bos) {
byte salt[] = getSalt();
byte[] salt = getSalt();
assert (salt.length == 16);
bos.write(salt);
byte encryptedVerifier[] = getEncryptedVerifier();
byte[] encryptedVerifier = getEncryptedVerifier();
assert (encryptedVerifier.length == 16);
bos.write(encryptedVerifier);
byte encryptedVerifierHash[] = getEncryptedVerifierHash();
byte[] encryptedVerifierHash = getEncryptedVerifierHash();
assert (encryptedVerifierHash.length == 16);
bos.write(encryptedVerifierHash);
}

+ 8
- 8
src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Encryptor.java View File

@@ -49,30 +49,30 @@ public class BinaryRC4Encryptor extends Encryptor implements Cloneable {
@Override
public void confirmPassword(String password) {
Random r = new SecureRandom();
byte salt[] = new byte[16];
byte verifier[] = new byte[16];
byte[] salt = new byte[16];
byte[] verifier = new byte[16];
r.nextBytes(salt);
r.nextBytes(verifier);
confirmPassword(password, null, null, verifier, salt, null);
}

@Override
public void confirmPassword(String password, byte keySpec[],
byte keySalt[], byte verifier[], byte verifierSalt[],
byte integritySalt[]) {
public void confirmPassword(String password, byte[] keySpec,
byte[] keySalt, byte[] verifier, byte[] verifierSalt,
byte[] integritySalt) {
BinaryRC4EncryptionVerifier ver = (BinaryRC4EncryptionVerifier)getEncryptionInfo().getVerifier();
ver.setSalt(verifierSalt);
SecretKey skey = BinaryRC4Decryptor.generateSecretKey(password, ver);
setSecretKey(skey);
try {
Cipher cipher = BinaryRC4Decryptor.initCipherForBlock(null, 0, getEncryptionInfo(), skey, Cipher.ENCRYPT_MODE);
byte encryptedVerifier[] = new byte[16];
byte[] encryptedVerifier = new byte[16];
cipher.update(verifier, 0, 16, encryptedVerifier);
ver.setEncryptedVerifier(encryptedVerifier);
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte calcVerifierHash[] = hashAlg.digest(verifier);
byte encryptedVerifierHash[] = cipher.doFinal(calcVerifierHash);
byte[] calcVerifierHash = hashAlg.digest(verifier);
byte[] encryptedVerifierHash = cipher.doFinal(calcVerifierHash);
ver.setEncryptedVerifierHash(encryptedVerifierHash);
} catch (GeneralSecurityException e) {
throw new EncryptedDocumentException("Password confirmation failed", e);

+ 9
- 9
src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java View File

@@ -74,15 +74,15 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
SecretKey skey = generateSecretKey(password, ver);
try {
Cipher cipher = initCipherForBlock(null, 0, getEncryptionInfo(), skey, Cipher.DECRYPT_MODE);
byte encryptedVerifier[] = ver.getEncryptedVerifier();
byte verifier[] = new byte[encryptedVerifier.length];
byte[] encryptedVerifier = ver.getEncryptedVerifier();
byte[] verifier = new byte[encryptedVerifier.length];
cipher.update(encryptedVerifier, 0, encryptedVerifier.length, verifier);
setVerifier(verifier);
byte encryptedVerifierHash[] = ver.getEncryptedVerifierHash();
byte verifierHash[] = cipher.doFinal(encryptedVerifierHash);
byte[] encryptedVerifierHash = ver.getEncryptedVerifierHash();
byte[] verifierHash = cipher.doFinal(encryptedVerifierHash);
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte calcVerifierHash[] = hashAlg.digest(verifier);
byte[] calcVerifierHash = hashAlg.digest(verifier);
if (Arrays.equals(calcVerifierHash, verifierHash)) {
setSecretKey(skey);
return true;
@@ -106,11 +106,11 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
throws GeneralSecurityException {
EncryptionVerifier ver = encryptionInfo.getVerifier();
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
byte blockKey[] = new byte[4];
byte[] blockKey = new byte[4];
LittleEndian.putUInt(blockKey, 0, block);
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
hashAlg.update(skey.getEncoded());
byte encKey[] = hashAlg.digest(blockKey);
byte[] encKey = hashAlg.digest(blockKey);
EncryptionHeader header = encryptionInfo.getHeader();
int keyBits = header.getKeySize();
encKey = CryptoFunctions.getBlock0(encKey, keyBits / 8);
@@ -133,7 +133,7 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
hashAlg.update(ver.getSalt());
byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password));
byte[] hash = hashAlg.digest(StringUtil.getToUnicodeLE(password));
return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId);
}

@@ -182,7 +182,7 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
}
sbis.setBlock(0);
int encryptedStreamDescriptorCount = (int) leis.readUInt();
StreamDescriptorEntry entries[] = new StreamDescriptorEntry[encryptedStreamDescriptorCount];
StreamDescriptorEntry[] entries = new StreamDescriptorEntry[encryptedStreamDescriptorCount];
for (int i = 0; i < encryptedStreamDescriptorCount; i++) {
StreamDescriptorEntry entry = new StreamDescriptorEntry();
entries[i] = entry;

+ 3
- 3
src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentInputStream.java View File

@@ -33,7 +33,7 @@ import org.apache.poi.util.Internal;
/* package */ class CryptoAPIDocumentInputStream extends ByteArrayInputStream {
private Cipher cipher;
private final CryptoAPIDecryptor decryptor;
private byte oneByte[] = { 0 };
private byte[] oneByte = {0};
public void seek(int newpos) {
if (newpos > count) {
@@ -64,7 +64,7 @@ import org.apache.poi.util.Internal;
}

@Override
public synchronized int read(byte b[], int off, int len) {
public synchronized int read(byte[] b, int off, int len) {
int readLen = super.read(b, off, len);
if (readLen ==-1) {
return -1;
@@ -77,7 +77,7 @@ import org.apache.poi.util.Internal;
return readLen;
}

public CryptoAPIDocumentInputStream(CryptoAPIDecryptor decryptor, byte buf[])
public CryptoAPIDocumentInputStream(CryptoAPIDecryptor decryptor, byte[] buf)
throws GeneralSecurityException {
super(buf);
this.decryptor = decryptor;

+ 1
- 1
src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java View File

@@ -31,7 +31,7 @@ import org.apache.poi.util.Internal;
/* package */ class CryptoAPIDocumentOutputStream extends ByteArrayOutputStream {
private final Cipher cipher;
private final CryptoAPIEncryptor encryptor;
private final byte oneByte[] = { 0 };
private final byte[] oneByte = {0};

public CryptoAPIDocumentOutputStream(CryptoAPIEncryptor encryptor) throws GeneralSecurityException {
this.encryptor = encryptor;

+ 3
- 3
src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java View File

@@ -37,17 +37,17 @@ public class CryptoAPIEncryptionVerifier extends StandardEncryptionVerifier impl
}

@Override
protected void setSalt(byte salt[]) {
protected void setSalt(byte[] salt) {
super.setSalt(salt);
}

@Override
protected void setEncryptedVerifier(byte encryptedVerifier[]) {
protected void setEncryptedVerifier(byte[] encryptedVerifier) {
super.setEncryptedVerifier(encryptedVerifier);
}

@Override
protected void setEncryptedVerifierHash(byte encryptedVerifierHash[]) {
protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) {
super.setEncryptedVerifierHash(encryptedVerifierHash);
}


+ 10
- 10
src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java View File

@@ -56,17 +56,17 @@ public class CryptoAPIEncryptor extends Encryptor implements Cloneable {
@Override
public void confirmPassword(String password) {
Random r = new SecureRandom();
byte salt[] = new byte[16];
byte verifier[] = new byte[16];
byte[] salt = new byte[16];
byte[] verifier = new byte[16];
r.nextBytes(salt);
r.nextBytes(verifier);
confirmPassword(password, null, null, verifier, salt, null);
}

@Override
public void confirmPassword(String password, byte keySpec[],
byte keySalt[], byte verifier[], byte verifierSalt[],
byte integritySalt[]) {
public void confirmPassword(String password, byte[] keySpec,
byte[] keySalt, byte[] verifier, byte[] verifierSalt,
byte[] integritySalt) {
assert(verifier != null && verifierSalt != null);
CryptoAPIEncryptionVerifier ver = (CryptoAPIEncryptionVerifier)getEncryptionInfo().getVerifier();
ver.setSalt(verifierSalt);
@@ -74,13 +74,13 @@ public class CryptoAPIEncryptor extends Encryptor implements Cloneable {
setSecretKey(skey);
try {
Cipher cipher = initCipherForBlock(null, 0);
byte encryptedVerifier[] = new byte[verifier.length];
byte[] encryptedVerifier = new byte[verifier.length];
cipher.update(verifier, 0, verifier.length, encryptedVerifier);
ver.setEncryptedVerifier(encryptedVerifier);
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
byte calcVerifierHash[] = hashAlg.digest(verifier);
byte encryptedVerifierHash[] = cipher.doFinal(calcVerifierHash);
byte[] calcVerifierHash = hashAlg.digest(verifier);
byte[] encryptedVerifierHash = cipher.doFinal(calcVerifierHash);
ver.setEncryptedVerifierHash(encryptedVerifierHash);
} catch (GeneralSecurityException e) {
throw new EncryptedDocumentException("Password confirmation failed", e);
@@ -121,7 +121,7 @@ public class CryptoAPIEncryptor extends Encryptor implements Cloneable {
public void setSummaryEntries(DirectoryNode dir, String encryptedStream, POIFSFileSystem entries)
throws IOException, GeneralSecurityException {
CryptoAPIDocumentOutputStream bos = new CryptoAPIDocumentOutputStream(this); // NOSONAR
byte buf[] = new byte[8];
byte[] buf = new byte[8];
bos.write(buf, 0, 8); // skip header
List<StreamDescriptorEntry> descList = new ArrayList<>();
@@ -168,7 +168,7 @@ public class CryptoAPIEncryptor extends Encryptor implements Cloneable {
bos.write(buf, 0, 1);
LittleEndian.putUInt(buf, 0, sde.reserved2);
bos.write(buf, 0, 4);
byte nameBytes[] = StringUtil.getToUnicodeLE(sde.streamName);
byte[] nameBytes = StringUtil.getToUnicodeLE(sde.streamName);
bos.write(nameBytes, 0, nameBytes.length);
LittleEndian.putShort(buf, 0, (short)0); // null-termination
bos.write(buf, 0, 2);

+ 8
- 8
src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java View File

@@ -56,13 +56,13 @@ public class StandardDecryptor extends Decryptor implements Cloneable {
Cipher cipher = getCipher(skey);

try {
byte encryptedVerifier[] = ver.getEncryptedVerifier();
byte verifier[] = cipher.doFinal(encryptedVerifier);
byte[] encryptedVerifier = ver.getEncryptedVerifier();
byte[] verifier = cipher.doFinal(encryptedVerifier);
setVerifier(verifier);
MessageDigest sha1 = CryptoFunctions.getMessageDigest(ver.getHashAlgorithm());
byte[] calcVerifierHash = sha1.digest(verifier);
byte encryptedVerifierHash[] = ver.getEncryptedVerifierHash();
byte decryptedVerifierHash[] = cipher.doFinal(encryptedVerifierHash);
byte[] encryptedVerifierHash = ver.getEncryptedVerifierHash();
byte[] decryptedVerifierHash = cipher.doFinal(encryptedVerifierHash);

// see 2.3.4.9 Password Verification (Standard Encryption)
// ... The number of bytes used by the encrypted Verifier hash MUST be 32 ...
@@ -83,14 +83,14 @@ public class StandardDecryptor extends Decryptor implements Cloneable {
protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver, int keySize) {
HashAlgorithm hashAlgo = ver.getHashAlgorithm();

byte pwHash[] = hashPassword(password, hashAlgo, ver.getSalt(), ver.getSpinCount());
byte[] pwHash = hashPassword(password, hashAlgo, ver.getSalt(), ver.getSpinCount());

byte[] blockKey = new byte[4];
LittleEndian.putInt(blockKey, 0, 0);

byte[] finalHash = CryptoFunctions.generateKey(pwHash, hashAlgo, blockKey, hashAlgo.hashSize);
byte x1[] = fillAndXor(finalHash, (byte) 0x36);
byte x2[] = fillAndXor(finalHash, (byte) 0x5c);
byte[] x1 = fillAndXor(finalHash, (byte) 0x36);
byte[] x2 = fillAndXor(finalHash, (byte) 0x5c);

byte[] x3 = new byte[x1.length + x2.length];
System.arraycopy(x1, 0, x3, 0, x1.length);
@@ -101,7 +101,7 @@ public class StandardDecryptor extends Decryptor implements Cloneable {
return new SecretKeySpec(key, ver.getCipherAlgorithm().jceId);
}

protected static byte[] fillAndXor(byte hash[], byte fillByte) {
protected static byte[] fillAndXor(byte[] hash, byte fillByte) {
byte[] buff = new byte[64];
Arrays.fill(buff, fillByte);


+ 10
- 10
src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java View File

@@ -38,17 +38,17 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En
throw new RuntimeException("Salt size != 16 !?");
}

byte salt[] = new byte[16];
byte[] salt = new byte[16];
is.readFully(salt);
setSalt(salt);
byte encryptedVerifier[] = new byte[16];
byte[] encryptedVerifier = new byte[16];
is.readFully(encryptedVerifier);
setEncryptedVerifier(encryptedVerifier);

verifierHashSize = is.readInt();

byte encryptedVerifierHash[] = new byte[header.getCipherAlgorithm().encryptedVerifierHashLength];
byte[] encryptedVerifierHash = new byte[header.getCipherAlgorithm().encryptedVerifierHashLength];
is.readFully(encryptedVerifierHash);
setEncryptedVerifierHash(encryptedVerifierHash);

@@ -69,7 +69,7 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En

// make method visible for this package
@Override
protected void setSalt(byte salt[]) {
protected void setSalt(byte[] salt) {
if (salt == null || salt.length != 16) {
throw new EncryptedDocumentException("invalid verifier salt");
}
@@ -78,26 +78,26 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En
// make method visible for this package
@Override
protected void setEncryptedVerifier(byte encryptedVerifier[]) {
protected void setEncryptedVerifier(byte[] encryptedVerifier) {
super.setEncryptedVerifier(encryptedVerifier);
}

// make method visible for this package
@Override
protected void setEncryptedVerifierHash(byte encryptedVerifierHash[]) {
protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) {
super.setEncryptedVerifierHash(encryptedVerifierHash);
}
@Override
public void write(LittleEndianByteArrayOutputStream bos) {
// see [MS-OFFCRYPTO] - 2.3.4.9
byte salt[] = getSalt();
byte[] salt = getSalt();
assert(salt.length == 16);
bos.writeInt(salt.length); // salt size
bos.write(salt);
// The resulting Verifier value MUST be an array of 16 bytes.
byte encryptedVerifier[] = getEncryptedVerifier();
byte[] encryptedVerifier = getEncryptedVerifier();
assert(encryptedVerifier.length == 16);
bos.write(encryptedVerifier);

@@ -111,7 +111,7 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En
// Verifier. If the encryption algorithm is RC4, the length MUST be 20 bytes. If the encryption
// algorithm is AES, the length MUST be 32 bytes. After decrypting the EncryptedVerifierHash
// field, only the first VerifierHashSize bytes MUST be used.
byte encryptedVerifierHash[] = getEncryptedVerifierHash();
byte[] encryptedVerifierHash = getEncryptedVerifierHash();
assert(encryptedVerifierHash.length == getCipherAlgorithm().encryptedVerifierHashLength);
bos.write(encryptedVerifierHash);
}

+ 5
- 5
src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java View File

@@ -78,7 +78,7 @@ public class StandardEncryptor extends Encryptor implements Cloneable {
* see [MS-OFFCRYPTO] - 2.3.4.7 ECMA-376 Document Encryption Key Generation
*/
@Override
public void confirmPassword(String password, byte keySpec[], byte keySalt[], byte verifier[], byte verifierSalt[], byte integritySalt[]) {
public void confirmPassword(String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt) {
StandardEncryptionVerifier ver = (StandardEncryptionVerifier)getEncryptionInfo().getVerifier();

ver.setSalt(verifierSalt);
@@ -87,9 +87,9 @@ public class StandardEncryptor extends Encryptor implements Cloneable {
Cipher cipher = getCipher(secretKey, null);
try {
byte encryptedVerifier[] = cipher.doFinal(verifier);
byte[] encryptedVerifier = cipher.doFinal(verifier);
MessageDigest hashAlgo = CryptoFunctions.getMessageDigest(ver.getHashAlgorithm());
byte calcVerifierHash[] = hashAlgo.digest(verifier);
byte[] calcVerifierHash = hashAlgo.digest(verifier);
// 2.3.3 EncryptionVerifier ...
// An array of bytes that contains the encrypted form of the
@@ -98,8 +98,8 @@ public class StandardEncryptor extends Encryptor implements Cloneable {
// Verifier. If the encryption algorithm is RC4, the length MUST be 20 bytes. If the encryption
// algorithm is AES, the length MUST be 32 bytes. After decrypting the EncryptedVerifierHash
// field, only the first VerifierHashSize bytes MUST be used.
int encVerHashSize = ver.getCipherAlgorithm().encryptedVerifierHashLength;
byte encryptedVerifierHash[] = cipher.doFinal(Arrays.copyOf(calcVerifierHash, encVerHashSize));
int encVerHashSize = ver.getCipherAlgorithm().encryptedVerifierHashLength;
byte[] encryptedVerifierHash = cipher.doFinal(Arrays.copyOf(calcVerifierHash, encVerHashSize));
ver.setEncryptedVerifier(encryptedVerifier);
ver.setEncryptedVerifierHash(encryptedVerifierHash);

+ 5
- 5
src/java/org/apache/poi/poifs/crypt/xor/XORDecryptor.java View File

@@ -48,7 +48,7 @@ public class XORDecryptor extends Decryptor implements Cloneable {
int keyComp = CryptoFunctions.createXorKey1(password);
int verifierComp = CryptoFunctions.createXorVerifier1(password);
if (keyVer == keyComp && verifierVer == verifierComp) {
byte xorArray[] = CryptoFunctions.createXorArray1(password);
byte[] xorArray = CryptoFunctions.createXorArray1(password);
setSecretKey(new SecretKeySpec(xorArray, "XOR"));
return true;
} else {
@@ -119,9 +119,9 @@ public class XORDecryptor extends Decryptor implements Cloneable {
@Override
protected int invokeCipher(int totalBytes, boolean doFinal) {
final int pos = (int)getPos();
final byte xorArray[] = getEncryptionInfo().getDecryptor().getSecretKey().getEncoded();
final byte chunk[] = getChunk();
final byte plain[] = getPlain();
final byte[] xorArray = getEncryptionInfo().getDecryptor().getSecretKey().getEncoded();
final byte[] chunk = getChunk();
final byte[] plain = getPlain();
final int posInChunk = pos & getChunkMask();
/*
@@ -164,7 +164,7 @@ public class XORDecryptor extends Decryptor implements Cloneable {
@Override
public void setNextRecordSize(int recordSize) {
final int pos = (int)getPos();
final byte chunk[] = getChunk();
final byte[] chunk = getChunk();
final int chunkMask = getChunkMask();
recordStart = pos;
recordEnd = recordStart+recordSize;

+ 2
- 2
src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java View File

@@ -35,7 +35,7 @@ public class XOREncryptionVerifier extends EncryptionVerifier implements Encrypt
* See [MS-OFFCRYPTO], 2.3.6.2 section, the first step of initializing XOR
* array where it describes the generation of 16-bit XorKey value.
*/
byte key[] = new byte[2];
byte[] key = new byte[2];
is.readFully(key);
setEncryptedKey(key);
@@ -43,7 +43,7 @@ public class XOREncryptionVerifier extends EncryptionVerifier implements Encrypt
* verificationBytes (2 bytes): An unsigned integer that specifies
* the password verification identifier.
*/
byte verifier[] = new byte[2];
byte[] verifier = new byte[2];
is.readFully(verifier);
setEncryptedVerifier(verifier);
}

+ 9
- 9
src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java View File

@@ -41,9 +41,9 @@ public class XOREncryptor extends Encryptor implements Cloneable {
public void confirmPassword(String password) {
int keyComp = CryptoFunctions.createXorKey1(password);
int verifierComp = CryptoFunctions.createXorVerifier1(password);
byte xorArray[] = CryptoFunctions.createXorArray1(password);
byte shortBuf[] = new byte[2];
byte[] xorArray = CryptoFunctions.createXorArray1(password);
byte[] shortBuf = new byte[2];
XOREncryptionVerifier ver = (XOREncryptionVerifier)getEncryptionInfo().getVerifier();
LittleEndian.putUShort(shortBuf, 0, keyComp);
ver.setEncryptedKey(shortBuf);
@@ -53,9 +53,9 @@ public class XOREncryptor extends Encryptor implements Cloneable {
}

@Override
public void confirmPassword(String password, byte keySpec[],
byte keySalt[], byte verifier[], byte verifierSalt[],
byte integritySalt[]) {
public void confirmPassword(String password, byte[] keySpec,
byte[] keySalt, byte[] verifier, byte[] verifierSalt,
byte[] integritySalt) {
confirmPassword(password);
}

@@ -137,9 +137,9 @@ public class XOREncryptor extends Encryptor implements Cloneable {
final int start = Math.max(posInChunk-(recordEnd-recordStart), 0);

final BitSet plainBytes = getPlainByteFlags();
final byte xorArray[] = getEncryptionInfo().getEncryptor().getSecretKey().getEncoded();
final byte chunk[] = getChunk();
final byte plain[] = (plainBytes.isEmpty()) ? null : chunk.clone();
final byte[] xorArray = getEncryptionInfo().getEncryptor().getSecretKey().getEncoded();
final byte[] chunk = getChunk();
final byte[] plain = (plainBytes.isEmpty()) ? null : chunk.clone();

/*
* From: http://social.msdn.microsoft.com/Forums/en-US/3dadbed3-0e68-4f11-8b43-3a2328d9ebd5

+ 1
- 1
src/java/org/apache/poi/poifs/dev/POIFSLister.java View File

@@ -38,7 +38,7 @@ public class POIFSLister {
*
* @param args the names of the files to be displayed
*/
public static void main(final String args[]) throws IOException {
public static void main(final String[] args) throws IOException {
if (args.length == 0) {
System.err.println("Must specify at least one file to view");
System.exit(1);

+ 1
- 1
src/java/org/apache/poi/poifs/dev/POIFSViewer.java View File

@@ -41,7 +41,7 @@ public final class POIFSViewer {
* @param args the names of the files to be displayed
*/

public static void main(final String args[]) {
public static void main(final String[] args) {
if (args.length == 0) {
System.err.println("Must specify at least one file to view");
System.exit(1);

+ 1
- 1
src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java View File

@@ -179,7 +179,7 @@ public class POIFSReader
* @exception IOException if the files can't be read or have invalid content
*/

public static void main(String args[]) throws IOException {
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.err.println("at least one argument required: input filename(s)");
System.exit(1);

+ 1
- 1
src/java/org/apache/poi/poifs/filesystem/Ole10Native.java View File

@@ -428,7 +428,7 @@ public class Ole10Native {
this.unknown1 = unknown1;
}

public void setDataBuffer(byte dataBuffer[]) {
public void setDataBuffer(byte[] dataBuffer) {
this.dataBuffer = dataBuffer.clone();
}
}

+ 1
- 1
src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java View File

@@ -787,7 +787,7 @@ public class POIFSFileSystem extends BlockStore
* @param args names of the files; arg[ 0 ] is the input file,
* arg[ 1 ] is the output file
*/
public static void main(String args[]) throws IOException {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.err.println(
"two arguments required: input filename and output filename");

+ 1
- 1
src/java/org/apache/poi/poifs/filesystem/POIFSStream.java View File

@@ -177,7 +177,7 @@ public class POIFSStream implements Iterable<ByteBuffer>
}
protected class StreamBlockByteBuffer extends OutputStream {
byte oneByte[] = new byte[1];
byte[] oneByte = new byte[1];
ByteBuffer buffer;
// Make sure we don't encounter a loop whilst overwriting
// the existing blocks

+ 1
- 1
src/java/org/apache/poi/poifs/macros/VBAMacroExtractor.java View File

@@ -34,7 +34,7 @@ import org.apache.poi.util.StringUtil;
* @since 3.15-beta2
*/
public class VBAMacroExtractor {
public static void main(String args[]) throws IOException {
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.err.println("Use:");
System.err.println(" VBAMacroExtractor <office.doc> [output]");

+ 1
- 1
src/java/org/apache/poi/sl/draw/BitmapImageRenderer.java View File

@@ -72,7 +72,7 @@ public class BitmapImageRenderer implements ImageRenderer {
}

@Override
public void loadImage(byte data[], String contentType) throws IOException {
public void loadImage(byte[] data, String contentType) throws IOException {
img = readImage(new ByteArrayInputStream(data), contentType);
}

+ 1
- 1
src/java/org/apache/poi/sl/draw/DrawFactory.java View File

@@ -211,7 +211,7 @@ public class DrawFactory {
}
}
/**
* Return a FontManager, either registered beforehand or a default implementation
*

+ 1
- 1
src/java/org/apache/poi/sl/draw/DrawFontManagerDefault.java View File

@@ -76,7 +76,7 @@ public class DrawFontManagerDefault implements DrawFontManager {
public static String mapSymbolChars(String text) {
// wingdings doesn't contain high-surrogates, so chars are ok
boolean changed = false;
char chrs[] = text.toCharArray();
char[] chrs = text.toCharArray();
for (int i=0; i<chrs.length; i++) {
// only change valid chars
if ((0x20 <= chrs[i] && chrs[i] <= 0x7f) ||

+ 2
- 2
src/java/org/apache/poi/sl/draw/DrawShape.java View File

@@ -65,7 +65,7 @@ public class DrawShape implements Drawable {

final Rectangle2D anchor = getAnchor(graphics, ps);

char cmds[] = isHSLF ? new char[]{ 'h','v','r' } : new char[]{ 'r','h','v' };
char[] cmds = isHSLF ? new char[]{'h', 'v', 'r'} : new char[]{'r', 'h', 'v'};
for (char ch : cmds) {
switch (ch) {
case 'h':
@@ -232,7 +232,7 @@ public class DrawShape implements Drawable {
lineDash = LineDash.SOLID;
}

int dashPatI[] = lineDash.pattern;
int[] dashPatI = lineDash.pattern;
final float dash_phase = 0;
float[] dashPatF = null;
if (dashPatI != null) {

+ 4
- 4
src/java/org/apache/poi/sl/draw/DrawTableShape.java View File

@@ -165,7 +165,7 @@ public class DrawTableShape extends DrawShape {
final int rows = table.getNumberOfRows();
final int cols = table.getNumberOfColumns();

BorderEdge edges[] = { BorderEdge.top, BorderEdge.left, null, null };
BorderEdge[] edges = {BorderEdge.top, BorderEdge.left, null, null};
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
edges[2] = (col == cols - 1) ? BorderEdge.right : null;
@@ -189,7 +189,7 @@ public class DrawTableShape extends DrawShape {
final int rows = table.getNumberOfRows();
final int cols = table.getNumberOfColumns();

BorderEdge edges[] = new BorderEdge[4];
BorderEdge[] edges = new BorderEdge[4];
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
edges[0] = (col == 0) ? BorderEdge.left : null;
@@ -215,7 +215,7 @@ public class DrawTableShape extends DrawShape {
final int rows = table.getNumberOfRows();
final int cols = table.getNumberOfColumns();

BorderEdge edges[] = new BorderEdge[2];
BorderEdge[] edges = new BorderEdge[2];
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
edges[0] = (col > 0 && col < cols - 1) ? BorderEdge.right : null;
@@ -232,7 +232,7 @@ public class DrawTableShape extends DrawShape {
* @param edges the border edges
* @param args the border attributes
*/
private static void setEdges(TableCell<?,?> cell, BorderEdge edges[], Object... args) {
private static void setEdges(TableCell<?,?> cell, BorderEdge[] edges, Object... args) {
if (cell == null) {
return;
}

+ 1
- 1
src/java/org/apache/poi/sl/draw/ImageRenderer.java View File

@@ -96,7 +96,7 @@ public interface ImageRenderer {
* @param data the raw image bytes
* @param contentType the content type
*/
void loadImage(byte data[], String contentType) throws IOException;
void loadImage(byte[] data, String contentType) throws IOException;

/**
* @return the dimension of the buffered image

+ 1
- 1
src/java/org/apache/poi/sl/image/ImageHeaderBitmap.java View File

@@ -35,7 +35,7 @@ public class ImageHeaderBitmap {
private final Dimension size;
public ImageHeaderBitmap(byte data[], int offset) {
public ImageHeaderBitmap(byte[] data, int offset) {
BufferedImage img = null;
try {
img = ImageIO.read(new ByteArrayInputStream(data, offset, data.length-offset));

+ 1
- 1
src/java/org/apache/poi/sl/image/ImageHeaderEMF.java View File

@@ -36,7 +36,7 @@ public class ImageHeaderEMF {
// rectangle that can be drawn around the image stored in the metafile.
private final Rectangle deviceBounds;

public ImageHeaderEMF(final byte data[], final int off) {
public ImageHeaderEMF(final byte[] data, final int off) {
int offset = off;
int type = (int)LittleEndian.getUInt(data, offset); offset += 4;
if (type != 1) {

+ 8
- 8
src/java/org/apache/poi/sl/image/ImageHeaderPICT.java View File

@@ -32,17 +32,17 @@ public class ImageHeaderPICT {

public static final double DEFAULT_RESOLUTION = Units.POINT_DPI;

private static final byte V2_HEADER[] = {
0x00, 0x11, // v2 version opcode
0x02, (byte)0xFF, // version number of new picture
0x0C, 0x00, // header opcode
(byte)0xFF, (byte)0xFE, 0x00, 0x00 // pic size dummy
private static final byte[] V2_HEADER = {
0x00, 0x11, // v2 version opcode
0x02, (byte) 0xFF, // version number of new picture
0x0C, 0x00, // header opcode
(byte) 0xFF, (byte) 0xFE, 0x00, 0x00 // pic size dummy
};

private final Rectangle bounds;
private final double hRes, vRes;

public ImageHeaderPICT(byte data[], final int off) {
public ImageHeaderPICT(byte[] data, final int off) {
// http://mirrors.apple2.org.za/apple.cabi.net/Graphics/PICT.and_QT.INFO/PICT.file.format.TI.txt
int offset = off;
// low order 16 bits of picture size - can be ignored
@@ -86,13 +86,13 @@ public class ImageHeaderPICT {
return bounds;
}

private static int readUnsignedShort(byte data[], int offset) {
private static int readUnsignedShort(byte[] data, int offset) {
int b0 = data[offset] & 0xFF;
int b1 = data[offset+1] & 0xFF;
return b0 << 8 | b1;
}

private static double readFixedPoint(byte data[], int offset) {
private static double readFixedPoint(byte[] data, int offset) {
int b0 = data[offset] & 0xFF;
int b1 = data[offset+1] & 0xFF;
int b2 = data[offset+2] & 0xFF;

+ 26
- 26
src/java/org/apache/poi/sl/usermodel/AutoNumberingScheme.java View File

@@ -245,31 +245,31 @@ public enum AutoNumberingScheme {
//M (1000), CM (900), D (500), CD (400), C (100), XC (90), L (50), XL (40), X (10), IX (9), V (5), IV (4) and I (1).
final int[] VALUES = new int[]{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
final String[] ROMAN = new String[]{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
final String conciseList[][] = {
{"XLV", "VL"}, //45
{"XCV", "VC"}, //95
{"CDL", "LD"}, //450
{"CML", "LM"}, //950
{"CMVC", "LMVL"}, //995
{"CDXC", "LDXL"}, //490
{"CDVC", "LDVL"}, //495
{"CMXC", "LMXL"}, //990
{"XCIX", "VCIV"}, //99
{"XLIX", "VLIV"}, //49
{"XLIX", "IL"}, //49
{"XCIX", "IC"}, //99
{"CDXC", "XD"}, //490
{"CDVC", "XDV"}, //495
{"CDIC", "XDIX"}, //499
{"LMVL", "XMV"}, //995
{"CMIC", "XMIX"}, //999
{"CMXC", "XM"}, // 990
{"XDV", "VD"}, //495
{"XDIX", "VDIV"}, //499
{"XMV", "VM"}, // 995
{"XMIX", "VMIV"}, //999
{"VDIV", "ID"}, //499
{"VMIV", "IM"} //999
final String[][] conciseList = {
{"XLV", "VL"}, //45
{"XCV", "VC"}, //95
{"CDL", "LD"}, //450
{"CML", "LM"}, //950
{"CMVC", "LMVL"}, //995
{"CDXC", "LDXL"}, //490
{"CDVC", "LDVL"}, //495
{"CMXC", "LMXL"}, //990
{"XCIX", "VCIV"}, //99
{"XLIX", "VLIV"}, //49
{"XLIX", "IL"}, //49
{"XCIX", "IC"}, //99
{"CDXC", "XD"}, //490
{"CDVC", "XDV"}, //495
{"CDIC", "XDIX"}, //499
{"LMVL", "XMV"}, //995
{"CMIC", "XMIX"}, //999
{"CMXC", "XM"}, // 990
{"XDV", "VD"}, //495
{"XDIX", "VDIV"}, //499
{"XMV", "VM"}, // 995
{"XMIX", "VMIV"}, //999
{"VDIV", "ID"}, //499
{"VMIV", "IM"} //999
};

StringBuilder sb = new StringBuilder();
@@ -280,7 +280,7 @@ public enum AutoNumberingScheme {
}
}
String result = sb.toString();
for (String cc[] : conciseList) {
for (String[] cc : conciseList) {
result = result.replace(cc[0], cc[1]);
}
return result;

+ 1
- 1
src/java/org/apache/poi/sl/usermodel/PresetColor.java View File

@@ -273,7 +273,7 @@ public enum PresetColor {
}
public static PresetColor valueOfNativeId(int nativeId) {
PresetColor vals[] = values();
PresetColor[] vals = values();
return (0 < nativeId && nativeId <= vals.length) ? vals[nativeId-1] : null;
}
}

+ 2
- 2
src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java View File

@@ -294,10 +294,10 @@ public class SlideShowFactory {
private static <
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> SlideShow<S,P> createSlideShow(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
> SlideShow<S,P> createSlideShow(String factoryClass, Object[] args) throws IOException, EncryptedDocumentException {
try {
Class<?> clazz = SlideShowFactory.class.getClassLoader().loadClass(factoryClass);
Class<?> argsClz[] = new Class<?>[args.length];
Class<?>[] argsClz = new Class<?>[args.length];
int i=0;
for (Object o : args) {
Class<?> c = o.getClass();

+ 1
- 1
src/java/org/apache/poi/sl/usermodel/StrokeStyle.java View File

@@ -81,7 +81,7 @@ public interface StrokeStyle {
/** PS_DASHDOTDOT system dash style / native 5 */
SYS_DASH_DOT_DOT(5, 11, 2,2,1,1,1,1);

public final int pattern[];
public final int[] pattern;
public final int nativeId;
public final int ooxmlId;


+ 2
- 2
src/java/org/apache/poi/ss/extractor/EmbeddedExtractor.java View File

@@ -234,7 +234,7 @@ public class EmbeddedExtractor implements Iterable<EmbeddedExtractor> {
}

// TODO: investigate if this is just an EMF-hack or if other formats are also embedded in EMF
byte pictureBytes[] = pd.getData();
byte[] pictureBytes = pd.getData();
int idxStart = indexOf(pictureBytes, 0, "%PDF-".getBytes(LocaleUtil.CHARSET_1252));
if (idxStart == -1) {
return null;
@@ -283,7 +283,7 @@ public class EmbeddedExtractor implements Iterable<EmbeddedExtractor> {
}

DocumentInputStream dis = dn.createDocumentInputStream("package");
byte data[] = IOUtils.toByteArray(dis);
byte[] data = IOUtils.toByteArray(dis);
dis.close();
return new EmbeddedData(dn.getName()+ext, data, contentType);

+ 2
- 2
src/java/org/apache/poi/ss/format/CellNumberFormatter.java View File

@@ -185,8 +185,8 @@ public class CellNumberFormatter extends CellFormatter {
} else {
afterFractional = null;
}
double scaleByRef[] = { ph.getScale() };
double[] scaleByRef = {ph.getScale()};
showGroupingSeparator = interpretIntegerCommas(descBuf, specials, decimalPoint, integerEnd(), fractionalEnd(), scaleByRef);
if (exponent == null) {
scale = scaleByRef[0];

+ 2
- 2
src/java/org/apache/poi/ss/formula/CacheAreaEval.java View File

@@ -63,8 +63,8 @@ public final class CacheAreaEval extends AreaEvalBase {
int height = area.getLastRow() - area.getFirstRow() + 1;
int width = area.getLastColumn() - area.getFirstColumn() + 1;
ValueEval newVals[] = new ValueEval[height * width];
ValueEval[] newVals = new ValueEval[height * width];
int startRow = area.getFirstRow() - getFirstRow();
int startCol = area.getFirstColumn() - getFirstColumn();

+ 2
- 2
src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java View File

@@ -347,8 +347,8 @@ public final class OperationEvaluationContext {

public ValueEval getAreaValueEval(int firstRowIndex, int firstColumnIndex,
int lastRowIndex, int lastColumnIndex, Object[][] tokens) {
ValueEval values[] = new ValueEval[tokens.length * tokens[0].length];
ValueEval[] values = new ValueEval[tokens.length * tokens[0].length];
int index = 0;
for (int jdx = 0; jdx < tokens.length; jdx++) {

+ 3
- 3
src/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java View File

@@ -33,7 +33,7 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple
return OperandResolver.coerceValueToDouble(ve);
}
public ValueEval evaluateArray(ValueEval args[], int srcRowIndex, int srcColumnIndex) {
public ValueEval evaluateArray(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
if (args.length != 2) {
return ErrorEval.VALUE_INVALID;
}
@@ -73,8 +73,8 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple
protected double[][] evaluate(double[][] d1, double[][] d2) throws IllegalArgumentException, EvaluationException {
int width = (d1[0].length < d2[0].length) ? d1[0].length : d2[0].length;
int height = (d1.length < d2.length) ? d1.length : d2.length;
double result[][] = new double[height][width];
double[][] result = new double[height][width];
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {

+ 3
- 3
src/java/org/apache/poi/ss/formula/functions/Days360.java View File

@@ -92,8 +92,8 @@ public class Days360 extends Var2or3ArgFunction {
private static double evaluate(double d0, double d1, boolean method) {
Calendar realStart = getDate(d0);
Calendar realEnd = getDate(d1);
int startingDate[] = getStartingDate(realStart, method);
int endingDate[] = getEndingDate(realEnd, startingDate, method);
int[] startingDate = getStartingDate(realStart, method);
int[] endingDate = getEndingDate(realEnd, startingDate, method);
return
(endingDate[0]*360+endingDate[1]*30+endingDate[2])-
(startingDate[0]*360+startingDate[1]*30+startingDate[2]);
@@ -115,7 +115,7 @@ public class Days360 extends Var2or3ArgFunction {
return new int[]{yyyy,mm,dd};
}

private static int[] getEndingDate(Calendar realEnd, int startingDate[], boolean method) {
private static int[] getEndingDate(Calendar realEnd, int[] startingDate, boolean method) {
int yyyy = realEnd.get(Calendar.YEAR);
int mm = realEnd.get(Calendar.MONTH);
int dd = Math.min(30, realEnd.get(Calendar.DAY_OF_MONTH));

+ 21
- 18
src/java/org/apache/poi/ss/formula/functions/MatrixFunction.java View File

@@ -96,12 +96,13 @@ public abstract class MatrixFunction implements Function{
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) {
if (arg0 instanceof AreaEval) {
double result[], resultArray[][];
double[] result;
double[][] resultArray;
int width, height;
try {
double values[] = collectValues(arg0);
double array[][] = fillDoubleArray(values,((AreaEval) arg0).getHeight(),((AreaEval) arg0).getWidth());
double[] values = collectValues(arg0);
double[][] array = fillDoubleArray(values, ((AreaEval) arg0).getHeight(), ((AreaEval) arg0).getWidth());
resultArray = evaluate(array);
width = resultArray[0].length;
height = resultArray.length;
@@ -112,8 +113,8 @@ public abstract class MatrixFunction implements Function{
catch(EvaluationException e){
return e.getErrorEval();
}
ValueEval vals[] = new ValueEval[result.length];
ValueEval[] vals = new ValueEval[result.length];
for (int idx = 0; idx < result.length; idx++) {
vals[idx] = new NumberEval(result[idx]);
@@ -130,10 +131,10 @@ public abstract class MatrixFunction implements Function{
}
}
else {
double result[][];
double[][] result;
try {
double value = NumericFunction.singleOperandEvaluate(arg0, srcRowIndex, srcColumnIndex);
double temp[][] = {{value}};
double[][] temp = {{value}};
result = evaluate(temp);
NumericFunction.checkValue(result[0][0]);
}
@@ -156,15 +157,17 @@ public abstract class MatrixFunction implements Function{
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
double result[];
double[] result;
int width, height;

try {
double array0[][], array1[][], resultArray[][];
double[][] array0;
double[][] array1;
double[][] resultArray;

if (arg0 instanceof AreaEval) {
try {
double values[] = collectValues(arg0);
double[] values = collectValues(arg0);
array0 = fillDoubleArray(values, ((AreaEval) arg0).getHeight(), ((AreaEval) arg0).getWidth());
}
catch(EvaluationException e) {
@@ -183,7 +186,7 @@ public abstract class MatrixFunction implements Function{
if (arg1 instanceof AreaEval) {
try {
double values[] = collectValues(arg1);
double[] values = collectValues(arg1);
array1 = fillDoubleArray(values, ((AreaEval) arg1).getHeight(),((AreaEval) arg1).getWidth());
}
catch (EvaluationException e) {
@@ -212,9 +215,9 @@ public abstract class MatrixFunction implements Function{
catch (IllegalArgumentException e) {
return ErrorEval.VALUE_INVALID;
}
ValueEval vals[] = new ValueEval[result.length];
ValueEval[] vals = new ValueEval[result.length];
for (int idx = 0; idx < result.length; idx++) {
vals[idx] = new NumberEval(result[idx]);
@@ -308,8 +311,8 @@ public abstract class MatrixFunction implements Function{
if (d1.length != d1[0].length) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
double result[][] = new double[1][1];
double[][] result = new double[1][1];
Array2DRowRealMatrix temp = new Array2DRowRealMatrix(d1);
result[0][0] = (new LUDecomposition(temp)).getDeterminant();
return result;
@@ -320,7 +323,7 @@ public abstract class MatrixFunction implements Function{
private final MutableValueCollector instance = new MutableValueCollector(false, false);
protected double[] collectValues(ValueEval arg) throws EvaluationException {
double values[] = instance.collectValues(arg);
double[] values = instance.collectValues(arg);
/* handle case where MMULT is operating on an array that is not completely filled*/
if (arg instanceof AreaEval && values.length == 1)

+ 2
- 2
src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java View File

@@ -319,10 +319,10 @@ public class WorkbookFactory {
* Uses reflection, so that this class can be in the Core non-OOXML
* POI jar without errors / broken references to the OOXML / XSSF code.
*/
private static Workbook createWorkbook(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
private static Workbook createWorkbook(String factoryClass, Object[] args) throws IOException, EncryptedDocumentException {
try {
Class<?> clazz = WorkbookFactory.class.getClassLoader().loadClass(factoryClass);
Class<?> argsClz[] = new Class<?>[args.length];
Class<?>[] argsClz = new Class<?>[args.length];
int i=0;
for (Object o : args) {
Class<?> c = o.getClass();

+ 1
- 2
src/java/org/apache/poi/ss/util/CellUtil.java View File

@@ -100,10 +100,9 @@ public final class CellUtil {
BORDER_RIGHT,
BORDER_TOP
)));


private static UnicodeMapping unicodeMappings[];
private static UnicodeMapping[] unicodeMappings;

private static final class UnicodeMapping {


+ 1
- 1
src/java/org/apache/poi/util/IOUtils.java View File

@@ -86,7 +86,7 @@ public final class IOUtils {
if (readBytes < limit) {
bos.write(new byte[limit-readBytes]);
}
byte peekedBytes[] = bos.toByteArray();
byte[] peekedBytes = bos.toByteArray();
if(stream instanceof PushbackInputStream) {
PushbackInputStream pin = (PushbackInputStream)stream;
pin.unread(peekedBytes, 0, readBytes);

+ 4
- 4
src/java/org/apache/poi/util/LittleEndianInputStream.java View File

@@ -57,7 +57,7 @@ public class LittleEndianInputStream extends FilterInputStream implements Little
@Override
public int readUByte() {
byte buf[] = new byte[1];
byte[] buf = new byte[1];
try {
checkEOF(read(buf), 1);
} catch (IOException e) {
@@ -84,7 +84,7 @@ public class LittleEndianInputStream extends FilterInputStream implements Little
@Override
public int readInt() {
byte buf[] = new byte[LittleEndianConsts.INT_SIZE];
byte[] buf = new byte[LittleEndianConsts.INT_SIZE];
try {
checkEOF(read(buf), buf.length);
} catch (IOException e) {
@@ -108,7 +108,7 @@ public class LittleEndianInputStream extends FilterInputStream implements Little
@Override
public long readLong() {
byte buf[] = new byte[LittleEndianConsts.LONG_SIZE];
byte[] buf = new byte[LittleEndianConsts.LONG_SIZE];
try {
checkEOF(read(buf), LittleEndianConsts.LONG_SIZE);
} catch (IOException e) {
@@ -124,7 +124,7 @@ public class LittleEndianInputStream extends FilterInputStream implements Little
@Override
public int readUShort() {
byte buf[] = new byte[LittleEndianConsts.SHORT_SIZE];
byte[] buf = new byte[LittleEndianConsts.SHORT_SIZE];
try {
checkEOF(read(buf), LittleEndianConsts.SHORT_SIZE);
} catch (IOException e) {

+ 8
- 4
src/java/org/apache/poi/util/POILogger.java View File

@@ -32,10 +32,14 @@ public abstract class POILogger {
public static final int ERROR = 7;
public static final int FATAL = 9;

/** Short strings for numeric log level. Use level as array index. */
protected static final String LEVEL_STRINGS_SHORT[] = {"?", "D", "?", "I", "?", "W", "?", "E", "?", "F", "?"};
/** Long strings for numeric log level. Use level as array index. */
protected static final String LEVEL_STRINGS[] = {"?0?", "DEBUG", "?2?", "INFO", "?4?", "WARN", "?6?", "ERROR", "?8?", "FATAL", "?10+?"};
/**
* Short strings for numeric log level. Use level as array index.
*/
protected static final String[] LEVEL_STRINGS_SHORT = {"?", "D", "?", "I", "?", "W", "?", "E", "?", "F", "?"};
/**
* Long strings for numeric log level. Use level as array index.
*/
protected static final String[] LEVEL_STRINGS = {"?0?", "DEBUG", "?2?", "INFO", "?4?", "WARN", "?6?", "ERROR", "?8?", "FATAL", "?10+?"};


/**

+ 2
- 2
src/java/org/apache/poi/util/StringUtil.java View File

@@ -407,7 +407,7 @@ public class StringUtil {
}
}

private static final int symbolMap_f020[] = {
private static final int[] symbolMap_f020 = {
' ', // 0xf020 space
'!', // 0xf021 exclam
8704, // 0xf022 universal
@@ -506,7 +506,7 @@ public class StringUtil {
' ', // 0xf07f not defined
};

private static final int symbolMap_f0a0[] = {
private static final int[] symbolMap_f0a0 = {
8364, // 0xf0a0 not defined / euro symbol
978, // 0xf0a1 upsilon1 (upper)
8242, // 0xf0a2 minute

+ 1
- 1
src/ooxml/java/org/apache/poi/openxml4j/opc/StreamHelper.java View File

@@ -64,7 +64,7 @@ public final class StreamHelper {
Result outputTarget = new StreamResult(new FilterOutputStream(
outStream) {
@Override
public void write(byte b[], int off, int len)
public void write(byte[] b, int off, int len)
throws IOException {
out.write(b, off, len);
}

+ 1
- 1
src/ooxml/java/org/apache/poi/openxml4j/util/ZipArchiveThresholdInputStream.java View File

@@ -75,7 +75,7 @@ public class ZipArchiveThresholdInputStream extends FilterInputStream {
}

@Override
public int read(byte b[], int off, int len) throws IOException {
public int read(byte[] b, int off, int len) throws IOException {
int cnt = super.read(b, off, len);
if (cnt > -1) {
checkThreshold();

+ 14
- 14
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java View File

@@ -111,7 +111,7 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
* blockSize bytes.
* 4. Use base64 to encode the result of step 3.
*/
byte verfierInputEnc[] = hashInput(ver, pwHash, kVerifierInputBlock, ver.getEncryptedVerifier(), Cipher.DECRYPT_MODE);
byte[] verfierInputEnc = hashInput(ver, pwHash, kVerifierInputBlock, ver.getEncryptedVerifier(), Cipher.DECRYPT_MODE);
setVerifier(verfierInputEnc);
MessageDigest hashMD = getMessageDigest(ver.getHashAlgorithm());
byte[] verifierHash = hashMD.digest(verfierInputEnc);
@@ -128,7 +128,7 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
* blockSize bytes, pad the hash value with 0x00 to an integral multiple of blockSize bytes.
* 4. Use base64 to encode the result of step 3.
*/
byte verifierHashDec[] = hashInput(ver, pwHash, kHashedVerifierBlock, ver.getEncryptedVerifierHash(), Cipher.DECRYPT_MODE);
byte[] verifierHashDec = hashInput(ver, pwHash, kHashedVerifierBlock, ver.getEncryptedVerifierHash(), Cipher.DECRYPT_MODE);
verifierHashDec = getBlock0(verifierHashDec, ver.getHashAlgorithm().hashSize);
/**
@@ -144,7 +144,7 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
* blockSize bytes.
* 4. Use base64 to encode the result of step 3.
*/
byte keyspec[] = hashInput(ver, pwHash, kCryptoKeyBlock, ver.getEncryptedKey(), Cipher.DECRYPT_MODE);
byte[] keyspec = hashInput(ver, pwHash, kCryptoKeyBlock, ver.getEncryptedKey(), Cipher.DECRYPT_MODE);
keyspec = getBlock0(keyspec, header.getKeySize()/8);
SecretKeySpec secretKey = new SecretKeySpec(keyspec, header.getCipherAlgorithm().jceId);

@@ -161,10 +161,10 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
* array with 0x00 to the next integral multiple of blockSize bytes.
* 4. Assign the encryptedHmacKey attribute to the base64-encoded form of the result of step 3.
*/
byte vec[] = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityKeyBlock, blockSize);
byte[] vec = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityKeyBlock, blockSize);
CipherAlgorithm cipherAlgo = header.getCipherAlgorithm();
Cipher cipher = getCipher(secretKey, cipherAlgo, header.getChainingMode(), vec, Cipher.DECRYPT_MODE);
byte hmacKey[] = cipher.doFinal(header.getEncryptedHmacKey());
byte[] hmacKey = cipher.doFinal(header.getEncryptedHmacKey());
hmacKey = getBlock0(hmacKey, header.getHashAlgorithm().hashSize);

/**
@@ -178,7 +178,7 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
*/
vec = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityValueBlock, blockSize);
cipher = getCipher(secretKey, cipherAlgo, ver.getChainingMode(), vec, Cipher.DECRYPT_MODE);
byte hmacValue[] = cipher.doFinal(header.getEncryptedHmacValue());
byte[] hmacValue = cipher.doFinal(header.getEncryptedHmacValue());
hmacValue = getBlock0(hmacValue, header.getHashAlgorithm().hashSize);
if (Arrays.equals(verifierHashDec, verifierHash)) {
@@ -222,21 +222,21 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate());
byte keyspec[] = cipher.doFinal(ace.encryptedKey);
byte[] keyspec = cipher.doFinal(ace.encryptedKey);
SecretKeySpec secretKey = new SecretKeySpec(keyspec, ver.getCipherAlgorithm().jceId);
Mac x509Hmac = CryptoFunctions.getMac(hashAlgo);
x509Hmac.init(secretKey);
byte certVerifier[] = x509Hmac.doFinal(ace.x509.getEncoded());
byte[] certVerifier = x509Hmac.doFinal(ace.x509.getEncoded());

byte vec[] = CryptoFunctions.generateIv(hashAlgo, header.getKeySalt(), kIntegrityKeyBlock, blockSize);
byte[] vec = CryptoFunctions.generateIv(hashAlgo, header.getKeySalt(), kIntegrityKeyBlock, blockSize);
cipher = getCipher(secretKey, cipherAlgo, header.getChainingMode(), vec, Cipher.DECRYPT_MODE);
byte hmacKey[] = cipher.doFinal(header.getEncryptedHmacKey());
byte[] hmacKey = cipher.doFinal(header.getEncryptedHmacKey());
hmacKey = getBlock0(hmacKey, hashAlgo.hashSize);

vec = CryptoFunctions.generateIv(hashAlgo, header.getKeySalt(), kIntegrityValueBlock, blockSize);
cipher = getCipher(secretKey, cipherAlgo, header.getChainingMode(), vec, Cipher.DECRYPT_MODE);
byte hmacValue[] = cipher.doFinal(header.getEncryptedHmacValue());
byte[] hmacValue = cipher.doFinal(header.getEncryptedHmacValue());
hmacValue = getBlock0(hmacValue, hashAlgo.hashSize);
@@ -256,14 +256,14 @@ public class AgileDecryptor extends Decryptor implements Cloneable {
return fillSize;
}

/* package */ static byte[] hashInput(AgileEncryptionVerifier ver, byte pwHash[], byte blockKey[], byte inputKey[], int cipherMode) {
/* package */ static byte[] hashInput(AgileEncryptionVerifier ver, byte[] pwHash, byte[] blockKey, byte[] inputKey, int cipherMode) {
CipherAlgorithm cipherAlgo = ver.getCipherAlgorithm();
ChainingMode chainMode = ver.getChainingMode();
int keySize = ver.getKeySize()/8;
int blockSize = ver.getBlockSize();
HashAlgorithm hashAlgo = ver.getHashAlgorithm();
byte intermedKey[] = generateKey(pwHash, hashAlgo, blockKey, keySize);
byte[] intermedKey = generateKey(pwHash, hashAlgo, blockKey, keySize);
SecretKey skey = new SecretKeySpec(intermedKey, cipherAlgo.jceId);
byte[] iv = generateIv(hashAlgo, ver.getSalt(), null, blockSize);
Cipher cipher = getCipher(skey, cipherAlgo, chainMode, iv, cipherMode);

+ 3
- 2
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java View File

@@ -28,7 +28,8 @@ import com.microsoft.schemas.office.x2006.encryption.EncryptionDocument;
import com.microsoft.schemas.office.x2006.encryption.STCipherChaining;

public class AgileEncryptionHeader extends EncryptionHeader implements Cloneable {
private byte encryptedHmacKey[], encryptedHmacValue[];
private byte[] encryptedHmacKey;
private byte[] encryptedHmacValue;
public AgileEncryptionHeader(String descriptor) {
this(AgileEncryptionInfoBuilder.parseDescriptor(descriptor));
@@ -100,7 +101,7 @@ public class AgileEncryptionHeader extends EncryptionHeader implements Cloneable

// make method visible for this package
@Override
protected void setKeySalt(byte salt[]) {
protected void setKeySalt(byte[] salt) {
if (salt == null || salt.length != getBlockSize()) {
throw new EncryptedDocumentException("invalid verifier salt");
}

+ 5
- 5
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java View File

@@ -43,8 +43,8 @@ public class AgileEncryptionVerifier extends EncryptionVerifier implements Clone

public static class AgileCertificateEntry {
X509Certificate x509;
byte encryptedKey[];
byte certVerifier[];
byte[] encryptedKey;
byte[] certVerifier;
}
private List<AgileCertificateEntry> certList = new ArrayList<>();
@@ -137,7 +137,7 @@ public class AgileEncryptionVerifier extends EncryptionVerifier implements Clone
}
@Override
protected void setSalt(byte salt[]) {
protected void setSalt(byte[] salt) {
if (salt == null || salt.length != getCipherAlgorithm().blockSize) {
throw new EncryptedDocumentException("invalid verifier salt");
}
@@ -146,13 +146,13 @@ public class AgileEncryptionVerifier extends EncryptionVerifier implements Clone
// make method visible for this package
@Override
protected void setEncryptedVerifier(byte encryptedVerifier[]) {
protected void setEncryptedVerifier(byte[] encryptedVerifier) {
super.setEncryptedVerifier(encryptedVerifier);
}

// make method visible for this package
@Override
protected void setEncryptedVerifierHash(byte encryptedVerifierHash[]) {
protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) {
super.setEncryptedVerifierHash(encryptedVerifierHash);
}


+ 17
- 17
src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java View File

@@ -81,8 +81,8 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
//arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 1_000_000;

private byte integritySalt[];
private byte pwHash[];
private byte[] integritySalt;
private byte[] pwHash;
protected AgileEncryptor() {
}
@@ -111,7 +111,7 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
}
@Override
public void confirmPassword(String password, byte keySpec[], byte keySalt[], byte verifier[], byte verifierSalt[], byte integritySalt[]) {
public void confirmPassword(String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt) {
AgileEncryptionVerifier ver = (AgileEncryptionVerifier)getEncryptionInfo().getVerifier();
AgileEncryptionHeader header = (AgileEncryptionHeader)getEncryptionInfo().getHeader();

@@ -135,7 +135,7 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
* blockSize bytes.
* 4. Use base64 to encode the result of step 3.
*/
byte encryptedVerifier[] = hashInput(ver, pwHash, kVerifierInputBlock, verifier, Cipher.ENCRYPT_MODE);
byte[] encryptedVerifier = hashInput(ver, pwHash, kVerifierInputBlock, verifier, Cipher.ENCRYPT_MODE);
ver.setEncryptedVerifier(encryptedVerifier);

@@ -153,7 +153,7 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
*/
MessageDigest hashMD = getMessageDigest(ver.getHashAlgorithm());
byte[] hashedVerifier = hashMD.digest(verifier);
byte encryptedVerifierHash[] = hashInput(ver, pwHash, kHashedVerifierBlock, hashedVerifier, Cipher.ENCRYPT_MODE);
byte[] encryptedVerifierHash = hashInput(ver, pwHash, kHashedVerifierBlock, hashedVerifier, Cipher.ENCRYPT_MODE);
ver.setEncryptedVerifierHash(encryptedVerifierHash);
/**
@@ -169,7 +169,7 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
* blockSize bytes.
* 4. Use base64 to encode the result of step 3.
*/
byte encryptedKey[] = hashInput(ver, pwHash, kCryptoKeyBlock, keySpec, Cipher.ENCRYPT_MODE);
byte[] encryptedKey = hashInput(ver, pwHash, kCryptoKeyBlock, keySpec, Cipher.ENCRYPT_MODE);
ver.setEncryptedKey(encryptedKey);
SecretKey secretKey = new SecretKeySpec(keySpec, header.getCipherAlgorithm().jceId);
@@ -202,10 +202,10 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
this.integritySalt = integritySalt.clone();

try {
byte vec[] = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityKeyBlock, header.getBlockSize());
byte[] vec = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityKeyBlock, header.getBlockSize());
Cipher cipher = getCipher(secretKey, header.getCipherAlgorithm(), header.getChainingMode(), vec, Cipher.ENCRYPT_MODE);
byte hmacKey[] = getBlock0(this.integritySalt, getNextBlockSize(this.integritySalt.length, blockSize));
byte encryptedHmacKey[] = cipher.doFinal(hmacKey);
byte[] hmacKey = getBlock0(this.integritySalt, getNextBlockSize(this.integritySalt.length, blockSize));
byte[] encryptedHmacKey = cipher.doFinal(hmacKey);
header.setEncryptedHmacKey(encryptedHmacKey);

cipher = Cipher.getInstance("RSA");
@@ -245,10 +245,10 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
int blockSize = header.getBlockSize();
HashAlgorithm hashAlgo = header.getHashAlgorithm();
Mac integrityMD = CryptoFunctions.getMac(hashAlgo);
byte hmacKey[] = getBlock0(this.integritySalt, getNextBlockSize(this.integritySalt.length, blockSize));
byte[] hmacKey = getBlock0(this.integritySalt, getNextBlockSize(this.integritySalt.length, blockSize));
integrityMD.init(new SecretKeySpec(hmacKey, hashAlgo.jceHmacId));

byte buf[] = new byte[1024];
byte[] buf = new byte[1024];
LittleEndian.putLong(buf, 0, oleStreamSize);
integrityMD.update(buf, 0, LittleEndianConsts.LONG_SIZE);
@@ -261,13 +261,13 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
} finally {
fis.close();
}
byte hmacValue[] = integrityMD.doFinal();
byte hmacValueFilled[] = getBlock0(hmacValue, getNextBlockSize(hmacValue.length, blockSize));
byte iv[] = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityValueBlock, blockSize);
byte[] hmacValue = integrityMD.doFinal();
byte[] hmacValueFilled = getBlock0(hmacValue, getNextBlockSize(hmacValue.length, blockSize));
byte[] iv = CryptoFunctions.generateIv(header.getHashAlgorithm(), header.getKeySalt(), kIntegrityValueBlock, blockSize);
Cipher cipher = CryptoFunctions.getCipher(getSecretKey(), header.getCipherAlgorithm(), header.getChainingMode(), iv, Cipher.ENCRYPT_MODE);
byte encryptedHmacValue[] = cipher.doFinal(hmacValueFilled);
byte[] encryptedHmacValue = cipher.doFinal(hmacValueFilled);
header.setEncryptedHmacValue(encryptedHmacValue);
}

+ 6
- 6
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureConfig.java View File

@@ -950,12 +950,12 @@ public class SignatureConfig {
public Provider getProvider() {
Provider prov = provider.get();
if (prov == null) {
String dsigProviderNames[] = {
System.getProperty("jsr105Provider"),
// Santuario xmlsec
"org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI",
// JDK xmlsec
"org.jcp.xml.dsig.internal.dom.XMLDSigRI"
String[] dsigProviderNames = {
System.getProperty("jsr105Provider"),
// Santuario xmlsec
"org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI",
// JDK xmlsec
"org.jcp.xml.dsig.internal.dom.XMLDSigRI"
};
for (String pn : dsigProviderNames) {
if (pn == null) {

+ 4
- 4
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/SignatureFacet.java View File

@@ -113,18 +113,18 @@ public abstract class SignatureFacet implements SignatureConfigurable {
}
}
protected Reference newReference(String uri, List<Transform> transforms, String type, String id, byte digestValue[])
protected Reference newReference(String uri, List<Transform> transforms, String type, String id, byte[] digestValue)
throws XMLSignatureException {
return newReference(uri, transforms, type, id, digestValue, signatureConfig);
}

public static Reference newReference(
String uri
String uri
, List<Transform> transforms
, String type
, String id
, byte digestValue[]
, SignatureConfig signatureConfig)
, byte[] digestValue
, SignatureConfig signatureConfig)
throws XMLSignatureException {
// the references appear in the package signature or the package object
// so we can use the default digest algorithm

+ 1
- 1
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java View File

@@ -233,7 +233,7 @@ public class XAdESXLSignatureFacet extends SignatureFacet {
DERTaggedObject derTaggedObject = (DERTaggedObject)ocspResponderId.toASN1Primitive();
if (2 == derTaggedObject.getTagNo()) {
ASN1OctetString keyHashOctetString = (ASN1OctetString)derTaggedObject.getObject();
byte key[] = keyHashOctetString.getOctets();
byte[] key = keyHashOctetString.getOctets();
responderId.setByKey(key);
} else {
X500Name name = X500Name.getInstance(derTaggedObject.getObject());

+ 1
- 1
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java View File

@@ -139,7 +139,7 @@ public class RelationshipTransformService extends TransformService {
try {
TransformDocument transDoc = TransformDocument.Factory.parse(parentNode, DEFAULT_XML_OPTIONS);
XmlObject xoList[] = transDoc.getTransform().selectChildren(RelationshipReferenceDocument.type.getDocumentElementName());
XmlObject[] xoList = transDoc.getTransform().selectChildren(RelationshipReferenceDocument.type.getDocumentElementName());
if (xoList.length == 0) {
LOG.log(POILogger.WARN, "no RelationshipReference/@SourceId parameters present");
}

+ 2
- 2
src/ooxml/java/org/apache/poi/poifs/crypt/temp/AesZipFileZipEntrySource.java View File

@@ -116,7 +116,7 @@ public final class AesZipFileZipEntrySource implements ZipEntrySource {
return fileToSource(tmpFile, keyBytes, ivBytes);
}

private static void copyToFile(InputStream is, File tmpFile, byte keyBytes[], byte ivBytes[]) throws IOException {
private static void copyToFile(InputStream is, File tmpFile, byte[] keyBytes, byte[] ivBytes) throws IOException {
SecretKeySpec skeySpec = new SecretKeySpec(keyBytes, CipherAlgorithm.aes128.jceId);
Cipher ciEnc = CryptoFunctions.getCipher(skeySpec, CipherAlgorithm.aes128, ChainingMode.cbc, ivBytes, Cipher.ENCRYPT_MODE, PADDING);
@@ -150,7 +150,7 @@ public final class AesZipFileZipEntrySource implements ZipEntrySource {
zis.close();
}

private static AesZipFileZipEntrySource fileToSource(File tmpFile, byte keyBytes[], byte ivBytes[]) throws IOException {
private static AesZipFileZipEntrySource fileToSource(File tmpFile, byte[] keyBytes, byte[] ivBytes) throws IOException {
SecretKeySpec skeySpec = new SecretKeySpec(keyBytes, CipherAlgorithm.aes128.jceId);
Cipher ciDec = CryptoFunctions.getCipher(skeySpec, CipherAlgorithm.aes128, ChainingMode.cbc, ivBytes, Cipher.DECRYPT_MODE, PADDING);
return new AesZipFileZipEntrySource(tmpFile, ciDec);

+ 2
- 2
src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java View File

@@ -288,7 +288,7 @@ public class XMLSlideShow extends POIXMLDocument
XSLFSlideLayout layout = sm.getLayout(SlideLayout.BLANK);
if (layout == null) {
LOG.log(POILogger.WARN, "Blank layout was not found - defaulting to first slide layout in master");
XSLFSlideLayout sl[] = sm.getSlideLayouts();
XSLFSlideLayout[] sl = sm.getSlideLayouts();
if (sl.length == 0) {
throw new POIXMLException("SlideMaster must contain a SlideLayout.");
}
@@ -580,7 +580,7 @@ public class XMLSlideShow extends POIXMLDocument
@Override
public XSLFPictureData findPictureData(byte[] pictureData) {
long checksum = IOUtils.calculateChecksum(pictureData);
byte cs[] = new byte[LittleEndianConsts.LONG_SIZE];
byte[] cs = new byte[LittleEndianConsts.LONG_SIZE];
LittleEndian.putLong(cs, 0, checksum);

for (XSLFPictureData pic : getPictureData()) {

+ 1
- 1
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java View File

@@ -233,7 +233,7 @@ public class XSLFColor {
// sRGB has a gamma of 2.2
CTSRgbColor rgb = fill.addNewSrgbClr();

byte rgbBytes[] = { (byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue() };
byte[] rgbBytes = {(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()};
rgb.setVal(rgbBytes);
alphaPct = (addAlpha) ? rgb.addNewAlpha() : null;
} else {

+ 1
- 1
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFMetroShape.java View File

@@ -43,7 +43,7 @@ public class XSLFMetroShape {
/*
* parses the metro bytes to a XSLF shape
*/
public static Shape<?,?> parseShape(byte metroBytes[])
public static Shape<?,?> parseShape(byte[] metroBytes)
throws InvalidFormatException, IOException, XmlException {
PackagePartName shapePN = PackagingURIHelper.createPartName("/drs/shapexml.xml");
OPCPackage pkg = null;

+ 2
- 2
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java View File

@@ -114,7 +114,7 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture
@Override
public byte[] getChecksum() {
cacheProperties();
byte cs[] = new byte[LittleEndianConsts.LONG_SIZE];
byte[] cs = new byte[LittleEndianConsts.LONG_SIZE];
LittleEndian.putLong(cs,0,checksum);
return cs;
}
@@ -139,7 +139,7 @@ public final class XSLFPictureData extends POIXMLDocumentPart implements Picture
*/
protected void cacheProperties() {
if (origSize == null || checksum == null) {
byte data[] = getData();
byte[] data = getData();
checksum = IOUtils.calculateChecksum(data);
PictureType pt = getType();

+ 2
- 2
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java View File

@@ -439,8 +439,8 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
return Integer.compare(pos1, pos2);
});

final ColorStyle cs[] = new ColorStyle[gs.length];
final float fractions[] = new float[gs.length];
final ColorStyle[] cs = new ColorStyle[gs.length];
final float[] fractions = new float[gs.length];

int i=0;
for (CTGradientStop cgs : gs) {

+ 1
- 1
src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java View File

@@ -179,7 +179,7 @@ public class PPTX2PNG {
}
} else {
for (String subrange : range.split(",")) {
String idx[] = subrange.split("-");
String[] idx = subrange.split("-");
switch (idx.length) {
default:
case 0: break;

+ 7
- 7
src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFPasswordHelper.java View File

@@ -66,8 +66,8 @@ public final class XSSFPasswordHelper {
cur.insertAttributeWithValue(getAttrName(prefix, "password"),
String.format(Locale.ROOT, "%04X", hash).toUpperCase(Locale.ROOT));
} else {
SecureRandom random = new SecureRandom();
byte salt[] = random.generateSeed(16);
SecureRandom random = new SecureRandom();
byte[] salt = random.generateSeed(16);
// Iterations specifies the number of times the hashing function shall be iteratively run (using each
// iteration's result as the input for the next iteration).
@@ -76,7 +76,7 @@ public final class XSSFPasswordHelper {
// Implementation Notes List:
// --> In this third stage, the reversed byte order legacy hash from the second stage shall
// be converted to Unicode hex string representation
byte hash[] = CryptoFunctions.hashPassword(password, hashAlgo, salt, spinCount, false);
byte[] hash = CryptoFunctions.hashPassword(password, hashAlgo, salt, spinCount, false);
cur.insertAttributeWithValue(getAttrName(prefix, "algorithmName"), hashAlgo.jceId);
cur.insertAttributeWithValue(getAttrName(prefix, "hashValue"), DatatypeConverter.printBase64Binary(hash));
@@ -117,12 +117,12 @@ public final class XSSFPasswordHelper {
if (hashVal == null || algoName == null || saltVal == null || spinCount == null) {
return false;
}
byte hash1[] = DatatypeConverter.parseBase64Binary(hashVal);
byte[] hash1 = DatatypeConverter.parseBase64Binary(hashVal);
HashAlgorithm hashAlgo = HashAlgorithm.fromString(algoName);
byte salt[] = DatatypeConverter.parseBase64Binary(saltVal);
byte[] salt = DatatypeConverter.parseBase64Binary(saltVal);
int spinCnt = Integer.parseInt(spinCount);
byte hash2[] = CryptoFunctions.hashPassword(password, hashAlgo, salt, spinCnt, false);
byte[] hash2 = CryptoFunctions.hashPassword(password, hashAlgo, salt, spinCnt, false);
return Arrays.equals(hash1, hash2);
}
}

+ 5
- 5
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java View File

@@ -270,7 +270,7 @@ public class XWPFSettings extends POIXMLDocumentPart {


SecureRandom random = new SecureRandom();
byte salt[] = random.generateSeed(16);
byte[] salt = random.generateSeed(16);

// Iterations specifies the number of times the hashing function shall be iteratively run (using each
// iteration's result as the input for the next iteration).
@@ -280,7 +280,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
// Implementation Notes List:
// --> In this third stage, the reversed byte order legacy hash from the second stage shall
// be converted to Unicode hex string representation
byte hash[] = CryptoFunctions.hashPassword(legacyHash, hashAlgo, salt, spinCount, false);
byte[] hash = CryptoFunctions.hashPassword(legacyHash, hashAlgo, salt, spinCount, false);

safeGetDocumentProtection().setSalt(salt);
safeGetDocumentProtection().setHash(hash);
@@ -300,8 +300,8 @@ public class XWPFSettings extends POIXMLDocumentPart {
*/
public boolean validateProtectionPassword(String password) {
BigInteger sid = safeGetDocumentProtection().getCryptAlgorithmSid();
byte hash[] = safeGetDocumentProtection().getHash();
byte salt[] = safeGetDocumentProtection().getSalt();
byte[] hash = safeGetDocumentProtection().getHash();
byte[] salt = safeGetDocumentProtection().getSalt();
BigInteger spinCount = safeGetDocumentProtection().getCryptSpinCount();

if (sid == null || hash == null || salt == null || spinCount == null) return false;
@@ -337,7 +337,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
// Implementation Notes List:
// --> In this third stage, the reversed byte order legacy hash from the second stage shall
// be converted to Unicode hex string representation
byte hash2[] = CryptoFunctions.hashPassword(legacyHash, hashAlgo, salt, spinCount.intValue(), false);
byte[] hash2 = CryptoFunctions.hashPassword(legacyHash, hashAlgo, salt, spinCount.intValue(), false);

return Arrays.equals(hash, hash2);
}

+ 6
- 6
src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java View File

@@ -45,13 +45,13 @@ public class TestDetectAsOOXML {
@Test
public void testDetectAsPOIFS() throws IOException {
Object fileAndMagic[][] = {
{ "SampleSS.xlsx", FileMagic.OOXML },
{ "SampleSS.xls", FileMagic.OLE2 },
{ "SampleSS.txt", FileMagic.UNKNOWN }
};
Object[][] fileAndMagic = {
{"SampleSS.xlsx", FileMagic.OOXML},
{"SampleSS.xls", FileMagic.OLE2},
{"SampleSS.txt", FileMagic.UNKNOWN}
};

for (Object fm[] : fileAndMagic) {
for (Object[] fm : fileAndMagic) {
InputStream is = HSSFTestDataSamples.openSampleFileStream((String)fm[0]);
is = FileMagic.prepareToCheckMagic(is);
FileMagic act = FileMagic.valueOf(is);

+ 1
- 1
src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java View File

@@ -360,7 +360,7 @@ public final class TestPOIXMLDocument {
UncaughtHandler uh = new UncaughtHandler();
// check schema type loading and check if we could run in an OOM
Thread ta[] = new Thread[30];
Thread[] ta = new Thread[30];
for (int j=0; j<10; j++) {
for (int i=0; i<ta.length; i++) {
ta[i] = new Thread(run);

+ 1
- 1
src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLiteAgent.java View File

@@ -43,7 +43,7 @@ public class OOXMLLiteAgent {
final Set<Integer> fileHashes = new HashSet<>();

public LoggingTransformer(String agentArgs) {
String args[] = (agentArgs == null ? "" : agentArgs).split("\\|",2);
String[] args = (agentArgs == null ? "" : agentArgs).split("\\|", 2);
path = Paths.get(args.length >= 1 ? args[0] : "ooxml-lite.out");
includes = Pattern.compile(args.length >= 2 ? args[1] : ".*/schemas/.*");


+ 7
- 7
src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackage.java View File

@@ -804,7 +804,7 @@ public final class TestPackage {
IOUtils.copy(is, bos2);
long size = bos2.size() - "</Types>".length();
append.write(bos2.toByteArray(), 0, (int) size);
byte spam[] = new byte[0x7FFF];
byte[] spam = new byte[0x7FFF];
Arrays.fill(spam, (byte) ' ');
// 0x7FFF0000 is the maximum for 32-bit zips, but less still works
while (size < 0x7FFF00) {
@@ -979,12 +979,12 @@ public final class TestPackage {
public void testTooShortFilterStreams() throws IOException {
File xssf = OpenXML4JTestDataSamples.getSampleFile("sample.xlsx");
File hssf = POIDataSamples.getSpreadSheetInstance().getFile("SampleSS.xls");
InputStream isList[] = {
new PushbackInputStream(new FileInputStream(xssf), 2),
new BufferedInputStream(new FileInputStream(xssf), 2),
new PushbackInputStream(new FileInputStream(hssf), 2),
new BufferedInputStream(new FileInputStream(hssf), 2),
InputStream[] isList = {
new PushbackInputStream(new FileInputStream(xssf), 2),
new BufferedInputStream(new FileInputStream(xssf), 2),
new PushbackInputStream(new FileInputStream(hssf), 2),
new BufferedInputStream(new FileInputStream(hssf), 2),
};
try {

+ 1
- 1
src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestRelationships.java View File

@@ -56,7 +56,7 @@ public class TestRelationships extends TestCase {
PackageRelationshipCollection rels = pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
PackageRelationship coreDocRelationship = rels.getRelationship(0);
PackagePart corePart = pkg.getPart(coreDocRelationship);
String relIds[] = { "rId1", "rId2", "rId3" };
String[] relIds = {"rId1", "rId2", "rId3"};
for (String relId : relIds) {
PackageRelationship rel = corePart.getRelationship(relId);
assertNotNull(rel);

+ 5
- 5
src/ooxml/testcases/org/apache/poi/poifs/crypt/TestAgileEncryptionParameters.java View File

@@ -43,7 +43,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class TestAgileEncryptionParameters {

static byte testData[];
static byte[] testData;
@Parameter(value = 0)
public CipherAlgorithm ca;
@@ -54,9 +54,9 @@ public class TestAgileEncryptionParameters {

@Parameters(name="{0} {1} {2}")
public static Collection<Object[]> data() {
CipherAlgorithm caList[] = { CipherAlgorithm.aes128, CipherAlgorithm.aes192, CipherAlgorithm.aes256, CipherAlgorithm.rc2, CipherAlgorithm.des, CipherAlgorithm.des3 };
HashAlgorithm haList[] = { HashAlgorithm.sha1, HashAlgorithm.sha256, HashAlgorithm.sha384, HashAlgorithm.sha512, HashAlgorithm.md5 };
ChainingMode cmList[] = { ChainingMode.cbc, ChainingMode.cfb };
CipherAlgorithm[] caList = {CipherAlgorithm.aes128, CipherAlgorithm.aes192, CipherAlgorithm.aes256, CipherAlgorithm.rc2, CipherAlgorithm.des, CipherAlgorithm.des3};
HashAlgorithm[] haList = {HashAlgorithm.sha1, HashAlgorithm.sha256, HashAlgorithm.sha384, HashAlgorithm.sha512, HashAlgorithm.md5};
ChainingMode[] cmList = {ChainingMode.cbc, ChainingMode.cfb};

List<Object[]> data = new ArrayList<>();
for (CipherAlgorithm ca : caList) {
@@ -101,7 +101,7 @@ public class TestAgileEncryptionParameters {
boolean passed = dec.verifyPassword("foobaa");
assertTrue(passed);
InputStream is = dec.getDataStream(fsDec);
byte actualData[] = IOUtils.toByteArray(is);
byte[] actualData = IOUtils.toByteArray(is);
is.close();
fsDec.close();
assertArrayEquals("Failed roundtrip - "+ca+"-"+ha+"-"+cm, testData, actualData);

+ 0
- 0
src/ooxml/testcases/org/apache/poi/poifs/crypt/TestCertificateEncryption.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save