--- Merge ---
Complexidade Senha - Tempo de Validade (fixed bug #5521) Tempo: 1 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@36828 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
4ee1aff7a1
commit
cdd93ae5b7
|
@ -4,13 +4,6 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.UsuarioDAO;
|
|
||||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empleado;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
|
||||||
import com.rjconsultores.ventaboletos.vo.caja.UsuarioActivoVO;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
|
@ -26,6 +19,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.UsuarioDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Empleado;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.caja.UsuarioActivoVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author rodrigo
|
* @author rodrigo
|
||||||
|
@ -35,57 +34,57 @@ public class UsuarioHibernateDAO extends GenericHibernateDAO<Usuario, Integer> i
|
||||||
@Autowired
|
@Autowired
|
||||||
private SQLBuilder sqlBuilder;
|
private SQLBuilder sqlBuilder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UsuarioHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public UsuarioHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Usuario> obtenerTodos() {
|
public List<Usuario> obtenerTodos() {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Usuario> buscarPeloNome(String nome) {
|
public List<Usuario> buscarPeloNome(String nome) {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
c.add(Restrictions.eq("nombusuario", nome));
|
c.add(Restrictions.eq("nombusuario", nome));
|
||||||
c.addOrder(Order.asc("nombusuario"));
|
c.addOrder(Order.asc("nombusuario"));
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Usuario buscarPeloNomeSenha(String stUsuario, String senha) {
|
public Usuario buscarPeloNomeSenha(String stUsuario, String senha) {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("claveUsuario", stUsuario));
|
c.add(Restrictions.eq("claveUsuario", stUsuario));
|
||||||
c.add(Restrictions.eq("senha", senha));
|
c.add(Restrictions.eq("senha", senha));
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
return (Usuario) c.uniqueResult();
|
return (Usuario) c.uniqueResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Usuario> buscarPorEmpleado(Empleado empleado) {
|
public List<Usuario> buscarPorEmpleado(Empleado empleado) {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
c.add(Restrictions.eq("empleado", empleado));
|
c.add(Restrictions.eq("empleado", empleado));
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Usuario> buscarPelaCveUsuario(String cveUsuario) {
|
public List<Usuario> buscarPelaCveUsuario(String cveUsuario) {
|
||||||
Query query = getSession().createQuery("select u from Usuario u where u.activo =1 and u.claveUsuario = :clave order by u.claveUsuario" );
|
Query query = getSession().createQuery("select u from Usuario u where u.activo =1 and u.claveUsuario = :clave order by u.claveUsuario");
|
||||||
query.setParameter("clave", cveUsuario);
|
query.setParameter("clave", cveUsuario);
|
||||||
|
|
||||||
return query.list();
|
return query.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<UsuarioActivoVO> buscarUsuariosActivo() {
|
public List<UsuarioActivoVO> buscarUsuariosActivo() {
|
||||||
String sqlBuscarUsuariosActivo = sqlBuilder.getSQLBuscarUsuariosActivo();
|
String sqlBuscarUsuariosActivo = sqlBuilder.getSQLBuscarUsuariosActivo();
|
||||||
|
|
||||||
SQLQuery sql = getSession().createSQLQuery(sqlBuscarUsuariosActivo)
|
SQLQuery sql = getSession().createSQLQuery(sqlBuscarUsuariosActivo)
|
||||||
.addScalar("usuarioId", IntegerType.INSTANCE)
|
.addScalar("usuarioId", IntegerType.INSTANCE)
|
||||||
|
@ -94,6 +93,6 @@ public class UsuarioHibernateDAO extends GenericHibernateDAO<Usuario, Integer> i
|
||||||
|
|
||||||
sql.setResultTransformer(new AliasToBeanResultTransformer(UsuarioActivoVO.class));
|
sql.setResultTransformer(new AliasToBeanResultTransformer(UsuarioActivoVO.class));
|
||||||
|
|
||||||
return sql.list();
|
return sql.list();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,6 +33,11 @@ import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author rodrigo
|
* @author rodrigo
|
||||||
|
@ -41,269 +47,283 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||||
@Table(name = "USUARIO")
|
@Table(name = "USUARIO")
|
||||||
public class Usuario implements Serializable, Authentication, UserDetails {
|
public class Usuario implements Serializable, Authentication, UserDetails {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "USUARIO_SEQ")
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "USUARIO_SEQ")
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
@Column(name = "NOMBUSUARIO")
|
@Column(name = "NOMBUSUARIO")
|
||||||
private String nombusuario;
|
private String nombusuario;
|
||||||
@Column(name = "NOMBPATERNO")
|
@Column(name = "NOMBPATERNO")
|
||||||
private String nombpaterno;
|
private String nombpaterno;
|
||||||
@Column(name = "NOMBMATERNO")
|
@Column(name = "NOMBMATERNO")
|
||||||
private String nombmaterno;
|
private String nombmaterno;
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
private Boolean activo;
|
private Boolean activo;
|
||||||
@Column(name = "FECMODIF")
|
@Column(name = "FECMODIF")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date fecmodif;
|
private Date fecmodif;
|
||||||
@Column(name = "USUARIOMODIF_ID")
|
@Column(name = "USUARIOMODIF_ID")
|
||||||
private Integer usuariomodifId;
|
private Integer usuariomodifId;
|
||||||
@Column(name = "DESCCONTRASENA")
|
@Column(name = "DESCCONTRASENA")
|
||||||
private String senha;
|
private String senha;
|
||||||
@Column(name = "CVEUSUARIO")
|
@Column(name = "CVEUSUARIO")
|
||||||
private String claveUsuario;
|
private String claveUsuario;
|
||||||
@Column(name = "DESCCORREO")
|
@Column(name = "DESCCORREO")
|
||||||
private String descCorreo;
|
private String descCorreo;
|
||||||
@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
|
@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@Fetch(FetchMode.SELECT)
|
@Fetch(FetchMode.SELECT)
|
||||||
private List<UsuarioPerfil> usuarioPerfilList;
|
private List<UsuarioPerfil> usuarioPerfilList;
|
||||||
@Column(name = "INDCORTEAUTOMATICO")
|
@Column(name = "INDCORTEAUTOMATICO")
|
||||||
private Boolean indCorteAutomatico;
|
private Boolean indCorteAutomatico;
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "EMPLEADO_ID")
|
@JoinColumn(name = "EMPLEADO_ID")
|
||||||
private Empleado empleado;
|
private Empleado empleado;
|
||||||
@OneToMany(mappedBy = "usuarioLog", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
|
@OneToMany(mappedBy = "usuarioLog", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@Fetch(FetchMode.SELECT)
|
@Fetch(FetchMode.SELECT)
|
||||||
private List<UsuarioEmpresa> usuarioEmpresaList;
|
private List<UsuarioEmpresa> usuarioEmpresaList;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL, fetch=FetchType.EAGER)
|
@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@Fetch(FetchMode.SELECT)
|
@Fetch(FetchMode.SELECT)
|
||||||
private List<UsuarioUbicacion> usuarioUbicacionList;
|
private List<UsuarioUbicacion> usuarioUbicacionList;
|
||||||
|
|
||||||
|
@Column(name = "FECCONTRASENA")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date fecContrasena;
|
||||||
|
|
||||||
|
public String getClaveUsuario() {
|
||||||
|
return claveUsuario;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClaveUsuario(String claveUsuario) {
|
||||||
|
this.claveUsuario = claveUsuario;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClaveUsuario() {
|
public Usuario() {
|
||||||
return claveUsuario;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setClaveUsuario(String claveUsuario) {
|
public Usuario(Integer usuarioId) {
|
||||||
this.claveUsuario = claveUsuario;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Usuario() {
|
public Integer getUsuarioId() {
|
||||||
}
|
return usuarioId;
|
||||||
|
}
|
||||||
|
|
||||||
public Usuario(Integer usuarioId) {
|
public void setUsuarioId(Integer usuarioId) {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUsuarioId() {
|
public String getNombusuario() {
|
||||||
return usuarioId;
|
return nombusuario;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsuarioId(Integer usuarioId) {
|
public void setNombusuario(String nombusuario) {
|
||||||
this.usuarioId = usuarioId;
|
this.nombusuario = nombusuario;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNombusuario() {
|
public String getNombpaterno() {
|
||||||
return nombusuario;
|
return nombpaterno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNombusuario(String nombusuario) {
|
public void setNombpaterno(String nombpaterno) {
|
||||||
this.nombusuario = nombusuario;
|
this.nombpaterno = nombpaterno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNombpaterno() {
|
public String getNombmaterno() {
|
||||||
return nombpaterno;
|
return nombmaterno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNombpaterno(String nombpaterno) {
|
public void setNombmaterno(String nombmaterno) {
|
||||||
this.nombpaterno = nombpaterno;
|
this.nombmaterno = nombmaterno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNombmaterno() {
|
public Boolean getActivo() {
|
||||||
return nombmaterno;
|
return activo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNombmaterno(String nombmaterno) {
|
public void setActivo(Boolean activo) {
|
||||||
this.nombmaterno = nombmaterno;
|
this.activo = activo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getActivo() {
|
public Date getFecmodif() {
|
||||||
return activo;
|
return fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivo(Boolean activo) {
|
public void setFecmodif(Date fecmodif) {
|
||||||
this.activo = activo;
|
this.fecmodif = fecmodif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getFecmodif() {
|
public Integer getUsuariomodifId() {
|
||||||
return fecmodif;
|
return usuariomodifId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFecmodif(Date fecmodif) {
|
public void setUsuariomodifId(Integer usuariomodifId) {
|
||||||
this.fecmodif = fecmodif;
|
this.usuariomodifId = usuariomodifId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUsuariomodifId() {
|
public String getSenha() {
|
||||||
return usuariomodifId;
|
return senha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsuariomodifId(Integer usuariomodifId) {
|
public void setSenha(String senha) {
|
||||||
this.usuariomodifId = usuariomodifId;
|
this.senha = senha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSenha() {
|
public List<UsuarioEmpresa> getUsuarioEmpresaList() {
|
||||||
return senha;
|
List<UsuarioEmpresa> tmp = new ArrayList<UsuarioEmpresa>();
|
||||||
}
|
if (usuarioEmpresaList != null) {
|
||||||
|
for (UsuarioEmpresa ce : this.usuarioEmpresaList) {
|
||||||
|
if (ce.getActivo()) {
|
||||||
|
tmp.add(ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setSenha(String senha) {
|
return tmp;
|
||||||
this.senha = senha;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public void setUsuarioEmpresaList(List<UsuarioEmpresa> usuarioEmpresaList) {
|
||||||
|
this.usuarioEmpresaList = usuarioEmpresaList;
|
||||||
|
}
|
||||||
|
|
||||||
public List<UsuarioEmpresa> getUsuarioEmpresaList() {
|
public List<UsuarioPerfil> getUsuarioPerfilList() {
|
||||||
List<UsuarioEmpresa> tmp = new ArrayList<UsuarioEmpresa>();
|
List<UsuarioPerfil> tmp = new ArrayList<UsuarioPerfil>();
|
||||||
if (usuarioEmpresaList != null) {
|
if (usuarioPerfilList != null) {
|
||||||
for (UsuarioEmpresa ce : this.usuarioEmpresaList) {
|
for (UsuarioPerfil cp : this.usuarioPerfilList) {
|
||||||
if (ce.getActivo()) {
|
if (cp.getActivo()) {
|
||||||
tmp.add(ce);
|
tmp.add(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsuarioEmpresaList(List<UsuarioEmpresa> usuarioEmpresaList) {
|
public List<Empresa> getEmpresa() {
|
||||||
this.usuarioEmpresaList = usuarioEmpresaList;
|
List<Empresa> tmp = new ArrayList<Empresa>();
|
||||||
}
|
if (usuarioEmpresaList != null) {
|
||||||
|
for (UsuarioEmpresa cp : this.usuarioEmpresaList) {
|
||||||
|
if ((cp.getActivo())) {
|
||||||
|
tmp.add(cp.getEmpresa());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<UsuarioPerfil> getUsuarioPerfilList() {
|
return tmp;
|
||||||
List<UsuarioPerfil> tmp = new ArrayList<UsuarioPerfil>();
|
}
|
||||||
if (usuarioPerfilList != null) {
|
|
||||||
for (UsuarioPerfil cp : this.usuarioPerfilList) {
|
|
||||||
if (cp.getActivo()) {
|
|
||||||
tmp.add(cp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmp;
|
public void setUsuarioPerfilList(List<UsuarioPerfil> usuarioPerfilList) {
|
||||||
}
|
this.usuarioPerfilList = usuarioPerfilList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Empleado getEmpleado() {
|
||||||
|
return empleado;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Empresa> getEmpresa() {
|
public void setEmpleado(Empleado empleado) {
|
||||||
List<Empresa> tmp = new ArrayList<Empresa>();
|
this.empleado = empleado;
|
||||||
if (usuarioEmpresaList != null) {
|
}
|
||||||
for (UsuarioEmpresa cp : this.usuarioEmpresaList) {
|
|
||||||
if ((cp.getActivo())) {
|
|
||||||
tmp.add(cp.getEmpresa());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmp;
|
@Override
|
||||||
}
|
public int hashCode() {
|
||||||
|
int hash = 0;
|
||||||
|
hash += (usuarioId != null ? usuarioId.hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUsuarioPerfilList(List<UsuarioPerfil> usuarioPerfilList) {
|
@Override
|
||||||
this.usuarioPerfilList = usuarioPerfilList;
|
public boolean equals(Object object) {
|
||||||
}
|
if (!(object instanceof Usuario)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Usuario other = (Usuario) object;
|
||||||
|
if ((this.usuarioId == null && other.usuarioId != null) || (this.usuarioId != null && !this.usuarioId.equals(other.usuarioId))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public Empleado getEmpleado() {
|
@Override
|
||||||
return empleado;
|
public String toString() {
|
||||||
}
|
return "com.rjconsultores.ventaboletos.entidad.Usuario[usuarioId=" + usuarioId + "]";
|
||||||
|
}
|
||||||
|
|
||||||
public void setEmpleado(Empleado empleado) {
|
public Collection<GrantedAuthority> getAuthorities() {
|
||||||
this.empleado = empleado;
|
return new ArrayList<GrantedAuthority>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getPassword() {
|
||||||
public int hashCode() {
|
return this.senha;
|
||||||
int hash = 0;
|
}
|
||||||
hash += (usuarioId != null ? usuarioId.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public String getUsername() {
|
||||||
public boolean equals(Object object) {
|
return this.nombusuario;
|
||||||
if (!(object instanceof Usuario)) {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Usuario other = (Usuario) object;
|
|
||||||
if ((this.usuarioId == null && other.usuarioId != null) || (this.usuarioId != null && !this.usuarioId.equals(other.usuarioId))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public boolean isAccountNonExpired() {
|
||||||
public String toString() {
|
return true;
|
||||||
return "com.rjconsultores.ventaboletos.entidad.Usuario[usuarioId=" + usuarioId + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<GrantedAuthority> getAuthorities() {
|
public boolean isAccountNonLocked() {
|
||||||
return new ArrayList<GrantedAuthority>();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public boolean isCredentialsNonExpired() {
|
||||||
return this.senha;
|
if (ApplicationProperties.getInstance().contrasenaValidaComplejidad()) {
|
||||||
}
|
if (getFecContrasena() != null) {
|
||||||
|
ConstanteService constanteService = (ConstanteService) AppContext.getApplicationContext().getBean("constanteService");
|
||||||
|
Constante contante = constanteService.buscarPorNomeConstante("CANT_DIAS_CONTRASENA");
|
||||||
|
Integer maxPrazoCambioContrasena = Integer.valueOf(contante.getValorconstante());
|
||||||
|
Date maxFechaContrasena = DateUtil.somarDias(getFecContrasena(), maxPrazoCambioContrasena);
|
||||||
|
if (Calendar.getInstance().getTime().after(maxFechaContrasena)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
return true;
|
||||||
return this.nombusuario;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAccountNonExpired() {
|
public boolean isEnabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAccountNonLocked() {
|
public Object getCredentials() {
|
||||||
return true;
|
return new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCredentialsNonExpired() {
|
public Object getDetails() {
|
||||||
return true;
|
return new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public Object getPrincipal() {
|
||||||
return true;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getCredentials() {
|
public boolean isAuthenticated() {
|
||||||
return new Object();
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getDetails() {
|
public void setAuthenticated(boolean bln) throws IllegalArgumentException {
|
||||||
return new Object();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Object getPrincipal() {
|
public String getName() {
|
||||||
return this;
|
return this.getNombusuario();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthenticated() {
|
public String getDescCorreo() {
|
||||||
return Boolean.TRUE;
|
return descCorreo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthenticated(boolean bln) throws IllegalArgumentException {
|
public void setDescCorreo(String descCorreo) {
|
||||||
}
|
this.descCorreo = descCorreo;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public Boolean getIndCorteAutomatico() {
|
||||||
return this.getNombusuario();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescCorreo() {
|
|
||||||
return descCorreo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescCorreo(String descCorreo) {
|
|
||||||
this.descCorreo = descCorreo;
|
|
||||||
}
|
|
||||||
public Boolean getIndCorteAutomatico() {
|
|
||||||
return indCorteAutomatico;
|
return indCorteAutomatico;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,16 +334,24 @@ public class Usuario implements Serializable, Authentication, UserDetails {
|
||||||
public List<UsuarioUbicacion> getUsuarioUbicacionList() {
|
public List<UsuarioUbicacion> getUsuarioUbicacionList() {
|
||||||
List<UsuarioUbicacion> ubicacionActivos = new ArrayList<UsuarioUbicacion>();
|
List<UsuarioUbicacion> ubicacionActivos = new ArrayList<UsuarioUbicacion>();
|
||||||
|
|
||||||
if(usuarioUbicacionList != null)
|
if (usuarioUbicacionList != null)
|
||||||
for(UsuarioUbicacion ubicacion : usuarioUbicacionList)
|
for (UsuarioUbicacion ubicacion : usuarioUbicacionList)
|
||||||
if(ubicacion.getActivo())
|
if (ubicacion.getActivo())
|
||||||
ubicacionActivos.add(ubicacion);
|
ubicacionActivos.add(ubicacion);
|
||||||
|
|
||||||
|
|
||||||
return ubicacionActivos;
|
return ubicacionActivos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsuarioUbicacionList(List<UsuarioUbicacion> usuarioUbicacionList) {
|
public void setUsuarioUbicacionList(List<UsuarioUbicacion> usuarioUbicacionList) {
|
||||||
this.usuarioUbicacionList = usuarioUbicacionList;
|
this.usuarioUbicacionList = usuarioUbicacionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getFecContrasena() {
|
||||||
|
return fecContrasena;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFecContrasena(Date fecContrasena) {
|
||||||
|
this.fecContrasena = fecContrasena;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ public interface UsuarioService {
|
||||||
|
|
||||||
public List<Usuario> obtenerTodos();
|
public List<Usuario> obtenerTodos();
|
||||||
|
|
||||||
public Usuario obtenerID(Integer id);
|
public Usuario obtenerID(Integer id);
|
||||||
|
|
||||||
public void borrar(Usuario entidad);
|
public void borrar(Usuario entidad);
|
||||||
|
|
||||||
public List<Usuario> buscarPeloNome(String nome);
|
public List<Usuario> buscarPeloNome(String nome);
|
||||||
|
|
||||||
|
@ -32,4 +32,6 @@ public interface UsuarioService {
|
||||||
public List<Usuario> buscarPelaCveUsuario(String claveUsuario);
|
public List<Usuario> buscarPelaCveUsuario(String claveUsuario);
|
||||||
|
|
||||||
public Usuario suscribirActualizar(Usuario entidad, String senha, Perfil perfil) throws BusinessException;
|
public Usuario suscribirActualizar(Usuario entidad, String senha, Perfil perfil) throws BusinessException;
|
||||||
|
|
||||||
|
public Usuario cambiarContrasena(Usuario entidad, String senha) throws BusinessException;
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.security.authentication.CredentialsExpiredException;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
|
@ -54,15 +55,15 @@ public class UsuarioServiceImpl implements UsuarioService, UserDetailsService {
|
||||||
|
|
||||||
@Transactional(rollbackFor = BusinessException.class)
|
@Transactional(rollbackFor = BusinessException.class)
|
||||||
@Override
|
@Override
|
||||||
public Usuario suscribirActualizar(Usuario entidad,String senha,Perfil perfil) throws BusinessException {
|
public Usuario suscribirActualizar(Usuario entidad, String senha, Perfil perfil) throws BusinessException {
|
||||||
|
|
||||||
//validación duplicado
|
// validación duplicado
|
||||||
List<Usuario> lsUsuario = this.buscarPelaCveUsuario(entidad.getClaveUsuario());
|
List<Usuario> lsUsuario = this.buscarPelaCveUsuario(entidad.getClaveUsuario());
|
||||||
boolean podeSalvar = false;
|
boolean podeSalvar = false;
|
||||||
if (lsUsuario.isEmpty()) {
|
if (lsUsuario.isEmpty()) {
|
||||||
podeSalvar = true;
|
podeSalvar = true;
|
||||||
} else {
|
} else {
|
||||||
if (entidad.getUsuarioId() != null){
|
if (entidad.getUsuarioId() != null) {
|
||||||
for (Usuario u : lsUsuario) {
|
for (Usuario u : lsUsuario) {
|
||||||
if (u.getUsuarioId().equals(entidad.getUsuarioId())) {
|
if (u.getUsuarioId().equals(entidad.getUsuarioId())) {
|
||||||
podeSalvar = true;
|
podeSalvar = true;
|
||||||
|
@ -74,17 +75,17 @@ public class UsuarioServiceImpl implements UsuarioService, UserDetailsService {
|
||||||
if (!podeSalvar) {
|
if (!podeSalvar) {
|
||||||
throw new BusinessException("MSG.Registro.Existe");
|
throw new BusinessException("MSG.Registro.Existe");
|
||||||
}
|
}
|
||||||
if (senha != null){
|
if (senha != null) {
|
||||||
//validación complejidad contrasena
|
// validación complejidad contrasena
|
||||||
if (ApplicationProperties.getInstance().contrasenaValidaComplejidad()){
|
if (ApplicationProperties.getInstance().contrasenaValidaComplejidad()) {
|
||||||
ContrasenaUtileria.validarContrasenaCompleja(senha);
|
ContrasenaUtileria.validarContrasenaCompleja(senha);
|
||||||
}
|
}
|
||||||
|
|
||||||
//encriptación contrasena
|
// encriptación contrasena
|
||||||
entidad.setSenha(ContrasenaUtileria.encriptarContrasena(senha));
|
entidad.setSenha(ContrasenaUtileria.encriptarContrasena(senha));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Perfil
|
// Perfil
|
||||||
UsuarioPerfil up = new UsuarioPerfil();
|
UsuarioPerfil up = new UsuarioPerfil();
|
||||||
up.setUsuario(entidad);
|
up.setUsuario(entidad);
|
||||||
up.setPerfil(perfil);
|
up.setPerfil(perfil);
|
||||||
|
@ -102,17 +103,61 @@ public class UsuarioServiceImpl implements UsuarioService, UserDetailsService {
|
||||||
lsUp.add(up);
|
lsUp.add(up);
|
||||||
entidad.setUsuarioPerfilList(lsUp);
|
entidad.setUsuarioPerfilList(lsUp);
|
||||||
|
|
||||||
|
|
||||||
entidad.setUsuariomodifId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuariomodifId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
entidad.setActivo(Boolean.TRUE);
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
if (entidad.getUsuarioId() == null){
|
if (entidad.getUsuarioId() == null) {
|
||||||
return usuarioDAO.suscribir(entidad);
|
return usuarioDAO.suscribir(entidad);
|
||||||
}else{
|
} else {
|
||||||
return usuarioDAO.actualizacion(entidad);
|
return usuarioDAO.actualizacion(entidad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = BusinessException.class)
|
||||||
|
@Override
|
||||||
|
public Usuario cambiarContrasena(Usuario entidad, String senha) throws BusinessException {
|
||||||
|
|
||||||
|
// validación duplicado
|
||||||
|
List<Usuario> lsUsuario = this.buscarPelaCveUsuario(entidad.getClaveUsuario());
|
||||||
|
boolean podeSalvar = false;
|
||||||
|
if (lsUsuario.isEmpty()) {
|
||||||
|
podeSalvar = true;
|
||||||
|
} else {
|
||||||
|
if (entidad.getUsuarioId() != null) {
|
||||||
|
for (Usuario u : lsUsuario) {
|
||||||
|
if (u.getUsuarioId().equals(entidad.getUsuarioId())) {
|
||||||
|
podeSalvar = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!podeSalvar) {
|
||||||
|
throw new BusinessException("MSG.Registro.Existe");
|
||||||
|
}
|
||||||
|
if (senha != null) {
|
||||||
|
// validación complejidad contrasena
|
||||||
|
if (ApplicationProperties.getInstance().contrasenaValidaComplejidad()) {
|
||||||
|
ContrasenaUtileria.validarContrasenaCompleja(senha);
|
||||||
|
}
|
||||||
|
|
||||||
|
// encriptación contrasena
|
||||||
|
entidad.setSenha(ContrasenaUtileria.encriptarContrasena(senha));
|
||||||
|
}
|
||||||
|
|
||||||
|
entidad.setFecContrasena(Calendar.getInstance().getTime());
|
||||||
|
entidad.setUsuariomodifId(entidad.getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
if (entidad.getUsuarioId() != null) {
|
||||||
|
return usuarioDAO.actualizacion(entidad);
|
||||||
|
} else {
|
||||||
|
throw new BusinessException("MSG.Registro.Existe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void borrar(Usuario entidad) {
|
public void borrar(Usuario entidad) {
|
||||||
|
|
||||||
|
@ -132,11 +177,12 @@ public class UsuarioServiceImpl implements UsuarioService, UserDetailsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Usuario buscarPeloNomeSenha(String stUsuario, String senha) {
|
public Usuario buscarPeloNomeSenha(String stUsuario, String senha) {
|
||||||
|
senha = ContrasenaUtileria.encriptarContrasena(senha);
|
||||||
return usuarioDAO.buscarPeloNomeSenha(stUsuario, senha);
|
return usuarioDAO.buscarPeloNomeSenha(stUsuario, senha);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException, DataAccessException {
|
public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException, DataAccessException, CredentialsExpiredException {
|
||||||
if (login == null) {
|
if (login == null) {
|
||||||
throw new UsernameNotFoundException("Usuario não encontrado");
|
throw new UsernameNotFoundException("Usuario não encontrado");
|
||||||
}
|
}
|
||||||
|
@ -146,7 +192,15 @@ public class UsuarioServiceImpl implements UsuarioService, UserDetailsService {
|
||||||
throw new UsernameNotFoundException("Usuario não encontrado");
|
throw new UsernameNotFoundException("Usuario não encontrado");
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.get(0);
|
Usuario user = list.get(0);
|
||||||
|
|
||||||
|
if (ApplicationProperties.getInstance().contrasenaValidaComplejidad()) {
|
||||||
|
if (!user.isCredentialsNonExpired()) {
|
||||||
|
throw new CredentialsExpiredException("Senha Expirada");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Usuario> buscarPorEmpleado(Empleado empleado) {
|
public List<Usuario> buscarPorEmpleado(Empleado empleado) {
|
||||||
|
|
|
@ -15,6 +15,9 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
public final class DateUtil {
|
public final class DateUtil {
|
||||||
|
|
||||||
|
public static Integer DIA = Integer.valueOf(1000 * 60 * 60 * 24);
|
||||||
|
public static Integer UM_DIA = Integer.valueOf(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No need for an instance
|
* No need for an instance
|
||||||
*/
|
*/
|
||||||
|
@ -532,4 +535,12 @@ public final class DateUtil {
|
||||||
return gcalendar.getTime();
|
return gcalendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Date somarDias(Date data, int quantidadeDias) {
|
||||||
|
Integer dias = UM_DIA * quantidadeDias;
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(data);
|
||||||
|
c.add(Calendar.DAY_OF_MONTH, dias);
|
||||||
|
return c.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue