Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 1ad2221f authored by Guillaume Thomazon's avatar Guillaume Thomazon
Browse files

Add validation IP.

git-svn-id: https://scm.gforge.inria.fr/authscm/ycadoret/svn/gazelle/Maven/gazelle-proxy/trunk@33598 356b4b1a-1d2b-0410-8bf1-ffa24008f01e
parent 8ff5b497
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,17 @@ import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.Redirect;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Name("messagesBean")
@Scope(ScopeType.PAGE)
public class MessagesBean {
private static Logger log = LoggerFactory.getLogger(MessagesBean.class);
private transient HibernateMessageDataModel<AbstractMessage> messageDataModel;
private MessageFilterStandard messageFilterStandard;
......@@ -148,6 +154,20 @@ public class MessagesBean {
return messageFilterStandard.getDicomRequestedSopClassUID();
}
public void validateDate() {
Date dateFrom = messageFilterStandard.getDateFrom();
Date dateTo = messageFilterStandard.getDateTo();
if ((dateFrom != null) && (dateTo != null)) {
if (dateTo.before(dateFrom)) {
log.error("DateFrom is after DateTo please correct !");
StatusMessages.instance().addToControlFromResourceBundleOrDefault("dateto",
StatusMessage.Severity.ERROR, "test", "Date to is before date from, please correct !");
messageFilterStandard.setDateTo(dateFrom);
}
}
}
public void setDicomRequestedSopClassUID(String dicomRequestedSopClassUID) {
messageFilterStandard.setDicomRequestedSopClassUID(dicomRequestedSopClassUID);
}
......@@ -223,7 +243,7 @@ public class MessagesBean {
}
return null;
}
public void setConnectionId(Integer connectionId) {
messageFilterStandard.setConnectionId(connectionId);
}
......@@ -265,4 +285,49 @@ public class MessagesBean {
messageFilterStandard.setResponderPort(responderPort);
}
public boolean validateInitiatorIP() {
String ipPattern = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
String hostname = getInitiatorIP();
if (hostname != null) {
if (hostname.matches(ipPattern)) {
return true;
} else {
log.error("You must enter a good format IP address !");
StatusMessages.instance().addToControlFromResourceBundleOrDefault("initiatorIP",
StatusMessage.Severity.ERROR, "test", "You must enter a valide IP address !");
return false;
}
} else {
log.error("You must enter a good format IP address !");
StatusMessages.instance().addToControlFromResourceBundleOrDefault("initiatorIP",
StatusMessage.Severity.ERROR, "test", "You must enter a valide IP address !");
return false;
}
}
public boolean validateResponderIP() {
String ipPattern = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
String hostname = null;
hostname = getResponderIP();
if (hostname != null) {
if (hostname.matches(ipPattern)) {
return true;
} else {
log.error("You must enter a good format IP address !");
StatusMessages.instance().addToControlFromResourceBundleOrDefault("responderIP",
StatusMessage.Severity.ERROR, "test", "You must enter a valide IP address !");
return false;
}
} else {
log.error("You must enter a good format IP address !");
StatusMessages.instance().addToControlFromResourceBundleOrDefault("responderIP",
StatusMessage.Severity.ERROR, "test", "You must enter a valide IP address !");
return false;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment