Changeset 535
- Timestamp:
- 11/26/13 12:22:37 (10 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Browser.java
r513 r535 16 16 import java.awt.event.WindowStateListener; 17 17 import java.io.File; 18 import java.net.Authenticator; 18 19 import java.net.URL; 19 20 import java.util.ArrayList; … … 31 32 import org.expeditee.importer.FrameDNDTransferHandler; 32 33 import org.expeditee.io.ItemSelection; 34 import org.expeditee.io.ProxyAuth; 33 35 import org.expeditee.items.Item; 34 36 import org.expeditee.items.widgets.WidgetCacheManager; … … 60 62 61 63 public static Browser _theBrowser = null; 64 65 public static ProxyAuth proxyAuth = new ProxyAuth(); 62 66 63 67 private MouseEventRouter _mouseEventRouter; … … 99 103 - _theBrowser.getOrigin().y; 100 104 _initComplete = true; 105 106 Authenticator.setDefault(proxyAuth); 101 107 } 102 108 }); -
trunk/src/org/expeditee/gui/FrameUtils.java
r529 r535 707 707 } else if (attribute.equals("colorwheel")) { 708 708 Item.COLOR_WHEEL = getColorWheel(item); 709 } else if (attribute.equals("proxy")) { 710 proxySetup(item); 709 } else if (attribute.equals("http_proxy")) { 710 httpProxySetup(item); 711 } else if (attribute.equals("https_proxy")) { 712 httpsProxySetup(item); 711 713 } else if (attribute.equals("fillcolorwheel")) { 712 714 Item.FILL_COLOR_WHEEL = getColorWheel(item); … … 738 740 739 741 /** 740 * Loads proxy config from a frame 741 * To be used with authentication code to allow web browsers to work through a proxy 742 * Loads http proxy config from a frame 742 743 * @author jts21 743 744 */ 744 private static void proxySetup(Item item) {745 private static void httpProxySetup(Item item) { 745 746 Frame child = item.getChild(); 746 // FrameUtils.Parse(child);747 String host = null, port = null, user = null, pass = null; 747 748 Password passwordWidget = null; 748 749 for(Item config : child.getAllItems()) { 749 // System.out.println(config.toString());750 750 if(config instanceof Text) { 751 751 String str = config.getText().trim().toLowerCase(); 752 752 if(str.startsWith("http_host:")) { 753 System.out.println(str.substring(10).trim()); 753 if(host != null) { 754 MessageBay.displayMessage("http_host was defined multiple times!", Color.ORANGE); 755 } 756 host = str.substring(10).trim(); 754 757 } else if(str.startsWith("http_port:")) { 755 System.out.println(str.substring(10).trim()); 756 } else if(str.startsWith("https_host:")) { 757 System.out.println(str.substring(11).trim()); 758 } else if(str.startsWith("https_port:")) { 759 System.out.println(str.substring(11).trim()); 760 } else if(str.startsWith("proxy_user:")) { 761 System.out.println(str.substring(11).trim()); 762 } else if(str.startsWith("proxy_pass:")) { // unencrypted password 763 System.out.println(str.substring(11).trim()); 758 if(port!= null) { 759 MessageBay.displayMessage("http_port was defined multiple times!", Color.ORANGE); 760 } 761 port = str.substring(10).trim(); 762 } else if(str.startsWith("http_user:")) { 763 if(user != null) { 764 MessageBay.displayMessage("http_user was defined multiple times!", Color.ORANGE); 765 } 766 user = str.substring(11).trim(); 767 } else if(str.startsWith("http_pass:")) { // unencrypted password 768 if(pass != null) { 769 MessageBay.displayMessage("http_pass was defined multiple times!", Color.ORANGE); 770 } 771 pass = str.substring(11).trim(); 764 772 } else if(str.startsWith("@iw:")) { // widget 765 773 // check if it's a password widget … … 768 776 try { 769 777 passwordWidget = (Password) InteractiveWidget.createWidget((Text)config); 770 System.out.println(passwordWidget.getPassword()); 778 if(pass != null) { 779 MessageBay.displayMessage("http_pass was defined multiple times!", Color.ORANGE); 780 } 781 pass = passwordWidget.getPassword(); 771 782 } catch (Exception e) { 772 783 e.printStackTrace(); … … 776 787 } 777 788 } else if(config instanceof WidgetCorner || config instanceof WidgetEdge) { 778 // System.out.println("BLAH");779 789 if(passwordWidget == null) { 780 790 InteractiveWidget iw; … … 787 797 passwordWidget = (Password) iw; 788 798 } 789 System.out.println(passwordWidget.getPassword()); 790 } 791 } 792 } 793 } 799 if(pass != null) { 800 MessageBay.displayMessage("http_pass was defined multiple times!", Color.ORANGE); 801 } 802 pass = passwordWidget.getPassword(); 803 } 804 } 805 } 806 System.setProperty("http.proxyHost", host); 807 System.setProperty("http.proxyPort", port); 808 Browser.proxyAuth.setupHTTP(user, pass); 809 } 810 811 /** 812 * Loads https proxy config from a frame 813 * @author jts21 814 */ 815 private static void httpsProxySetup(Item item) { 816 Frame child = item.getChild(); 817 if(child == null) { 818 return; 819 } 820 String host = null, port = null, user = null, pass = null; 821 Password passwordWidget = null; 822 for(Item config : child.getAllItems()) { 823 if(config instanceof Text) { 824 String str = config.getText().trim().toLowerCase(); 825 if(str.startsWith("http_host:")) { 826 if(host != null) { 827 MessageBay.displayMessage("http_host was defined multiple times!", Color.ORANGE); 828 } 829 host = str.substring(10).trim(); 830 } else if(str.startsWith("http_port:")) { 831 if(port!= null) { 832 MessageBay.displayMessage("http_port was defined multiple times!", Color.ORANGE); 833 } 834 port = str.substring(10).trim(); 835 } else if(str.startsWith("http_user:")) { 836 if(user != null) { 837 MessageBay.displayMessage("http_user was defined multiple times!", Color.ORANGE); 838 } 839 user = str.substring(11).trim(); 840 } else if(str.startsWith("http_pass:")) { // unencrypted password 841 if(pass != null) { 842 MessageBay.displayMessage("http_pass was defined multiple times!", Color.ORANGE); 843 } 844 pass = str.substring(11).trim(); 845 } else if(str.startsWith("@iw:")) { // widget 846 // check if it's a password widget 847 if(str.substring(4).trim().startsWith("org.expeditee.items.widgets.password")) { 848 if(passwordWidget == null) { 849 try { 850 passwordWidget = (Password) InteractiveWidget.createWidget((Text)config); 851 if(pass != null) { 852 MessageBay.displayMessage("http_pass was defined multiple times!", Color.ORANGE); 853 } 854 pass = passwordWidget.getPassword(); 855 } catch (Exception e) { 856 e.printStackTrace(); 857 } 858 } 859 } 860 } 861 } else if(config instanceof WidgetCorner || config instanceof WidgetEdge) { 862 if(passwordWidget == null) { 863 InteractiveWidget iw; 864 if(config instanceof WidgetCorner) { 865 iw = ((WidgetCorner)config).getWidgetSource(); 866 } else { 867 iw = ((WidgetEdge)config).getWidgetSource(); 868 } 869 if(iw instanceof Password) { 870 passwordWidget = (Password) iw; 871 } 872 if(pass != null) { 873 MessageBay.displayMessage("http_pass was defined multiple times!", Color.ORANGE); 874 } 875 pass = passwordWidget.getPassword(); 876 } 877 } 878 } 879 System.setProperty("https.proxyHost", host); 880 System.setProperty("https.proxyPort", port); 881 Browser.proxyAuth.setupHTTPS(user, pass); 882 } 883 884 794 885 795 886 private static List<Text> getStyle(Frame child) {
Note:
See TracChangeset
for help on using the changeset viewer.