• 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/RarUsingRarChecker.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
/**
12
 * The RAR command line supports a larger number of functions when compared to WinRAR, but does not support ZIP and other formats.
13
 * https://www.win-rar.com/cmd-shell-mode.html
14
 */
15
public final class RarUsingRarChecker extends FileChecker {
16
    private static final boolean DEBUG = false;
17
    private String toolPath;
18

19
    public RarUsingRarChecker() {
20
        super();
×
21
        toolPath = conf.getString(Constants.RAR_PATH_KEY);
×
22
    }
×
23

24
    @Override
25
    public String[] getFileExtensions() {
26
        return new String[]{"rar"};
×
27
    }
28

29
    @Override
30
    public String getFileDescription() {
31
        return "*.rar";
×
32
    }
33

34
    @Override
35
    public String getDescription() {
36
        return "RAR Checker(Using Rar.exe)";
×
37
    }
38

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

49
    @Override
50
    public boolean checkPassword(String password) {
51
        String target = file.getAbsolutePath();
×
52
        String cmd = String.format("%s t -p\"%s\" \"%s\"", toolPath, password, target);
×
53
        if (DEBUG) {
54
            logger.info("checkPassword cmd: " + cmd);
55
        }
56
        boolean result = false;
×
57
        try (NoLogOutputStream outStream = new NoLogOutputStream();
×
58
             NoLogOutputStream errStream = new NoLogOutputStream()
×
59
        ) {
60
            CommandLine commandLine = CommandLine.parse(cmd);
×
61
            DefaultExecutor exec = new DefaultExecutor();
×
62
            PumpStreamHandler streamHandler = new PumpStreamHandler(outStream, errStream);
×
63
            exec.setStreamHandler(streamHandler);
×
64
            int exitValue = exec.execute(commandLine);
×
65
            result = (exitValue == 0);
×
66
        } catch (IOException e) {
×
NEW
67
            logger.error("checkPassword IOException");
×
68
        }
×
69
        return result;
×
70
    }
71
}
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