Commit 7cbdfe05 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added validation of IP addressed. JM-380

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2714 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2c9c3550
......@@ -17,6 +17,7 @@
org.jivesoftware.util.*"
errorPage="error.jsp"
%>
<%@ page import="java.util.regex.Pattern"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -54,12 +55,17 @@
authHandler.setAllowAnonymous(anonLogin);
// Build a Map with the allowed IP addresses
Pattern pattern = Pattern.compile("(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)" +
"(?:(?:\\*|25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){2}" +
"(?:\\*|25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)");
Map<String,String> newMap = new HashMap<String,String>();
StringTokenizer tokens = new StringTokenizer(allowedIPs, ", ");
while (tokens.hasMoreTokens()) {
String address = tokens.nextToken().trim();
if (pattern.matcher(address).matches()) {
newMap.put(address, "");
}
}
ClientSession.setAllowedIPs(newMap);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment