@Retention(RUNTIME)
@Target({METHOD,TYPE,FIELD})
@Documented
@Inherited
public @interface Authenticated
The following sample shows examples of use of Authenticated annotation in a JAX-RS/Jersey application:
@Authenticated
@ApplicationPath("myApp")
public class SecuredApplication extends javax.ws.rs.core.Application { ... }
@Authenticated(false)
@Path("/")
public class PublicResource {
@GET
public String getResourceContent() { ... }
// Only authenticated users can update the content of the public resource
@Authenticated
@PUT
public Response setNewResourceContent(String content) { ... }
}
Authenticated annotation is not cumulative - e.g. if you define this annotation on a resource method, it will take ALL values from this instance of Authenticated (so if you want to use a custom authentication provider, you must define it again in each Authenticated instance).
| Modifier and Type | Optional Element | Description |
|---|---|---|
boolean |
optional |
If set to optional, authentication will be attempted, yet if it fails, we would still be called
without authenticated user/service.
|
java.lang.String |
provider |
Explicit authentication provider to use when processing this Authorized.
|
boolean |
value |
Determine whether authentication should be enabled.
|
boolean value
truetrue if authentication should be enabled.boolean optional
java.lang.String provider
AuthenticationProvider.Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.