Java Code Examples for java.util.zip.ZipEntry#getExtra()

The following examples show how to use java.util.zip.ZipEntry#getExtra() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ASiCEXAdESMimetypePositionTest.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void onDocumentSigned(byte[] byteArray) {
	super.onDocumentSigned(byteArray);
	DSSDocument doc = new InMemoryDocument(byteArray);

	StringBuilder hex = new StringBuilder(byteArray.length * 2);
	for (byte b : byteArray) {
		hex.append(String.format("%02x", b & 0xff));

	}
	assertEquals("504b0304", hex.substring(0, 8).toLowerCase());

	try (InputStream is = doc.openStream(); ZipInputStream zis = new ZipInputStream(is)) {
		ZipEntry entry;
		String name = null;
		while ((entry = ASiCUtils.getNextValidEntry(zis)) != null) {
			name = entry.getName();
			break;
		}
		assertEquals("mimetype", name);
		assertEquals(0, entry.getMethod());
		if (entry.getExtra() != null) {
			assertEquals(0, entry.getExtra().length);
		}
	} catch (IOException e1) {
		throw new DSSException(e1);
	}
}
 
Example 2
Source File: TestExtraTime.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 3
Source File: TestExtraTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 4
Source File: TestExtraTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 5
Source File: TestExtraTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 6
Source File: TestExtraTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 7
Source File: TestExtraTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 8
Source File: TestExtraTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 9
Source File: TestExtraTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 10
Source File: TestExtraTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 11
Source File: ZippedEntry.java    From rxjava2-extras with Apache License 2.0 5 votes vote down vote up
public ZippedEntry(ZipEntry e, InputStream is) {
    this.name = e.getName();
    this.time = e.getTime();
    // this.mtime = e.getLastModifiedTime();
    // this.atime = e.getLastAccessTime();
    // this.ctime = e.getCreationTime();
    this.crc = e.getCrc();
    this.size = e.getSize();
    this.csize = e.getCompressedSize();
    this.method = e.getMethod();
    this.extra = e.getExtra();
    this.comment = e.getComment();
    this.is = is;
}
 
Example 12
Source File: TestExtraTime.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 13
Source File: TestExtraTime.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 14
Source File: TestExtraTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 15
Source File: TestExtraTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 16
Source File: TestExtraTime.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 17
Source File: TestExtraTime.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 18
Source File: TestExtraTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 19
Source File: TestExtraTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
Example 20
Source File: TestExtraTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void check(ZipEntry ze, byte[] extra) {
    if (extra != null) {
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}