Commit a5e4d05d26d285c07b95552a076c126a0269128b
1 parent
4223dcb4
Exists in
master
webservice para validar acesso ao webservice 'ASES'.
Showing
3 changed files
with
80 additions
and
0 deletions
Show diff stats
Desenvolvimento/Codificacao/e-Selo/pom.xml
@@ -162,5 +162,10 @@ | @@ -162,5 +162,10 @@ | ||
162 | <artifactId>jta</artifactId> | 162 | <artifactId>jta</artifactId> |
163 | <version>1.1</version> | 163 | <version>1.1</version> |
164 | </dependency> | 164 | </dependency> |
165 | + <dependency> | ||
166 | + <groupId>javax.ws.rs</groupId> | ||
167 | + <artifactId>javax.ws.rs-api</artifactId> | ||
168 | + <version>2.0</version> | ||
169 | +</dependency> | ||
165 | </dependencies> | 170 | </dependencies> |
166 | </project> | 171 | </project> |
167 | \ No newline at end of file | 172 | \ No newline at end of file |
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/UsuarioServicoWebController.java
0 → 100644
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +package br.com.eselo.controller; | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | +import br.com.caelum.vraptor.Post; | ||
6 | +import br.com.caelum.vraptor.Resource; | ||
7 | +import br.com.caelum.vraptor.Result; | ||
8 | +import br.com.caelum.vraptor.view.Results; | ||
9 | +import br.com.eselo.dao.UsuarioServicoWebDAO; | ||
10 | +import br.com.eselo.model.UsuarioServicoWeb; | ||
11 | + | ||
12 | +@Resource | ||
13 | +public class UsuarioServicoWebController { | ||
14 | + | ||
15 | + | ||
16 | + private final UsuarioServicoWebDAO dao; | ||
17 | + private final Result result; | ||
18 | + | ||
19 | + public UsuarioServicoWebController(UsuarioServicoWebDAO _dao, Result result) { | ||
20 | + this.dao = _dao; | ||
21 | + this.result = result; | ||
22 | + | ||
23 | + | ||
24 | + } | ||
25 | + | ||
26 | + | ||
27 | + //@Path("/existe_usuario_servico_web") | ||
28 | + @Post("/existe_usuario_servico_web") | ||
29 | + public void existeUsuarioServicoWeb(String codigoHash) { | ||
30 | + | ||
31 | + Boolean usuarioAutorizado = false; | ||
32 | + UsuarioServicoWeb carregado = dao.existeUsuarioServicoWeb(codigoHash); | ||
33 | + if (carregado != null) { | ||
34 | + usuarioAutorizado = true; | ||
35 | + } | ||
36 | + | ||
37 | + result.use(Results.json()).withoutRoot().from(usuarioAutorizado).serialize(); | ||
38 | + } | ||
39 | + | ||
40 | +} |
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/dao/UsuarioServicoWebDAO.java
0 → 100644
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +package br.com.eselo.dao; | ||
2 | + | ||
3 | +import org.hibernate.Session; | ||
4 | +import org.hibernate.criterion.Restrictions; | ||
5 | + | ||
6 | +import br.com.caelum.vraptor.ioc.Component; | ||
7 | +import br.com.eselo.model.Usuario; | ||
8 | +import br.com.eselo.model.UsuarioServicoWeb; | ||
9 | + | ||
10 | +@Component | ||
11 | +public class UsuarioServicoWebDAO extends GenericDAO<UsuarioServicoWeb> { | ||
12 | + | ||
13 | + public UsuarioServicoWebDAO(Session _session) { | ||
14 | + super(_session); | ||
15 | + } | ||
16 | + | ||
17 | + public UsuarioServicoWeb existeUsuarioServicoWeb(String codigoHash) { | ||
18 | + return (UsuarioServicoWeb) getSession().createCriteria(getPersistentClass()) | ||
19 | + .add(Restrictions.eq("codigoHash", codigoHash)) | ||
20 | + .add(Restrictions.eq("usuarioAtivo", true)) | ||
21 | + .uniqueResult(); | ||
22 | + | ||
23 | + /*UsuarioServicoWeb encontrado = | ||
24 | + (UsuarioServicoWeb) getSession().createCriteria(getPersistentClass()) | ||
25 | + .add(Restrictions.eq("hash_code", codigoHash)) | ||
26 | + .add(Restrictions.eq("usuario_ativo", true)) | ||
27 | + .uniqueResult(); | ||
28 | + if(encontrado != null) | ||
29 | + { | ||
30 | + usuarioAutorizado = true; | ||
31 | + }*/ | ||
32 | + | ||
33 | + } | ||
34 | + | ||
35 | +} |