diff --git a/src/java/applicationContext-security.xml b/src/java/applicationContext-security.xml index 1204a9228..d686e79e1 100644 --- a/src/java/applicationContext-security.xml +++ b/src/java/applicationContext-security.xml @@ -1,34 +1,41 @@ - - - - + + + - - - - - - - - - - - + + + + + + - - + - + diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/CambiaContrasenaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/CambiaContrasenaController.java new file mode 100644 index 000000000..e3ab34230 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/CambiaContrasenaController.java @@ -0,0 +1,83 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.util.resource.Labels; +import org.zkoss.zhtml.Messagebox; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.util.Clients; +import org.zkoss.zul.Textbox; + +import com.rjconsultores.ventaboletos.entidad.Usuario; +import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.service.UsuarioService; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; + +@Controller("cambiaContrasenaController") +@Scope("prototype") +public class CambiaContrasenaController extends MyGenericForwardComposer { + + private static final long serialVersionUID = 1L; + private static Logger log = Logger.getLogger(EditarUsuarioController.class); + + @Autowired + private UsuarioService usuarioService; + + private Textbox txtUser; + private Textbox txtPassword; + private Textbox txtNewPassword; + private Textbox txtConfirmPassword; + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + } + + public void onClick$btnSalvar(Event ev) throws InterruptedException { + + try { + if (StringUtils.isBlank(txtUser.getValue()) || StringUtils.isBlank(txtPassword.getValue()) + || StringUtils.isBlank(txtNewPassword.getValue()) || StringUtils.isBlank(txtConfirmPassword.getValue())) { + Messagebox.show(Labels.getLabel("winCambiaContrasena.erro.camposVazios"), + Labels.getLabel("winCambiaContrasena.title"), Messagebox.OK, Messagebox.INFORMATION); + return; + } + + Usuario usuario = usuarioService.buscarPeloNomeSenha(txtUser.getValue(), txtPassword.getValue()); + if (usuario == null) { + Messagebox.show(Labels.getLabel("winCambiaContrasena.erro.usuarioSenha"), + Labels.getLabel("winCambiaContrasena.title"), Messagebox.OK, Messagebox.INFORMATION); + return; + } + + if (txtPassword.getValue().equals(txtNewPassword.getValue())) { + Messagebox.show(Labels.getLabel("winCambiaContrasena.erro.senhasIguais"), + Labels.getLabel("winCambiaContrasena.title"), Messagebox.OK, Messagebox.INFORMATION); + return; + } + + if (!txtNewPassword.getValue().equals(txtConfirmPassword.getValue())) { + Messagebox.show(Labels.getLabel("winCambiaContrasena.erro.senhasDiferentes"), + Labels.getLabel("winCambiaContrasena.title"), Messagebox.OK, Messagebox.INFORMATION); + return; + } + + usuarioService.cambiarContrasena(usuario, txtNewPassword.getValue()); + + Messagebox.show(Labels.getLabel("winCambiaContrasena.MSG.suscribirOK"), + Labels.getLabel("winCambiaContrasena.title"), Messagebox.OK, Messagebox.INFORMATION); + + closeWindow(); + + } catch (BusinessException ex) { + log.error(ex.getLocalizedMessage()); + Clients.alert(ex.getLocalizedMessage(), Labels.getLabel("winCambiaContrasena.title"), Messagebox.INFORMATION); + } + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/PantallaUtileria.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/PantallaUtileria.java index 9338c0987..fe65e8824 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/PantallaUtileria.java +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/PantallaUtileria.java @@ -5,120 +5,153 @@ import java.util.Map; import org.apache.log4j.Logger; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Desktop; +import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Path; import org.zkoss.zk.ui.UiException; import org.zkoss.zul.Window; public class PantallaUtileria { - public static int OVERLAPPED = 1; - public static int MODAL = 2; - private static Logger log = Logger.getLogger(MyGenericForwardComposer.class); + public static int OVERLAPPED = 1; + public static int MODAL = 2; + private static Logger log = Logger.getLogger(MyGenericForwardComposer.class); - public static void openWindow(String component, String title, Map args, Desktop desktop) { - PantallaUtileria.openWindow(component, title, args, OVERLAPPED, desktop); - } + public static void openWindow(String component, String title, Map args, Desktop desktop) { + PantallaUtileria.openWindow(component, title, args, OVERLAPPED, desktop); + } - public static void openWindowPosi(String component, String title, Map args, String pos, Desktop desktop) { - PantallaUtileria.openWindowPosi(component, title, args, OVERLAPPED, pos, desktop); - } + public static void openWindowPosi(String component, String title, Map args, String pos, Desktop desktop) { + PantallaUtileria.openWindowPosi(component, title, args, OVERLAPPED, pos, desktop); + } - public static void openWindowPosi(String component, String title, Map args, int type, String pos, Desktop desktop) { - Window win1 = null; + public static void openWindowPosi(String component, String title, Map args, int type, String pos, Desktop desktop) { + Window win1 = null; - try { - win1 = (Window) desktop.getExecution().createComponents(component, null, args); + try { + win1 = (Window) desktop.getExecution().createComponents(component, null, args); - Component c = Path.getComponent("/win/" + win1.getId()); - if (c != null) { - c.detach(); - } + Component c = Path.getComponent("/win/" + win1.getId()); + if (c != null) { + c.detach(); + } - win1.setTitle(title); - win1.setClosable(true); - win1.setMaximizable(false); - if (OVERLAPPED == type) { - win1.doOverlapped(); - } else { - win1.doHighlighted(); - } + win1.setTitle(title); + win1.setClosable(true); + win1.setMaximizable(false); + if (OVERLAPPED == type) { + win1.doOverlapped(); + } else { + win1.doHighlighted(); + } - win1.setPosition(pos); - win1.setPage(desktop.getPage("mainWin")); - win1.setParent(desktop.getPage("mainWin").getFellow("win")); - } catch (Exception e) { - log.error(e); - if (win1 != null) { - win1.detach(); - } + win1.setPosition(pos); + win1.setPage(desktop.getPage("mainWin")); + win1.setParent(desktop.getPage("mainWin").getFellow("win")); + } catch (Exception e) { + log.error(e); + if (win1 != null) { + win1.detach(); + } - throw UiException.Aide.wrap(e); - } - } + throw UiException.Aide.wrap(e); + } + } - public static void openWindow(String component, String title, Map args, int type, Desktop desktop) { - Window win1 = null; + public static void openWindow(String component, String title, Map args, int type, Desktop desktop) { + Window win1 = null; - try { - win1 = (Window) desktop.getExecution().createComponents(component, null, args); + try { + win1 = (Window) desktop.getExecution().createComponents(component, null, args); - Component c = Path.getComponent("/win/" + win1.getId()); - if (c != null) { - c.detach(); - } + Component c = Path.getComponent("/win/" + win1.getId()); + if (c != null) { + c.detach(); + } - win1.setTitle(title); - win1.setClosable(true); - win1.setMaximizable(false); - if (OVERLAPPED == type) { - win1.doOverlapped(); - } else { - win1.doHighlighted(); - } + win1.setTitle(title); + win1.setClosable(true); + win1.setMaximizable(false); + if (OVERLAPPED == type) { + win1.doOverlapped(); + } else { + win1.doHighlighted(); + } - win1.setPosition("center"); - win1.setPage(desktop.getPage("mainWin")); - win1.setParent(desktop.getPage("mainWin").getFellow("win")); - } catch (Exception e) { - log.error(e); - if (win1 != null) { - win1.detach(); - } + win1.setPosition("center"); + win1.setPage(desktop.getPage("mainWin")); + win1.setParent(desktop.getPage("mainWin").getFellow("win")); + } catch (Exception e) { + log.error(e); + if (win1 != null) { + win1.detach(); + } - throw UiException.Aide.wrap(e); - } - } + throw UiException.Aide.wrap(e); + } + } - public static void openWindow(String component, String title, Map args, int type, Boolean closabled, Desktop desktop) { - Window win1 = null; + public static void openWindow(String component, String title, Map args, int type, Boolean closabled, Desktop desktop) { + Window win1 = null; - try { - win1 = (Window) desktop.getExecution().createComponents(component, null, args); + try { + win1 = (Window) desktop.getExecution().createComponents(component, null, args); - Component c = Path.getComponent("/win/" + win1.getId()); - if (c != null) { - c.detach(); - } + Component c = Path.getComponent("/win/" + win1.getId()); + if (c != null) { + c.detach(); + } - win1.setTitle(title); - win1.setClosable(closabled); - win1.setMaximizable(false); - if (OVERLAPPED == type) { - win1.doOverlapped(); - } else { - win1.doHighlighted(); - } + win1.setTitle(title); + win1.setClosable(closabled); + win1.setMaximizable(false); + if (OVERLAPPED == type) { + win1.doOverlapped(); + } else { + win1.doHighlighted(); + } - win1.setPosition("center"); - win1.setPage(desktop.getPage("mainWin")); - win1.setParent(desktop.getPage("mainWin").getFellow("win")); - } catch (Exception e) { - log.error(e); - if (win1 != null) { - win1.detach(); - } + win1.setPosition("center"); + win1.setPage(desktop.getPage("mainWin")); + win1.setParent(desktop.getPage("mainWin").getFellow("win")); + } catch (Exception e) { + log.error(e); + if (win1 != null) { + win1.detach(); + } - throw UiException.Aide.wrap(e); - } - } + throw UiException.Aide.wrap(e); + } + } + + public static void openWindow(String component, String title, Map args, int type) { + Window win1 = null; + + try { + win1 = (Window) Executions.createComponents(component, null, null); + + Component c = Path.getComponent("/win/" + win1.getId()); + if (c != null) { + c.detach(); + } + + win1.setTitle(title); + win1.setClosable(true); + win1.setMaximizable(false); + if (OVERLAPPED == type) { + win1.doOverlapped(); + } else { + win1.doHighlighted(); + } + + win1.setPosition("center"); + + } catch (Exception e) { + log.error(e); + if (win1 != null) { + win1.detach(); + } + + throw UiException.Aide.wrap(e); + } + } } diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 9216a01bc..fc56f4680 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -4842,4 +4842,16 @@ indexController.mniMovimentacionBilhetesPuntoVenta.label=Movimentación de Estoq complejidadContrasena.CANT_MIN_CARACTER=La contraseña debe de tener un tamaño minimo de {0} complejidadContrasena.CANT_MIN_LETRA=La contraseña debe de tener al menor {0} letra complejidadContrasena.CANT_MIN_NUMERO=La contraseña debe de tener al menor {0} número -complejidadContrasena.CANT_ESPECIALES=La contrasena debe de tener al menor {0} caracteres especiales \ No newline at end of file +complejidadContrasena.CANT_ESPECIALES=La contrasena debe de tener al menor {0} caracteres especiales + +winCambiaContrasena.title = Cambiar Contraseña +winCambiaContrasena.lblUsuario = Usuário: +winCambiaContrasena.lblSenha = Contraseña: +winCambiaContrasena.lblNovaSenha = Nueva Contraseña: +winCambiaContrasena.lblConfirmaSenha = Confirmar Nueva Contraseña: +winCambiaContrasena.btnAcessar = Salvar +winCambiaContrasena.erro.camposVazios = Hay campos que no fueron llenados +winCambiaContrasena.erro.senhasIguais = La nueva contraseña no puede ser idéntica a la contraseña anterior +winCambiaContrasena.erro.senhasDiferentes = La nueva contraseña y la confirmación de contraseña debe ser la misma +winCambiaContrasena.erro.usuarioSenha = Usuario y / o contraseña no existe +winCambiaContrasena.MSG.suscribirOK = La contraseña ha sido cambiada diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index d78f8bff6..9a3e98662 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -4923,4 +4923,16 @@ editarOCDParamController.MSG.borrarOK = Parâmetro OCD eliminado com sucesso. complejidadContrasena.CANT_MIN_CARACTER=A senha deve ter um tamanho mínimo de {0} caracteres complejidadContrasena.CANT_MIN_LETRA=A senha deve ter ao menos {0} letra complejidadContrasena.CANT_MIN_NUMERO=A senha deve ter ao menos {0} número -complejidadContrasena.CANT_ESPECIALES=A senha deve ter ao menos {0} caracteres especiais \ No newline at end of file +complejidadContrasena.CANT_ESPECIALES=A senha deve ter ao menos {0} caracteres especiais + +winCambiaContrasena.title = Alterar Senha +winCambiaContrasena.lblUsuario = Usuário: +winCambiaContrasena.lblSenha = Senha: +winCambiaContrasena.lblNovaSenha = Nova Senha: +winCambiaContrasena.lblConfirmaSenha = Confirmar Nova Senha: +winCambiaContrasena.btnAcessar = Salvar +winCambiaContrasena.erro.camposVazios = Existem campos que não foram preenchidos +winCambiaContrasena.erro.senhasIguais = A nova senha não pode ser identica a senha antiga +winCambiaContrasena.erro.senhasDiferentes = A nova senha e a confirmação de senha devem ser iguais +winCambiaContrasena.erro.usuarioSenha = Usuário e/ou senha não existe +winCambiaContrasena.MSG.suscribirOK = A senha foi alterada \ No newline at end of file diff --git a/web/gui/seguridad/cambiaContrasena.zul b/web/gui/seguridad/cambiaContrasena.zul new file mode 100644 index 000000000..ae748439c --- /dev/null +++ b/web/gui/seguridad/cambiaContrasena.zul @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + +