Examples of CentralDirectoryEntry


Examples of com.zwl.util.zip.impl.CentralDirectoryEntry

      long nextFileOffset = raFile.getFilePointer();
      String fileName = new String( fileNameBytes, charset );
     
      ExtZipEntry zipEntry = new ExtZipEntry( fileName );

      CentralDirectoryEntry cde = new CentralDirectoryEntry( raFile, fileOffset );
      zipEntry.setCentralDirectoryEntry( cde );

      zipEntry.setCompressedSize( cde.getCompressedSize() );
      zipEntry.setSize( cde.getUncompressedSize() );

      long dosTime = raFile.readInt( fileOffset + 12 );
      zipEntry.setTime( ExtZipEntry.dosToJavaTime(dosTime) );
     
      if( cde.isEncrypted() ) {
        zipEntry.setMethod( cde.getActualCompressionMethod() );
        zipEntry.setOffset( (int)(cde.getLocalHeaderOffset() + cde.getLocalHeaderSize()) + cde.getCryptoHeaderLength() );
        zipEntry.initEncryptedEntry();
      } else {
        zipEntry.setMethod( ZipEntry.DEFLATED );
        zipEntry.setPrimaryCompressionMethod( ZipEntry.DEFLATED );
      }
View Full Code Here

Examples of com.zwl.util.zip.impl.CentralDirectoryEntry

      throw new ZipException("zipEntry must NOT be NULL");
    }
    if( zipEntry.isEncrypted() ) {
      byte[] pwBytes = password.getBytes(charset);
     
      CentralDirectoryEntry cde = zipEntry.getCentralDirectoryEntry();
      int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength();
     
      byte[] salt = raFile.readByteArray( cryptoHeaderOffset, 16 );
      byte[] pwVerification = raFile.readByteArray( cryptoHeaderOffset+16, 2 );

      if( LOG.isLoggable(Level.FINEST) ) {
        LOG.finest( "\n" + cde.toString() );
        LOG.finest( "offset    = " + zipEntry.getOffset() );
        LOG.finest( "cryptoOff = " + cryptoHeaderOffset );
        LOG.finest( "pwBytes   = " + ByteArrayHelper.toString(pwBytes) + " - " + pwBytes.length );
        LOG.finest( "salt      = " + ByteArrayHelper.toString(salt) + " - " + salt.length );
        LOG.finest( "pwVerif   = " + ByteArrayHelper.toString(pwVerification) + " - " + pwVerification.length );
      }
     
      // encrypter throws ZipException for wrong password
      AESDecrypter decrypter = new AESDecrypterBC( pwBytes, salt, pwVerification );

      // create tmp file to contains the decrypted, but still compressed data
      File tmpFile = new File( outFile.getPath() + "_TMP.zip" );
      makeDir( new File(tmpFile.getParent()) );
      ExtZipOutputStream zos = new ExtZipOutputStream( tmpFile );
      ExtZipEntry tmpEntry = new ExtZipEntry( zipEntry );
      tmpEntry.setPrimaryCompressionMethod( zipEntry.getMethod() );
      zos.putNextEntry( tmpEntry );

      raFile.seek( cde.getOffset() );
      byte[] buffer = new byte[bufferSize];
      int remaining = (int)zipEntry.getEncryptedDataSize();
      while( remaining>0 ) {
        int len = (remaining>buffer.length) ? buffer.length : remaining;
        int read = raFile.readByteArray(buffer,len);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.