fixes bug#21427

qua:junia
dev:wallace

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@105403 d1611594-4594-4d17-8e1d-87c2c4800839
master
changelogweb 2021-02-19 12:59:16 +00:00
parent efcc11fd14
commit 69742dc180
1 changed files with 46 additions and 13 deletions

View File

@ -10,6 +10,7 @@ import java.util.List;
import javax.servlet.ServletContext;
import javax.sql.DataSource;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.flywaydb.core.Flyway;
import org.quartz.JobDetail;
@ -138,16 +139,57 @@ public class MyAppInit implements org.zkoss.zk.ui.util.WebAppInit {
ApplicationProperties.getInstance().singletonImage();
}
/**
* Se nenhuma das constantes abaixo estiver configurada, o serviço de geração é iniciado.
*
* SERVIDOR_GENERACION_CORRIDA_EXCLUSIVO : Tem o IP aonde será liberado a geração de corrida. Somente nesse IP
*
* SERVIDOR_EXCEPCION_GENERACION_CORRIDA: Tem o IP aonde não será gerado a corrida. Somente esse IP
*
* * @return
*/
private boolean ipBloqueadoGeracaoServico() {
Constante constanteServidorExclusivo= getConstanteService().buscarPorNomeConstante("SERVIDOR_GENERACION_CORRIDA_EXCLUSIVO");
Constante constanteServidorException = getConstanteService().buscarPorNomeConstante("SERVIDOR_EXCEPCION_GENERACION_CORRIDA");
String ipConstante = constanteServidorException == null ? "" : constanteServidorException.getValorconstante();
log.info(" IP Constante: " + ipConstante);
String ipConstanteExcepcion = constanteServidorException == null ? "" : constanteServidorException.getValorconstante();
String ipConstanteExclusivo = constanteServidorExclusivo == null ? "" : constanteServidorExclusivo.getValorconstante();
if (ipConstante.equals("")) {
log.info(" IP Constante Excepcion: " + ipConstanteExcepcion);
log.info(" IP Constante Exclusivo: " + ipConstanteExclusivo);
if (StringUtils.isBlank(ipConstanteExclusivo) && StringUtils.isBlank(ipConstanteExcepcion)){
return false;
}
List<String> lsIps = getListIp();
if (StringUtils.isNotBlank(ipConstanteExclusivo)){
if (lsIps.contains(ipConstanteExclusivo)) {
log.info(" IP não bloqueado. Liberado exclusivamente. ");
return false;
}
}
if (StringUtils.isNotBlank(ipConstanteExcepcion)){
if (lsIps.contains(ipConstanteExcepcion)) {
log.info(" IP bloqueado. Bloqueado por excecao. ");
return true;
}
}
return false;
}
private List<String> getListIp() {
List<String> lsIps = new ArrayList<String>();
String ipExternalAWS = IPValidatorUtileria.getIpExternalAWS();
@ -159,16 +201,7 @@ public class MyAppInit implements org.zkoss.zk.ui.util.WebAppInit {
if (ipExternalAWS!=null){lsIps.add(ipExternalAWS);}
if (ip!=null){lsIps.add(ip);}
if (lsIps.contains(ipConstante)) {
log.info(" IP bloqueado");
return true;
} else {
return false;
}
return lsIps;
}
private Integer[] horaExecucion(String nombConstante) {