July 2017
Intermediate to advanced
466 pages
11h 24m
English
To secure the REST server, we will use a filter just like we used in Chapter 9, Taking Notes with Monumentum. We'll start by defining the annotation that will specify which endpoints need to be secured, as follows:
@NameBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Secure {}
We will apply this preceding annotation to each secured endpoint (annotations condensed to one line for brevity):
@GET @Path("conversations") @Secure public Response getConversations() { ... @POST @Path("conversations") @Secure public Response sendMessage(Message message) throws InterruptedException { ... @GET @Path("status") @Produces(SseFeature.SERVER_SENT_EVENTS) @Secure public ...Read now
Unlock full access