diff --git a/build.gradle b/build.gradle index 07e69c5..6789fa1 100644 --- a/build.gradle +++ b/build.gradle @@ -89,15 +89,15 @@ dependencies { implementation 'com.github.javaparser:javaparser-core:3.25.1' - implementation 'org.springframework.boot:spring-boot-starter-web' // Web支持 - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' // JPA数据库支持 - implementation 'org.springframework.boot:spring-boot-starter-validation' // 参数校验 + //implementation 'org.springframework.boot:spring-boot-starter-web' // Web支持 + //implementation 'org.springframework.boot:spring-boot-starter-data-jpa' // JPA数据库支持 + //implementation 'org.springframework.boot:spring-boot-starter-validation' // 参数校验 // 安全相关依赖 - implementation 'org.springframework.boot:spring-boot-starter-security' // Spring Security - implementation 'io.jsonwebtoken:jjwt-api:0.12.3' // JWT API - runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3', // JWT实现 - 'io.jsonwebtoken:jjwt-jackson:0.12.3' // JWT序列化 + //implementation 'org.springframework.boot:spring-boot-starter-security' // Spring Security + //implementation 'io.jsonwebtoken:jjwt-api:0.12.3' // JWT API + //runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3', // JWT实现 + // 'io.jsonwebtoken:jjwt-jackson:0.12.3' // JWT序列化 runtimeOnly 'com.mysql:mysql-connector-j' diff --git a/language/sys_zh_CN.properties b/language/sys_zh_CN.properties index 1f75a43..74b7cc8 100644 --- a/language/sys_zh_CN.properties +++ b/language/sys_zh_CN.properties @@ -45,8 +45,17 @@ fridaWindow.inject.end.err=[ERROR] \u505C\u6B62\u5931\u8D25: fridaWindow.inject.end.err.1=[WARN] \u6CA1\u6709\u6B63\u5728\u8FD0\u884C\u7684\u6CE8\u5165\u8FDB\u7A0B fridaWindow.menu=\u6587\u4EF6 fridaWindow.menu.exit=\u9000\u51FA +fridaWindow.menu.open=\u6253\u5F00\u6587\u4EF6 +fridaWindow.menu.save=\u4FDD\u5B58\u6587\u4EF6 fridaWindow.menu.2=\u9000\u51FA fridaWindow.menu.help=\u5E2E\u52A9 +fridaWindow.menu.settingsMenu=\u8BBE\u7F6E +fridaWindow.menu.settingsMenu.settingsItem=\u7F16\u8F91\u5668\u8BBE\u7F6E +fridaWindow.settings.title=\u8BBE\u7F6E +fridaWindow.settings.font=\u5B57\u4F53 +fridaWindow.settings.size=\u5927\u5C0F +fridaWindow.settings.theme=\u4E3B\u9898 +fridaWindow.menu.settingsMenu.settingsItem.1=\u8BBE\u7F6E fridaWindow.menu.help.about=\u5173\u4E8E localWindow.newBtn=\u65B0\u5BF9\u8BDD diff --git a/src/main/java/com/axis/innovators/box/AxisInnovatorsBox.java b/src/main/java/com/axis/innovators/box/AxisInnovatorsBox.java index 45be370..f106032 100644 --- a/src/main/java/com/axis/innovators/box/AxisInnovatorsBox.java +++ b/src/main/java/com/axis/innovators/box/AxisInnovatorsBox.java @@ -17,6 +17,8 @@ import com.axis.innovators.box.tools.LibraryLoad; import com.axis.innovators.box.tools.StateManager; import com.axis.innovators.box.tools.SystemInfoUtil; import com.axis.innovators.box.util.PythonResult; +import com.axis.innovators.box.util.UserLocalInformation; +import com.axis.innovators.box.verification.UserTags; import com.formdev.flatlaf.FlatLightLaf; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,6 +60,7 @@ public class AxisInnovatorsBox { private final RegistrationTopic registrationTopic = new RegistrationTopic(this); private final List windowsJDialogList = new ArrayList<>(); private final StateManager stateManager = new StateManager(); + private UserTags userTags; public AxisInnovatorsBox(String[] args) { this.args = args; @@ -340,7 +343,7 @@ public class AxisInnovatorsBox { public static void run(String[] args) { main = new AxisInnovatorsBox(args); try { - //main.initLog4j2(); + main.initLog4j2(); main.setTopic(); List> validFiles = ArgsParser.parseArgs(args); @@ -356,10 +359,13 @@ public class AxisInnovatorsBox { main.thread = new Thread(() -> { try { - - // 登录窗口 - LoginWindow.createAndShow(); - + UserLocalInformation userLocalInformation = new UserLocalInformation(main); + main.userTags = userLocalInformation.getUserTags(); + if (main.userTags == null) { + // 登录窗口 + main.userTags = LoginWindow.createAndShow(); + userLocalInformation.setUserTags(main.userTags); + } // 主任务1:加载插件 logger.info("Loaded plugins Started"); @@ -460,6 +466,14 @@ public class AxisInnovatorsBox { return AUTHOR; } + /** + * 获取用户标签 + * @return 用户标签 + */ + public UserTags getUserTags() { + return userTags; + } + /** * 获取状态管理器 * @return 状态管理器 diff --git a/src/main/java/com/axis/innovators/box/gui/FridaWindow.java b/src/main/java/com/axis/innovators/box/gui/FridaWindow.java index 4975575..1fb734c 100644 --- a/src/main/java/com/axis/innovators/box/gui/FridaWindow.java +++ b/src/main/java/com/axis/innovators/box/gui/FridaWindow.java @@ -16,16 +16,17 @@ import org.fife.ui.rtextarea.RTextScrollPane; import javax.swing.*; import javax.swing.border.EmptyBorder; +import javax.swing.event.ChangeListener; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import java.awt.*; import java.awt.event.*; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Arrays; +import java.io.*; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.List; +import java.util.function.Consumer; +import java.util.prefs.Preferences; /** * Frida注入工具窗口 @@ -41,6 +42,7 @@ public class FridaWindow extends WindowsJDialog { // IDEA风格配色 private static final Color BACKGROUND = new Color(0x2B2B2B); private static final Color SELECTION_COLOR = new Color(0x214283); + private JDialog settingsDialog; public FridaWindow(Window owner) { super(owner, language.getText("fridaWindow.title"), ModalityType.APPLICATION_MODAL); @@ -99,6 +101,66 @@ public class FridaWindow extends WindowsJDialog { }); } + private void createMenuBar() { + JMenuBar menuBar = new JMenuBar(); + // 菜单栏深色背景 + menuBar.setBackground(new Color(0x3C3F41)); + menuBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); + + // 统一设置菜单UI属性 + UIManager.put("Menu.background", new Color(0x3C3F41)); + UIManager.put("Menu.foreground", new Color(0xBBBBBB)); + UIManager.put("MenuItem.background", new Color(0x3C3F41)); + UIManager.put("MenuItem.foreground", new Color(0xBBBBBB)); + UIManager.put("MenuItem.selectionBackground", new Color(0x214283)); + + // 文件菜单 + JMenu fileMenu = new JMenu(language.getText("fridaWindow.menu")); + styleMenu(fileMenu); + + // 退出菜单项 + JMenuItem exitItem = new JMenuItem(language.getText("fridaWindow.menu.exit")); + styleMenuItem(exitItem); + exitItem.addActionListener(e -> dispose()); + + JMenuItem openItem = new JMenuItem(language.getText("fridaWindow.menu.open")); + styleMenuItem(openItem); + openItem.addActionListener(e -> openFile()); + + JMenuItem saveItem = new JMenuItem(language.getText("fridaWindow.menu.save")); + styleMenuItem(saveItem); + saveItem.addActionListener(e -> saveFile()); + + fileMenu.add(exitItem); + fileMenu.add(openItem); + fileMenu.add(saveItem); + + // 帮助菜单 + JMenu helpMenu = new JMenu(language.getText("fridaWindow.menu.help")); + styleMenu(helpMenu); + + // 设置菜单 + JMenu settingsMenu = new JMenu(language.getText("fridaWindow.menu.settingsMenu")); + styleMenu(fileMenu); + + JMenuItem settingsItem = new JMenuItem(language.getText("fridaWindow.menu.settingsMenu.settingsItem")); + styleMenuItem(settingsItem); + settingsItem.addActionListener(e -> settingsWindow()); + settingsMenu.add(settingsItem); + + // 关于菜单项 + JMenuItem aboutItem = new JMenuItem(language.getText("fridaWindow.menu.help.about")); + styleMenuItem(aboutItem); + aboutItem.addActionListener(e -> showAboutDialog()); + + helpMenu.add(aboutItem); + + menuBar.add(fileMenu); + menuBar.add(settingsMenu); + menuBar.add(helpMenu); + setJMenuBar(menuBar); + } + private void styleTextField(JTextField field, String placeholder) { field.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12)); field.setBackground(new Color(0x3C3F41)); @@ -154,6 +216,7 @@ public class FridaWindow extends WindowsJDialog { public void mouseEntered(MouseEvent e) { btn.setBackground(new Color(color).brighter()); } + public void mouseExited(MouseEvent e) { btn.setBackground(new Color(color)); } @@ -161,6 +224,246 @@ public class FridaWindow extends WindowsJDialog { return btn; } + private void settingsWindow() { + settingsDialog = new JDialog(this, "编辑器设置", true); + settingsDialog.setSize(600, 450); + settingsDialog.setLocationRelativeTo(this); + + JPanel mainPanel = new JPanel(new BorderLayout(10, 10)); + mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + + // 配置选项面板 + JTabbedPane tabbedPane = new JTabbedPane(); + + // 颜色设置面板 + JPanel colorPanel = createColorSettingsPanel(); + tabbedPane.addTab("语法颜色", colorPanel); + + // 字体设置面板 + JPanel fontPanel = createFontSettingsPanel(); + tabbedPane.addTab("字体设置", fontPanel); + + // 底部按钮 + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + JButton saveBtn = createModernButton("保存", 0x6897BB); + JButton defaultBtn = createModernButton("恢复默认", 0x808080); + JButton cancelBtn = createModernButton("取消", 0xD25252); + + saveBtn.addActionListener(e -> applyAndSaveSettings()); + defaultBtn.addActionListener(e -> restoreDefaultSettings()); + cancelBtn.addActionListener(e -> settingsDialog.dispose()); + + buttonPanel.add(defaultBtn); + buttonPanel.add(cancelBtn); + buttonPanel.add(saveBtn); + + mainPanel.add(tabbedPane, BorderLayout.CENTER); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + + settingsDialog.setContentPane(mainPanel); + settingsDialog.setVisible(true); + } + + private JPanel createColorSettingsPanel() { + JPanel panel = new JPanel(new BorderLayout()); + + // 使用LinkedHashMap保持顺序 + Map tokenConfig = new LinkedHashMap<>(); + tokenConfig.put("关键字(Frida)", Token.RESERVED_WORD); + tokenConfig.put("标准库函数", Token.RESERVED_WORD_2); + tokenConfig.put("内置函数", Token.FUNCTION); + tokenConfig.put("字符串", Token.LITERAL_STRING_DOUBLE_QUOTE); + tokenConfig.put("数字", Token.LITERAL_NUMBER_DECIMAL_INT); + tokenConfig.put("注释", Token.COMMENT_EOL); + tokenConfig.put("运算符", Token.OPERATOR); + tokenConfig.put("标识符", Token.IDENTIFIER); + tokenConfig.put("分隔符", Token.SEPARATOR); + tokenConfig.put("正则表达式", Token.REGEX); + + DefaultTableModel model = new DefaultTableModel(new Object[]{"语法元素", "颜色示例"}, 0); + for (Map.Entry entry : tokenConfig.entrySet()) { + Style style = scriptArea.getSyntaxScheme().getStyle(entry.getValue()); + model.addRow(new Object[]{entry.getKey(), style.foreground}); + } + + JTable colorTable = new JTable(model); + colorTable.setRowHeight(30); + colorTable.getColumnModel().getColumn(1).setCellRenderer(new ColorRenderer()); + colorTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + int column = colorTable.columnAtPoint(e.getPoint()); + if (e.getClickCount() == 1 && column == 1) { + int row = colorTable.rowAtPoint(e.getPoint()); + Color current = (Color) colorTable.getValueAt(row, 1); + Color newColor = JColorChooser.showDialog(settingsDialog, + "选择颜色", current); + if (newColor != null) { + colorTable.setValueAt(newColor, row, 1); + } + } + } + }); + + JScrollPane scrollPane = new JScrollPane(colorTable); + panel.add(scrollPane, BorderLayout.CENTER); + + // 保存颜色配置引用 + panel.putClientProperty("tokenConfig", tokenConfig); + panel.putClientProperty("colorTable", colorTable); + + return panel; + } + + private JPanel createFontSettingsPanel() { + JPanel panel = new JPanel(new GridLayout(0, 2, 10, 10)); + + // 字体名称 + String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getAvailableFontFamilyNames(); + JComboBox fontCombo = new JComboBox<>(fontNames); + fontCombo.setSelectedItem(scriptArea.getFont().getFamily()); + + // 字体样式 + JCheckBox boldCheck = new JCheckBox("粗体"); + JCheckBox italicCheck = new JCheckBox("斜体"); + + // 字号 + SpinnerModel sizeModel = new SpinnerNumberModel( + scriptArea.getFont().getSize(), 8, 48, 1); + JSpinner sizeSpinner = new JSpinner(sizeModel); + + panel.add(new JLabel("字体名称:")); + panel.add(fontCombo); + panel.add(new JLabel("字号:")); + panel.add(sizeSpinner); + panel.add(new JLabel("样式:")); + JPanel stylePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + stylePanel.add(boldCheck); + stylePanel.add(italicCheck); + panel.add(stylePanel); + + // 预览区域 + JTextArea preview = new JTextArea("Frida示例代码:\nJava.perform(() => {\n // 注释\n console.log('Hello');\n for (var i = 0; i < 10; i++) {\n" + + " \n" + + "}});"); + preview.setFont(scriptArea.getFont()); + preview.setEditable(false); + preview.setBackground(scriptArea.getBackground()); + preview.setForeground(scriptArea.getForeground()); + + // 监听变化 + fontCombo.addActionListener(e -> updateFontPreview(fontCombo, sizeSpinner, boldCheck, italicCheck, preview)); + sizeSpinner.addChangeListener(e -> updateFontPreview(fontCombo, sizeSpinner, boldCheck, italicCheck, preview)); + boldCheck.addActionListener(e -> updateFontPreview(fontCombo, sizeSpinner, boldCheck, italicCheck, preview)); + italicCheck.addActionListener(e -> updateFontPreview(fontCombo, sizeSpinner, boldCheck, italicCheck, preview)); + + panel.add(new JLabel("预览:")); + panel.add(new JScrollPane(preview)); + + // 保存控件引用 + panel.putClientProperty("fontCombo", fontCombo); + panel.putClientProperty("sizeSpinner", sizeSpinner); + panel.putClientProperty("boldCheck", boldCheck); + panel.putClientProperty("italicCheck", italicCheck); + + return panel; + } + + private void updateFontPreview(JComboBox fontCombo, JSpinner sizeSpinner, + JCheckBox boldCheck, JCheckBox italicCheck, JTextArea preview) { + String fontName = (String) fontCombo.getSelectedItem(); + int size = (Integer) sizeSpinner.getValue(); + int style = Font.PLAIN; + if (boldCheck.isSelected()) style |= Font.BOLD; + if (italicCheck.isSelected()) style |= Font.ITALIC; + Font newFont = new Font(fontName, style, size); + preview.setFont(newFont); + } + + private void applyAndSaveSettings() { + // 应用颜色设置 + JPanel colorPanel = (JPanel) ((JTabbedPane)settingsDialog.getContentPane() + .getComponent(0)).getComponent(0); + + Map tokenConfig = (Map) colorPanel.getClientProperty("tokenConfig"); + JTable colorTable = (JTable) colorPanel.getClientProperty("colorTable"); + + SyntaxScheme scheme = scriptArea.getSyntaxScheme(); + for (int i = 0; i < colorTable.getRowCount(); i++) { + String tokenName = (String) colorTable.getValueAt(i, 0); + Color color = (Color) colorTable.getValueAt(i, 1); + Integer tokenType = tokenConfig.get(tokenName); + if (tokenType != null) { + scheme.getStyle(tokenType).foreground = color; + } + } + + // 应用字体设置 + JPanel fontPanel = (JPanel) ((JTabbedPane)settingsDialog.getContentPane() + .getComponent(0)).getComponent(1); + + JComboBox fontCombo = (JComboBox) fontPanel.getClientProperty("fontCombo"); + JSpinner sizeSpinner = (JSpinner) fontPanel.getClientProperty("sizeSpinner"); + JCheckBox boldCheck = (JCheckBox) fontPanel.getClientProperty("boldCheck"); + JCheckBox italicCheck = (JCheckBox) fontPanel.getClientProperty("italicCheck"); + + String fontName = (String) fontCombo.getSelectedItem(); + int size = (Integer) sizeSpinner.getValue(); + int style = Font.PLAIN; + if (boldCheck.isSelected()) style |= Font.BOLD; + if (italicCheck.isSelected()) style |= Font.ITALIC; + Font newFont = new Font(fontName, style, size); + scriptArea.setFont(newFont); + + // 保存到首选项 + Preferences prefs = Preferences.userNodeForPackage(FridaWindow.class); + prefs.putInt("editor.font.style", style); + prefs.putInt("editor.font.size", size); + prefs.put("editor.font.name", fontName); + + settingsDialog.dispose(); + scriptArea.repaint(); + } + + private void restoreDefaultSettings() { + // 恢复颜色默认 + configureIDEATheme(scriptArea.getSyntaxScheme()); + + // 恢复字体默认 + Font defaultFont = new Font("JetBrains Mono", Font.PLAIN, 13); + if (!Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment() + .getAvailableFontFamilyNames()).contains("JetBrains Mono")) { + defaultFont = new Font("Consolas", Font.PLAIN, 14); + } + scriptArea.setFont(defaultFont); + + // 清除首选项存储 + Preferences prefs = Preferences.userNodeForPackage(FridaWindow.class); + prefs.remove("editor.font.name"); + prefs.remove("editor.font.style"); + prefs.remove("editor.font.size"); + + settingsDialog.dispose(); + scriptArea.repaint(); + } + + // 自定义表格渲染器用于显示颜色 + private static class ColorRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + Component c = super.getTableCellRendererComponent(table, value, + isSelected, hasFocus, row, column); + if (value instanceof Color) { + setText(""); + setBackground((Color) value); + setBorder(BorderFactory.createLineBorder(Color.GRAY)); + } + return c; + } + } + private void styleComboBox(JComboBox combo) { combo.setRenderer(new DefaultListCellRenderer() { @Override @@ -174,44 +477,55 @@ public class FridaWindow extends WindowsJDialog { }); } - private void createMenuBar() { - JMenuBar menuBar = new JMenuBar(); - // 菜单栏深色背景 - menuBar.setBackground(new Color(0x3C3F41)); - menuBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); - // 统一设置菜单UI属性 - UIManager.put("Menu.background", new Color(0x3C3F41)); - UIManager.put("Menu.foreground", new Color(0xBBBBBB)); - UIManager.put("MenuItem.background", new Color(0x3C3F41)); - UIManager.put("MenuItem.foreground", new Color(0xBBBBBB)); - UIManager.put("MenuItem.selectionBackground", new Color(0x214283)); - - // 文件菜单 - JMenu fileMenu = new JMenu(language.getText("fridaWindow.menu")); - styleMenu(fileMenu); - - // 退出菜单项 - JMenuItem exitItem = new JMenuItem(language.getText("fridaWindow.menu.exit")); - styleMenuItem(exitItem); - exitItem.addActionListener(e -> dispose()); - - // 帮助菜单 - JMenu helpMenu = new JMenu(language.getText("fridaWindow.menu.help")); - styleMenu(helpMenu); - - // 关于菜单项 - JMenuItem aboutItem = new JMenuItem(language.getText("fridaWindow.menu.help.about")); - styleMenuItem(aboutItem); - aboutItem.addActionListener(e -> showAboutDialog()); - - helpMenu.add(aboutItem); - - menuBar.add(fileMenu); - menuBar.add(helpMenu); - setJMenuBar(menuBar); + private void openFile() { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter("Frida脚本配置 (*.frida)", "frida")); + int result = fileChooser.showOpenDialog(this); + if (result == JFileChooser.APPROVE_OPTION) { + try (BufferedReader reader = new BufferedReader(new FileReader(fileChooser.getSelectedFile()))) { + String pid = reader.readLine(); + StringBuilder script = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + script.append(line).append("\n"); + } + pidField.setText(pid); + scriptArea.setText(script.toString()); + } catch (IOException ex) { + logger.error("文件打开失败", ex); + JOptionPane.showMessageDialog(this, + "无法加载文件: " + ex.getMessage(), + "IO错误", + JOptionPane.ERROR_MESSAGE); + } + } } + private void saveFile() { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter("Frida脚本配置 (*.frida)", "frida")); + int result = fileChooser.showSaveDialog(this); + if (result == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + if (!file.getName().toLowerCase().endsWith(".frida")) { + file = new File(file.getParentFile(), file.getName() + ".frida"); + } + try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { + writer.write(pidField.getText()); + writer.newLine(); + writer.write(scriptArea.getText()); + } catch (IOException ex) { + logger.error("文件保存失败", ex); + JOptionPane.showMessageDialog(this, + "无法保存文件: " + ex.getMessage(), + "IO错误", + JOptionPane.ERROR_MESSAGE); + } + } + } + + private void styleMenu(JMenu menu) { menu.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12)); menu.setForeground(new Color(0xBBBBBB)); @@ -232,6 +546,7 @@ public class FridaWindow extends WindowsJDialog { public void mouseEntered(MouseEvent e) { item.setBackground(new Color(0x515658)); } + public void mouseExited(MouseEvent e) { item.setBackground(new Color(0x3C3F41)); } @@ -443,7 +758,9 @@ public class FridaWindow extends WindowsJDialog { isRepetition = true; } else { try { - frida.run(() -> {}).execute(frida12 -> {}).start(); + frida.run(() -> { + }).execute(frida12 -> { + }).start(); } catch (Exception ex) { logger.error("Injection failure", ex); } @@ -491,8 +808,7 @@ public class FridaWindow extends WindowsJDialog { public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { contextMenu.show(table, e.getX(), e.getY()); - } - else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { + } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { injectSelectedProcess(); } } @@ -505,7 +821,7 @@ public class FridaWindow extends WindowsJDialog { private DefaultTableModel createTableModel() { processList = getProcesses(); - String[] columns = { "进程名称", "进程ID" }; + String[] columns = {"进程名称", "进程ID"}; Object[][] data = getTableData(processList); return new DefaultTableModel(data, columns) { @Override @@ -572,6 +888,7 @@ public class FridaWindow extends WindowsJDialog { /** * 执行cmd命令获取所有进程信息 + * * @return 进程信息列表 */ private List getProcesses() { @@ -597,7 +914,8 @@ public class FridaWindow extends WindowsJDialog { } } - private record ProcessInfo(long pid, String name) {} + private record ProcessInfo(long pid, String name) { + } public static void main(String[] args) { diff --git a/src/main/java/com/axis/innovators/box/gui/LoginWindow.java b/src/main/java/com/axis/innovators/box/gui/LoginWindow.java index 25c6714..3ce71b6 100644 --- a/src/main/java/com/axis/innovators/box/gui/LoginWindow.java +++ b/src/main/java/com/axis/innovators/box/gui/LoginWindow.java @@ -1,5 +1,6 @@ package com.axis.innovators.box.gui; +import com.axis.innovators.box.verification.OnlineVerification; import com.axis.innovators.box.verification.UserTags; import com.axis.innovators.box.verification.VerificationService; import com.formdev.flatlaf.FlatDarculaLaf; @@ -8,6 +9,7 @@ import com.formdev.flatlaf.FlatIntelliJLaf; import javax.swing.*; import javax.swing.border.LineBorder; import java.awt.*; +import java.lang.reflect.InvocationTargetException; import java.util.concurrent.atomic.AtomicReference; /** @@ -22,21 +24,17 @@ public class LoginWindow { private JCheckBox showPasswordCheckBox; private static final int FIELD_WIDTH = 300; private static final int FIELD_HEIGHT = 35; - public static UserTags createAndShow() { + public static UserTags createAndShow() throws InterruptedException, InvocationTargetException { AtomicReference result = new AtomicReference<>(UserTags.None); - try { - SwingUtilities.invokeAndWait(() -> { - LoginWindow loginWindow = new LoginWindow(); - loginWindow.dialog.setVisible(true); - result.set(loginResult.get()); + SwingUtilities.invokeAndWait(() -> { + LoginWindow loginWindow = new LoginWindow(); + loginWindow.dialog.setVisible(true); + result.set(loginResult.get()); - if(result.get() == UserTags.None) { - System.exit(0); - } - }); - } catch (Exception e) { - e.printStackTrace(); - } + if (result.get() == UserTags.None) { + System.exit(0); + } + }); return result.get(); } @@ -268,7 +266,9 @@ public class LoginWindow { return; } - loginResult.set(VerificationService.determineUserType(null)); + OnlineVerification onlineVerification = OnlineVerification.validateLogin(email, password); + loginResult.set(VerificationService.determineUserType(onlineVerification)); + dialog.dispose(); } diff --git a/src/main/java/com/axis/innovators/box/register/RegistrationTopic.java b/src/main/java/com/axis/innovators/box/register/RegistrationTopic.java index e8b5fc1..1786ff0 100644 --- a/src/main/java/com/axis/innovators/box/register/RegistrationTopic.java +++ b/src/main/java/com/axis/innovators/box/register/RegistrationTopic.java @@ -10,7 +10,16 @@ import java.util.List; import java.util.Objects; /** - * 注册主题 + * 注册主题类,用于管理和注册主题。 + * 该类允许添加主题,并提供了一系列方法来获取和管理已注册的主题。 + *

+ * 主要功能: + * - 注册主题类或 LookAndFeel 主题 + * - 检查主题是否已加载 + * - 设置主题加载状态 + * - 检查主题列表是否为空 + * - 获取已注册的主题类、主题名、图标、提示信息等 + * * @author tzdwindows 7 */ public class RegistrationTopic { @@ -24,16 +33,24 @@ public class RegistrationTopic { private final AxisInnovatorsBox axisInnovatorsBox; private String loadTopics = ""; + /** + * 构造函数,初始化 RegistrationTopic 实例。 + * + * @param axisInnovatorsBox AxisInnovatorsBox 实例,用于检查窗口状态 + */ public RegistrationTopic(AxisInnovatorsBox axisInnovatorsBox) { this.axisInnovatorsBox = axisInnovatorsBox; } /** - * 注册主题 - * @param topicClass 主题类 - * @param topicName 主题名 - * @param icon 显示图标 - * @param registeredName 注册名 + * 注册主题类。 + * + * @param topicClass 主题类名 + * @param topicName 主题名称 + * @param tip 主题提示信息 + * @param icon 主题图标 + * @param registeredName 主题注册名 + * @throws RegistrationError 如果注册名已存在,则抛出异常 */ public void addTopic(String topicClass, String topicName, String tip ,Icon icon, String registeredName) { if (!axisInnovatorsBox.isWindow()) { @@ -52,11 +69,14 @@ public class RegistrationTopic { } /** - * 注册主题 - * @param topicClass 主题类 - * @param topicName 主题名 - * @param icon 显示图标 - * @param registeredName 注册名 + * 注册 LookAndFeel 主题。 + * + * @param topicClass LookAndFeel 主题类 + * @param topicName 主题名称 + * @param tip 主题提示信息 + * @param icon 主题图标 + * @param registeredName 主题注册名 + * @throws RegistrationError 如果注册名已存在,则抛出异常 */ public void addTopic(LookAndFeel topicClass, String topicName, String tip ,Icon icon, String registeredName) { if (!axisInnovatorsBox.isWindow()) { @@ -75,8 +95,10 @@ public class RegistrationTopic { } /** - * 判断是否已经加载 - * @return 是否已经加载 + * 检查指定主题是否已加载。 + * + * @param loading 要检查的主题名 + * @return 如果主题已加载,则返回 true;否则返回 false */ public boolean isLoading(String loading) { if (loadTopics.isEmpty()) { @@ -86,49 +108,82 @@ public class RegistrationTopic { } /** - * 设置是否加载 - * @param loading 是否加载 + * 设置当前加载的主题。 + * + * @param loading 要加载的主题名 */ public void setLoading(String loading) { loadTopics = loading; } /** - * 判断是否为空 - * @return 是否为空 + * 检查主题列表是否为空。 + * + * @return 如果主题列表为空,则返回 true;否则返回 false */ public boolean isEmpty() { return registeredNameList.isEmpty(); } /** - * 获取主题类 - * @return 主题类 + * 获取已注册的主题类列表。 + * + * @return 主题类列表 */ public List getTopicsClasses() { return topicsClasses; } + /** + * 获取 AxisInnovatorsBox 实例。 + * + * @return AxisInnovatorsBox 实例 + */ public AxisInnovatorsBox getAxisInnovatorsBox() { return axisInnovatorsBox; } + /** + * 获取已注册的 LookAndFeel 主题类列表。 + * + * @return LookAndFeel 主题类列表 + */ public List getTopicsClassesLookAndFeel() { return topicsClassesLookAndFeel; } + /** + * 获取已注册的主题图标列表。 + * + * @return 主题图标列表 + */ public List getIconList() { return iconList; } + /** + * 获取已注册的主题名列表。 + * + * @return 主题名列表 + */ public List getRegisteredNameList() { return registeredNameList; } + /** + * 获取已注册的主题提示信息列表。 + * + * @return 主题提示信息列表 + */ public List getTipList() { return tipList; } + /** + * 获取已注册的主题名称列表。 + * + * @return 主题名称列表 + */ public List getTopicsName() { return topicsName; } diff --git a/src/main/java/com/axis/innovators/box/util/UserLocalInformation.java b/src/main/java/com/axis/innovators/box/util/UserLocalInformation.java new file mode 100644 index 0000000..121edf4 --- /dev/null +++ b/src/main/java/com/axis/innovators/box/util/UserLocalInformation.java @@ -0,0 +1,44 @@ +package com.axis.innovators.box.util; + +import com.axis.innovators.box.AxisInnovatorsBox; +import com.axis.innovators.box.verification.OnlineVerification; +import com.axis.innovators.box.verification.UserTags; +import com.axis.innovators.box.verification.VerificationService; + +/** + * 用于存储用户信息 + * @author tzdwindows 7 + */ +public class UserLocalInformation { + private final AxisInnovatorsBox main; + + public UserLocalInformation(AxisInnovatorsBox main){ + this.main = main; + } + + /** + * 设置用户信息 + * @param userTags 用户信息 + */ + public void setUserTags(UserTags userTags){ + OnlineVerification onlineVerification = userTags.getUser(); + main.getStateManager().saveState("password", onlineVerification.password); + main.getStateManager().saveState("verification", onlineVerification.onlineVerification); + } + + /** + * 获取用户信息 + * @return 用户信息 + */ + public UserTags getUserTags(){ + String verification = main.getStateManager().getState("verification"); + String password = main.getStateManager().getState("password"); + if (verification == null || password == null){ + return null; + } + OnlineVerification onlineVerification = OnlineVerification.validateLogin( + verification, + password); + return VerificationService.determineUserType(onlineVerification); + } +} diff --git a/src/main/java/com/axis/innovators/box/verification/OnlineVerification.java b/src/main/java/com/axis/innovators/box/verification/OnlineVerification.java index ef20f91..a7d6d9a 100644 --- a/src/main/java/com/axis/innovators/box/verification/OnlineVerification.java +++ b/src/main/java/com/axis/innovators/box/verification/OnlineVerification.java @@ -9,17 +9,28 @@ import java.util.UUID; public class OnlineVerification { public String onlineVerification; public UserTags userTags; - - public OnlineVerification(){ - - } + public String password; OnlineVerification(String onlineVerification, UserTags userTags){ this.onlineVerification = onlineVerification; this.userTags = userTags; } - public OnlineVerification validateLogin(String identifier, String password){ + /** + * 验证登录 + * @param identifier + * @param password + */ + OnlineVerification(String identifier, String password){ + this.onlineVerification = identifier; + this.password = password; + } + + public static OnlineVerification validateLogin(String identifier){ return new OnlineVerification(identifier, UserTags.RegularUsers); } + + public static OnlineVerification validateLogin(String identifier, String password){ + return new OnlineVerification(identifier, password); + } } diff --git a/src/main/java/com/axis/innovators/box/verification/UserTags.java b/src/main/java/com/axis/innovators/box/verification/UserTags.java index 55f966c..4725353 100644 --- a/src/main/java/com/axis/innovators/box/verification/UserTags.java +++ b/src/main/java/com/axis/innovators/box/verification/UserTags.java @@ -1,5 +1,7 @@ package com.axis.innovators.box.verification; +import com.axis.innovators.box.AxisInnovatorsBox; + /** * 用户标签组 * @author tzdwindows 7 @@ -28,5 +30,14 @@ public enum UserTags { /** * 企业用户标签 */ - EnterpriseUsers + EnterpriseUsers; + + private OnlineVerification onlineVerification; + void setUser(OnlineVerification onlineVerification) { + this.onlineVerification = onlineVerification; + } + + public OnlineVerification getUser() { + return onlineVerification; + } } diff --git a/src/main/java/com/axis/innovators/box/verification/VerificationService.java b/src/main/java/com/axis/innovators/box/verification/VerificationService.java index 1eceeac..cdbf950 100644 --- a/src/main/java/com/axis/innovators/box/verification/VerificationService.java +++ b/src/main/java/com/axis/innovators/box/verification/VerificationService.java @@ -4,12 +4,10 @@ package com.axis.innovators.box.verification; * @author tzdwindows 7 */ public class VerificationService { - public static OnlineVerification validateLogin(String identifier, String password) { - return null; - } - public static UserTags determineUserType(OnlineVerification identifier) { - return UserTags.RegularUsers; + UserTags userTags = UserTags.RegularUsers; + userTags.setUser(identifier); + return userTags; } /** diff --git a/state/toolbox.properties b/state/toolbox.properties index e69de29..e6cd80c 100644 --- a/state/toolbox.properties +++ b/state/toolbox.properties @@ -0,0 +1,4 @@ +#Updated configuration +#Fri Mar 07 17:43:24 CST 2025 +password=safasf +verification=aasfsaf