diff --git a/misc/runTest.sh b/misc/runTest.sh old mode 100755 new mode 100644 diff --git a/src/Common/.classpath b/src/Common/.classpath old mode 100755 new mode 100644 diff --git a/src/Common/.project b/src/Common/.project old mode 100755 new mode 100644 diff --git a/src/HTML_Renderer/.classpath b/src/HTML_Renderer/.classpath old mode 100755 new mode 100644 diff --git a/src/HTML_Renderer/.project b/src/HTML_Renderer/.project old mode 100755 new mode 100644 diff --git a/src/HTML_Renderer/COBRA-ACK.txt b/src/HTML_Renderer/COBRA-ACK.txt old mode 100755 new mode 100644 diff --git a/src/HTML_Renderer/COBRA-README.txt b/src/HTML_Renderer/COBRA-README.txt old mode 100755 new mode 100644 diff --git a/src/HTML_Renderer/LICENSE.txt b/src/HTML_Renderer/LICENSE.txt old mode 100755 new mode 100644 diff --git a/src/HTML_Renderer/build.xml b/src/HTML_Renderer/build.xml index 0745489f..4d0fcc78 100644 --- a/src/HTML_Renderer/build.xml +++ b/src/HTML_Renderer/build.xml @@ -72,7 +72,7 @@ - + diff --git a/src/HTML_Renderer/org/w3c/COPYRIGHT.html b/src/HTML_Renderer/org/w3c/COPYRIGHT.html old mode 100755 new mode 100644 diff --git a/src/Platform_Core/org/lobobrowser/gui/FramePanel.java b/src/Platform_Core/org/lobobrowser/gui/FramePanel.java index 623b300b..2f0afb0d 100644 --- a/src/Platform_Core/org/lobobrowser/gui/FramePanel.java +++ b/src/Platform_Core/org/lobobrowser/gui/FramePanel.java @@ -739,6 +739,7 @@ private void navigateLocal(final @NonNull URL url, final String method, final Re } private void navigateLocal(final NavigationEvent event) { + // request Manager reset!!! requestManager.reset(event.getURL()); try { this.dispatchBeforeLocalNavigate(event); @@ -878,6 +879,7 @@ public NavigatorWindowImpl run() { }); final FramePanel newFrame = wcontext.getFramePanel(); + // ATTENTION!!! Frame Panel request manager reset! newFrame.requestManager.reset(url); final UserAgentContext uaContext = new SilentUserAgentContextImpl(newFrame); @@ -1323,6 +1325,7 @@ private void updateContentProperties(final ComponentContent content) { } } + // New request manager. private final RequestManager requestManager = new RequestManager(this); public boolean isRequestPermitted(final Request request) { diff --git a/src/Platform_Core/org/lobobrowser/security/PermissionSystem.java b/src/Platform_Core/org/lobobrowser/security/PermissionSystem.java index f8f141f0..12f25f98 100644 --- a/src/Platform_Core/org/lobobrowser/security/PermissionSystem.java +++ b/src/Platform_Core/org/lobobrowser/security/PermissionSystem.java @@ -16,6 +16,7 @@ import org.lobobrowser.ua.UserAgentContext.RequestKind; public class PermissionSystem { + static enum Permission { Allow, Deny, Undecided; @@ -315,7 +316,12 @@ public void setPermission(final Permission permission) { myPermission = permission; store.storePermissions(hostPattern, requestHost, kindOpt, permission); } - + + // A method that returns the permission in here. + public Permission getMyPermission() { + return myPermission; + } + } } diff --git a/src/Platform_Core/org/lobobrowser/security/PermissionTable.java b/src/Platform_Core/org/lobobrowser/security/PermissionTable.java index 6add87f5..80790d1f 100644 --- a/src/Platform_Core/org/lobobrowser/security/PermissionTable.java +++ b/src/Platform_Core/org/lobobrowser/security/PermissionTable.java @@ -55,6 +55,7 @@ protected int calculateTabWidth(final int tabPlacement, final int tabIndex, fina private static JPanel makeBoardView(final PermissionBoard board, final String[] columnNames, final String[][] requestData, final List buttons, final ChangeListener listener) { + final JPanel grid = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; @@ -72,6 +73,9 @@ private static JPanel makeBoardView(final PermissionBoard board, final String[] for (int i = 0, numRows = board.getRowCount(); i < numRows; i++) { gbc.gridy = i + 1; final PermissionRow row = rows.get(i).getValue(); + + // calculate the values + addRowToGrid(grid, gbc, row, requestData[i], listener, buttons); } } @@ -88,6 +92,7 @@ private static void addRowToGrid(final JPanel grid, final GridBagConstraints gbc if (j == 0) { gbc.weightx = 1d; cell = row.getHostCell(); + } else { gbc.weightx = 0d; cell = row.getRequestCell(j - 1); diff --git a/src/Platform_Core/org/lobobrowser/security/RequestManager.java b/src/Platform_Core/org/lobobrowser/security/RequestManager.java index d485afac..25be0dd6 100644 --- a/src/Platform_Core/org/lobobrowser/security/RequestManager.java +++ b/src/Platform_Core/org/lobobrowser/security/RequestManager.java @@ -26,7 +26,9 @@ import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.JLabel; import javax.swing.JScrollPane; +import javax.swing.SwingConstants; import org.lobobrowser.security.PermissionSystem.Permission; import org.lobobrowser.security.PermissionSystem.PermissionBoard.PermissionRow; @@ -41,7 +43,10 @@ public final class RequestManager { private static final Logger logger = Logger.getLogger(RequestManager.class.getName()); private final NavigatorFrame frame; - + + // Values that track whether or not a request is accepted or rejected. + int accepted; + int rejected; public RequestManager(final NavigatorFrame frame) { this.frame = frame; @@ -110,6 +115,7 @@ private Request rewriteRequest(final Request request) { } } + // A method that determines whether or not a given request is permitted. public boolean isRequestPermitted(final Request request) { final Request finalRequest = rewriteRequest(request); @@ -125,15 +131,25 @@ public boolean isRequestPermitted(final Request request) { if (protocolTest.equals("http") && frameProtocol.equals("https")) { updateCounter(finalRequest.url.getHost(), RequestKind.UnsecuredHTTP); if (!httpPermitted) { + // The request isn't permitted, so it's rejected. + rejected++; return false; } } } - - // dumpCounters(); + + if (permitted == true) { + // The request is permitted, so we increment accepted. + accepted++; + } else { + // The request is not permitted, so we increment rejected. + rejected++; + } return permitted; } else { logger.severe("Unexpected permission system state. Request without context!"); + // The request is not permitted, so we increment rejected. + rejected++; return false; } } @@ -141,6 +157,10 @@ public boolean isRequestPermitted(final Request request) { private void setupPermissionSystem(final String frameHost) { final RequestRuleStore permissionStore = RequestRuleStore.getStore(); final PermissionSystem system = new PermissionSystem(frameHost, permissionStore); + + // Initialize the accept and reject details. + accepted = 0; + rejected = 0; // Prime the boards with atleast one row system.getLastBoard().getRow(frameHost); @@ -174,14 +194,12 @@ public synchronized void reset(final URL frameUrl) { } public void manageRequests(final JComponent initiatorComponent) { - // permissionSystemOpt.ifPresent(r -> r.dump()); final ManageDialog dlg = new ManageDialog(new JFrame(), getFrameURL().map(u -> u.toExternalForm()).orElse("Empty!"), initiatorComponent); dlg.setVisible(true); } private synchronized String[][] getRequestData() { - // hostToCounterMap.keySet().stream().forEach(System.out::println); return hostToCounterMap.entrySet().stream().map(entry -> { final List rowElements = new LinkedList<>(); @@ -219,7 +237,15 @@ public ManageDialog(final JFrame parent, final String title, final JComponent in final JPanel buttonPane = new JPanel(); final JButton button = new JButton("OK"); + + JLabel aLabel = new JLabel("Accepted Requests: " + accepted); + buttonPane.add(aLabel); buttonPane.add(button); + + // Add relevant statistics to button pane. + JLabel oLabel = new JLabel("Total Requests: " + (accepted + rejected)); + buttonPane.add(oLabel); + button.addActionListener(this); getContentPane().add(buttonPane, BorderLayout.SOUTH); setDefaultCloseOperation(DISPOSE_ON_CLOSE); @@ -296,6 +322,11 @@ public void windowActivated(final WindowEvent e) { public void allowAllFirstPartyRequests() { permissionSystemOpt.ifPresent(p -> { final PermissionRow row = p.getLastBoard().getRow(getFrameHost().get()); + // Was the request we are changing initially denied? + if (row.getHostCell().getMyPermission() == Permission.Deny) { + rejected--; + } + accepted++; row.getHostCell().setPermission(Permission.Allow); }); } diff --git a/src/XAMJ_Build/.externalToolBuilders/API_Doc_Builder.launch b/src/XAMJ_Build/.externalToolBuilders/API_Doc_Builder.launch old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/.externalToolBuilders/Ant Builder.launch b/src/XAMJ_Build/.externalToolBuilders/Ant Builder.launch old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/.externalToolBuilders/Installer Builder.launch b/src/XAMJ_Build/.externalToolBuilders/Installer Builder.launch old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/.project b/src/XAMJ_Build/.project old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/build.xml.disabled b/src/XAMJ_Build/build.xml.disabled old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/default-shortcut-spec.xml b/src/XAMJ_Build/default-shortcut-spec.xml old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/install.xml b/src/XAMJ_Build/install.xml old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/re_manifest.mf b/src/XAMJ_Build/re_manifest.mf old mode 100755 new mode 100644 diff --git a/src/XAMJ_Build/windows-shortcut-spec.xml b/src/XAMJ_Build/windows-shortcut-spec.xml old mode 100755 new mode 100644