Created
May 12, 2016 13:24
-
-
Save rafaelzomer/2600ddc0604567080d07ac1ee722978b to your computer and use it in GitHub Desktop.
Current session on Spring Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
public class ConfigController { | |
@Autowired | |
private UsuarioLogado usuarioLogado; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@Scope(value="session", proxyMode= ScopedProxyMode.TARGET_CLASS) | |
//Ignorar properties que a session injeta nessa classe | |
@JsonIgnoreProperties({ "targetSource", "advisors", "classFilter", "frozen", "targetClass", | |
"proxyTargetClass", "exposeProxy", "proxiedInterfaces", "targetObject", "preFiltered"}) | |
public class UsuarioLogado implements Serializable { | |
private Long id; | |
private String descricao; | |
private HashMap<Long, Permissao> permissoes; | |
private Empresa empresa; | |
public void deslogar() { | |
this.id = null; | |
this.descricao = null; | |
this.permissoes = null; | |
this.empresa = null; | |
} | |
public Empresa getEmpresa() { | |
return empresa; | |
} | |
public void setEmpresa(Empresa empresa) { | |
this.empresa = empresa; | |
} | |
public Long getId() { | |
return id; | |
} | |
public void setId(Long id) { | |
this.id = id; | |
} | |
public HashMap<Long, Permissao> getPermissoes() { | |
return permissoes; | |
} | |
public void setPermissoes(HashMap<Long, Permissao> permissoes) { | |
this.permissoes = permissoes; | |
} | |
public String getDescricao() { | |
return descricao; | |
} | |
public void setDescricao(String descricao) { | |
this.descricao = descricao; | |
} | |
@Override | |
public String toString() { | |
return "UsuarioLogado{" + | |
"id=" + id + | |
"descricao=" + descricao + | |
", permissoes=" + (permissoes != null ? permissoes.size() : null) + | |
'}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment