--- Merge ---
Complexidade Senha - Tempo de Validade (fixed bug #5521) Tempo: 1 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@36828 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
6f16f4d0f8
commit
f6df6b8dda
|
@ -1,34 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- - Spring namespace-based configuration -->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
|
||||
|
||||
<security:http auto-config="true" access-denied-page="/accessDenied.zul">
|
||||
<security:form-login login-page="/index.zul" default-target-url="/index.zul" authentication-failure-url="/index.zul" always-use-default-target='true'/>
|
||||
<security:logout logout-success-url="/index.zul" invalidate-session="true"/>
|
||||
<security:form-login login-page="/index.zul"
|
||||
default-target-url="/index.zul" authentication-failure-url="/index.zul"
|
||||
always-use-default-target='true' />
|
||||
<security:logout logout-success-url="/index.zul"
|
||||
invalidate-session="true" />
|
||||
|
||||
<security:intercept-url pattern="/gui/img/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/gui/js/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/gui/**" access="IS_AUTHENTICATED_REMEMBERED" />
|
||||
<security:intercept-url pattern="/" access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/login.zul" access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/index.zul" access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
|
||||
|
||||
<!--security:session-management> <security:concurrency-control max-sessions="1" error-if-maximum-exceeded="true"/> </security:session-management -->
|
||||
|
||||
<!--security:remember-me/ -->
|
||||
<security:intercept-url pattern="/gui/img/**"
|
||||
access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/gui/js/**"
|
||||
access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/gui/**"
|
||||
access="IS_AUTHENTICATED_REMEMBERED" />
|
||||
<security:intercept-url pattern="/"
|
||||
access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/login.zul"
|
||||
access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
<security:intercept-url pattern="/index.zul"
|
||||
access="IS_AUTHENTICATED_ANONYMOUSLY" />
|
||||
|
||||
</security:http>
|
||||
|
||||
<bean id="passwordEncoder" class="com.rjconsultores.ventaboletos.utilerias.spring.security.MiPasswordEncoder" />
|
||||
|
||||
<bean id="passwordEncoder"
|
||||
class="com.rjconsultores.ventaboletos.utilerias.spring.security.MiPasswordEncoder" />
|
||||
<security:authentication-manager>
|
||||
<security:authentication-provider user-service-ref="usuarioService">
|
||||
<security:authentication-provider
|
||||
user-service-ref="usuarioService">
|
||||
<security:password-encoder ref="passwordEncoder" />
|
||||
</security:authentication-provider>
|
||||
</security:authentication-manager>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ 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;
|
||||
|
@ -121,4 +122,36 @@ public class PantallaUtileria {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4843,3 +4843,15 @@ complejidadContrasena.CANT_MIN_CARACTER=La contraseña debe de tener un tamaño
|
|||
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
|
||||
|
||||
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
|
||||
|
|
|
@ -4924,3 +4924,15 @@ complejidadContrasena.CANT_MIN_CARACTER=A senha deve ter um tamanho mínimo de {
|
|||
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
|
||||
|
||||
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
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?page contentType="text/html;charset=UTF-8"?>
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winCambiaContrasena"?>
|
||||
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||
|
||||
<zk xmlns="http://www.zkoss.org/2005/zul"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:w="http://www.zkoss.org/2005/zk/client"
|
||||
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
||||
|
||||
<window id="winCambiaContrasena" title="${c:l('winCambiaContrasena.title')}" border="normal"
|
||||
apply="${cambiaContrasenaController}" width="410px" closable="false" position="center" mode="overlapped">
|
||||
|
||||
<grid>
|
||||
<rows>
|
||||
<row align="left">
|
||||
<label value="${c:l('winCambiaContrasena.lblUsuario')}" />
|
||||
<hbox align="center">
|
||||
<image src="/gui/img/user24.png" />
|
||||
<textbox id="txtUser" name="j_username" constraint="no empty"
|
||||
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row align="left">
|
||||
<label value="${c:l('winCambiaContrasena.lblSenha')}" />
|
||||
<hbox align="center">
|
||||
<image src="/gui/img/pass24_4.png" />
|
||||
<textbox id="txtPassword" type="password" name="j_password" constraint="no empty" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row align="left">
|
||||
<label value="${c:l('winCambiaContrasena.lblNovaSenha')}" />
|
||||
<hbox align="center">
|
||||
<image src="/gui/img/pass24_4.png" />
|
||||
<textbox id="txtNewPassword" type="password" name="j_password" constraint="no empty" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row align="left">
|
||||
<label value="${c:l('winCambiaContrasena.lblConfirmaSenha')}" />
|
||||
<hbox align="center">
|
||||
<image src="/gui/img/pass24_4.png" />
|
||||
<textbox id="txtConfirmPassword" type="password" name="j_password" constraint="no empty" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row spans="2" align="center">
|
||||
<hbox align="center">
|
||||
<button id="btnSalvar" height="18" image="/gui/img/save.png" width="90px"
|
||||
tooltiptext="${c:l('winCambiaContrasena.btnAcessar')}" label="${c:l('winCambiaContrasena.btnAcessar')}"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
</window>
|
||||
</zk>
|
|
@ -4,21 +4,26 @@
|
|||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winLogin"?>
|
||||
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||
|
||||
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:w="http://www.zkoss.org/2005/zk/client"
|
||||
<zk xmlns="http://www.zkoss.org/2005/zul"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:w="http://www.zkoss.org/2005/zk/client"
|
||||
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
||||
|
||||
<window id="winLogin" title="${c:l('winLogin.title')}" border="normal" width="400px" closable="false" position="center"
|
||||
<window id="winLogin" title="${c:l('winLogin.title')}"
|
||||
border="normal" width="400px" closable="false" position="center"
|
||||
mode="overlapped" onCreate="u.focus()">
|
||||
|
||||
<h:form id="f" name="f" action="j_spring_security_check" method="POST" xmlns:h="http://www.w3.org/1999/xhtml">
|
||||
<h:form id="f" name="f" action="j_spring_security_check"
|
||||
method="POST" xmlns:h="http://www.w3.org/1999/xhtml">
|
||||
<grid w:onOK="validate()">
|
||||
<rows>
|
||||
<row align="left">
|
||||
<label value="${c:l('winLogin.lblUsuario')}" />
|
||||
<hbox align="center">
|
||||
<image src="/gui/img/user24.png" />
|
||||
<textbox id="u" name="j_username" constraint="no empty"
|
||||
<textbox id="u" name="j_username"
|
||||
constraint="no empty"
|
||||
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
|
||||
</hbox>
|
||||
</row>
|
||||
|
@ -26,45 +31,42 @@
|
|||
<label value="${c:l('winLogin.lblSenha')}" />
|
||||
<hbox align="center">
|
||||
<image src="/gui/img/pass24_4.png" />
|
||||
<textbox id="p" type="password" name="j_password" constraint="no empty" />
|
||||
<textbox id="p" type="password"
|
||||
name="j_password" constraint="no empty" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row spans="2" align="center">
|
||||
<hbox align="center">
|
||||
<h:input type="button" value="${c:l('winLogin.btnAcessar')}" w:onClick="validate()" />
|
||||
<h:input type="button"
|
||||
value="${c:l('winLogin.btnAcessar')}" w:onClick="validate()" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</h:form>
|
||||
<script type="text/javascript">
|
||||
function validate() {
|
||||
var pwd = jq('$p').val() == '';
|
||||
var name = jq('$u').val() == '';
|
||||
function validate() { var pwd = jq('$p').val() == ''; var
|
||||
name = jq('$u').val() == '';
|
||||
|
||||
|
||||
var ok = 1;
|
||||
|
||||
if (name == true){
|
||||
ok = 0;
|
||||
}
|
||||
if (pwd == true){
|
||||
ok = 0;
|
||||
}
|
||||
if (name == true){ ok = 0; } if (pwd == true){ ok = 0; }
|
||||
|
||||
if(ok == 1){
|
||||
jq('$f').submit();
|
||||
}
|
||||
}
|
||||
if(ok == 1){ jq('$f').submit(); } }
|
||||
</script>
|
||||
<zscript>
|
||||
|
||||
//System.out.println("gleimar="+Executions.getCurrent().getSession().getAttribute(org.springframework.security.web.authentication.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY));
|
||||
Exception exep = Executions.getCurrent().getSession().getAttribute(org.springframework.security.web.authentication.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);
|
||||
|
||||
if (exep != null) {
|
||||
if (exep instanceof org.springframework.security.authentication.CredentialsExpiredException) {
|
||||
com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria.openWindow("/gui/seguridad/cambiaContrasena.zul",
|
||||
org.zkoss.util.resource.Labels.getLabel("winCambiaContrasena.title"), new HashMap(), 2);
|
||||
|
||||
} else {
|
||||
Clients.alert(org.zkoss.util.resource.Labels.getLabel("winLogin.lblloginIncorreto"),
|
||||
org.zkoss.util.resource.Labels.getLabel("winLogin.title"), Messagebox.INFORMATION);
|
||||
}
|
||||
|
||||
}
|
||||
</zscript>
|
||||
|
|
Loading…
Reference in New Issue