Commit 8f9d0607ca81de5d81ef7a60e4751797d46e3164
1 parent
91416358
Exists in
master
redmine #4583 validacao usuario ldap ao assinar
Showing
1 changed file
with
25 additions
and
35 deletions
Show diff stats
cit-ecm-api/src/main/java/br/com/centralit/api/service/impl/AssinaturaServiceImpl.java
| ... | ... | @@ -35,10 +35,13 @@ import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
| 35 | 35 | import br.com.centralit.framework.util.UtilObjeto; |
| 36 | 36 | import br.com.centralit.framework.util.UtilString; |
| 37 | 37 | |
| 38 | - | |
| 39 | 38 | /** |
| 40 | - * <p><b>Title: </b></p> | |
| 41 | - * <p><b>Description: </b></p> | |
| 39 | + * <p> | |
| 40 | + * <b>Title: </b> | |
| 41 | + * </p> | |
| 42 | + * <p> | |
| 43 | + * <b>Description: </b> | |
| 44 | + * </p> | |
| 42 | 45 | * <p> |
| 43 | 46 | * <b>Title: </b> |
| 44 | 47 | * </p> |
| ... | ... | @@ -56,39 +59,30 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 56 | 59 | |
| 57 | 60 | @Autowired |
| 58 | 61 | private AssinaturaDao assinaturaDao; |
| 59 | - | |
| 60 | 62 | |
| 61 | 63 | @Autowired |
| 62 | 64 | private DocumentoGedService documentoGedService; |
| 63 | - | |
| 64 | 65 | |
| 65 | 66 | @Autowired |
| 66 | 67 | private UsuarioService usuarioService; |
| 67 | - | |
| 68 | 68 | |
| 69 | 69 | @Autowired |
| 70 | 70 | private DominioService dominioService; |
| 71 | - | |
| 72 | 71 | |
| 73 | 72 | @Autowired |
| 74 | 73 | private FuncaoService funcaoService; |
| 75 | - | |
| 76 | 74 | |
| 77 | 75 | @Autowired |
| 78 | 76 | private PessoaService pessoaService; |
| 79 | - | |
| 80 | 77 | |
| 81 | 78 | @Autowired |
| 82 | 79 | private HistoricoAlteracaoProcessoService historicoAlteracaoProcessoService; |
| 83 | - | |
| 84 | 80 | |
| 85 | 81 | @Autowired |
| 86 | 82 | private TarjaAssinaturaService tarjaAssinaturaService; |
| 87 | - | |
| 88 | 83 | |
| 89 | 84 | @Value("${metodo.autenticacao.ldap}") |
| 90 | 85 | private String ldap; |
| 91 | - | |
| 92 | 86 | |
| 93 | 87 | @Value("${ldap.host.name}") |
| 94 | 88 | public String ldapHostName; |
| ... | ... | @@ -103,12 +97,10 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 103 | 97 | public String ldapSearchDC; |
| 104 | 98 | |
| 105 | 99 | @Autowired |
| 106 | - public AssinaturaServiceImpl( AssinaturaDao assinaturaDao) { | |
| 107 | 100 | public AssinaturaServiceImpl( AssinaturaDao assinaturaDao ) { |
| 108 | 101 | |
| 109 | 102 | this.dao = assinaturaDao; |
| 110 | 103 | } |
| 111 | - | |
| 112 | 104 | |
| 113 | 105 | /** |
| 114 | 106 | * Salva assinatura do documento e gera histórico |
| ... | ... | @@ -120,7 +112,7 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 120 | 112 | validarSenha(assinatura.getPassword(), usuario); |
| 121 | 113 | montarTransients(assinatura, usuario); |
| 122 | 114 | historicoAlteracaoProcessoService.gerarHistoricoAssinatura(assinatura); |
| 123 | - tarjaAssinaturaService.gerarAssinaturaInternaUsuario(assinatura,assinatura.getDocumentoGed().getFormaCriacao().getCodigo()); | |
| 115 | + tarjaAssinaturaService.gerarAssinaturaInternaUsuario(assinatura, assinatura.getDocumentoGed().getFormaCriacao().getCodigo()); | |
| 124 | 116 | tarjaAssinaturaService.gerarAssinaturaInternaUsuario(assinatura, assinatura.getDocumentoGed().getFormaCriacao().getCodigo()); |
| 125 | 117 | alterarEstadoDocumento(assinatura.getDocumentoGed()); |
| 126 | 118 | return super.save(assinatura); |
| ... | ... | @@ -133,10 +125,11 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 133 | 125 | * @param documentoGed |
| 134 | 126 | */ |
| 135 | 127 | private void alterarEstadoDocumento(DocumentoGed documentoGed) { |
| 136 | - if(documentoGed.getFormaCriacao().getCodigo().equals(1L) && !documentoGed.getEstado().getCodigo().equals(2L)) | |
| 137 | 128 | |
| 138 | 129 | if (documentoGed.getFormaCriacao().getCodigo().equals(1L) && !documentoGed.getEstado().getCodigo().equals(2L)) |
| 139 | - documentoGed.setEstado(dominioService.findByChaveAndCodigo("estadoDocumentoGed", 2L)); | |
| 130 | + | |
| 131 | + if (documentoGed.getFormaCriacao().getCodigo().equals(1L) && !documentoGed.getEstado().getCodigo().equals(2L)) | |
| 132 | + documentoGed.setEstado(dominioService.findByChaveAndCodigo("estadoDocumentoGed", 2L)); | |
| 140 | 133 | } |
| 141 | 134 | |
| 142 | 135 | /** |
| ... | ... | @@ -154,7 +147,6 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 154 | 147 | assinatura.setTipoAssinatura(dominioService.findByChaveAndCodigo(Dominio.TIPO_ASSINATURA, Dominio.TIPO_ASSINATURA_INTERNA)); |
| 155 | 148 | assinatura.setFuncao(funcaoService.getReference(assinatura.getFuncao().getId())); |
| 156 | 149 | } |
| 157 | - | |
| 158 | 150 | |
| 159 | 151 | /** |
| 160 | 152 | * Método responsável por validar senha para assinar o documento |
| ... | ... | @@ -164,24 +156,25 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 164 | 156 | * @param usuario |
| 165 | 157 | */ |
| 166 | 158 | private void validarSenha(String password, Usuario usuario) { |
| 167 | - | |
| 168 | - if(!UtilString.isNullOrEmpty(ldap) && ldap.equals("false")) { | |
| 169 | 159 | |
| 170 | - if(UtilString.isNullOrEmpty(password)) | |
| 171 | - if (!UtilString.isNullOrEmpty(ldap) && !Boolean.parseBoolean(ldap)) { | |
| 160 | + if (!UtilString.isNullOrEmpty(ldap) && ldap.equals("false")) { | |
| 172 | 161 | |
| 173 | 162 | if (UtilString.isNullOrEmpty(password)) |
| 174 | - throw new BusinessException("ECM.VALIDACAO.SENHA_ASSINATURA", CodigoErro.REGRA_NEGOCIO.getValue(), ""); | |
| 175 | - | |
| 176 | - if(!UtilObjeto.isReferencia(this.usuarioService.loadUserByUsernamePasswordMobile(usuario.getUsername(), password))) | |
| 163 | + if (!UtilString.isNullOrEmpty(ldap) && !Boolean.parseBoolean(ldap)) { | |
| 164 | + | |
| 165 | + if (UtilString.isNullOrEmpty(password)) | |
| 166 | + throw new BusinessException("ECM.VALIDACAO.SENHA_ASSINATURA", CodigoErro.REGRA_NEGOCIO.getValue(), ""); | |
| 167 | + | |
| 168 | + if (!UtilObjeto.isReferencia(this.usuarioService.loadUserByUsernamePasswordMobile(usuario.getUsername(), password))) | |
| 177 | 169 | |
| 178 | - if (!UtilObjeto.isReferencia(this.usuarioService.loadUserByUsernamePasswordMobile(usuario.getUsername(), password))) | |
| 179 | - throw new BusinessException("ECM.VALIDACAO.SENHA_ASSINATURA_INVALIDA", CodigoErro.REGRA_NEGOCIO.getValue(), ""); | |
| 180 | - | |
| 170 | + if (!UtilObjeto.isReferencia(this.usuarioService.loadUserByUsernamePasswordMobile(usuario.getUsername(), password))) | |
| 171 | + throw new BusinessException("ECM.VALIDACAO.SENHA_ASSINATURA_INVALIDA", CodigoErro.REGRA_NEGOCIO.getValue(), ""); | |
| 181 | 172 | |
| 182 | - } else if (!UtilString.isNullOrEmpty(ldap) && Boolean.parseBoolean(ldap)) { | |
| 173 | + } else if (!UtilString.isNullOrEmpty(ldap) && Boolean.parseBoolean(ldap)) { | |
| 174 | + | |
| 175 | + autenticarMaster(password, usuario.getUsername()); | |
| 176 | + } | |
| 183 | 177 | |
| 184 | - autenticarMaster(password, usuario.getUsername()); | |
| 185 | 178 | } |
| 186 | 179 | } |
| 187 | 180 | |
| ... | ... | @@ -211,11 +204,10 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 211 | 204 | if (autenticarUser(result.getName() + "," + ldapSearchDC, password)) { |
| 212 | 205 | return Boolean.TRUE; |
| 213 | 206 | } else { |
| 214 | - //TODO LDAP validação | |
| 215 | 207 | throw new BusinessException("ECM.VALIDACAO.SENHA_ASSINATURA_INVALIDA", CodigoErro.REGRA_NEGOCIO.getValue(), ""); |
| 216 | 208 | } |
| 217 | 209 | } |
| 218 | - | |
| 210 | + | |
| 219 | 211 | } catch (AuthenticationException authEx) { |
| 220 | 212 | throw new BusinessException("ECM.VALIDACAO.SENHA_ASSINATURA_INVALIDA", CodigoErro.REGRA_NEGOCIO.getValue(), ""); |
| 221 | 213 | } catch (NamingException namEx) { |
| ... | ... | @@ -250,7 +242,6 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 250 | 242 | */ |
| 251 | 243 | @Override |
| 252 | 244 | public Boolean validarAssinaturaPorUsuario(Long idDocumento) { |
| 253 | - return this.assinaturaDao.validarAssinaturaPorUsuario(idDocumento, ((Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId()); | |
| 254 | 245 | |
| 255 | 246 | return this.assinaturaDao.validarAssinaturaPorUsuario(idDocumento, ( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); |
| 256 | 247 | } |
| ... | ... | @@ -260,10 +251,9 @@ public class AssinaturaServiceImpl extends GenericServiceImpl<Assinatura, Long> |
| 260 | 251 | |
| 261 | 252 | Assinatura assinatura = (Assinatura) this.assinaturaDao.getReference(id); |
| 262 | 253 | assinatura.getConteudoTarja().setConteudo(tarjaAssinaturaService.decrypted(assinatura.getConteudoTarja().getConteudoCriptografado())); |
| 263 | - if(UtilObjeto.isReferencia(assinatura.getDocumentoGed().getConteudoTarja())){ | |
| 264 | 254 | if (UtilObjeto.isReferencia(assinatura.getDocumentoGed().getConteudoTarja())) { |
| 265 | 255 | assinatura.getDocumentoGed().getConteudoTarja().setConteudo(tarjaAssinaturaService.decrypted(assinatura.getDocumentoGed().getConteudoTarja().getConteudoCriptografado())); |
| 266 | 256 | } |
| 267 | 257 | return assinatura; |
| 268 | 258 | } |
| 269 | -} | |
| 270 | 259 | \ No newline at end of file |
| 260 | +} | ... | ... |