August 2018
Intermediate to advanced
314 pages
8h 9m
English
In the preceding code block, we have the code of the App1 application. When this application is accessed by a GET request, a request is sent to the authentication service to validate whether the user has already logged in:
import javax.inject.Inject;import javax.ws.rs.*;import javax.ws.rs.core.Response;import java.util.Objects;@Path("app1")public class App1 { @Inject private Auth auth; @GET public Response helloWorld( String token ){ if( !auth.isLogged( token ) ){ throw new WebApplicationException(Response.Status.UNAUTHORIZED); } return Response.ok("Hello World. Welcome to App1!").build(); } @POST @Consumes("application/x-www-form-urlencoded") public Response helloWorld(@FormParam("login") String login ...
Read now
Unlock full access