Nick Burch created COMPRESS-298: ----------------------------------- Summary: Cleaner way to catch/detect Seven7 files which are password protected Key: COMPRESS-298 URL: https://issues.apache.org/jira/browse/COMPRESS-298 Project: Commons Compress Issue Type: Improvement Components: Archivers Affects Versions: 1.8.1 Reporter: Nick Burch
Currently, if we open a password protected 7z file and call {{getNextEntry()}} on it, it will blow up with an IOException with a specific string: {code} java.io.IOException: Cannot read encrypted files without a password at org.apache.commons.compress.archivers.sevenz.AES256SHA256Decoder$1.init(AES256SHA256Decoder.java:56) at org.apache.commons.compress.archivers.sevenz.AES256SHA256Decoder$1.read(AES256SHA256Decoder.java:112) at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) at org.tukaani.xz.rangecoder.RangeDecoderFromStream.<init>(Unknown Source) at org.tukaani.xz.LZMAInputStream.initialize(Unknown Source) at org.tukaani.xz.LZMAInputStream.initialize(Unknown Source) at org.tukaani.xz.LZMAInputStream.<init>(Unknown Source) at org.apache.commons.compress.archivers.sevenz.Coders$LZMADecoder.decode(Coders.java:113) at org.apache.commons.compress.archivers.sevenz.Coders.addDecoder(Coders.java:77) at org.apache.commons.compress.archivers.sevenz.SevenZFile.buildDecoderStack(SevenZFile.java:853) at org.apache.commons.compress.archivers.sevenz.SevenZFile.buildDecodingStream(SevenZFile.java:820) at org.apache.commons.compress.archivers.sevenz.SevenZFile.getNextEntry(SevenZFile.java:151) {code} It would be good if either a specific subtype of IOException could be thrown (which could then be caught to differentiate this from other kinds of IO problems), or if a method could be added to SevenZFile which could be called to see if a password is needed / given password is correct (If implemented, this would help make the code in Tika dealing with 7z files cleaner) -- This message was sent by Atlassian JIRA (v6.3.4#6332)