Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.srv.web.managebean.sessao; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import javax.faces.bean.ManagedBean; |
||
| 5 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 6 | import org.springframework.context.annotation.Scope; |
||
| 7 | import org.springframework.security.core.Authentication; |
||
| 8 | import org.springframework.security.core.context.SecurityContextHolder; |
||
| 9 | import org.springframework.stereotype.Component; |
||
| 10 | import br.gov.al.saude.framework.core.util.VerificadorUtil; |
||
| 11 | import br.gov.al.saude.framework.model.UsuarioView; |
||
| 12 | import br.gov.al.saude.framework.security.authentication.entity.UserIndra; |
||
| 13 | import br.gov.al.saude.srv.core.application.servidor.ServidorFacade; |
||
| 14 | import br.gov.al.saude.srv.model.Servidor; |
||
| 15 | |||
| 16 | @Component |
||
| 17 | @ManagedBean |
||
| 18 | @Scope("session") |
||
| 19 | public class SessaoBean implements Serializable { |
||
| 20 | |||
| 21 | private ServidorFacade servidorFacade; |
||
| 22 | private Servidor servidor; |
||
| 23 | |||
| 24 | private static final long serialVersionUID = 1L; |
||
| 25 | |||
| 26 | @Autowired |
||
| 27 | public SessaoBean(ServidorFacade servidorFacade) { |
||
| 28 | this.servidorFacade = servidorFacade; |
||
| 29 | getServidor(); |
||
| 30 | } |
||
| 31 | |||
| 32 | public UserIndra obterUserIndra() { |
||
| 33 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
||
| 34 | UserIndra principal = (UserIndra) authentication.getPrincipal(); |
||
| 35 | return principal; |
||
| 36 | } |
||
| 37 | |||
| 38 | public UsuarioView getUsuarioLogado() { |
||
| 39 | return (UsuarioView) obterUserIndra().getPrincipal(); |
||
| 40 | } |
||
| 41 | |||
| 42 | public Servidor getServidor() { |
||
| 43 | if(VerificadorUtil.estaNulo(servidor)){ |
||
| 44 | try { |
||
| 45 | setServidor(servidorFacade.consultarServidorPorSequencial(getUsuarioLogado().getSequencialPessoa())); |
||
| 46 | } catch (Exception e) {} |
||
| 47 | } |
||
| 48 | return servidor; |
||
| 49 | } |
||
| 50 | |||
| 51 | public void setServidor(Servidor servidor) { |
||
| 52 | this.servidor = servidor; |
||
| 53 | } |
||
| 54 | |||
| 55 | } |