• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #631

02 Mar 2024 04:18PM UTC coverage: 3.216% (-0.02%) from 3.232%
#631

push

jiangxincode
fix codefactor issues

0 of 180 new or added lines in 11 files covered. (0.0%)

3 existing lines in 2 files now uncovered.

240 of 7463 relevant lines covered (3.22%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/file/password/recovery/checker/ArchiveUsingWinRarChecker.java
1
package edu.jiangxin.apktoolbox.file.password.recovery.checker;
2

3
import edu.jiangxin.apktoolbox.utils.Constants;
4
import edu.jiangxin.apktoolbox.utils.NoLogOutputStream;
5
import org.apache.commons.exec.CommandLine;
6
import org.apache.commons.exec.DefaultExecutor;
7
import org.apache.commons.exec.PumpStreamHandler;
8

9
import java.io.IOException;
10

11
public class ArchiveUsingWinRarChecker extends FileChecker {
12
    private static final boolean DEBUG = false;
13
    private String toolPath;
14

15
    public ArchiveUsingWinRarChecker() {
16
        super();
×
17
        toolPath = conf.getString(Constants.WIN_RAR_PATH_KEY);
×
18
    }
×
19

20
    @Override
21
    public String[] getFileExtensions() {
22
        return new String[]{"rar", "zip", "7z", "arj", "bz2", "cab", "gz", "iso", "jar", "lz", "lzh", "tar", "uue", "xz", "z", "zst"};
×
23
    }
24

25
    @Override
26
    public String getFileDescription() {
27
        return "*.rar; *.zip; *.7z; ...";
×
28
    }
29

30
    @Override
31
    public String getDescription() {
32
        return "Archive Checker(Using WinRar.exe)";
×
33
    }
34

35
    @Override
36
    public int getMaxThreadNum() {
37
        return 5;
×
38
    }
39

40
    @Override
41
    public boolean prepareChecker() {
42
        try {
43
            Runtime.getRuntime().exec(toolPath);
×
44
        } catch (IOException e) {
×
45
            return false;
×
46
        }
×
47
        return true;
×
48
    }
49

50
    @Override
51
    public boolean checkPassword(String password) {
52
        String target = file.getAbsolutePath();
×
53
        if (password != null && password.contains("\"")) {
×
54
            // It is useless to escape the password
55
            logger.warn("checkPassword password contain double quote characters[Not Supported]");
×
56
            return false;
×
57
        }
58
        String cmd = String.format("%s t -inul -ibck -p\"%s\" \"%s\"", toolPath, password, target);
×
59
        if (DEBUG) {
60
            logger.info("checkPassword cmd: " + cmd);
61
        }
62
        boolean result = false;
×
63
        try (NoLogOutputStream outStream = new NoLogOutputStream();
×
64
             NoLogOutputStream errStream = new NoLogOutputStream()
×
65
        ) {
66
            CommandLine commandLine = CommandLine.parse(cmd);
×
67
            DefaultExecutor exec = new DefaultExecutor();
×
68
            PumpStreamHandler streamHandler = new PumpStreamHandler(outStream, errStream);
×
69
            exec.setStreamHandler(streamHandler);
×
70
            int exitValue = exec.execute(commandLine);
×
71
            result = (exitValue == 0);
×
72
        } catch (IOException e) {
×
NEW
73
            logger.error("checkPassword IOException");
×
74
        }
×
75
        return result;
×
76
    }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc