Revision 38794 branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/wfs/gui/wizards/WFSWizard.java
WFSWizard.java | ||
---|---|---|
6 | 6 |
import java.awt.geom.Rectangle2D; |
7 | 7 |
import java.net.MalformedURLException; |
8 | 8 |
import java.net.URL; |
9 |
import java.util.ArrayList; |
|
9 | 10 |
import java.util.Iterator; |
10 | 11 |
import java.util.List; |
11 | 12 |
import java.util.prefs.Preferences; |
... | ... | |
353 | 354 |
btnConnect.addActionListener(new java.awt.event.ActionListener() { |
354 | 355 |
|
355 | 356 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
357 |
|
|
358 |
/* |
|
359 |
* Check if there is a suspicious parameter in URL |
|
360 |
* The user should approve it |
|
361 |
*/ |
|
362 |
if (!checkServerUrl()) { |
|
363 |
return; |
|
364 |
} |
|
365 |
|
|
356 | 366 |
btnConnect.setEnabled(false); // This avoids multiple |
357 | 367 |
// contiguous actions |
358 | 368 |
|
... | ... | |
379 | 389 |
*/ |
380 | 390 |
thisWFSPanel.callStateChanged(false); |
381 | 391 |
} |
392 |
|
|
393 |
|
|
382 | 394 |
}); |
383 | 395 |
|
384 | 396 |
// If user press the 'Enter' key -> advance |
... | ... | |
662 | 674 |
public WFSServerExplorer getServerExplorer() { |
663 | 675 |
return serverExplorer; |
664 | 676 |
} |
677 |
|
|
665 | 678 |
|
679 |
|
|
666 | 680 |
/** |
667 | 681 |
* Returns the rectangle that contains all the others |
668 | 682 |
* |
... | ... | |
801 | 815 |
return false; |
802 | 816 |
} |
803 | 817 |
} |
818 |
|
|
819 |
|
|
820 |
|
|
821 |
/** |
|
822 |
* This method suggests user to remove suspicious parameters |
|
823 |
* such as "request=..." |
|
824 |
*/ |
|
825 |
private boolean checkServerUrl() { |
|
826 |
|
|
827 |
Object sel_obj = cmbHost.getModel().getSelectedItem(); |
|
828 |
if (sel_obj != null) { |
|
829 |
|
|
830 |
String url = sel_obj.toString(); |
|
831 |
List<String> suspi = getSuspiciousParameters(url); |
|
832 |
if (suspi != null && suspi.size() > 0) { |
|
833 |
if (userWantsToContinue(suspi)) { |
|
834 |
return true; |
|
835 |
} |
|
836 |
} |
|
837 |
} |
|
838 |
return false; |
|
839 |
} |
|
840 |
|
|
841 |
/** |
|
842 |
* @param suspi |
|
843 |
* @return |
|
844 |
*/ |
|
845 |
private boolean userWantsToContinue(List<String> suspi) { |
|
846 |
|
|
847 |
String tit = PluginServices.getText(this, "server"); |
|
848 |
String msg = PluginServices.getText(this, "Dangerous_parameters_found_Continue_question"); |
|
849 |
int len = suspi.size(); |
|
850 |
msg = msg + " '"; |
|
851 |
for (int i=0; i<(len-1); i++) { |
|
852 |
msg = msg + suspi.get(i) + ", "; |
|
853 |
} |
|
854 |
msg = msg + suspi.get(len-1) + "'"; |
|
855 |
|
|
856 |
int user_opt = JOptionPane.showConfirmDialog( |
|
857 |
thisWFSPanel, msg, tit, JOptionPane.YES_NO_OPTION); |
|
858 |
|
|
859 |
return user_opt == JOptionPane.YES_OPTION; |
|
860 |
} |
|
861 |
|
|
862 |
/** |
|
863 |
* @param url |
|
864 |
* @return |
|
865 |
*/ |
|
866 |
private List<String> getSuspiciousParameters(String _url) { |
|
867 |
|
|
868 |
String str_url = _url; |
|
869 |
int len = SUSPICIOUS_PARAMS.length; |
|
870 |
String item = null; |
|
871 |
ArrayList<String> resp = new ArrayList<String>(); |
|
872 |
for (int i=0; i<len; i++) { |
|
873 |
item = SUSPICIOUS_PARAMS[i]; |
|
874 |
item = "&" + item + "="; |
|
875 |
if (str_url.indexOf(item) != 1) { |
|
876 |
resp.add(SUSPICIOUS_PARAMS[i]); |
|
877 |
} |
|
878 |
} |
|
879 |
return resp; |
|
880 |
} |
|
881 |
|
|
882 |
private static final String[] SUSPICIOUS_PARAMS = |
|
883 |
{ "request" }; // , ""}; |
|
804 | 884 |
} |
Also available in: Unified diff