}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
if (getResourceName() != null && isCommiting()) {
ActionErrors errs = super.validate(mapping, request);
AbstractWizardSequence seq = getWizardSequence(request);
if (!Util.isNullOrTrimmedBlank(sourceInterface)) {
/**
* For remote tunnels, the listening interface must be a valid
* IP address of a network interface on this server
*/
if(getTunnelType() == TransportType.REMOTE_TUNNEL_ID) {
if(!sourceInterface.trim().equals("0.0.0.0") &&
!sourceInterface.trim().equals("127.0.0.2"))
try {
InetAddress addr = InetAddress.getByName(sourceInterface);
NetworkInterface nif = NetworkInterface.getByInetAddress(addr);
if(nif == null) {
throw new Exception();
}
}
catch(Exception e) {
errs.add(Globals.ERROR_KEY, new ActionMessage("tunnelWizard.tunnelDetails.error.invalidRemoteSourceInterface"));
}
}
else {
/**
* For local tunnels, we do not know what will be a valid IP
* address until the client is running so all we can do
* is validate that it looks like an IP address
*/
if(!IPV4AddressValidator.isIpAddressExpressionValid(sourceInterface)) {
errs.add(Globals.ERROR_KEY, new ActionMessage("tunnelWizard.tunnelDetails.error.invalidLocalSourceInterface"));
}
}
}
try {
int port = Integer.valueOf(sourcePort).intValue();
if(port < 0 || port > 65535) {
throw new IllegalArgumentException();
}
} catch (Exception e) {
errs.add(Globals.ERROR_KEY, new BundleActionMessage(seq.getCurrentPageForm().getResourceBundle(), seq
.getCurrentPageForm().getResourcePrefix()
+ ".error.sourcePortNotInteger"));
}
try {
int port = Integer.valueOf(destinationPort).intValue();
if(port < 1 || port > 65535) {
throw new IllegalArgumentException();
}
} catch (Exception e) {
errs.add(Globals.ERROR_KEY, new BundleActionMessage(seq.getCurrentPageForm().getResourceBundle(), seq
.getCurrentPageForm().getResourcePrefix()
+ ".error.destinationPortNotInteger"));
}
if (destinationHost == null || destinationHost.equals("")) {
errs.add(Globals.ERROR_KEY, new BundleActionMessage(seq.getCurrentPageForm().getResourceBundle(), seq
.getCurrentPageForm().getResourcePrefix()
+ ".error.noDestinationHost"));
}
else{
if(!HostnameOrIPAddressWithReplacementsValidator.isValidAsHostOrIp(destinationHost)) {
errs.add(Globals.ERROR_KEY, new ActionMessage("tunnelWizard.tunnelDetails.error.invalidHost"));
}
}
if (transport.equals(TransportType.UDP_TUNNEL) && tunnelType == TransportType.REMOTE_TUNNEL_ID) {
errs.add(Globals.ERROR_KEY, new BundleActionMessage(seq.getCurrentPageForm().getResourceBundle(), seq
.getCurrentPageForm().getResourcePrefix()
+ ".error.remote.udp"));
}
return errs;