diff --git a/src/main/java/com/covas/Resources/TokenRessource.java b/src/main/java/com/covas/Resources/TokenRessource.java index e017aed..883cc74 100644 --- a/src/main/java/com/covas/Resources/TokenRessource.java +++ b/src/main/java/com/covas/Resources/TokenRessource.java @@ -4,15 +4,12 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashSet; -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; + import javax.inject.Inject; import javax.ws.rs.CookieParam; import javax.ws.rs.GET; -import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; @@ -29,7 +26,7 @@ import org.eclipse.microprofile.jwt.JsonWebToken; import org.jboss.resteasy.annotations.jaxrs.HeaderParam; import org.postgresql.shaded.com.ongres.scram.common.bouncycastle.base64.Base64; -@Path("/token") +@Path("/api") public class TokenRessource { @Inject JsonWebToken jwt; @@ -39,6 +36,7 @@ public class TokenRessource { @GET @Produces(MediaType.APPLICATION_JSON) + @Path("token") public Response getUserName(@HeaderParam("Authorization") String auth, @CookieParam("jwt") String jwtCookie) { String name = "anonymous"; String password = ""; diff --git a/src/main/java/com/covas/Resources/UsersRessources.java b/src/main/java/com/covas/Resources/UsersRessources.java new file mode 100644 index 0000000..097d96f --- /dev/null +++ b/src/main/java/com/covas/Resources/UsersRessources.java @@ -0,0 +1,35 @@ +package com.covas.Resources; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.covas.Entity.UsersEntity; + + +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +@Path("/api") +public class UsersRessources { + + @GET + @Path("users") + public Response getUsers(){ + return Response.ok(UsersEntity.listAll()).build(); + } + + @GET + @Path("user/{id}") + public Response getSingleUser(Long id){ + UsersEntity users = UsersEntity.findById(id); + if(users == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } + return Response.ok(users).build(); + } + + +}