( IContextMenuInvocation invocation )
| 129 | } |
| 130 | |
| 131 | @Override |
| 132 | public List<JMenuItem> createMenuItems ( IContextMenuInvocation invocation ) { |
| 133 | // this.currentInvocation = invocation; |
| 134 | JMenuItem jMenuItem = new JMenuItem("Decode-Autodecoder"); |
| 135 | JMenuItem jMenuItem2 = new JMenuItem("Encode-Autodecoder"); |
| 136 | List<JMenuItem> jMenuItemList = new ArrayList<>(); |
| 137 | jMenuItemList.add(jMenuItem); |
| 138 | jMenuItemList.add(jMenuItem2); |
| 139 | |
| 140 | // 监听上下文菜单点击事件 |
| 141 | jMenuItem.addActionListener(a -> { // 解密 |
| 142 | int[] selectedIndex = invocation.getSelectionBounds(); |
| 143 | IHttpRequestResponse req = invocation.getSelectedMessages()[0]; |
| 144 | byte[] request = req.getRequest(); |
| 145 | byte[] param = new byte[selectedIndex[1] - selectedIndex[0]]; |
| 146 | System.arraycopy(request, selectedIndex[0], param, 0, selectedIndex[1] - selectedIndex[0]); |
| 147 | String selectString = new String(param); |
| 148 | try { |
| 149 | ClickEncodeDecode.Decode(invocation,selectString); |
| 150 | } catch (Exception e) { |
| 151 | e.printStackTrace(); |
| 152 | } |
| 153 | // stdout.println(selectString);// 获取选中的内容 |
| 154 | }); |
| 155 | |
| 156 | // 监听上下文菜单点击事件 |
| 157 | jMenuItem2.addActionListener(a -> { // 加密 |
| 158 | int[] selectedIndex = invocation.getSelectionBounds(); |
| 159 | IHttpRequestResponse req = invocation.getSelectedMessages()[0]; |
| 160 | byte[] request = req.getRequest(); |
| 161 | byte[] param = new byte[selectedIndex[1] - selectedIndex[0]]; |
| 162 | System.arraycopy(request, selectedIndex[0], param, 0, selectedIndex[1] - selectedIndex[0]); |
| 163 | String selectString = new String(param); |
| 164 | try { |
| 165 | ClickEncodeDecode.Encode(invocation,selectString); |
| 166 | } catch (Exception e) { |
| 167 | e.printStackTrace(); |
| 168 | } |
| 169 | }); |
| 170 | return jMenuItemList; |
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse iHttpRequestResponse) { //处理请求包 |
nothing calls this directly
no test coverage detected