diff --git a/pom.xml b/pom.xml index 78690c0bb..f43af0f8f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,12 +4,12 @@ 4.0.0 br.com.rjconsultores ventaboletosadm - 1.63.4 + 1.63.5 war - 1.44.0 - 1.36.0 + 1.44.1 + 1.37.0 UTF-8 UTF-8 diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java index e2e396475..b2cff4450 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/catalogos/EditarEmpresaController.java @@ -7,8 +7,10 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.StringWriter; import java.math.BigDecimal; import java.security.InvalidKeyException; +import java.security.KeyFactory; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -20,6 +22,7 @@ import java.security.UnrecoverableEntryException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.security.spec.PKCS8EncodedKeySpec; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -33,6 +36,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; @@ -79,6 +84,7 @@ import com.rjconsultores.ventaboletos.entidad.ComEmpFormapago; import com.rjconsultores.ventaboletos.entidad.ComEmpTipoEventoExtra; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.EmpresaAdyenConfig; +import com.rjconsultores.ventaboletos.entidad.EmpresaCertificadoConfig; import com.rjconsultores.ventaboletos.entidad.EmpresaCieloLinkConfig; import com.rjconsultores.ventaboletos.entidad.EmpresaContaBancaria; import com.rjconsultores.ventaboletos.entidad.EmpresaEmail; @@ -97,6 +103,7 @@ import com.rjconsultores.ventaboletos.entidad.InstiFinanceira; import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; import com.rjconsultores.ventaboletos.entidad.Parada; import com.rjconsultores.ventaboletos.entidad.TipoEventoExtra; +import com.rjconsultores.ventaboletos.enums.EnumTipoCertificado; import com.rjconsultores.ventaboletos.enums.TipoCstGratuidade; import com.rjconsultores.ventaboletos.enums.TipoEmail; import com.rjconsultores.ventaboletos.enums.TipoOperacaoECommerce; @@ -105,6 +112,7 @@ import com.rjconsultores.ventaboletos.rest.MercadoPagoService; import com.rjconsultores.ventaboletos.service.CategoriaService; import com.rjconsultores.ventaboletos.service.CiudadService; import com.rjconsultores.ventaboletos.service.EmpresaAdyenConfigService; +import com.rjconsultores.ventaboletos.service.EmpresaCertificadoConfigService; import com.rjconsultores.ventaboletos.service.EmpresaCieloLinkService; import com.rjconsultores.ventaboletos.service.EmpresaEmailConfigService; import com.rjconsultores.ventaboletos.service.EmpresaEmailEComerceService; @@ -187,6 +195,8 @@ public class EditarEmpresaController extends MyGenericForwardComposer { private EmpresaAdyenConfigService empresaAdyenConfigService; @Autowired private EmpresaMercadoPagoConfigService empresaMercadoPagoConfigService; + @Autowired + private EmpresaCertificadoConfigService empresaCertificadoConfigService; @Autowired private EmpresaPMArtespConfigService empresaPMArtespConfigService; @@ -203,6 +213,7 @@ public class EditarEmpresaController extends MyGenericForwardComposer { private EmpresaSaferConfig empresaSaferConfig; private EmpresaAdyenConfig empresaAdyenConfig; private EmpresaMercadoPagoConfig empresaMercadoPagoConfig; + private EmpresaCertificadoConfig empresaCertificadoConfigSaftao; private MyListbox empresaList; private MyTextbox txtNome; private MyTextbox txtCNPJ; @@ -499,6 +510,11 @@ public class EditarEmpresaController extends MyGenericForwardComposer { private Textbox txtUrlIntegracaoARTESP; private Textbox txtTokenIntegracaoARTESP; + private Label lblCertificadoSaftao; + private Checkbox chkIndSaftao; + private byte[] certificadoSaftao; + private Tab tabSaftao; + private MyComboboxEstandar cmbTipoDePassagem; private MyComboboxEstandar cmbOrgaoConcedente; @@ -532,6 +548,7 @@ public class EditarEmpresaController extends MyGenericForwardComposer { empresaSaferConfig = empresaSaferConfigService.buscarPorEmpresa(empresa); empresaAdyenConfig = empresaAdyenConfigService.buscarPorEmpresa(empresa); empresaMercadoPagoConfig = empresaMercadoPagoConfigService.buscarPorEmpresa(empresa); + empresaCertificadoConfigSaftao = empresaCertificadoConfigService.buscarPorEmpresa(empresa, EnumTipoCertificado.SAFTAO); empresaPMArtespConfig = empresaPMArtespConfigService.buscarPorEmpresa(empresa); } @@ -625,6 +642,16 @@ public class EditarEmpresaController extends MyGenericForwardComposer { } } + if (empresaCertificadoConfigSaftao != null) { + certificadoSaftao = empresaCertificadoConfigSaftao.getCertificado(); + if(certificadoSaftao != null){ + InputStream certStream = new ByteArrayInputStream(certificadoSaftao); + if (certStream != null) { + lblCertificadoSaftao.setValue(getCerticateInfoSaftao(certStream)); + } + } + } + mostrarAbaSaftao(); mostrarAbaSafer(); if (empresaAdyenConfig != null) { @@ -771,6 +798,8 @@ public class EditarEmpresaController extends MyGenericForwardComposer { chkIndAgrupamentoLocalidadeConexao.setChecked(BooleanUtils.toBoolean(empresa.getIndAgrupLocConexao())); chkIndSegundaViaSeguroOpcional.setChecked(BooleanUtils.toBoolean(empresa.getIndSegundaViaSegOpcional())); chkIndJurosCredito.setChecked(BooleanUtils.toBoolean(empresa.getIndJurosCredito())); + chkIndSaftao.setChecked(BooleanUtils.toBoolean(empresa.getIndSaftao())); + chkIndHabilitaVendaDeBilheteSemelhante.setChecked(BooleanUtils.toBoolean(empresa.getIndVendeDeBilheteSemelhante())); chkIndHabilitaTaxaConvenienciaSomenteVenda.setChecked(BooleanUtils.toBoolean(empresa.getIndTaxaConvenienciaSoVenda())); chkIndHabilitaHoraEmbarque.setChecked(empresa.getHoraInicioEmbarque() != null && empresa.getHoraFimEmbarque() != null); @@ -1053,6 +1082,7 @@ public class EditarEmpresaController extends MyGenericForwardComposer { chkIndCheckinBloqueadoNoshow.getValue(); chkIndSegundaViaSeguroOpcional.getValue(); chkIndJurosCredito.getValue(); + chkIndSaftao.getValue(); chkIndHabilitaVendaDeBilheteSemelhante.getValue(); chkIndHabilitaTaxaConvenienciaSomenteVenda.getValue(); chkIndHabilitaHoraEmbarque.getValue(); @@ -1198,6 +1228,7 @@ public class EditarEmpresaController extends MyGenericForwardComposer { empresa.setIndAgrupLocConexao(chkIndAgrupamentoLocalidadeConexao.isChecked()); empresa.setIndSegundaViaSegOpcional(chkIndSegundaViaSeguroOpcional.isChecked()); empresa.setIndJurosCredito(chkIndJurosCredito.isChecked()); + empresa.setIndSaftao(chkIndSaftao.isChecked()); empresa.setIndVendeDeBilheteSemelhante(chkIndHabilitaVendaDeBilheteSemelhante.isChecked()); empresa.setIndTaxaConvenienciaSoVenda(chkIndHabilitaTaxaConvenienciaSomenteVenda.isChecked()); empresa.setIndIntegracaoAGR(chkIndntegracaoAGR.isChecked()); @@ -2166,29 +2197,38 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException { lsStoreMercadoPago = new ArrayList(); lsPosMercadoPago = new ArrayList(); - RetornoStoreVO retornoStoreVO = MercadoPagoService.getInstance().retornarStoreMercadoPago( - txtUserIdMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue()); - - if (retornoStoreVO != null){ - for (StoreVO vo : retornoStoreVO.getResults()) { - if (store != null && vo.toString().equals(store)) { - this.storeVO = vo; + if (StringUtils.isNotBlank(txtUserIdMercadoPago.getValue()) + && StringUtils.isNotBlank(txtUrlApiMercadoPago.getValue()) + && StringUtils.isNotBlank(txtTokenMercadoPago.getValue())) { + RetornoStoreVO retornoStoreVO = MercadoPagoService.getInstance().retornarStoreMercadoPago( + txtUserIdMercadoPago.getValue(), txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue()); + + if (retornoStoreVO != null) { + for (StoreVO vo : retornoStoreVO.getResults()) { + if (store != null && vo.toString().equals(store)) { + this.storeVO = vo; + } + lsStoreMercadoPago.add(vo); } - lsStoreMercadoPago.add(vo); } } - RetornoPosVO retornoPosVO = MercadoPagoService.getInstance() - .retornarPosMercadoPago(txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue()); - - if (retornoPosVO != null) { - for (PosVO vo : retornoPosVO.getResults()) { - if (pos != null && vo.toString().equals(pos)) { - this.posVO = vo; + if (StringUtils.isNotBlank(txtUrlApiMercadoPago.getValue()) + && StringUtils.isNotBlank(txtTokenMercadoPago.getValue())) { + + RetornoPosVO retornoPosVO = MercadoPagoService.getInstance() + .retornarPosMercadoPago(txtUrlApiMercadoPago.getValue(), txtTokenMercadoPago.getValue()); + + if (retornoPosVO != null) { + for (PosVO vo : retornoPosVO.getResults()) { + if (pos != null && vo.toString().equals(pos)) { + this.posVO = vo; + } + lsPosMercadoPago.add(vo); } - lsPosMercadoPago.add(vo); } } + } public Combobox getCmbEstadoInscEstadual() { @@ -2800,6 +2840,12 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException { } } + private void mostrarAbaSaftao() { + if (ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.IS_VENDA_SAFTAO.getDescricao(), true)) { + tabSaftao.setVisible(true); + } + } + private void popularCombobox() { for (AuthType tipoAutorizacao : AuthType.values()) { Comboitem comboItem = new Comboitem(tipoAutorizacao.toString()); @@ -2885,6 +2931,52 @@ public void onClick$btnTestEmailFlexBus(Event ev) throws InterruptedException { return true; } + + public void uploadFileSaftao(UploadEvent event) { + org.zkoss.util.media.Media media = event.getMedia(); + + try { + String info = getCerticateInfoSaftao(media.getStreamData()); + + if (info != null) { + certificadoSaftao = media.getByteData(); + lblCertificadoSaftao.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 getCerticateInfoSaftao(InputStream cerFileStream) throws IOException, Exception { + + StringWriter writer = new StringWriter(); + IOUtils.copy(cerFileStream, writer, "UTF-8"); + + String privateKeyContent = writer != null ? writer.toString() : null; + + if (privateKeyContent == null) { + return null; + } + + privateKeyContent = privateKeyContent.replaceAll("-----END PRIVATE KEY-----", "") + .replaceAll("-----BEGIN PRIVATE KEY-----", "").replaceAll("-----BEGIN RSA PRIVATE KEY-----", "") + .replaceAll("-----END RSA PRIVATE KEY-----", "").replaceAll("\r\n", "").replaceAll("\n", ""); + + KeyFactory kf = KeyFactory.getInstance("RSA"); + + PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyContent)); + + PrivateKey privKey = kf.generatePrivate(keySpecPKCS8); + + return privKey.toString(); + } public EmpresaEmailFlexBusService getEmpresaEmailFlexBusService() { return empresaEmailFlexBusService; diff --git a/src/java/spring-config.xml b/src/java/spring-config.xml index da1fe9c85..57362af54 100644 --- a/src/java/spring-config.xml +++ b/src/java/spring-config.xml @@ -385,6 +385,7 @@ com.rjconsultores.ventaboletos.entidad.EmpresaEmailEComerce com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig com.rjconsultores.ventaboletos.entidad.EmpresaSaferConfig + com.rjconsultores.ventaboletos.entidad.EmpresaCertificadoConfig com.rjconsultores.ventaboletos.entidad.CtrlFechamentoCaixa com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada diff --git a/web/WEB-INF/i3-label_en.label b/web/WEB-INF/i3-label_en.label index cc4cbc713..c67b9032f 100644 --- a/web/WEB-INF/i3-label_en.label +++ b/web/WEB-INF/i3-label_en.label @@ -9703,6 +9703,10 @@ editarEmpresaController.confMovFPTrocaVlrDeposito=Soma Forma de Pagamento 'TROCA editarEmpresaController.confMovFPTrocaVlrDeposito.help=Soma Forma de Pagamento 'TROCA PASSAGEM' no Valor de Depósito na Conferência de Movimento editarEmpresaController.indSegundaViaSeguroOpcional= Emite Segunda via do seguro opcional editarEmpresaController.indJurosCredito= Habilita juros no cartão de crédito +editarEmpresaController.indSaftao= Enable SaftAO +editarEmpresaController.saftao.titulo= SaftAO +editarEmpresaController.lblCertificadoSaftao.value = Certificate Information +editarEmpresaController.lblCarregarCertificadoSaftao.value = Upload Certificate editarEmpresaController.encerraViagemFechorllegada.ajuda=Habilita o encerramento pela data de chegada. O padrão é a validação pela data de saída. editarEmpresaController.usaTabelaPrecoEmbarcada.ajuda=Utilizar tabela de preço da Embarcada diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index f56b5f358..7c3a1b0b8 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -9394,6 +9394,10 @@ editarEmpresaController.comTransfGeraCaja.help=Transferencias de suma que mueven editarEmpresaController.indSegundaViaSeguroOpcional= Emite una segunda copia del seguro opcional editarEmpresaController.indSegundaViaSeguroOpcional.tooltip=Con este flag seleccionado, al emitir una 2da copia de boleto con seguro vinculado opcional, el sistema también emite la 2da copia del seguro y lo registra en caja en transacciones que no generan efectivo. Además, con esta bandera seleccionada, al cambiar/transferir un billete, el seguro anterior se cancela automáticamente en caja y el importe pagado se utiliza como “crédito” para pagar el nuevo seguro que se registrará en caja. editarEmpresaController.indJurosCredito= Habilita juros no cartão de crédito +editarEmpresaController.indSaftao= Habilita SaftAO +editarEmpresaController.saftao.titulo= SaftAO +editarEmpresaController.lblCertificadoSaftao.value = Información certificada +editarEmpresaController.lblCarregarCertificadoSaftao.value = Cargar certificado editarEmpresaController.encerraViagemFechorllegada.ajuda=Controla o encerramento da viagem pela data de saída data de chegada da corrida. editarEmpresaController.usaTabelaPrecoEmbarcada.ajuda=Utilizar tabela de preço da Embarcada diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 8eddd7937..019531bd3 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -9795,6 +9795,10 @@ editarEmpresaController.indSegundaViaSeguroOpcional.tooltip=Com esta flag marcad editarEmpresaController.indJurosCredito= Habilita juros no cartão de crédito editarEmpresaController.indHabilitaVendaDeBilheteSemelhante= Hailita a venda de bilhete semelhante na mesma cesta de compra. editarEmpresaController.indHabilitaVendaDeBilheteSemelhante.help = Habilita a venda de bilhetes semelhante na mesma cesta de compra, respeitando o preço do primeiro bilhete. +editarEmpresaController.indSaftao= Habilita SaftAO +editarEmpresaController.saftao.titulo= SaftAO +editarEmpresaController.lblCertificadoSaftao.value = Informações Certificado +editarEmpresaController.lblCarregarCertificadoSaftao.value = Carregar Certificado editarEmpresaController.indHabilitaTaxaConvenienciaSomenteVenda=Habilita Taxa de Conveniência apenas nas operações de venda. editarEmpresaController.indHabilitaTaxaConvenienciaSomenteVenda.help=Com a Flag marcada, a taxa de conveniência configurada no ponto de venda será aplicada apenas nas operações de venda. NÃO se aplica às operações de troca, transferência, marcação de aberto, etc. diff --git a/web/gui/catalogos/editarEmpresa.zul b/web/gui/catalogos/editarEmpresa.zul index 5c8c71a36..3df50d0fd 100644 --- a/web/gui/catalogos/editarEmpresa.zul +++ b/web/gui/catalogos/editarEmpresa.zul @@ -66,10 +66,10 @@ label="${c:l('editarEmpresaController.lblAdyen.value')}" /> - - + @@ -2597,11 +2597,49 @@ - + + + + + + + + + + + + + + + +                          + + + +              + + + + + + + + + + +