Commit 847a7ef8096cb2d56fbccea812b707c58e49bf8c
1 parent
c6a6ba14
Exists in
master
[3576] - Ajustar modelo e cadastros: Tipo de documento, tipo de processo, documento e processo.
Showing
2 changed files
with
134 additions
and
0 deletions
Show diff stats
cit-ecm-api/src/main/java/br/com/centralit/api/security/CustomExpressionHandler.java
0 → 100644
| @@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
| 1 | +package br.com.centralit.api.security; | ||
| 2 | + | ||
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 4 | +import org.springframework.security.access.expression.SecurityExpressionOperations; | ||
| 5 | +import org.springframework.security.authentication.AuthenticationTrustResolverImpl; | ||
| 6 | +import org.springframework.security.core.Authentication; | ||
| 7 | +import org.springframework.security.web.FilterInvocation; | ||
| 8 | +import org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler; | ||
| 9 | +import org.springframework.security.web.access.expression.WebSecurityExpressionRoot; | ||
| 10 | + | ||
| 11 | +import br.com.centralit.api.service.CredencialProcessoService; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * @author Rob Winch | ||
| 15 | + */ | ||
| 16 | +public class CustomExpressionHandler extends DefaultWebSecurityExpressionHandler { | ||
| 17 | + | ||
| 18 | + @Autowired | ||
| 19 | + private CredencialProcessoService credencialProcessoService; | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + protected SecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication, FilterInvocation fi) { | ||
| 23 | + | ||
| 24 | + WebSecurityExpressionRoot root = new CustomWebSecurityExpresssionRoot(authentication, fi, credencialProcessoService); | ||
| 25 | + root.setPermissionEvaluator(this.getPermissionEvaluator()); | ||
| 26 | + root.setTrustResolver(new AuthenticationTrustResolverImpl()); | ||
| 27 | + root.setRoleHierarchy(this.getRoleHierarchy()); | ||
| 28 | + return root; | ||
| 29 | + } | ||
| 30 | +} |
cit-ecm-api/src/main/java/br/com/centralit/api/security/CustomWebSecurityExpresssionRoot.java
0 → 100644
| @@ -0,0 +1,104 @@ | @@ -0,0 +1,104 @@ | ||
| 1 | +package br.com.centralit.api.security; | ||
| 2 | + | ||
| 3 | +import org.springframework.security.core.Authentication; | ||
| 4 | +import org.springframework.security.web.FilterInvocation; | ||
| 5 | +import org.springframework.security.web.access.expression.WebSecurityExpressionRoot; | ||
| 6 | + | ||
| 7 | +import br.com.centralit.api.service.CredencialProcessoService; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * <p> | ||
| 11 | + * <img src="http://centralit.com.br/images/logo_central.png"> | ||
| 12 | + * </p> | ||
| 13 | + * | ||
| 14 | + * <p> | ||
| 15 | + * <b>Company: </b> Central IT - Governança Corporativa - | ||
| 16 | + * </p> | ||
| 17 | + * | ||
| 18 | + * <p> | ||
| 19 | + * <b>Title: </b> | ||
| 20 | + * </p> | ||
| 21 | + * | ||
| 22 | + * <p> | ||
| 23 | + * <b>Description: </b> | ||
| 24 | + * </p> | ||
| 25 | + * | ||
| 26 | + * <p> | ||
| 27 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | ||
| 28 | + * </p> | ||
| 29 | + * | ||
| 30 | + * <p> | ||
| 31 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | ||
| 32 | + * </p> | ||
| 33 | + * | ||
| 34 | + * @since 30/03/2016 - 10:43:40 | ||
| 35 | + * | ||
| 36 | + * @version 1.0.0 | ||
| 37 | + * | ||
| 38 | + * @author rogerio.costa | ||
| 39 | + * | ||
| 40 | + */ | ||
| 41 | +public class CustomWebSecurityExpresssionRoot extends WebSecurityExpressionRoot { | ||
| 42 | + | ||
| 43 | + /** Atributo credencialProcessoService. */ | ||
| 44 | + private CredencialProcessoService credencialProcessoService; | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Responsável pela criação de novas instâncias desta classe. | ||
| 48 | + * | ||
| 49 | + * @param authentication | ||
| 50 | + * @param filterInvocation | ||
| 51 | + * @param credencialProcessoService | ||
| 52 | + */ | ||
| 53 | + public CustomWebSecurityExpresssionRoot( Authentication authentication, FilterInvocation filterInvocation, CredencialProcessoService credencialProcessoService ) { | ||
| 54 | + | ||
| 55 | + super(authentication, filterInvocation); | ||
| 56 | + | ||
| 57 | + this.credencialProcessoService = credencialProcessoService; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * <p> | ||
| 62 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | ||
| 63 | + * </p> | ||
| 64 | + * | ||
| 65 | + * <p> | ||
| 66 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | ||
| 67 | + * </p> | ||
| 68 | + * | ||
| 69 | + * Método responsável por verificar se o usuario tem permissão para credenciar | ||
| 70 | + * | ||
| 71 | + * @author rogerio.costa | ||
| 72 | + * | ||
| 73 | + * @return boolean | ||
| 74 | + */ | ||
| 75 | + public boolean permiteCredenciar() { | ||
| 76 | + | ||
| 77 | + Long idProcesso = (Long) this.request.getSession().getAttribute("idProcesso"); | ||
| 78 | + | ||
| 79 | + return this.credencialProcessoService.permiteCredenciar(idProcesso); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * <p> | ||
| 84 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | ||
| 85 | + * </p> | ||
| 86 | + * | ||
| 87 | + * <p> | ||
| 88 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | ||
| 89 | + * </p> | ||
| 90 | + * | ||
| 91 | + * Método responsável por verificar se o usuario logado não é o criador do processo, e se contem uma credencial para o mesmo | ||
| 92 | + * | ||
| 93 | + * @author rogerio.costa | ||
| 94 | + * | ||
| 95 | + * @return boolean | ||
| 96 | + */ | ||
| 97 | + public boolean permiteRenunciar() { | ||
| 98 | + | ||
| 99 | + Long idProcesso = (Long) this.request.getSession().getAttribute("idProcesso"); | ||
| 100 | + | ||
| 101 | + return this.credencialProcessoService.permiteRenunciar(idProcesso); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | +} |