fixes bug#23184

dev:lucas

qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@109163 d1611594-4594-4d17-8e1d-87c2c4800839
master
lucas.taia 2021-10-15 18:36:10 +00:00
parent 256580db71
commit b9aca41faa
8 changed files with 232 additions and 5 deletions

View File

@ -71,7 +71,9 @@ public class EditarCustomController extends MyGenericForwardComposer {
cmbTipo.setDisabled(Boolean.TRUE); cmbTipo.setDisabled(Boolean.TRUE);
cmbSistema.setValue(SistemaEnum.getSistema(custom.getSistema()).toString()); cmbSistema.setValue(SistemaEnum.getSistema(custom.getSistema()).toString());
cmbTipo.setValue(CustomTipo.getCustomTipo(custom.getTipo()).toString()); if (custom.getTipo() != null) {
cmbTipo.setValue(CustomTipo.getCustomTipo(custom.getTipo()).toString());
}
} }

View File

@ -4,8 +4,25 @@
*/ */
package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos; package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
import java.security.UnrecoverableEntryException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,8 +42,10 @@ import org.zkforge.ckez.CKeditor;
import org.zkoss.util.resource.Labels; import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.UiException;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.UploadEvent;
import org.zkoss.zkplus.databind.BindingListModel; import org.zkoss.zkplus.databind.BindingListModel;
import org.zkoss.zkplus.databind.BindingListModelList; import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.Button; import org.zkoss.zul.Button;
@ -36,9 +55,11 @@ import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Decimalbox; import org.zkoss.zul.Decimalbox;
import org.zkoss.zul.Image; import org.zkoss.zul.Image;
import org.zkoss.zul.Intbox; import org.zkoss.zul.Intbox;
import org.zkoss.zul.Label;
import org.zkoss.zul.Messagebox; import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Radio; import org.zkoss.zul.Radio;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.Tab;
import org.zkoss.zul.Textbox; import org.zkoss.zul.Textbox;
import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema; import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema;
@ -54,6 +75,7 @@ import com.rjconsultores.ventaboletos.entidad.EmpresaEmail;
import com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig; import com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig;
import com.rjconsultores.ventaboletos.entidad.EmpresaEmailFlexBus; import com.rjconsultores.ventaboletos.entidad.EmpresaEmailFlexBus;
import com.rjconsultores.ventaboletos.entidad.EmpresaImposto; import com.rjconsultores.ventaboletos.entidad.EmpresaImposto;
import com.rjconsultores.ventaboletos.entidad.EmpresaSaferConfig;
import com.rjconsultores.ventaboletos.entidad.Estado; import com.rjconsultores.ventaboletos.entidad.Estado;
import com.rjconsultores.ventaboletos.entidad.FormaPago; import com.rjconsultores.ventaboletos.entidad.FormaPago;
import com.rjconsultores.ventaboletos.entidad.InscricaoEstadual; import com.rjconsultores.ventaboletos.entidad.InscricaoEstadual;
@ -68,6 +90,7 @@ import com.rjconsultores.ventaboletos.service.EmpresaEmailConfigService;
import com.rjconsultores.ventaboletos.service.EmpresaEmailFlexBusService; import com.rjconsultores.ventaboletos.service.EmpresaEmailFlexBusService;
import com.rjconsultores.ventaboletos.service.EmpresaEmailService; import com.rjconsultores.ventaboletos.service.EmpresaEmailService;
import com.rjconsultores.ventaboletos.service.EmpresaImpostoService; import com.rjconsultores.ventaboletos.service.EmpresaImpostoService;
import com.rjconsultores.ventaboletos.service.EmpresaSaferConfigService;
import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.EstadoService; import com.rjconsultores.ventaboletos.service.EstadoService;
import com.rjconsultores.ventaboletos.service.FormaPagoService; import com.rjconsultores.ventaboletos.service.FormaPagoService;
@ -120,14 +143,16 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
private EmpresaEmailService empresaEmailService; private EmpresaEmailService empresaEmailService;
@Autowired @Autowired
private EmpresaEmailConfigService empresaEmailConfigService; private EmpresaEmailConfigService empresaEmailConfigService;
@Autowired @Autowired
private EmpresaEmailFlexBusService empresaEmailFlexBusService; private EmpresaEmailFlexBusService empresaEmailFlexBusService;
@Autowired
private EmpresaSaferConfigService empresaSaferConfigService;
private Empresa empresa; private Empresa empresa;
private EmpresaEmail empresaEmail; private EmpresaEmail empresaEmail;
private EmpresaEmailConfig empresaEmailConfig; private EmpresaEmailConfig empresaEmailConfig;
private EmpresaEmailFlexBus empresaEmailFlexBus; private EmpresaEmailFlexBus empresaEmailFlexBus;
private EmpresaSaferConfig empresaSaferConfig;
private MyListbox empresaList; private MyListbox empresaList;
private MyTextbox txtNome; private MyTextbox txtNome;
private MyTextbox txtCNPJ; private MyTextbox txtCNPJ;
@ -331,6 +356,12 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
private Decimalbox txtIrkPadrao; private Decimalbox txtIrkPadrao;
private Label lblCertificado;
private Textbox txtSenhaCertificado;
private Textbox txtPartnerId;
private Textbox txtContractId;
private byte[] certificado;
private Tab tabSafer;
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
@ -354,6 +385,7 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
if (empresa != null && empresa.getEmpresaId() != null) { if (empresa != null && empresa.getEmpresaId() != null) {
empresaEmail = empresaEmailService.buscarPorEmpresa(empresa); empresaEmail = empresaEmailService.buscarPorEmpresa(empresa);
empresaEmailConfig = empresaEmailConfigService.buscarPorEmpresa(empresa); empresaEmailConfig = empresaEmailConfigService.buscarPorEmpresa(empresa);
empresaSaferConfig = empresaSaferConfigService.buscarPorEmpresa(empresa);
} }
if (empresa != null && empresa.getEmpresaId() != null) { if (empresa != null && empresa.getEmpresaId() != null) {
@ -385,7 +417,6 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
} else { } else {
chkAutenticacao.setChecked(true); chkAutenticacao.setChecked(true);
} }
if (empresaEmailFlexBus != null) { if (empresaEmailFlexBus != null) {
if(empresaEmailFlexBus.getIndAutenticacao()){ if(empresaEmailFlexBus.getIndAutenticacao()){
chkAutenticacaoFlexBus.setChecked(true); chkAutenticacaoFlexBus.setChecked(true);
@ -398,6 +429,21 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
chkAutenticacaoFlexBus.setChecked(true); chkAutenticacaoFlexBus.setChecked(true);
} }
if (empresaSaferConfig != null) {
txtPartnerId.setText(empresaSaferConfig.getPartnerId());
txtContractId.setText(empresaSaferConfig.getContractId());
txtSenhaCertificado.setText(empresaSaferConfig.getSenha());
certificado = empresaSaferConfig.getCertificado();
if(certificado != null){
InputStream certStream = new ByteArrayInputStream(certificado);
if (certStream != null) {
lblCertificado.setValue(getCerticateInfo(certStream));
}
}
}
mostrarAbaSafer();
if (empresa.getIndfechatarifa() == null) { if (empresa.getIndfechatarifa() == null) {
rdgFechaSalida.setChecked(Boolean.TRUE); rdgFechaSalida.setChecked(Boolean.TRUE);
} else if (empresa.getIndfechatarifa()) { } else if (empresa.getIndfechatarifa()) {
@ -904,6 +950,16 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
preencheInformacoesEmpresaConfig(); preencheInformacoesEmpresaConfig();
empresaEmailConfigService.actualizacion(empresaEmailConfig); empresaEmailConfigService.actualizacion(empresaEmailConfig);
} }
if (empresaSaferConfig == null) {
empresaSaferConfig = new EmpresaSaferConfig();
empresaSaferConfig.setEmpresa(empresa);
preencheInformacoesSaferConfig();
empresaSaferConfig = empresaSaferConfigService.suscribir(empresaSaferConfig);
} else {
preencheInformacoesSaferConfig();
empresaSaferConfigService.actualizacion(empresaSaferConfig);
}
Messagebox.show(Labels.getLabel("editarEmpresaController.MSG.suscribirOK"), Messagebox.show(Labels.getLabel("editarEmpresaController.MSG.suscribirOK"),
Labels.getLabel("editarEmpresaController.window.title"), Labels.getLabel("editarEmpresaController.window.title"),
@ -948,6 +1004,12 @@ public class EditarEmpresaController extends MyGenericForwardComposer {
empresaEmailFlexBus.setIndAutenticacao(chkAutenticacaoFlexBus.isChecked()); empresaEmailFlexBus.setIndAutenticacao(chkAutenticacaoFlexBus.isChecked());
} }
private void preencheInformacoesSaferConfig() {
empresaSaferConfig.setPartnerId(txtPartnerId.getValue());
empresaSaferConfig.setContractId(txtContractId.getValue());
empresaSaferConfig.setSenha(txtSenhaCertificado.getValue());
empresaSaferConfig.setCertificado(certificado);
}
private boolean validarEmail() { private boolean validarEmail() {
if (txtEmail.getText() == null || txtEmail.getText().isEmpty()) { if (txtEmail.getText() == null || txtEmail.getText().isEmpty()) {
@ -1958,6 +2020,76 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException {
validarCPFCNPJ(numDoc); validarCPFCNPJ(numDoc);
} }
public void uploadFile(UploadEvent event) {
org.zkoss.util.media.Media media = event.getMedia();
try {
String info = getCerticateInfo(media.getStreamData());
if (info != null) {
certificado = media.getByteData();
lblCertificado.setValue(info);
} else {
Messagebox.show(
Labels.getLabel("editarMarcaController.MSG.errorIMG") + " " + media,
Labels.getLabel("editarEmpresaController.window.title"),
Messagebox.OK, Messagebox.ERROR);
}
} catch (Exception ex) {
log.error(ex);
throw UiException.Aide.wrap(ex);
}
}
private String getCerticateInfo(InputStream cerFileStream) throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, UnrecoverableEntryException, InvalidKeyException, SignatureException {
Certificate certificate = null;
PrivateKey pvtkey = null;
Enumeration<String> aliasList;
String alias;
String certPassword = txtSenhaCertificado.getValue();
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(cerFileStream, certPassword.toCharArray());
aliasList = keyStore.aliases();
while (aliasList.hasMoreElements()) {
alias = aliasList.nextElement();
KeyStore.ProtectionParameter entryPassword = new KeyStore.PasswordProtection(certPassword.toCharArray());
KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(alias, entryPassword);
pvtkey = privateKeyEntry.getPrivateKey();
X509Certificate c = (X509Certificate) keyStore.getCertificate(alias);
PrivateKey privKey = pvtkey;
Signature sign = Signature.getInstance("SHA256withRSA");
sign.initSign(privKey);
byte[] bytes = "TestSign".getBytes();
sign.update(bytes);
byte[] signature = sign.sign();
PublicKey pubKey = c.getPublicKey();
Signature verify = Signature.getInstance("SHA256withRSA");
verify.initVerify(pubKey);
verify.update(bytes);
boolean signatureVerified = verify.verify(signature);
if (signatureVerified) {
SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String dadosCertificado = "Certificado: OK" + "\n"
+ "Validade: " + fmt.format(c.getNotBefore()) + " até " + fmt.format(c.getNotAfter()) +
"\n" + "Tipo: " + c.getVersion() + "\n" +
c.getSubjectDN().getName();
return dadosCertificado;
}
}
return null;
}
private void mostrarAbaSafer() {
if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.INTEGRACION_SAFER.getDescricao())) {
tabSafer.setVisible(true);
}
}
private boolean validarCPFCNPJ(String numDoc) { private boolean validarCPFCNPJ(String numDoc) {
try { try {
if(numDoc == null) { if(numDoc == null) {

View File

@ -253,7 +253,8 @@ public class EditarPricingController extends PricingController {
private Radio rdOcupacaoTrechoSim; private Radio rdOcupacaoTrechoSim;
private Radio rdOcupacaoTrechoNao; private Radio rdOcupacaoTrechoNao;
private Checkbox chkIndSafer;
private void clearCombobox(Combobox combobox) { private void clearCombobox(Combobox combobox) {
int size = combobox.getItemCount(); int size = combobox.getItemCount();
@ -581,6 +582,10 @@ public class EditarPricingController extends PricingController {
chkIndSomenteAssentoSugerido.setChecked(pricing.getIndSomenteAssentoSugerido()); chkIndSomenteAssentoSugerido.setChecked(pricing.getIndSomenteAssentoSugerido());
chkIndPricingDividirIdaEVolta.setChecked(pricing.getIndPricingDividirIdaEVolta()); chkIndPricingDividirIdaEVolta.setChecked(pricing.getIndPricingDividirIdaEVolta());
if (pricing.getIndSafer() != null) {
chkIndSafer.setChecked(pricing.getIndSafer());
}
if (lsPricingImporte.size() > 0) { if (lsPricingImporte.size() > 0) {
radioImp.setChecked(true); radioImp.setChecked(true);
onClick$radioImp(null); onClick$radioImp(null);
@ -1018,6 +1023,7 @@ public class EditarPricingController extends PricingController {
pricing.setIndOcupacaoPorTrecho(rdOcupacaoTrechoSim.isChecked()); pricing.setIndOcupacaoPorTrecho(rdOcupacaoTrechoSim.isChecked());
pricing.setIndSomenteAssentoSugerido(chkIndSomenteAssentoSugerido.isChecked()); pricing.setIndSomenteAssentoSugerido(chkIndSomenteAssentoSugerido.isChecked());
pricing.setIndSafer(chkIndSafer.isChecked());
pricing.setIndPricingDividirIdaEVolta(chkIndPricingDividirIdaEVolta.isChecked()); pricing.setIndPricingDividirIdaEVolta(chkIndPricingDividirIdaEVolta.isChecked());

View File

@ -479,6 +479,7 @@
<value>com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria</value> <value>com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria</value>
<value>com.rjconsultores.ventaboletos.entidad.EmpresaEmail</value> <value>com.rjconsultores.ventaboletos.entidad.EmpresaEmail</value>
<value>com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig</value> <value>com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig</value>
<value>com.rjconsultores.ventaboletos.entidad.EmpresaSaferConfig</value>
<value>com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa</value> <value>com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa</value>
<value>com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude</value> <value>com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude</value>
<value>com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada</value> <value>com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada</value>

View File

@ -1648,6 +1648,12 @@ editarEmpresaImpostoController.bpe.value = Habilitar BPe
editarEmpresaImpostoController.tributoEmissao.value = Tributa Emissão editarEmpresaImpostoController.tributoEmissao.value = Tributa Emissão
editarEmpresaImpostoController.tributoViagem.value = Tributa Viagem editarEmpresaImpostoController.tributoViagem.value = Tributa Viagem
editarEmpresaController.lblSafer.value = Safer
editarEmpresaController.lblCodigoSafer.value = Código do parceiro
editarEmpresaController.lblCodigoContratoSafer.value = Código do contrato
editarEmpresaController.lblInfoSafer.value = Informações Certificado
editarEmpresaController.lblCarregarCertificadoSafer.value = Carregar Certificado
# Muestra o ponto de Búsqueda de venta # Muestra o ponto de Búsqueda de venta
busquedaPuntoVentaController.window.title = Punto de venta ( Agencia ) busquedaPuntoVentaController.window.title = Punto de venta ( Agencia )
busquedaPuntoVentaController.btnRefresh.tooltiptext = Actualizar busquedaPuntoVentaController.btnRefresh.tooltiptext = Actualizar

View File

@ -1863,6 +1863,12 @@ editarEmpresaImpostoController.bpe.value = Habilitar BPe
editarEmpresaImpostoController.tributoEmissao.value = Tributa Emissão editarEmpresaImpostoController.tributoEmissao.value = Tributa Emissão
editarEmpresaImpostoController.tributoViagem.value = Tributa Viagem editarEmpresaImpostoController.tributoViagem.value = Tributa Viagem
editarEmpresaController.lblSafer.value = Safer
editarEmpresaController.lblCodigoSafer.value = Código do parceiro
editarEmpresaController.lblCodigoContratoSafer.value = Código do contrato
editarEmpresaController.lblInfoSafer.value = Informações Certificado
editarEmpresaController.lblCarregarCertificadoSafer.value = Carregar Certificado
# Muestra o ponto de Pesquisa de Venda # Muestra o ponto de Pesquisa de Venda
busquedaPuntoVentaController.window.title = Ponto de Venda ( Agência ) busquedaPuntoVentaController.window.title = Ponto de Venda ( Agência )
busquedaPuntoVentaController.btnRefresh.tooltiptext = Atualizar busquedaPuntoVentaController.btnRefresh.tooltiptext = Atualizar

View File

@ -29,6 +29,7 @@
<tabbox vflex="1" hflex="1"> <tabbox vflex="1" hflex="1">
<tabs> <tabs>
<tab <tab
label="${c:l('editarEmpresaController.lbNome.value')}" /> label="${c:l('editarEmpresaController.lbNome.value')}" />
<tab <tab
@ -55,8 +56,17 @@
label="${c:l('editarEmpresaController.voucherPersonalizado.label')}" /> label="${c:l('editarEmpresaController.voucherPersonalizado.label')}" />
<tab <tab
label="${c:l('editarEmpresaController.configuracaoFlexbus.label')}" /> label="${c:l('editarEmpresaController.configuracaoFlexbus.label')}" />
<tab id="tabSafer" visible="false"
label="${c:l('editarEmpresaController.lblSafer.value')}" />
</tabs> </tabs>
<tabpanels style="overflow: auto"> <tabpanels style="overflow: auto">
<tabpanel> <tabpanel>
<grid fixedLayout="true"> <grid fixedLayout="true">
<columns> <columns>
@ -1957,11 +1967,67 @@
width="100%"> width="100%">
</ckeditor> </ckeditor>
</tabpanel> </tabpanel>
</tabpanels> </tabpanels>
</tabbox> </tabbox>
</tabpanel> </tabpanel>
<tabpanel>
<grid fixedLayout="true">
<columns>
<column width="25%" />
<column width="75%" />
</columns>
<rows>
<row>
<label
value="${c:l('editarEmpresaController.lblCodigoSafer.value')}" />
<textbox id="txtPartnerId"
maxlength="100"
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
</row>
<row>
<label
value="${c:l('editarEmpresaController.lblCodigoContratoSafer.value')}" />
<textbox id="txtContractId"
maxlength="100"
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
</row>
<row spans="2">
<groupbox>
<caption
label="${c:l('editarEmpresaController.lblInfoSafer.value')}" />
                        
<hlayout>
             
<label
value="${c:l('winLogin.lblSenha')}" />
<textbox
id="txtSenhaCertificado" type="password" />
<fileupload
label="${c:l('editarEmpresaController.lblCarregarCertificadoSafer.value')}"
onUpload="winEditarEmpresa$composer.uploadFile(event)" />
            
</hlayout>
</groupbox>
</row>
<row spans="2">
<label id="lblCertificado"
multiline="true" />
</row>
</rows>
</grid>
</tabpanel>
</tabpanels> </tabpanels>
</tabbox> </tabbox>

View File

@ -225,6 +225,14 @@
</hbox> </hbox>
<checkbox id="chkIndSomenteAssentoSugerido"/> <checkbox id="chkIndSomenteAssentoSugerido"/>
</row> </row>
<row>
<hbox>
<label
value="Vende Safer" />
</hbox>
<checkbox id="chkIndSafer"/>
</row>
</rows> </rows>
</grid> </grid>