Rev 226 | Rev 242 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 226 | Rev 227 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | 4 | ||
| 5 | import org.springframework.stereotype.Controller; |
5 | import org.springframework.stereotype.Controller; |
| 6 | 6 | ||
| 7 | import br.com.ec.domain.dto.UsuarioDTO; |
7 | import br.com.ec.domain.dto.UsuarioDTO; |
| 8 | import br.com.ec.domain.service.ContextoSeguranca; |
8 | import br.com.ec.domain.service.ContextoSeguranca; |
| - | 9 | import br.com.ec.domain.service.PerfilService; |
|
| 9 | import br.com.ec.domain.service.UsuarioService; |
10 | import br.com.ec.domain.service.UsuarioService; |
| 10 | import br.com.ec.web.exception.VerificadorLancamentoException; |
11 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 11 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
12 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
| 12 | import br.com.ec.web.message.LancadorMensagem; |
13 | import br.com.ec.web.message.LancadorMensagem; |
| 13 | 14 | ||
| Line 21... | Line 22... | ||
| 21 | private String loginParaResetarSenha; |
22 | private String loginParaResetarSenha; |
| 22 | private String cpfParaResetarSenha; |
23 | private String cpfParaResetarSenha; |
| 23 | 24 | ||
| 24 | private ContextoSeguranca contextoSeguranca; |
25 | private ContextoSeguranca contextoSeguranca; |
| 25 | private UsuarioService usuarioService; |
26 | private UsuarioService usuarioService; |
| - | 27 | private PerfilService perfilService; |
|
| 26 | 28 | ||
| 27 | @Inject |
29 | @Inject |
| 28 | public SegurancaBean(ContextoSeguranca contextoSeguranca, UsuarioService usuarioService/*, PerfilService perfilService*/) { |
- | |
| - | 30 | public SegurancaBean(ContextoSeguranca contextoSeguranca, UsuarioService usuarioService, PerfilService perfilService) { |
|
| 29 | this.contextoSeguranca = contextoSeguranca; |
31 | this.contextoSeguranca = contextoSeguranca; |
| 30 | this.usuarioService = usuarioService; |
32 | this.usuarioService = usuarioService; |
| 31 | // this.perfilService = perfilService;
|
- | |
| - | 33 | this.perfilService = perfilService; |
|
| 32 | }
|
34 | }
|
| 33 | 35 | ||
| 34 | public UsuarioDTO getUsuarioDTO() { |
36 | public UsuarioDTO getUsuarioDTO() { |
| 35 | if (usuarioDTO == null) { |
37 | if (usuarioDTO == null) { |
| 36 | setUsuarioDTO(contextoSeguranca.obterUsuario()); |
38 | setUsuarioDTO(contextoSeguranca.obterUsuario()); |
| Line 91... | Line 93... | ||
| 91 | LancadorMensagem.lancarSucesso("SENHA PROVISÓRIA ENVIADA PARA O EMAIL: " + emailEnviado); |
93 | LancadorMensagem.lancarSucesso("SENHA PROVISÓRIA ENVIADA PARA O EMAIL: " + emailEnviado); |
| 92 | }
|
94 | }
|
| 93 | }); |
95 | }); |
| 94 | }
|
96 | }
|
| 95 | 97 | ||
| 96 | /*
|
- | |
| 97 | public Boolean temPerfilAdministrador() {
|
98 | public Boolean temPerfilAdministrador() { |
| 98 | return perfilService.temPerfilAdministrador(getUsuario());
|
- | |
| - | 99 | return perfilService.temPerfilAdministrador(getUsuarioDTO().getPerfis()); |
|
| 99 | }
|
100 | }
|
| 100 |
|
101 | |
| 101 | public Boolean temPerfilGerenteAdministrativo() {
|
102 | public Boolean temPerfilGerenteAdministrativo() { |
| 102 | return perfilService.temPerfilGerenteAdministrativo(getUsuario());
|
- | |
| - | 103 | return perfilService.temPerfilGerenteAdministrativo(getUsuarioDTO().getPerfis()); |
|
| 103 | }
|
104 | }
|
| 104 | */
|
- | |
| - | 105 | ||
| 105 | /************************************************************************/
|
106 | /************************************************************************/
|
| 106 | 107 | ||
| 107 | /*
|
- | |
| 108 | public Boolean temPerfilGerenteFinanceiro() {
|
108 | public Boolean temPerfilGerenteFinanceiro() { |
| 109 | return perfilService.temPerfilGerenteFinanceiro(getUsuario());
|
- | |
| - | 109 | return perfilService.temPerfilGerenteFinanceiro(getUsuarioDTO().getPerfis()); |
|
| 110 | }
|
110 | }
|
| 111 |
|
111 | |
| 112 | public Boolean temPerfilGerenteComercial() {
|
112 | public Boolean temPerfilGerenteComercial() { |
| 113 | return perfilService.temPerfilGerenteComercial(getUsuario());
|
- | |
| - | 113 | return perfilService.temPerfilGerenteComercial(getUsuarioDTO().getPerfis()); |
|
| 114 | }
|
114 | }
|
| 115 |
|
115 | |
| 116 | public Boolean temPerfilGerenteDeLojistica() {
|
116 | public Boolean temPerfilGerenteDeLojistica() { |
| 117 | return perfilService.temPerfilGerenteDeLojistica(getUsuario());
|
- | |
| - | 117 | return perfilService.temPerfilGerenteDeLojistica(getUsuarioDTO().getPerfis()); |
|
| 118 | }
|
118 | }
|
| 119 |
|
119 | |
| 120 | public Boolean temPerfilVendedor() {
|
120 | public Boolean temPerfilVendedor() { |
| 121 | return perfilService.temPerfilVendedor(getUsuario());
|
- | |
| - | 121 | return perfilService.temPerfilVendedor(getUsuarioDTO().getPerfis()); |
|
| 122 | }
|
122 | }
|
| 123 |
|
123 | |
| 124 | public Boolean temPerfilGerenteDeCompras() {
|
124 | public Boolean temPerfilGerenteDeCompras() { |
| 125 | return perfilService.temPerfilGerenteDeCompras(getUsuario());
|
- | |
| - | 125 | return perfilService.temPerfilGerenteDeCompras(getUsuarioDTO().getPerfis()); |
|
| 126 | }
|
126 | }
|
| 127 |
|
127 | |
| 128 | public Boolean temPerfilGerenteVivo() {
|
128 | public Boolean temPerfilGerenteVivo() { |
| 129 | return perfilService.temPerfilGerenteVivo(getUsuario());
|
- | |
| - | 129 | return perfilService.temPerfilGerenteVivo(getUsuarioDTO().getPerfis()); |
|
| 130 | }
|
130 | }
|
| 131 |
|
131 | |
| 132 | public Boolean temPerfilTecnico() {
|
132 | public Boolean temPerfilTecnico() { |
| 133 | return perfilService.temPerfilTecnico(getUsuario());
|
- | |
| - | 133 | return perfilService.temPerfilTecnico(getUsuarioDTO().getPerfis()); |
|
| 134 | }
|
134 | }
|
| 135 |
|
135 | |
| 136 | public Boolean temPerfilRecursosHumanos() {
|
136 | public Boolean temPerfilRecursosHumanos() { |
| 137 | return perfilService.temPerfilRecursosHumanos(getUsuario());
|
- | |
| - | 137 | return perfilService.temPerfilRecursosHumanos(getUsuarioDTO().getPerfis()); |
|
| 138 | }
|
138 | }
|
| 139 |
|
139 | |
| 140 | public Boolean temPerfilGerenteDeOperacoes() {
|
140 | public Boolean temPerfilGerenteDeOperacoes() { |
| 141 | return perfilService.temPerfilGerenteDeOperacoes(getUsuario());
|
- | |
| - | 141 | return perfilService.temPerfilGerenteDeOperacoes(getUsuarioDTO().getPerfis()); |
|
| 142 | }
|
142 | }
|
| 143 |
|
143 | |
| 144 | public Boolean temPerfilSupervisor() {
|
144 | public Boolean temPerfilSupervisor() { |
| 145 | return perfilService.temPerfilSupervisor(getUsuario());
|
- | |
| - | 145 | return perfilService.temPerfilSupervisor(getUsuarioDTO().getPerfis()); |
|
| 146 | }
|
146 | }
|
| 147 |
|
147 | |
| 148 | public Boolean temPerfilTreinamento() {
|
148 | public Boolean temPerfilTreinamento() { |
| 149 | return perfilService.temPerfilTreinamento(getUsuario());
|
- | |
| - | 149 | return perfilService.temPerfilTreinamento(getUsuarioDTO().getPerfis()); |
|
| 150 | }
|
150 | }
|
| 151 |
|
151 | |
| 152 | public Boolean temPerfilLoja() {
|
152 | public Boolean temPerfilLoja() { |
| 153 | return perfilService.temPerfilLoja(getUsuario());
|
- | |
| - | 153 | return perfilService.temPerfilLoja(getUsuarioDTO().getPerfis()); |
|
| 154 | }
|
154 | }
|
| 155 |
|
155 | |
| - | 156 | /*
|
|
| 156 | public Boolean temAcessoLoja(Long sequencialLoja) {
|
157 | public Boolean temAcessoLoja(Long sequencialLoja) {
|
| 157 | return temPerfilGerenteAdministrativo() || verificarAcessoLoja(getUsuario(), sequencialLoja);
|
- | |
| - | 158 | return temPerfilGerenteAdministrativo() || verificarAcessoLoja(getUsuarioDTO().getPerfis(), sequencialLoja);
|
|
| 158 | }
|
159 | }
|
| 159 |
|
160 |
|
| 160 | public Boolean temAcessoLojaVivo() {
|
161 | public Boolean temAcessoLojaVivo() {
|
| 161 | return temPerfilGerenteAdministrativo() || verificarAcessoLoja(getUsuario(), ConstantesSEC.SEQUENCIAL_LOJA_VIVO_4);
|
- | |
| - | 162 | return temPerfilGerenteAdministrativo() || verificarAcessoLoja(getUsuarioDTO().getPerfis(), ConstantesSEC.SEQUENCIAL_LOJA_VIVO_4);
|
|
| 162 | }
|
163 | }
|
| 163 |
|
164 |
|
| 164 | public Boolean temAcessoLojaCasaDasCapas() {
|
165 | public Boolean temAcessoLojaCasaDasCapas() {
|
| 165 | return temPerfilGerenteDeCompras() || temPerfilGerenteComercial() || (verificarAcessoLoja(getUsuario(), ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17) && temPerfilVendedor());
|
- | |
| - | 166 | return temPerfilGerenteDeCompras() || temPerfilGerenteComercial() || (verificarAcessoLoja(getUsuarioDTO().getPerfis(), ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17) && temPerfilVendedor());
|
|
| 166 | }
|
167 | }
|
| 167 |
|
168 |
|
| 168 | public Boolean naoTemAcessoLojaCasaDasCapas() {
|
169 | public Boolean naoTemAcessoLojaCasaDasCapas() {
|
| 169 | return temPerfilGerenteDeCompras() || temPerfilGerenteComercial() || !(verificarAcessoLoja(getUsuario(), ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17) && temPerfilVendedor());
|
- | |
| - | 170 | return temPerfilGerenteDeCompras() || temPerfilGerenteComercial() || !(verificarAcessoLoja(getUsuarioDTO().getPerfis(), ConstantesSEC.SEQUENCIAL_CASA_DAS_CAPAS_17) && temPerfilVendedor());
|
|
| 170 | }
|
171 | }
|
| - | 172 | */
|
|
| 171 |
|
173 | |
| - | 174 | /*
|
|
| 172 | private Boolean verificarAcessoLoja(Usuario usuario, Long sequencialLoja) {
|
175 | private Boolean verificarAcessoLoja(Usuario usuario, Long sequencialLoja) {
|
| 173 | for (UsuarioLoja usuarioLoja : usuario.getLojas()) {
|
176 | for (UsuarioLoja usuarioLoja : usuario.getLojas()) {
|
| 174 | if (usuarioLoja.getLoja().getSequencial().equals(sequencialLoja)) {
|
177 | if (usuarioLoja.getLoja().getSequencial().equals(sequencialLoja)) {
|
| 175 | return true;
|
178 | return true;
|
| 176 | }
|
179 | }
|