|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.util.zip.InflaterInputStream
ru.protek.component.xzip.XZipInputStream
public class XZipInputStream
Это моя переделка класса java.util.zip.ZipInputStream. В стандартный класс добавлена возможность раззиповывать архивы, зашифрованные паролем. Алгоритм шифрации для старого зипа (версии 2). Все, что добавлено нового, находиться в конце файла (кое-какие изменения есть и в теле класса, но это не важно). Пример использования (из криптованного паролем "vlad" архива "crypt.zip" извлекаются все файлы):
XZipEntry ze; FileOutputStream fo; FileInputStream fi = new FileInputStream("crypt.zip"); XZipInputStream zi = new XZipInputStream(fi); zi.setPassword("vlad"); zi.setPasswordEncode("Cp1256"); for(ze = zi.getNextEntry(); ze != null; ze = zi.getNextEntry()) { fo = new FileOutputStream(ze.getName() + ".decrypt"); for(int r = zi.read();r >= 0; r = zi.read()) fo.write(r); fo.close(); zi.closeEntry(); } zi.close();
Field Summary | |
---|---|
protected XCRC32 |
crc32
Значение хэш функции CRC32. |
protected byte[] |
originalbuf
|
protected byte[] |
randomBeginBytes
Набор случайных чисел, которые шифруются перед шифруемым сообщением. |
Fields inherited from class java.util.zip.InflaterInputStream |
---|
buf, inf, len |
Fields inherited from class java.io.FilterInputStream |
---|
in |
Fields inherited from interface ru.protek.component.xzip.XZipConstants |
---|
CENATT, CENATX, CENCOM, CENCRC, CENDSK, CENEXT, CENFLG, CENHDR, CENHOW, CENLEN, CENNAM, CENOFF, CENSIG, CENSIZ, CENTIM, CENVEM, CENVER, ENDCOM, ENDHDR, ENDOFF, ENDSIG, ENDSIZ, ENDSUB, ENDTOT, EXTCRC, EXTHDR, EXTLEN, EXTSIG, EXTSIZ, LOCCRC, LOCEXT, LOCFLG, LOCHDR, LOCHOW, LOCLEN, LOCNAM, LOCSIG, LOCSIZ, LOCTIM, LOCVER |
Constructor Summary | |
---|---|
XZipInputStream(java.io.InputStream theIn)
Creates a new ZIP input stream. |
Method Summary | |
---|---|
int |
available()
Returns 0 after EOF has reached for the current entry data, otherwise always return 1. |
void |
close()
Closes this input stream and releases any system resources associated with the stream. |
void |
closeEntry()
Closes the current ZIP entry and positions the stream for reading the next entry. |
protected XZipEntry |
createZipEntry(java.lang.String name)
Creates a new XZipEntry object for the specified
entry name. |
protected void |
fill()
Переписанный вертуальный метод, в котором, собственно, происходит расшифровка буфера, перед тем как распокавать этот буфер. |
XZipEntry |
getNextEntry()
Переписанная функция getNextEntry() выдает очередное вхождение зипованного файла в архив. |
XZipEntry |
getNextEntry1()
Reads the next ZIP file entry and positions the stream at the beginning of the entry data. |
java.lang.String |
getPassword()
Возврашает тикущей пароль. |
java.lang.String |
getPasswordEncode()
Возврашает кодировку в которой установлен пароль. |
int |
read(byte[] b,
int off,
int len)
Reads from the current ZIP entry into an array of bytes. |
void |
setPassword(java.lang.String thePassword)
Устанавливает пароль. |
void |
setPasswordEncode(java.lang.String thePasswordEncode)
Устанавливает кодировку строки пароля. |
long |
skip(long n)
Skips specified number of bytes in the current ZIP entry. |
Methods inherited from class java.util.zip.InflaterInputStream |
---|
mark, markSupported, read, reset |
Methods inherited from class java.io.FilterInputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte[] originalbuf
protected byte[] randomBeginBytes
protected XCRC32 crc32
Constructor Detail |
---|
public XZipInputStream(java.io.InputStream theIn)
theIn
- the actual input streamMethod Detail |
---|
public XZipEntry getNextEntry1() throws java.io.IOException
java.util.zip.ZipException
- if a ZIP file error has occurred
java.io.IOException
- if an I/O error has occurredpublic void closeEntry() throws java.io.IOException
java.util.zip.ZipException
- if a ZIP file error has occurred
java.io.IOException
- if an I/O error has occurredpublic int available() throws java.io.IOException
available
in class java.util.zip.InflaterInputStream
java.io.IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.util.zip.InflaterInputStream
b
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes read
java.util.zip.ZipException
- if a ZIP file error has occurred
java.io.IOException
- if an I/O error has occurredpublic long skip(long n) throws java.io.IOException
skip
in class java.util.zip.InflaterInputStream
n
- the number of bytes to skip
java.util.zip.ZipException
- if a ZIP file error has occurred
java.io.IOException
- if an I/O error has occurred
java.lang.IllegalArgumentException
- if n < 0public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.util.zip.InflaterInputStream
java.io.IOException
- if an I/O error has occurredprotected XZipEntry createZipEntry(java.lang.String name)
XZipEntry
object for the specified
entry name.
name
- the ZIP file entry name
public XZipEntry getNextEntry() throws java.io.IOException
java.io.IOException
- ошибка ввода-вывода.protected void fill() throws java.io.IOException
fill
in class java.util.zip.InflaterInputStream
java.io.IOException
- ошибка ввода-вывода.public java.lang.String getPassword()
public void setPassword(java.lang.String thePassword)
thePassword
- Пароль.public java.lang.String getPasswordEncode()
public void setPasswordEncode(java.lang.String thePasswordEncode)
thePasswordEncode
- кодировка строки пароля.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |