*/
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();
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);
*/
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;
*/
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);
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);
* @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 );
}
}
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);
*/
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);
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 );
*/
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: */
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;
* @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"))
*/
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);
}
*/
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);
* @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();
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()) {
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 =
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;
}
@Override
- public void readPlain(byte b[], int off, int len) {
+ public void readPlain(byte[] b, int off, int len) {
ccis.readPlain(b, off, len);
}
}
@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);
@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");
* @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);
// 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)
{
* @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);
}
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)
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);
}
}
@SuppressWarnings("resource")
- void encryptBytes(byte buf[]) {
+ void encryptBytes(byte[] buf) {
EncryptionInfo ei = getEncryptionInfo();
if (ei == null) {
return;
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;
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);
// 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;
}
// 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) {
*
*/
@Override
- public void readPlain(byte b[], int off, int len) {
+ public void readPlain(byte[] b, int off, int len) {
if (len <= 0) {
return;
}
* @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)
// 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);
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;
* @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);
}
* 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;
* </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);
}
}
- 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}
};
/**
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);
// 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);
}
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);
}
public static class DataSpaceMap implements EncryptionRecord {
- DataSpaceMapEntry entries[];
+ DataSpaceMapEntry[] entries;
- public DataSpaceMap(DataSpaceMapEntry entries[]) {
+ public DataSpaceMap(DataSpaceMapEntry[] entries) {
this.entries = entries.clone();
}
}
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;
}
public static class DataSpaceDefinition implements EncryptionRecord {
- String transformer[];
+ String[] transformer;
- public DataSpaceDefinition(String transformer[]) {
+ public DataSpaceDefinition(String[] transformer) {
this.transformer = transformer.clone();
}
}
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) {
/* 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
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;
return keySalt;
}
- protected void setKeySalt(byte salt[]) {
+ protected void setKeySalt(byte[] salt) {
this.keySalt = (salt == null) ? null : salt.clone();
}
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);
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;
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();
}
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);
}
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);
}
@Override
- protected void setSalt(byte salt[]) {
+ protected void setSalt(byte[] salt) {
if (salt == null || salt.length != 16) {
throw new EncryptedDocumentException("invalid verifier 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);
}
@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);
}
@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);
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;
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);
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);
}
}
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;
/* 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) {
}
@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;
return readLen;
}
- public CryptoAPIDocumentInputStream(CryptoAPIDecryptor decryptor, byte buf[])
+ public CryptoAPIDocumentInputStream(CryptoAPIDecryptor decryptor, byte[] buf)
throws GeneralSecurityException {
super(buf);
this.decryptor = decryptor;
/* 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;
}
@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);
}
@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);
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);
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<>();
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);
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 ...
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);
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);
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);
// 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");
}
// 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);
// 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);
}
* 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);
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
// 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);
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 {
@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();
/*
@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;
* 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);
* 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);
}
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);
}
@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);
}
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
*
* @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);
* @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);
* @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);
this.unknown1 = unknown1;
}
- public void setDataBuffer(byte dataBuffer[]) {
+ public void setDataBuffer(byte[] dataBuffer) {
this.dataBuffer = dataBuffer.clone();
}
}
* @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");
}
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
* @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]");
}
@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);
}
}
}
-
+
/**
* Return a FontManager, either registered beforehand or a default implementation
*
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) ||
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':
lineDash = LineDash.SOLID;
}
- int dashPatI[] = lineDash.pattern;
+ int[] dashPatI = lineDash.pattern;
final float dash_phase = 0;
float[] dashPatF = null;
if (dashPatI != null) {
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;
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;
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;
* @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;
}
* @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
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));
// 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) {
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
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;
//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();
}
}
String result = sb.toString();
- for (String cc[] : conciseList) {
+ for (String[] cc : conciseList) {
result = result.replace(cc[0], cc[1]);
}
return result;
}
public static PresetColor valueOfNativeId(int nativeId) {
- PresetColor vals[] = values();
+ PresetColor[] vals = values();
return (0 < nativeId && nativeId <= vals.length) ? vals[nativeId-1] : null;
}
}
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();
/** 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;
}
// 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;
}
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);
} 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];
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();
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++) {
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;
}
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++) {
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]);
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));
@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;
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]);
}
}
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]);
}
@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) {
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) {
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]);
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;
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)
* 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();
BORDER_RIGHT,
BORDER_TOP
)));
-
- private static UnicodeMapping unicodeMappings[];
+ private static UnicodeMapping[] unicodeMappings;
private static final class UnicodeMapping {
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);
@Override
public int readUByte() {
- byte buf[] = new byte[1];
+ byte[] buf = new byte[1];
try {
checkEOF(read(buf), 1);
} catch (IOException e) {
@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) {
@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) {
@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) {
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+?"};
/**
}
}
- private static final int symbolMap_f020[] = {
+ private static final int[] symbolMap_f020 = {
' ', // 0xf020 space
'!', // 0xf021 exclam
8704, // 0xf022 universal
' ', // 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
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);
}
}
@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();
* 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);
* 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);
/**
* 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);
* 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);
/**
*/
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)) {
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);
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);
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));
// 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");
}
public static class AgileCertificateEntry {
X509Certificate x509;
- byte encryptedKey[];
- byte certVerifier[];
+ byte[] encryptedKey;
+ byte[] certVerifier;
}
private List<AgileCertificateEntry> certList = new ArrayList<>();
}
@Override
- protected void setSalt(byte salt[]) {
+ protected void setSalt(byte[] salt) {
if (salt == null || salt.length != getCipherAlgorithm().blockSize) {
throw new EncryptedDocumentException("invalid verifier salt");
}
// 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);
}
//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() {
}
}
@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();
* 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);
*/
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);
/**
* 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);
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");
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);
} 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);
}
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) {
}
}
- 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
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());
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");
}
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);
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);
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.");
}
@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()) {
// 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 {
/*
* 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;
@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;
}
*/
protected void cacheProperties() {
if (origSize == null || checksum == null) {
- byte data[] = getData();
+ byte[] data = getData();
checksum = IOUtils.calculateChecksum(data);
PictureType pt = getType();
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) {
}
} else {
for (String subrange : range.split(",")) {
- String idx[] = subrange.split("-");
+ String[] idx = subrange.split("-");
switch (idx.length) {
default:
case 0: break;
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).
// 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));
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);
}
}
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).
// 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);
*/
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;
// 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);
}
@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);
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);
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/.*");
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) {
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 {
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);
@RunWith(Parameterized.class)
public class TestAgileEncryptionParameters {
- static byte testData[];
+ static byte[] testData;
@Parameter(value = 0)
public CipherAlgorithm ca;
@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) {
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);
*/
static final String certDN = "CN=poitest";
// static final File pfxFile = TempFile.createTempFile("poitest", ".pfx");
- static byte pfxFileBytes[];
+ static byte[] pfxFileBytes;
static class CertData {
KeyPair keypair;
File file = POIDataSamples.getDocumentInstance().getFile("VariousPictures.docx");
InputStream fis = new FileInputStream(file);
- byte byteExpected[] = IOUtils.toByteArray(fis);
+ byte[] byteExpected = IOUtils.toByteArray(fis);
fis.close();
OutputStream os = enc.getDataStream(fs);
assertTrue("certificate verification failed", passed);
fis = agDec.getDataStream(fs);
- byte byteActual[] = IOUtils.toByteArray(fis);
+ byte[] byteActual = IOUtils.toByteArray(fis);
fis.close();
assertThat(byteExpected, equalTo(byteActual));
continue;
}
assertEquals(entry.getSize() - 1, zin.skip(entry.getSize() - 1));
- byte buf[] = new byte[10];
+ byte[] buf = new byte[10];
int readBytes = zin.read(buf);
// zin.available() doesn't work for entries
assertEquals("size failed for " + entry.getName(), 1, readBytes);
}
// check that same verifier/salt lead to same hashes
- final byte verifierSaltExpected[] = infoExpected.getVerifier().getSalt();
- final byte verifierExpected[] = decExpected.getVerifier();
- final byte keySalt[] = infoExpected.getHeader().getKeySalt();
- final byte keySpec[] = decExpected.getSecretKey().getEncoded();
- final byte integritySalt[] = decExpected.getIntegrityHmacKey();
+ final byte[] verifierSaltExpected = infoExpected.getVerifier().getSalt();
+ final byte[] verifierExpected = decExpected.getVerifier();
+ final byte[] keySalt = infoExpected.getHeader().getKeySalt();
+ final byte[] keySpec = decExpected.getSecretKey().getEncoded();
+ final byte[] integritySalt = decExpected.getIntegrityHmacKey();
// the hmacs of the file always differ, as we use PKCS5-padding to pad the bytes
// whereas office just uses random bytes
// byte integrityHash[] = d.getIntegrityHmacValue();
}
// check that same verifier/salt lead to same hashes
- final byte verifierSaltExpected[] = infoExpected.getVerifier().getSalt();
- final byte verifierExpected[] = d.getVerifier();
- final byte keySpec[] = d.getSecretKey().getEncoded();
- final byte keySalt[] = infoExpected.getHeader().getKeySalt();
+ final byte[] verifierSaltExpected = infoExpected.getVerifier().getSalt();
+ final byte[] verifierExpected = d.getVerifier();
+ final byte[] keySpec = d.getSecretKey().getEncoded();
+ final byte[] keySalt = infoExpected.getHeader().getKeySalt();
final EncryptionInfo infoActual = new EncryptionInfo(
@Test
public void getSignerUnsigned() throws Exception {
- String testFiles[] = {
- "hello-world-unsigned.docx",
- "hello-world-unsigned.pptx",
- "hello-world-unsigned.xlsx",
- "hello-world-office-2010-technical-preview-unsigned.docx"
+ String[] testFiles = {
+ "hello-world-unsigned.docx",
+ "hello-world-unsigned.pptx",
+ "hello-world-unsigned.xlsx",
+ "hello-world-office-2010-technical-preview-unsigned.docx"
};
for (String testFile : testFiles) {
@Test
public void getSigner() throws Exception {
- String testFiles[] = {
- "hyperlink-example-signed.docx",
- "hello-world-signed.docx",
- "hello-world-signed.pptx",
- "hello-world-signed.xlsx",
- "hello-world-office-2010-technical-preview.docx",
- "ms-office-2010-signed.docx",
- "ms-office-2010-signed.pptx",
- "ms-office-2010-signed.xlsx",
- "Office2010-SP1-XAdES-X-L.docx",
- "signed.docx",
+ String[] testFiles = {
+ "hyperlink-example-signed.docx",
+ "hello-world-signed.docx",
+ "hello-world-signed.pptx",
+ "hello-world-signed.xlsx",
+ "hello-world-office-2010-technical-preview.docx",
+ "ms-office-2010-signed.docx",
+ "ms-office-2010-signed.pptx",
+ "ms-office-2010-signed.xlsx",
+ "Office2010-SP1-XAdES-X-L.docx",
+ "signed.docx",
};
for (String testFile : testFiles) {
String certDigestXQuery = declareNS +
"$this//xades:SigningCertificate/xades:Cert/xades:CertDigest";
- XmlObject xoList[] = sigDoc.selectPath(certDigestXQuery);
+ XmlObject[] xoList = sigDoc.selectPath(certDigestXQuery);
assertEquals(xoList.length, 1);
DigestAlgAndValueType certDigest = (DigestAlgAndValueType) xoList[0];
assertNotNull(certDigest.getDigestValue());
is.close();
Key key = keystore.getKey("poitest", password.toCharArray());
- Certificate chainList[] = keystore.getCertificateChain("poitest");
+ Certificate[] chainList = keystore.getCertificateChain("poitest");
List<X509Certificate> certChain = new ArrayList<>();
for (Certificate c : chainList) {
certChain.add((X509Certificate)c);
signatureConfig.setKey(keyPair.getPrivate());
signatureConfig.setSigningCertificateChain(Collections.singletonList(x509));
- HashAlgorithm testAlgo[] = { HashAlgorithm.sha224, HashAlgorithm.sha256
- , HashAlgorithm.sha384, HashAlgorithm.sha512, HashAlgorithm.ripemd160 };
+ HashAlgorithm[] testAlgo = {HashAlgorithm.sha224, HashAlgorithm.sha256
+ , HashAlgorithm.sha384, HashAlgorithm.sha512, HashAlgorithm.ripemd160};
for (HashAlgorithm ha : testAlgo) {
OPCPackage pkg = null;
}
private void initKeyPair(String alias, String subjectDN, String pfxInput) throws Exception {
- final char password[] = "test".toCharArray();
+ final char[] password = "test".toCharArray();
File file = new File("build/test.pfx");
KeyStore keystore = KeyStore.getInstance("PKCS12");
"\u304C\u597D\u304D\u3067\u3001\u5C0F\u3055\u3044\u9803\u3001\u53E4\u4EE3\u751F\u7269\u306E\u56F3" +
"\u9451\u3092\u4E00\u7DD2\u306B\u898B\u3066\u305F\u306E\u601D\u3044\u51FA\u3059\u301C\u3068\u3044";
- private static final String INIT_FONTS[] = { "mona.ttf" };
+ private static final String[] INIT_FONTS = {"mona.ttf"};
// currently linux and mac return quite different values
private static final int[] expected_sizes = {
}
private void testTextDirection(SlideShow<?,?> ppt1) throws IOException {
-
- TextDirection tds[] = {
- TextDirection.HORIZONTAL,
- TextDirection.VERTICAL,
- TextDirection.VERTICAL_270,
- // TextDirection.STACKED is not supported on HSLF
+
+ TextDirection[] tds = {
+ TextDirection.HORIZONTAL,
+ TextDirection.VERTICAL,
+ TextDirection.VERTICAL_270,
+ // TextDirection.STACKED is not supported on HSLF
};
TableShape<?,?> tbl1 = ppt1.createSlide().createTable(1, 3);
@Test
public void tableSpan() throws IOException {
- String files[] = (xslfOnly()) ? new String[]{ "bug60993.pptx" } : new String[]{ "bug60993.pptx", "bug60993.ppt" };
+ String[] files = (xslfOnly()) ? new String[]{"bug60993.pptx"} : new String[]{"bug60993.pptx", "bug60993.ppt"};
for (String f : files) {
SlideShow<?,?> ppt = openSampleSlideshow(f);
Slide<?,?> slide = ppt.getSlides().get(0);
public static String md5hash(byte[] input) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
- byte hash[] = md.digest(input);
+ byte[] hash = md.digest(input);
return DatatypeConverter.printBase64Binary(hash);
} catch (NoSuchAlgorithmException e) {
// doesn't happen
static void validateEmbeddedObjects(Workbook wb) throws IOException {
boolean ooxml = wb.getClass().getName().toLowerCase(Locale.ROOT).contains("xssf");
- byte data[] = (ooxml) ? samplePPTX : samplePPT;
+ byte[] data = (ooxml) ? samplePPTX : samplePPT;
Iterator<Integer> shapeIds = Arrays.asList(1025,1026,2049).iterator();
EmbeddedExtractor ee = new EmbeddedExtractor();
for (Sheet sheet : wb) {
static void addEmbeddedObjects(Workbook wb) throws IOException {
boolean ooxml = wb.getClass().getName().toLowerCase(Locale.ROOT).contains("xssf");
int picIdx = wb.addPicture(samplePNG, Workbook.PICTURE_TYPE_PNG);
- byte data[] = (ooxml) ? samplePPTX : samplePPT;
+ byte[] data = (ooxml) ? samplePPTX : samplePPT;
String ext = (ooxml) ? ".pptx" : ".ppt";
int oleIdx1a = wb.addOlePackage(data, "dummy1a"+ext, "dummy1a"+ext, "dummy1a"+ext);
private static final int NUMBER_OF_TESTS = 200;
private volatile Throwable exception;
- private int executions[];
+ private int[] executions;
// the actual thread-safe temp-file strategy
private static TempFileCreationStrategy createTempFileCreationStrategy(File poiTempFileDirectory) {
@Test
public void bug60499() throws IOException, InvalidFormatException {
InputStream is = slTests.openResourceAsStream("bug60499.pptx");
- byte buf[] = IOUtils.toByteArray(is);
+ byte[] buf = IOUtils.toByteArray(is);
is.close();
PackagePartName ppn = PackagingURIHelper.createPartName("/ppt/media/image1.png");
assertTrue(actualStyle instanceof SolidPaint);
SolidPaint ps = (SolidPaint)actualStyle;
Color actual = DrawPaint.applyColorTransform(ps.getSolidColor());
- float expRGB[] = expected.getRGBComponents(null);
- float actRGB[] = actual.getRGBComponents(null);
+ float[] expRGB = expected.getRGBComponents(null);
+ float[] actRGB = actual.getRGBComponents(null);
assertArrayEquals(expRGB, actRGB, 0.0001f);
}
}
private void comparePoint(PathIterator pi, int type, double x0, double y0) {
- double points[] = new double[6];
+ double[] points = new double[6];
int piType = pi.currentSegment(points);
assertEquals(type, piType);
assertEquals(x0, points[0], 0);
@Test
public void testSlideLayoutNames() throws IOException {
- final String names[] = {
- "Blank", "Title Only", "Section Header", "Picture with Caption", "Title and Content"
- , "Title Slide", "Title and Vertical Text", "Vertical Title and Text", "Comparison"
- , "Two Content", "Content with Caption"
+ final String[] names = {
+ "Blank", "Title Only", "Section Header", "Picture with Caption", "Title and Content"
+ , "Title Slide", "Title and Vertical Text", "Vertical Title and Text", "Comparison"
+ , "Two Content", "Content with Caption"
};
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("layouts.pptx");
for (String name : names) {
assertNotNull(ppt.findLayout(name));
}
- final SlideLayout layTypes[] = {
- SlideLayout.BLANK, SlideLayout.TITLE_ONLY, SlideLayout.SECTION_HEADER
- , SlideLayout.PIC_TX, SlideLayout.TITLE_AND_CONTENT, SlideLayout.TITLE
- , SlideLayout.VERT_TX, SlideLayout.VERT_TITLE_AND_TX, SlideLayout.TWO_TX_TWO_OBJ
- , SlideLayout.TWO_OBJ, SlideLayout.OBJ_TX
+ final SlideLayout[] layTypes = {
+ SlideLayout.BLANK, SlideLayout.TITLE_ONLY, SlideLayout.SECTION_HEADER
+ , SlideLayout.PIC_TX, SlideLayout.TITLE_AND_CONTENT, SlideLayout.TITLE
+ , SlideLayout.VERT_TX, SlideLayout.VERT_TITLE_AND_TX, SlideLayout.TWO_TX_TWO_OBJ
+ , SlideLayout.TWO_OBJ, SlideLayout.OBJ_TX
};
for (SlideLayout sl : layTypes){
assertNotNull(ppt.getSlideMasters().get(0).getLayout(sl));
private final String testFileSimple = "Themes.xlsx";
private final String testFileComplex = "Themes2.xlsx";
// TODO .xls version available too, add HSSF support then check
-
+
// What colours they should show up as
- private static String rgbExpected[] = {
+ private static String[] rgbExpected = {
"ffffff", // Lt1
"000000", // Dk1
"eeece1", // Lt2
public void testZipBombNotTriggeredOnUselessContent() throws IOException {
SXSSFWorkbook swb = new SXSSFWorkbook(null, 1, true, true);
SXSSFSheet s = swb.createSheet();
- char useless[] = new char[32767];
+ char[] useless = new char[32767];
Arrays.fill(useless, ' ');
for (int row=0; row<1; row++) {
Row r = s.createRow(row);
for (int col=0; col<10; col++) {
- char prefix[] = Integer.toHexString(row*1000+col).toCharArray();
+ char[] prefix = Integer.toHexString(row * 1000 + col).toCharArray();
Arrays.fill(useless, 0, 10, ' ');
System.arraycopy(prefix, 0, useless, 0, prefix.length);
String ul = new String(useless);
private void verifyBug54084Unicode(Workbook wb) {
// expected data is stored in UTF-8 in a text-file
- byte data[] = HSSFTestDataSamples.getTestDataFileContent("54084 - Greek - beyond BMP.txt");
+ byte[] data = HSSFTestDataSamples.getTestDataFileContent("54084 - Greek - beyond BMP.txt");
String testData = new String(data, StandardCharsets.UTF_8).trim();
Sheet sheet = wb.getSheetAt(0);
ByteArrayOutputStream bos = new ByteArrayOutputStream(8096);
wb.write(bos);
- byte firstSave[] = bos.toByteArray();
+ byte[] firstSave = bos.toByteArray();
bos.reset();
wb.write(bos);
- byte secondSave[] = bos.toByteArray();
+ byte[] secondSave = bos.toByteArray();
/*OutputStream stream = new FileOutputStream("C:\\temp\\poi.xlsx");
try {
Pattern p = Pattern.compile("<br/>");
int count = 0;
for (XmlObject xo : vml.getItems()) {
- String split[] = p.split(xo.toString());
+ String[] split = p.split(xo.toString());
count += split.length-1;
}
assertEquals(16, count);
@Test
public void bug59058() throws IOException, XmlException {
- String files[] = { "bug57031.docx", "bug59058.docx" };
+ String[] files = {"bug57031.docx", "bug59058.docx"};
for (String f : files) {
ZipFile zf = new ZipFile(samples.getFile(f));
ZipArchiveEntry entry = zf.getEntry("word/document.xml");
dumpVal("First few bytes are", ds, indent+1);
if (stream instanceof PointerContainingStream) {
- Stream streams[] = ((PointerContainingStream)stream).getPointedToStreams();
+ Stream[] streams = ((PointerContainingStream) stream).getPointedToStreams();
dumpVal("Nbr of children", streams.length, indent+1);
for(Stream s : streams) {
}
}
if(stream instanceof ChunkStream) {
- Chunk chunks[] = ((ChunkStream)stream).getChunks();
+ Chunk[] chunks = ((ChunkStream) stream).getChunks();
dumpVal("Nbr of chunks", chunks.length, indent+1);
for(Chunk chunk : chunks) {
dumpVal("Length is", chunk._getContents().length, indent);
dumpVal("OD Size is", chunk.getOnDiskSize(), indent);
dumpVal("T / S is", chunk.getTrailer() + " / " + chunk.getSeparator(), indent);
- Command commands[] = chunk.getCommands();
+ Command[] commands = chunk.getCommands();
dumpVal("Nbr of commands", commands.length, indent);
for(Command command : commands) {
dumpVal(command.getDefinition().getName(), ""+command.getValue(), indent+1);
* The cubic Bezier curves SHOULD be drawn using the current pen.
*/
- Point2D pnt[] = { new Point2D.Double(), new Point2D.Double(), new Point2D.Double() };
+ Point2D[] pnt = {new Point2D.Double(), new Point2D.Double(), new Point2D.Double()};
int i=0;
if (hasStartPoint()) {
long size = readRectL(leis, bounds);
int count = (int)leis.readUInt();
size += LittleEndianConsts.INT_SIZE;
- Point2D points[] = new Point2D[count];
+ Point2D[] points = new Point2D[count];
for (int i=0; i<count; i++) {
points[i] = new Point2D.Double();
size += readPoint(leis, points[i]);
@Override
protected int readString(LittleEndianInputStream leis, StringBuilder sb, int limit) throws IOException {
sb.setLength(0);
- byte buf[] = new byte[limit*2];
+ byte[] buf = new byte[limit * 2];
leis.readFully(buf);
int b1, b2, readBytes = 0;
thisLen = len - offset;
}
- byte data[] = IOUtils.safelyAllocate(thisLen, MAX_RECORD_LENGTH);
+ byte[] data = IOUtils.safelyAllocate(thisLen, MAX_RECORD_LENGTH);
System.arraycopy(attr.getData(), offset, data, 0, thisLen);
System.out.print(
new DefaultEscherRecordFactory();
ArrayList<EscherRecord> ec = new ArrayList<>();
- byte data[] = getData();
+ byte[] data = getData();
int left = data.length;
while(left > 0) {
EscherRecord er = erf.createRecord(data, 0);
size += records[i].getRecordSize();
}
- byte data[] = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
+ byte[] data = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
size = 0;
for(int i=0; i<records.length; i++) {
int thisSize =
return data;
}
- protected final void setData(byte data[]) {
+ protected final void setData(byte[] data) {
this.data = data.clone();
}
// Now parse the first 512 bytes, and produce
// all our bits
- byte data[] = getData();
+ byte[] data = getData();
// Check first 8 bytes
String f8 = new String(data, 0, 8, LocaleUtil.CHARSET_1252);
*/
public String getBitType() { return bitType; }
public final byte[] getData() { return data; }
- protected final void setData(byte data[]) {
+ protected final void setData(byte[] data) {
this.data = data.clone();
}
return plcValB;
}
- final void setPreData(int preData[]) {
+ final void setPreData(int[] preData) {
this.preData = preData.clone();
}
super(thingType, bitType, data);
// Grab our 4x pre-data
- int preData[] = {
- LittleEndian.getUShort(data, 8+0),
- LittleEndian.getUShort(data, 8+2),
- LittleEndian.getUShort(data, 8+4),
- LittleEndian.getUShort(data, 8+6)
- };
+ int[] preData = {
+ LittleEndian.getUShort(data, 8 + 0),
+ LittleEndian.getUShort(data, 8 + 2),
+ LittleEndian.getUShort(data, 8 + 4),
+ LittleEndian.getUShort(data, 8 + 6)
+ };
setPreData(preData);
// And grab the 2 byte values
int cntPlcs = getNumberOfPLCs();
- long plcValA[] = new long[cntPlcs], plcValB[] = new long[cntPlcs];
- for(int i=0; i<cntPlcs; i++) {
+ long[] plcValA = new long[cntPlcs];
+ long[] plcValB = new long[cntPlcs];
+ for(int i=0; i<cntPlcs; i++) {
plcValA[i] = LittleEndian.getUShort(data, 16+(4*i));
plcValB[i] = LittleEndian.getUShort(data, 16+(4*i)+2);
}
super(thingType, bitType, data);
// Grab our 4x pre-data
- int preData[] = {
- LittleEndian.getUShort(data, 8+0),
- LittleEndian.getUShort(data, 8+2),
- LittleEndian.getUShort(data, 8+4),
- LittleEndian.getUShort(data, 8+6)
- };
+ int[] preData = {
+ LittleEndian.getUShort(data, 8 + 0),
+ LittleEndian.getUShort(data, 8 + 2),
+ LittleEndian.getUShort(data, 8 + 4),
+ LittleEndian.getUShort(data, 8 + 6)
+ };
setPreData(preData);
// And grab the 4 byte values
int cntPlcs = getNumberOfPLCs();
- long plcValA[] = new long[cntPlcs], plcValB[] = new long[cntPlcs];
- for(int i=0; i<cntPlcs; i++) {
+ long[] plcValA = new long[cntPlcs];
+ long[] plcValB = new long[cntPlcs];
+ for(int i=0; i<cntPlcs; i++) {
plcValA[i] = LittleEndian.getUInt(data, 16+(8*i));
plcValB[i] = LittleEndian.getUInt(data, 16+(8*i)+4);
}
super(thingType, bitType, data);
// Grab our 7x pre-data
- int preData[] = {
- LittleEndian.getUShort(data, 8+0),
- LittleEndian.getUShort(data, 8+2),
- LittleEndian.getUShort(data, 8+4),
- LittleEndian.getUShort(data, 8+6),
- LittleEndian.getUShort(data, 8+8),
- LittleEndian.getUShort(data, 8+10),
- LittleEndian.getUShort(data, 8+12)
- };
+ int[] preData = {
+ LittleEndian.getUShort(data, 8 + 0),
+ LittleEndian.getUShort(data, 8 + 2),
+ LittleEndian.getUShort(data, 8 + 4),
+ LittleEndian.getUShort(data, 8 + 6),
+ LittleEndian.getUShort(data, 8 + 8),
+ LittleEndian.getUShort(data, 8 + 10),
+ LittleEndian.getUShort(data, 8 + 12)
+ };
setPreData(preData);
// And grab the 4 byte values
int cntPlcs = getNumberOfPLCs();
- long plcValA[] = new long[cntPlcs], plcValB[] = new long[cntPlcs];
- for(int i=0; i<cntPlcs; i++) {
+ long[] plcValA = new long[cntPlcs];
+ long[] plcValB = new long[cntPlcs];
+ for(int i=0; i<cntPlcs; i++) {
plcValA[i] = LittleEndian.getUInt(data, 22+(8*i));
plcValB[i] = LittleEndian.getUInt(data, 22+(8*i)+4);
}
// We have 4 bytes, then the start point of each
// hyperlink, then the end point of the text.
- int preData[] = new int[1+cntPlcs+1];
+ int[] preData = new int[1 + cntPlcs + 1];
for(int i=0; i<preData.length; i++) {
preData[i] = (int)LittleEndian.getUInt(data, 8+(i*4));
}
until = twoStartsAt + (cntPlcs-2)*threePlusIncrement;
}
- long plcValA[] = new long[(until-at)/2];
- long plcValB[] = new long[0];
+ long[] plcValA = new long[(until - at) / 2];
+ long[] plcValB = new long[0];
for(int i=0; i<plcValA.length; i++) {
plcValA[i] = LittleEndian.getUShort(data, at+(i*2));
}
}
public void setText(String text) {
- byte data[] = IOUtils.safelyAllocate(text.length()*2, MAX_RECORD_LENGTH);
+ byte[] data = IOUtils.safelyAllocate(text.length() * 2, MAX_RECORD_LENGTH);
StringUtil.putUnicodeLE(text, data, 0);
setData(data);
}
if(nl && length > 0)out.write(CR);
}
- private static final byte hexval[] =
- {(byte) '0', (byte) '1', (byte) '2', (byte) '3',
- (byte) '4', (byte) '5', (byte) '6', (byte) '7',
- (byte) '8', (byte) '9', (byte) 'A', (byte) 'B',
- (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F'};
+ private static final byte[] hexval =
+ {(byte) '0', (byte) '1', (byte) '2', (byte) '3',
+ (byte) '4', (byte) '5', (byte) '6', (byte) '7',
+ (byte) '8', (byte) '9', (byte) 'A', (byte) 'B',
+ (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F'};
}
* right now this function takes one parameter: a ppt file, and outputs
* a dump of what it contains
*/
- public static void main(String args[]) throws IOException
+ public static void main(String[] args) throws IOException
{
if(args.length == 0) {
System.err.println("Useage: SlideShowDumper [-escher|-basicescher] <filename>");
* right now this function takes one parameter: a ppt file, and outputs a
* dump of what it contains
*/
- public static void main(String args[]) throws IOException {
+ public static void main(String[] args) throws IOException {
String filename = "";
boolean verbose = false;
boolean escher = false;
* Utility to extract pictures from a PowerPoint file.
*/
public final class ImageExtractor {
- public static void main(String args[]) throws IOException {
+ public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.err.println("Usage:");
System.err.println("\tImageExtractor <file>");
/**
* Basic extractor. Returns all the text, and optionally all the notes
*/
- public static void main(String args[]) throws IOException {
+ public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.err.println("Useage:");
System.err.println("\tPowerPointExtractor [-notes] <file>");
* Really basic text extractor, that will also return lots of crud text.
* Takes a single argument, the file to extract from
*/
- public static void main(String args[]) throws IOException
+ public static void main(String[] args) throws IOException
{
if(args.length < 1) {
System.err.println("Useage:");
*/
@SuppressWarnings("unchecked")
public T getShape() {
- byte metroBytes[] = getMetroBytes();
+ byte[] metroBytes = getMetroBytes();
if (metroBytes == null) {
return null;
}
* @param data the data stream
* @param offset the offset within the data
*/
- public void parseProperty(byte data[], int offset) {
+ public void parseProperty(byte[] data, int offset) {
tabStops.addAll(readTabStops(new LittleEndianByteArrayInputStream(data, offset)));
}
public void writeOut(OutputStream out) throws IOException {
// Data
- byte data[] = new byte[1024];
+ byte[] data = new byte[1024];
LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(data, 0);
bos.writeShort(ei.getVersionMajor());
bos.writeShort(ei.getVersionMinor());
@Override
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
int bytesRemaining = readHeader( data, offset );
- byte remainingData[] = IOUtils.safelyAllocate(bytesRemaining, MAX_RECORD_LENGTH);
+ byte[] remainingData = IOUtils.safelyAllocate(bytesRemaining, MAX_RECORD_LENGTH);
System.arraycopy(data, offset+8, remainingData, 0, bytesRemaining);
setRemainingData(remainingData);
return bytesRemaining + 8;
LittleEndian.putShort(data, offset, getOptions());
LittleEndian.putShort(data, offset+2, getRecordId());
-
- byte childBytes[] = getRemainingData();
+
+ byte[] childBytes = getRemainingData();
LittleEndian.putInt(data, offset+4, childBytes.length);
System.arraycopy(childBytes, 0, data, offset+8, childBytes.length);
@SuppressWarnings("resource")
BufAccessBAOS bos = new BufAccessBAOS(); // NOSONAR
- byte intbuf[] = new byte[4];
+ byte[] intbuf = new byte[4];
int lastPersistEntry = -1;
int lastSlideId = -1;
for (Entry<Integer,Integer> me : orderedSlideLocations.entrySet()) {
out.write(_header);
writeLittleEndian(_slideTime, out);
writeLittleEndian(_soundIdRef, out);
-
- byte byteBuf[] = new byte[LittleEndianConsts.BYTE_SIZE];
+
+ byte[] byteBuf = new byte[LittleEndianConsts.BYTE_SIZE];
LittleEndian.putUByte(byteBuf, 0, _effectDirection);
out.write(byteBuf);
LittleEndian.putUByte(byteBuf, 0, _effectType);
}
out.append(" original byte stream \n");
-
- byte buf[] = IOUtils.safelyAllocate(rawContents.length+reserved.length, MAX_RECORD_LENGTH);
+
+ byte[] buf = IOUtils.safelyAllocate(rawContents.length + reserved.length, MAX_RECORD_LENGTH);
System.arraycopy(rawContents, 0, buf, 0, rawContents.length);
System.arraycopy(reserved, 0, buf, rawContents.length, reserved.length);
out.append( HexDump.dump(buf, 0, 0) );
assert(size > 0);
int covered = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- TextSpecInfoRun runs[] = getTextSpecInfoRuns();
+ TextSpecInfoRun[] runs = getTextSpecInfoRuns();
assert(runs.length > 0);
for (int i=0; i<runs.length && covered < size; i++) {
TextSpecInfoRun run = runs[i];
* @throws java.io.IOException if an error occurs.
*/
public void writeOut(OutputStream out) throws IOException {
- final byte buf[] = new byte[4];
+ final byte[] buf = new byte[4];
LittleEndian.putInt(buf, 0, length);
out.write(buf);
LittleEndian.putInt(buf, 0, mask);
out.write(buf);
- Object flds[] = {
- spellFld, spellInfo, "spell info",
- langFld, langId, "lang id",
- altLangFld, altLangId, "alt lang id",
- bidiFld, bidi, "bidi",
- pp10extFld, pp10extMask, "pp10 extension field",
- smartTagFld, smartTagsBytes, "smart tags"
+ Object[] flds = {
+ spellFld, spellInfo, "spell info",
+ langFld, langId, "lang id",
+ altLangFld, altLangId, "alt lang id",
+ bidiFld, bidi, "bidi",
+ pp10extFld, pp10extMask, "pp10 extension field",
+ smartTagFld, smartTagsBytes, "smart tags"
};
for (int i=0; i<flds.length-1; i+=3) {
if (!fld.isSet(mask)) continue;
boolean valid;
if (valO instanceof byte[]) {
- byte bufB[] = (byte[])valO;
+ byte[] bufB = (byte[]) valO;
valid = bufB.length > 0;
out.write(bufB);
} else if (valO instanceof Integer) {
boolean fSystemRGB = ecr.hasSystemRGBFlag();
boolean fSchemeIndex = ecr.hasSchemeIndexFlag();
boolean fSysIndex = ecr.hasSysIndexFlag();
-
- int rgb[] = ecr.getRGB();
+
+ int[] rgb = ecr.getRGB();
HSLFSheet sheet = getSheet();
if (fSchemeIndex && sheet != null) {
ExEmbed exEmbed = new ExEmbed();
// remove unneccessary infos, so we don't need to specify the type
// of the ole object multiple times
- Record children[] = exEmbed.getChildRecords();
+ Record[] children = exEmbed.getChildRecords();
exEmbed.removeChild(children[2]);
exEmbed.removeChild(children[3]);
exEmbed.removeChild(children[4]);
private static final BitField fieldRecInst = new BitField(0xFFF0);
- private static final int BLIB_STORE_ENTRY_PARTS[] = {
- 1, // btWin32
- 1, // btMacOS
- 16, // rgbUid
- 2, // tag
- 4, // size
- 4, // cRef
- 4, // foDelay
- 1, // unused1
- 1, // cbName (@ index 33)
- 1, // unused2
- 1, // unused3
+ private static final int[] BLIB_STORE_ENTRY_PARTS = {
+ 1, // btWin32
+ 1, // btMacOS
+ 16, // rgbUid
+ 2, // tag
+ 4, // size
+ 4, // cRef
+ 4, // foDelay
+ 1, // unused1
+ 1, // cbName (@ index 33)
+ 1, // unused2
+ 1, // unused3
};
protected HSLFSlideShowEncrypted(DocumentEncryptionAtom dea) {
}
}
- protected Record[] updateEncryptionRecord(Record records[]) {
+ protected Record[] updateEncryptionRecord(Record[] records) {
String password = Biff8EncryptionKey.getCurrentUserPassword();
if (password == null) {
if (dea == null) {
dea = new DocumentEncryptionAtom();
}
EncryptionInfo ei = dea.getEncryptionInfo();
- byte salt[] = ei.getVerifier().getSalt();
+ byte[] salt = ei.getVerifier().getSalt();
Encryptor enc = getEncryptionInfo().getEncryptor();
if (salt == null) {
enc.confirmPassword(password);
} else {
- byte verifier[] = ei.getDecryptor().getVerifier();
+ byte[] verifier = ei.getDecryptor().getVerifier();
enc.confirmPassword(password, null, null, verifier, salt, null);
}
* Before this method is called, make sure that the offsets are correct,
* i.e. call {@link HSLFSlideShowImpl#updateAndWriteDependantRecords(OutputStream, Map)}
*/
- protected static Record[] normalizeRecords(Record records[]) {
+ protected static Record[] normalizeRecords(Record[] records) {
// http://msdn.microsoft.com/en-us/library/office/gg615594(v=office.14).aspx
// repeated slideIds can be overwritten, i.e. ignored
}
- protected static Record[] removeEncryptionRecord(Record records[]) {
+ protected static Record[] removeEncryptionRecord(Record[] records) {
int deaSlideId = -1;
int deaOffset = -1;
PersistPtrHolder ptr = null;
}
- protected static Record[] addEncryptionRecord(Record records[], DocumentEncryptionAtom dea) {
+ protected static Record[] addEncryptionRecord(Record[] records, DocumentEncryptionAtom dea) {
assert(dea != null);
int ueaIdx = -1, ptrIdx = -1, deaIdx = -1, idx = -1;
for (Record r : records) {
uea.setEncryptSessionPersistIdRef(nextSlideId);
uea.setMaxPersistWritten(nextSlideId);
- Record newRecords[] = new Record[records.length+1];
+ Record[] newRecords = new Record[records.length + 1];
if (ptrIdx > 0) {
System.arraycopy(records, 0, newRecords, 0, ptrIdx);
}
super.afterInsert(sh);
Set<HSLFLine> lineSet = new HashSet<>();
- for (HSLFTableCell row[] : cells) {
+ for (HSLFTableCell[] row : cells) {
for (HSLFTableCell c : row) {
addShape(c);
for (HSLFLine bt : new HSLFLine[]{ c.borderTop, c.borderRight, c.borderBottom, c.borderLeft }) {
if (cells == null) {
initTable();
} else {
- for (HSLFTableCell cols[] : cells) {
+ for (HSLFTableCell[] cols : cells) {
for (HSLFTableCell col : cols) {
col.setSheet(sheet);
}
}
double currentWidth = cells[0][col].getAnchor().getWidth();
double dx = width - currentWidth;
- for (HSLFTableCell cols[] : cells) {
+ for (HSLFTableCell[] cols : cells) {
Rectangle2D anchor = cols[col].getAnchor();
anchor.setRect(anchor.getX(), anchor.getY(), width, anchor.getHeight());
cols[col].setAnchor(anchor);
* @return text run records
*/
public Record[] getRecords() {
- Record r[] = _headerAtom.getParentRecord().getChildRecords();
+ Record[] r = _headerAtom.getParentRecord().getChildRecords();
return getRecords(r, new int[] { 0 }, _headerAtom);
}
}
}
- Record result[] = new Record[length];
+ Record[] result = new Record[length];
System.arraycopy(records, startIdx[0], result, 0, length);
startIdx[0] += length;
* are queried
*/
protected <T extends TextProp> T getPropVal(TextPropCollection props, String propName) {
- String propNames[] = propName.split(",");
+ String[] propNames = propName.split(",");
for (String pn : propNames) {
T prop = props.findByName(pn);
if (isValidProp(prop)) {
}
}
- final String propNames[] = propName.split(",");
+ final String[] propNames = propName.split(",");
final HSLFSheet sheet = getSheet();
final int txtype = getRunType();
final HSLFMasterSheet master;
if (sheet != null) {
PPDrawing drawing = sheet.getPPDrawing();
if (drawing != null) {
- EscherTextboxWrapper wrappers[] = drawing.getTextboxWrappers();
+ EscherTextboxWrapper[] wrappers = drawing.getTextboxWrappers();
if (wrappers != null) {
for (EscherTextboxWrapper w : wrappers) {
// check for object identity
int cap = ps.getLineCap().awtFlag;
int join = ps.getLineJoin().awtFlag;
float miterLimit = (float)getProperties().getPenMiterLimit();
- float dashes[] = ps.getLineDashes();
+ float[] dashes = ps.getLineDashes();
boolean dashAlt = ps.isAlternateDash();
// This value is not an integer index into the dash pattern array.
// Instead, it is a floating-point value that specifies a linear distance.
private long headerColorUsed = -1;
@SuppressWarnings("unused")
private long headerColorImportant = -1;
- private Color colorTable[];
+ private Color[] colorTable;
@SuppressWarnings("unused")
private int colorMaskR,colorMaskG,colorMaskB;
// size of header and color table, for start of image data calculation
private int introSize;
- private byte imageData[];
+ private byte[] imageData;
public int init(LittleEndianInputStream leis, int recordSize) throws IOException {
leis.mark(10000);
int imageSize = (int)Math.max(imageData.length, introSize+headerImageSize);
// create the image data and leave the parsing to the ImageIO api
- byte buf[] = IOUtils.safelyAllocate(BMP_HEADER_SIZE+imageSize, MAX_RECORD_LENGTH);
+ byte[] buf = IOUtils.safelyAllocate(BMP_HEADER_SIZE + imageSize, MAX_RECORD_LENGTH);
// https://en.wikipedia.org/wiki/BMP_file_format # Bitmap file header
buf[0] = (byte)'B';
/**
* An array of bytes of size ByteCount.
*/
- private byte escapeData[];
+ private byte[] escapeData;
@Override
public HwmfRecordType getWmfRecordType() {
}
protected int readString(LittleEndianInputStream leis, StringBuilder sb, int limit) throws IOException {
- byte buf[] = new byte[limit], b, readBytes = 0;
+ byte[] buf = new byte[limit];
+ byte b;
+ byte readBytes = 0;
do {
if (readBytes == limit) {
return -1;
}
public String describeCmd() {
- String stack[] = new String[10];
+ String[] stack = new String[10];
int stackPnt = 0;
for (char c : opCmd.toCharArray()) {
*/
protected byte[] rawTextBytes;
/**
- * An optional array of 16-bit signed integers that indicate the distance between
- * origins of adjacent character cells. For example, Dx[i] logical units separate the origins of
- * character cell i and character cell i + 1. If this field is present, there MUST be the same
+ * An optional array of 16-bit signed integers that indicate the distance between
+ * origins of adjacent character cells. For example, Dx[i] logical units separate the origins of
+ * character cell i and character cell i + 1. If this field is present, there MUST be the same
* number of values as there are characters in the string.
*/
protected final List<Integer> dx = new ArrayList<>();
* The META_SETTEXTALIGN record defines text-alignment values in the playback device context.
*/
public static class WmfSetTextAlign implements HwmfRecord {
-
+
/**
* The drawing position in the playback device context MUST be updated after each text
* output call. It MUST be used as the reference point.<p>
* A 16-bit unsigned integer that defines the horizontal (x-axis) coordinate,
* in logical units, of the left endpoint of the scanline.
*/
- private int left_scanline[];
+ private int[] left_scanline;
/**
* A 16-bit unsigned integer that defines the horizontal (x-axis) coordinate,
* in logical units, of the right endpoint of the scanline.
*/
- private int right_scanline[];
+ private int[] right_scanline;
/**
* A 16-bit unsigned integer that MUST be the same as the value of the Count
* field; it is present to allow upward travel in the structure.
/**
* An array of Scan objects that define the scanlines in the region.
*/
- private WmfScanObject scanObjects[];
+ private WmfScanObject[] scanObjects;
@Override
public HwmfRecordType getWmfRecordType() {
updateEncryptionInfo();
EncryptionInfo ei = getEncryptionInfo();
if (ei != null) {
- byte buf[] = new byte[1000];
+ byte[] buf = new byte[1000];
LittleEndianByteArrayOutputStream leos = new LittleEndianByteArrayOutputStream(buf, 0);
leos.writeShort(ei.getVersionMajor());
leos.writeShort(ei.getVersionMinor());
fBase.setFObfuscated(false);
}
Encryptor enc = _encryptionInfo.getEncryptor();
- byte salt[] = _encryptionInfo.getVerifier().getSalt();
+ byte[] salt = _encryptionInfo.getVerifier().getSalt();
if (salt == null) {
enc.confirmPassword(password);
} else {
- byte verifier[] = _encryptionInfo.getDecryptor().getVerifier();
+ byte[] verifier = _encryptionInfo.getDecryptor().getVerifier();
enc.confirmPassword(password, null, null, verifier, salt, null);
}
}
is = dec.getDataStream(dis, streamSize, 0);
if (encryptionOffset > 0) {
ChunkedCipherInputStream cis = (ChunkedCipherInputStream)is;
- byte plain[] = IOUtils.safelyAllocate(encryptionOffset, MAX_RECORD_LENGTH);
+ byte[] plain = IOUtils.safelyAllocate(encryptionOffset, MAX_RECORD_LENGTH);
cis.readPlain(plain, 0, encryptionOffset);
bos.write(plain);
}
int num = number;
final int radix = 26;
- char buf[] = new char[33];
+ char[] buf = new char[33];
int charPos = buf.length;
while (num > 0) {
return LittleEndian.getInt( codeBytes, 0 );
case 7:
- byte threeByteInt[] = new byte[4];
+ byte[] threeByteInt = new byte[4];
threeByteInt[0] = _grpprl[_gOffset];
threeByteInt[1] = _grpprl[_gOffset + 1];
threeByteInt[2] = _grpprl[_gOffset + 2];
// Placeholder EMFs for clients that don't support the OLE components.
List<HSLFPictureData> pictures = slideShow.getPictureData();
assertEquals("Should be two pictures", 2, pictures.size());
-
- long checkSums[] = { 0xD37A4204l, 0x26A62F68l, 0x82853169l, 0xE0E45D2Bl };
+
+ long[] checkSums = {0xD37A4204l, 0x26A62F68l, 0x82853169l, 0xE0E45D2Bl};
int checkId = 0;
// check for checksum to be uptodate
ppt = new HSLFSlideShow(new ByteArrayInputStream(bos.toByteArray()));
HSLFObjectShape comp = (HSLFObjectShape)ppt.getSlides().get(0).getShapes().get(0);
- byte compData[] = IOUtils.toByteArray(comp.getObjectData().getInputStream());
+ byte[] compData = IOUtils.toByteArray(comp.getObjectData().getInputStream());
bos.reset();
poiData1.writeFilesystem(bos);
- byte expData[] = bos.toByteArray();
+ byte[] expData = bos.toByteArray();
assertArrayEquals(expData, compData);
assertEquals(true, rt.isUnderlined());
assertEquals("Arial", rt.getFontFamily());
} else if (tpara.getRunType() == TextHeaderAtom.BODY_TYPE){
- int indents[] = { 32, 28, 24 };
+ int[] indents = {32, 28, 24};
for (HSLFTextRun rt : tpara.getTextRuns()) {
int indent = tpara.getIndentLevel();
assertEquals(indents[indent], rt.getFontSize(), 0);
@Test
public void cryptoAPIDecryptionOther() throws Exception {
- String encPpts[] = {
- "Password_Protected-56-hello.ppt",
- "Password_Protected-hello.ppt",
- "Password_Protected-np-hello.ppt",
+ String[] encPpts = {
+ "Password_Protected-56-hello.ppt",
+ "Password_Protected-hello.ppt",
+ "Password_Protected-np-hello.ppt",
};
Biff8EncryptionKey.setCurrentUserPassword("hello");
String rawText = HSLFTextParagraph.getRawText(slide.getTextParagraphs().get(0));
assertEquals("Dominic Salemno", rawText);
- String picCmp[][] = {
+ String[][] picCmp = {
{"0", "nKsDTKqxTCR8LFkVVWlP9GSTvZ0="},
{"95163", "SuNOR+9V1UVYZIoeD65l3VTaLoc="},
{"100864", "Ql3IGrr4bNq07ZTp5iPg7b+pva8="},
List<HSLFPictureData> pd = ss.getSlideShowImpl().getPictureData();
int i = 0;
for (HSLFPictureData p : pd) {
- byte hash[] = md.digest(p.getData());
+ byte[] hash = md.digest(p.getData());
assertEquals(Integer.parseInt(picCmp[i][0]), p.getOffset());
assertEquals(picCmp[i][1], Base64.encodeBase64String(hash));
i++;
@Test
public void testLoadWriteC() {
// BitMaskTextProperties will sanitize the output
- byte expected[] = data_c.clone();
+ byte[] expected = data_c.clone();
expected[56] = 0;
expected[68] = 0;
doReadWrite(data_c, expected, data_c_text_len);
HSLFAutoShape as = (HSLFAutoShape)ppt.getSlides().get(0).getShapes().get(0);
AbstractEscherOptRecord opt = as.getEscherOptRecord();
EscherArrayProperty ep = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__SHADECOLORS);
- double exp[][] = {
- // r, g, b, position
- { 94, 158, 255, 0 },
- { 133, 194, 255, 0.399994 },
- { 196, 214, 235, 0.699997 },
- { 255, 235, 250, 1 }
+ double[][] exp = {
+ // r, g, b, position
+ {94, 158, 255, 0},
+ {133, 194, 255, 0.399994},
+ {196, 214, 235, 0.699997},
+ {255, 235, 250, 1}
};
int i = 0;
- for (byte data[] : ep) {
+ for (byte[] data : ep) {
EscherColorRef ecr = new EscherColorRef(data, 0, 4);
- int rgb[] = ecr.getRGB();
+ int[] rgb = ecr.getRGB();
double pos = Units.fixedPointToDouble(LittleEndian.getInt(data, 4));
assertEquals((int)exp[i][0], rgb[0]);
assertEquals((int)exp[i][1], rgb[1]);
@Test
public void bug58718() throws IOException {
- String files[] = { "bug58718_008524.ppt","bug58718_008558.ppt","bug58718_349008.ppt","bug58718_008495.ppt", };
+ String[] files = {"bug58718_008524.ppt", "bug58718_008558.ppt", "bug58718_349008.ppt", "bug58718_008495.ppt",};
for (String f : files) {
File sample = HSLFTestDataSamples.getSampleFile(f);
try (SlideShowExtractor ex = new SlideShowExtractor(SlideShowFactory.create(sample))) {
@Override
public void write(int b) throws IOException {}
};
-
- final boolean found[] = { false };
+
+ final boolean[] found = {false};
DummyGraphics2d dgfx = new DummyGraphics2d(new PrintStream(nullOutput)){
@Override
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
public void bug55902mixedFontWithChineseCharacters() throws IOException, FontFormatException {
// font files need to be downloaded first via
// ant test-scratchpad-download-resources
- String fontFiles[][] = {
- // Calibri is not available on *nix systems, so we need to use another similar free font
- { "build/scratchpad-test-resources/Cabin-Regular.ttf", "mapped", "Calibri" },
+ String[][] fontFiles = {
+ // Calibri is not available on *nix systems, so we need to use another similar free font
+ {"build/scratchpad-test-resources/Cabin-Regular.ttf", "mapped", "Calibri"},
- // use "MS PGothic" if available (Windows only) ...
- // for the junit test not all chars are rendered
- { "build/scratchpad-test-resources/mona.ttf", "fallback", "Cabin" }
+ // use "MS PGothic" if available (Windows only) ...
+ // for the junit test not all chars are rendered
+ {"build/scratchpad-test-resources/mona.ttf", "fallback", "Cabin"}
};
// setup fonts (especially needed, when run under *nix systems)
Map<String,String> fontMap = new HashMap<>();
Map<String,String> fallbackMap = new HashMap<>();
- for (String fontFile[] : fontFiles) {
+ for (String[] fontFile : fontFiles) {
File f = new File(fontFile[0]);
assumeTrue("necessary font file "+f.getName()+" not downloaded.", f.exists());
@Ignore("Just for visual validation - antialiasing is different on various systems")
public void bug54541()
throws IOException, ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
- String files[] = {
+ String[] files = {
// "sample_pptx_grouping_issues.pptx",
// "54542_cropped_bitmap.pptx",
// "54541_cropped_bitmap.ppt",
// "54541_cropped_bitmap2.ppt",
- "alterman_security.ppt",
+ "alterman_security.ppt",
// "alterman_security3.pptx",
};
assertEquals("sdfsdfsdf", rt.get(0).getRawText());
textParas = textParass.get(1);
- String texts[] = {"Sdfsdfsdf\r","Dfgdfg\r","Dfgdfgdfg\r","Sdfsdfs\r","Sdfsdf\r"};
- int indents[] = {0,0,0,1,1};
+ String[] texts = {"Sdfsdfsdf\r", "Dfgdfg\r", "Dfgdfgdfg\r", "Sdfsdfs\r", "Sdfsdf\r"};
+ int[] indents = {0, 0, 0, 1, 1};
int i=0;
for (HSLFTextParagraph p : textParas) {
assertEquals(texts[i], p.getTextRuns().get(0).getRawText());
HSLFSlideShow ppt = HSLFTestDataSamples.getSlideShow("52244.ppt");
HSLFSlide slide = ppt.getSlides().get(0);
- int sizes[] = { 36, 24, 12, 32, 12, 12 };
+ int[] sizes = {36, 24, 12, 32, 12, 12};
int i=0;
for (List<HSLFTextParagraph> textParas : slide.getTextParagraphs()) {
if (pd.getType() != PictureType.WMF) {
continue;
}
- byte wmfData[] = pd.getData();
+ byte[] wmfData = pd.getData();
String filename = String.format(Locale.ROOT, "%s-%04d.wmf", basename, wmfIdx);
FileOutputStream fos = new FileOutputStream(new File(outdir, filename));
fos.write(wmfData);
File outdir = new File("build/wmf");
outdir.mkdirs();
final String startFile = "";
- File files[] = indir.listFiles(new FileFilter() {
+ File[] files = indir.listFiles(new FileFilter() {
boolean foundStartFile;
+
@Override
public boolean accept(File pathname) {
foundStartFile |= startFile.isEmpty() || pathname.getName().contains(startFile);
*/
public class TestFieldsTables extends HWPFTestCase {
- private static final String EXPECTED[] = {
- "[19, 43) - FLD - 0x13; 0x1f\n" + "[43, 54) - FLD - 0x14; 0xff\n"
- + "[54, 59) - FLD - 0x15; 0x81\n",
+ private static final String[] EXPECTED = {
+ "[19, 43) - FLD - 0x13; 0x1f\n" + "[43, 54) - FLD - 0x14; 0xff\n"
+ + "[54, 59) - FLD - 0x15; 0x81\n",
- "[31, 59) - FLD - 0x13; 0x45\n" + "[59, 61) - FLD - 0x14; 0xff\n"
- + "[61, 66) - FLD - 0x15; 0x80\n",
+ "[31, 59) - FLD - 0x13; 0x45\n" + "[59, 61) - FLD - 0x14; 0xff\n"
+ + "[61, 66) - FLD - 0x15; 0x80\n",
- "[23, 49) - FLD - 0x13; 0x11\n" + "[49, 64) - FLD - 0x14; 0xff\n"
- + "[64, 69) - FLD - 0x15; 0x80\n",
+ "[23, 49) - FLD - 0x13; 0x11\n" + "[49, 64) - FLD - 0x14; 0xff\n"
+ + "[64, 69) - FLD - 0x15; 0x80\n",
- "[18, 42) - FLD - 0x13; 0x21\n" + "[42, 44) - FLD - 0x14; 0xff\n"
- + "[44, 47) - FLD - 0x15; 0x81\n"
- + "[47, 75) - FLD - 0x13; 0x1d\n"
- + "[75, 85) - FLD - 0x14; 0xff\n"
- + "[85, 91) - FLD - 0x15; 0x81\n",
+ "[18, 42) - FLD - 0x13; 0x21\n" + "[42, 44) - FLD - 0x14; 0xff\n"
+ + "[44, 47) - FLD - 0x15; 0x81\n"
+ + "[47, 75) - FLD - 0x13; 0x1d\n"
+ + "[75, 85) - FLD - 0x14; 0xff\n"
+ + "[85, 91) - FLD - 0x15; 0x81\n",
- "[30, 54) - FLD - 0x13; 0x20\n" + "[54, 62) - FLD - 0x14; 0xff\n"
- + "[62, 68) - FLD - 0x15; 0x81\n",
+ "[30, 54) - FLD - 0x13; 0x20\n" + "[54, 62) - FLD - 0x14; 0xff\n"
+ + "[62, 68) - FLD - 0x15; 0x81\n",
- "[1, 31) - FLD - 0x13; 0x15\n" + "[31, 51) - FLD - 0x14; 0xff\n"
- + "[51, 541) - FLD - 0x15; 0x81\n",
+ "[1, 31) - FLD - 0x13; 0x15\n" + "[31, 51) - FLD - 0x14; 0xff\n"
+ + "[51, 541) - FLD - 0x15; 0x81\n",
- "[19, 47) - FLD - 0x13; 0x19\n" + "[47, 49) - FLD - 0x14; 0xff\n"
- + "[49, 55) - FLD - 0x15; 0x81\n"
+ "[19, 47) - FLD - 0x13; 0x19\n" + "[47, 49) - FLD - 0x14; 0xff\n"
+ + "[49, 55) - FLD - 0x15; 0x81\n"
};
@Override
public void newNumberTypes() throws Exception {
ClipboardData cd = new ClipboardData();
cd.setValue(new byte[10]);
-
- Object exp[][] = {
- { Variant.VT_CF, cd.toByteArray() },
- { Variant.VT_BOOL, true },
- { Variant.VT_LPSTR, "codepagestring" },
- { Variant.VT_LPWSTR, "widestring" },
- { Variant.VT_I2, -1 }, // int, not short ... :(
- { Variant.VT_UI2, 0xFFFF },
- { Variant.VT_I4, -1 },
- { Variant.VT_UI4, 0xFFFFFFFFL },
- { Variant.VT_I8, -1L },
- { Variant.VT_UI8, BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TEN) },
- { Variant.VT_R4, -999.99f },
- { Variant.VT_R8, -999.99d },
+
+ Object[][] exp = {
+ {Variant.VT_CF, cd.toByteArray()},
+ {Variant.VT_BOOL, true},
+ {Variant.VT_LPSTR, "codepagestring"},
+ {Variant.VT_LPWSTR, "widestring"},
+ {Variant.VT_I2, -1}, // int, not short ... :(
+ {Variant.VT_UI2, 0xFFFF},
+ {Variant.VT_I4, -1},
+ {Variant.VT_UI4, 0xFFFFFFFFL},
+ {Variant.VT_I8, -1L},
+ {Variant.VT_UI8, BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TEN)},
+ {Variant.VT_R4, -999.99f},
+ {Variant.VT_R8, -999.99d},
};
HSSFWorkbook wb = new HSSFWorkbook();
POIFSFileSystem poifs = new POIFSFileSystem();
DocumentSummaryInformation dsi = PropertySetFactory.newDocumentSummaryInformation();
CustomProperties cpList = new CustomProperties();
- for (Object o[] : exp) {
+ for (Object[] o : exp) {
int type = (Integer)o[0];
Property p = new Property(PropertyIDMap.PID_MAX+type, type, o[1]);
cpList.put("testprop"+type, new CustomProperty(p, "testprop"+type));
dsi = (DocumentSummaryInformation)PropertySetFactory.create(poifs.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME);
cpList = dsi.getCustomProperties();
int i=0;
- for (Object o[] : exp) {
+ for (Object[] o : exp) {
Object obj = cpList.get("testprop"+o[0]);
if (o[1] instanceof byte[]) {
assertArrayEquals("property "+i, (byte[])o[1], (byte[])obj);
@Test
public void extRstEqualsAndHashCode() {
- byte buf[] = new byte[200];
+ byte[] buf = new byte[200];
LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0);
String str = "\u1d02\u1d12\u1d22";
bos.writeShort(1);
public void testOlderFormat_bug46918() {
// There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918
// They all had the following hex encoding:
- byte data[] = HexRead.readFromString("00 01 0A 00 1E 14 00 0A FF FF FF FF 00 00");
+ byte[] data = HexRead.readFromString("00 01 0A 00 1E 14 00 0A FF FF FF FF 00 00");
RecordInputStream in = TestcaseRecordInputStream.create(data);
ExtendedPivotTableViewFieldsRecord rec;
throw e;
}
- byte expReserData[] = HexRead.readFromString("1E 14 00 0A FF FF FF FF 00 00" +
- "FF FF 00 00 00 00 00 00 00 00");
+ byte[] expReserData = HexRead.readFromString("1E 14 00 0A FF FF FF FF 00 00" +
+ "FF FF 00 00 00 00 00 00 00 00");
TestcaseRecordInputStream.confirmRecordEncoding(ExtendedPivotTableViewFieldsRecord.sid, expReserData, rec.serialize());
}
g2D.drawArc( x, y, width, height, startAngle, arcAngle );
}
- public void drawBytes(byte data[], int offset, int length, int x, int y) {
+ public void drawBytes(byte[] data, int offset, int length, int x, int y) {
String l =
"drawBytes(byte[],int,int,int,int):" +
"\n data = " + Arrays.toString(data) +
g2D.drawBytes( data, offset, length, x, y );
}
- public void drawChars(char data[], int offset, int length, int x, int y) {
+ public void drawChars(char[] data, int offset, int length, int x, int y) {
String l =
"drawChars(data,int,int,int,int):" +
"\n data = " + Arrays.toString(data) +
g2D.drawPolygon( p );
}
- public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {
+ public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
String l =
"drawPolygon(int[],int[],int):" +
"\n xPoints = " + Arrays.toString(xPoints) +
g2D.drawPolygon( xPoints, yPoints, nPoints );
}
- public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {
+ public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
String l =
"drawPolyline(int[],int[],int):" +
"\n xPoints = " + Arrays.toString(xPoints) +
g2D.fillPolygon( p );
}
- public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {
+ public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
String l =
"fillPolygon(int[],int[],int):" +
"\n xPoints = " + Arrays.toString(xPoints) +
// test if inserted EscherMetafileBlip will be read again
HSSFWorkbook wb = new HSSFWorkbook();
- byte pictureDataEmf[] = POIDataSamples.getDocumentInstance().readFile("vector_image.emf");
+ byte[] pictureDataEmf = POIDataSamples.getDocumentInstance().readFile("vector_image.emf");
int indexEmf = wb.addPicture(pictureDataEmf, HSSFWorkbook.PICTURE_TYPE_EMF);
- byte pictureDataPng[] = POIDataSamples.getSpreadSheetInstance().readFile("logoKarmokar4.png");
+ byte[] pictureDataPng = POIDataSamples.getSpreadSheetInstance().readFile("logoKarmokar4.png");
int indexPng = wb.addPicture(pictureDataPng, HSSFWorkbook.PICTURE_TYPE_PNG);
- byte pictureDataWmf[] = POIDataSamples.getSlideShowInstance().readFile("santa.wmf");
+ byte[] pictureDataWmf = POIDataSamples.getSlideShowInstance().readFile("santa.wmf");
int indexWmf = wb.addPicture(pictureDataWmf, HSSFWorkbook.PICTURE_TYPE_WMF);
HSSFSheet sheet = wb.createSheet();
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
- byte pictureDataOut[] = wb.getAllPictures().get(0).getData();
+ byte[] pictureDataOut = wb.getAllPictures().get(0).getData();
assertArrayEquals(pictureDataEmf, pictureDataOut);
- byte wmfNoHeader[] = new byte[pictureDataWmf.length-22];
+ byte[] wmfNoHeader = new byte[pictureDataWmf.length - 22];
System.arraycopy(pictureDataWmf, 22, wmfNoHeader, 0, pictureDataWmf.length-22);
pictureDataOut = wb.getAllPictures().get(2).getData();
assertArrayEquals(wmfNoHeader, pictureDataOut);
int key = CryptoFunctions.createXorKey1("abc");
assertEquals(20810, key);
assertEquals(52250, verifier);
-
- byte xorArrAct[] = CryptoFunctions.createXorArray1("abc");
- byte xorArrExp[] = HexRead.readFromString("AC-CC-A4-AB-D6-BA-C3-BA-D6-A3-2B-45-D3-79-29-BB");
+
+ byte[] xorArrAct = CryptoFunctions.createXorArray1("abc");
+ byte[] xorArrExp = HexRead.readFromString("AC-CC-A4-AB-D6-BA-C3-BA-D6-A3-2B-45-D3-79-29-BB");
assertThat(xorArrExp, equalTo(xorArrAct));
}
@Test
public void testFiles() throws IOException, Ole10NativeException {
- File files[] = {
- // bug 51891
- POIDataSamples.getPOIFSInstance().getFile("multimedia.doc"),
- // tika bug 1072
- POIDataSamples.getPOIFSInstance().getFile("20-Force-on-a-current-S00.doc"),
- // other files containing ole10native records ...
- POIDataSamples.getDocumentInstance().getFile("Bug53380_3.doc"),
- POIDataSamples.getDocumentInstance().getFile("Bug47731.doc")
+ File[] files = {
+ // bug 51891
+ POIDataSamples.getPOIFSInstance().getFile("multimedia.doc"),
+ // tika bug 1072
+ POIDataSamples.getPOIFSInstance().getFile("20-Force-on-a-current-S00.doc"),
+ // other files containing ole10native records ...
+ POIDataSamples.getDocumentInstance().getFile("Bug53380_3.doc"),
+ POIDataSamples.getDocumentInstance().getFile("Bug47731.doc")
};
for (File f : files) {
public void NPOIFSReadCopyWritePOIFSRead() throws IOException {
File testFile = POIDataSamples.getSpreadSheetInstance().getFile("Simple.xls");
POIFSFileSystem src = new POIFSFileSystem(testFile);
- byte wbDataExp[] = IOUtils.toByteArray(src.createDocumentInputStream("Workbook"));
+ byte[] wbDataExp = IOUtils.toByteArray(src.createDocumentInputStream("Workbook"));
POIFSFileSystem nfs = new POIFSFileSystem();
EntryUtils.copyNodes(src.getRoot(), nfs.getRoot());
nfs.close();
POIFSFileSystem pfs = new POIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
- byte wbDataAct[] = IOUtils.toByteArray(pfs.createDocumentInputStream("Workbook"));
+ byte[] wbDataAct = IOUtils.toByteArray(pfs.createDocumentInputStream("Workbook"));
assertThat(wbDataExp, equalTo(wbDataAct));
pfs.close();
@Test
public void testFailWhenNoArguments() {
- ValueEval ve[] = new ValueEval[0];
+ ValueEval[] ve = new ValueEval[0];
assertEquals(VALUE_INVALID, WorkdayFunction.instance.evaluate(ve, null));
}
@Test
public void testFailWhenLessThan2Arguments() {
- ValueEval ve[] = new ValueEval[1];
+ ValueEval[] ve = new ValueEval[1];
assertEquals(VALUE_INVALID, WorkdayFunction.instance.evaluate(ve, null));
}
@Test
public void testFailWhenMoreThan3Arguments() {
- ValueEval ve[] = new ValueEval[4];
+ ValueEval[] ve = new ValueEval[4];
assertEquals(VALUE_INVALID, WorkdayFunction.instance.evaluate(ve, null));
}
@Test
public void testFailWhenArgumentsAreNotDatesNorNumbers() {
- ValueEval ve[] = { new StringEval("Potato"), new StringEval("Cucumber") };
+ ValueEval[] ve = {new StringEval("Potato"), new StringEval("Cucumber")};
assertEquals(VALUE_INVALID, WorkdayFunction.instance.evaluate(ve, EC));
}
public void testReturnWorkdays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 3, 30);
Date expDate = expCal.getTime();
- ValueEval ve[] = { new StringEval(STARTING_DATE), new NumberEval(151) };
+ ValueEval[] ve = {new StringEval(STARTING_DATE), new NumberEval(151)};
Date actDate = DateUtil.getJavaDate(((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue());
assertEquals(expDate, actDate);
}
Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 8, 27);
Date expDate = expCal.getTime();
- ValueEval ve[] = { new StringEval("2013/09/30"), new NumberEval(-1) };
+ ValueEval[] ve = {new StringEval("2013/09/30"), new NumberEval(-1)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
assertEquals(41544.0, numberValue, 0);
public void testReturnWorkdaysSpanningAWeekendAddingDays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 8, 30);
Date expDate = expCal.getTime();
-
- ValueEval ve[] = { new StringEval("2013/09/27"), new NumberEval(1) };
+
+ ValueEval[] ve = {new StringEval("2013/09/27"), new NumberEval(1)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
assertEquals(41547.0, numberValue, 0);
public void testReturnWorkdaysWhenStartIsWeekendAddingDays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 9, 7);
Date expDate = expCal.getTime();
-
- ValueEval ve[] = { new StringEval("2013/10/06"), new NumberEval(1) };
+
+ ValueEval[] ve = {new StringEval("2013/10/06"), new NumberEval(1)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
assertEquals(41554.0, numberValue, 0);
public void testReturnWorkdaysWhenStartIsWeekendSubtractingDays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 9, 4);
Date expDate = expCal.getTime();
-
- ValueEval ve[] = { new StringEval("2013/10/06"), new NumberEval(-1) };
+
+ ValueEval[] ve = {new StringEval("2013/10/06"), new NumberEval(-1)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
assertEquals(41551.0, numberValue, 0);
public void testReturnWorkdaysWithDaysTruncated() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 3, 30);
Date expDate = expCal.getTime();
-
- ValueEval ve[] = { new StringEval(STARTING_DATE), new NumberEval(151.99999) };
+
+ ValueEval[] ve = {new StringEval(STARTING_DATE), new NumberEval(151.99999)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
Date actDate = DateUtil.getJavaDate(numberValue);
public void testReturnRetroativeWorkday() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2008, 8, 23);
Date expDate = expCal.getTime();
-
- ValueEval ve[] = { new StringEval(STARTING_DATE), new NumberEval(-5), new StringEval(RETROATIVE_HOLIDAY) };
+
+ ValueEval[] ve = {new StringEval(STARTING_DATE), new NumberEval(-5), new StringEval(RETROATIVE_HOLIDAY)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
Date actDate = DateUtil.getJavaDate(numberValue);
public void testReturnNetworkdaysWithManyHolidays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 4, 5);
Date expDate = expCal.getTime();
-
- ValueEval ve[] = {
- new StringEval(STARTING_DATE), new NumberEval(151),
- new MockAreaEval(FIRST_HOLIDAY, SECOND_HOLIDAY, THIRD_HOLIDAY) };
+
+ ValueEval[] ve = {
+ new StringEval(STARTING_DATE), new NumberEval(151),
+ new MockAreaEval(FIRST_HOLIDAY, SECOND_HOLIDAY, THIRD_HOLIDAY)};
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
Date actDate = DateUtil.getJavaDate(numberValue);
}
private void checkValue(double startDate, int monthInc, double expectedResult) {
- ValueEval ve[] = {new NumberEval(startDate), new NumberEval(monthInc)};
+ ValueEval[] ve = {new NumberEval(startDate), new NumberEval(monthInc)};
NumberEval result = (NumberEval) eOMonth.evaluate(ve, ec);
assertEquals(expectedResult, result.getNumberValue(), 0);
}
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);
Date expDate = cal.getTime();
-
- ValueEval ve[] = {
- new NumberEval(DateUtil.getExcelDate(startDate)),
- new NumberEval(offset)
+
+ ValueEval[] ve = {
+ new NumberEval(DateUtil.getExcelDate(startDate)),
+ new NumberEval(offset)
};
NumberEval result = (NumberEval) eOMonth.evaluate(ve, ec);
Date actDate = DateUtil.getJavaDate(result.getNumberValue());
@Test
public void testBug56688() {
- ValueEval ve[] = {new NumberEval(DATE_1902_09_26), new RefEvalImplementation(new NumberEval(0))};
+ ValueEval[] ve = {new NumberEval(DATE_1902_09_26), new RefEvalImplementation(new NumberEval(0))};
NumberEval result = (NumberEval) eOMonth.evaluate(ve, ec);
assertEquals(DATE_1902_09_30, result.getNumberValue(), 0);
}
@Test
public void testRefEvalStartDate() {
- ValueEval ve[] = {new RefEvalImplementation(new NumberEval(DATE_1902_09_26)), new NumberEval(0)};
+ ValueEval[] ve = {new RefEvalImplementation(new NumberEval(DATE_1902_09_26)), new NumberEval(0)};
NumberEval result = (NumberEval) eOMonth.evaluate(ve, ec);
assertEquals(DATE_1902_09_30, result.getNumberValue(), 0);
}
}
public void testNpv() {
- double r, v[], npv, x;
-
+ double r;
+ double[] v;
+ double npv;
+ double x;
+
r = 1; v = new double[]{100, 200, 300, 400};
npv = FinanceLib.npv(r, v);
x = 162.5;
}
AreaEval arg1 = EvalFactory.createAreaEval("C1:D5", values);
- ValueEval args[] = { new NumberEval(function), arg1 };
+ ValueEval[] args = {new NumberEval(function), arg1};
ValueEval result = new Subtotal().evaluate(args, 0, 0);
Calendar expCal = LocaleUtil.getLocaleCalendar(1900, 0, 0);
- Calendar actCal[] = {
- DateUtil.getJavaCalendar(dateValue),
- DateUtil.getJavaCalendar(dateValue, use1904windowing),
- DateUtil.getJavaCalendar(dateValue, use1904windowing, tz),
- DateUtil.getJavaCalendar(dateValue, use1904windowing, tz, roundSeconds)
+ Calendar[] actCal = {
+ DateUtil.getJavaCalendar(dateValue),
+ DateUtil.getJavaCalendar(dateValue, use1904windowing),
+ DateUtil.getJavaCalendar(dateValue, use1904windowing, tz),
+ DateUtil.getJavaCalendar(dateValue, use1904windowing, tz, roundSeconds)
};
assertEquals(expCal, actCal[0]);
assertEquals(expCal, actCal[1]);
byte[] testArray = testArray();
ByteArrayOutputStream streamAct = new ByteArrayOutputStream();
HexDump.dump(testArray, 0, streamAct, 0);
- byte bytesAct[] = streamAct.toByteArray();
- byte bytesExp[] = toHexDump(0,0);
+ byte[] bytesAct = streamAct.toByteArray();
+ byte[] bytesExp = toHexDump(0, 0);
assertEquals("array size mismatch", bytesExp.length, bytesAct.length);
assertArrayEquals("array mismatch", bytesExp, bytesAct);
private byte[] toHexDump(long offset, int index) {
StringBuilder strExp = new StringBuilder(), chrs = new StringBuilder();
- Object obj[] = new Object[33];
+ Object[] obj = new Object[33];
StringBuilder format = new StringBuilder();
for (int j = 0; j < 16 && (index + j*16) < 256; j++) {
testdata[0] = 0x01;
testdata[1] = (byte) 0xFF;
testdata[2] = 0x02;
- short expected[] = new short[2];
+ short[] expected = new short[2];
expected[0] = ( short ) 0xFF01;
expected[1] = 0x02FF;
expected[1] = (byte) 0xFF;
expected[2] = 0x02;
byte[] received = new byte[ LittleEndianConsts.SHORT_SIZE + 1 ];
- short testdata[] = new short[2];
+ short[] testdata = new short[2];
testdata[0] = ( short ) 0xFF01;
testdata[1] = 0x02FF;