forked from bigolol/JoanaKeyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JoanaView.java
103 lines (87 loc) · 3.08 KB
/
JoanaView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package joanakeygui;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.graph.GraphIntegrity;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import joanakeygui.joanahandler.Helper;
import joanakeygui.joanahandler.JoanaInstance;
/**
*
* @author holgerklein
*/
public class JoanaView {
private File currentJarFile;
private File currentJavaFolderFile;
private String currentMainClass;
private FXMLDocumentController controller;
private JoanaInstance joanaInstance;
public JoanaView(FXMLDocumentController controller) {
this.controller = controller;
}
public void setCurrentJarFile(File jarFile) {
if (jarFile == null) {
return;
}
this.currentJarFile = jarFile;
controller.setJarPAth(jarFile.getAbsolutePath());
boolean correctJarFile = checkIfCorrectJarFile();
//handle result
tryCreateJoana();
}
public void setCurrentJavaFolderFile(File folderDir) {
if (folderDir == null) {
return;
}
this.currentJavaFolderFile = folderDir;
controller.setFolderPath(folderDir.getAbsolutePath());
controller.letUserChooseMainClass(Helper.getAllClassesContainingMainMethod(this.currentJavaFolderFile));
tryCreateJoana();
}
public void setCurrentMainClass(String currentMainClass) {
this.currentMainClass = currentMainClass;
tryCreateJoana();
}
private void tryCreateJoana() {
if (currentMainClass == null || currentJavaFolderFile == null || currentJarFile == null) {
return;
}
try {
joanaInstance = new JoanaInstance(
currentJarFile.getAbsolutePath(),
currentJavaFolderFile.getAbsolutePath(),
currentMainClass);
controller.letUserAddSinksAndSrcs(joanaInstance);
} catch (ClassHierarchyException ex) {
Logger.getLogger(JoanaView.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(JoanaView.class.getName()).log(Level.SEVERE, null, ex);
} catch (GraphIntegrity.UnsoundGraphException ex) {
Logger.getLogger(JoanaView.class.getName()).log(Level.SEVERE, null, ex);
} catch (CancelException ex) {
Logger.getLogger(JoanaView.class.getName()).log(Level.SEVERE, null, ex);
}
}
private boolean checkIfCorrectJarFile() {
return true;
}
public JoanaInstance getJoanaInstance() {
return joanaInstance;
}
public File getCurrentJarFile() {
return currentJarFile;
}
public File getCurrentJavaFolderFile() {
return currentJavaFolderFile;
}
public String getCurrentMainClass() {
return currentMainClass;
}
}