Search in sources :

Example 11 with RolesAllowed

use of javax.annotation.security.RolesAllowed in project drill by apache.

the class AuthDynamicFeature method configure.

@Override
public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) {
    AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
    // RolesAllowed on the method takes precedence over PermitAll
    RolesAllowed ra = am.getAnnotation(RolesAllowed.class);
    if (ra != null) {
        configuration.register(AuthCheckFilter.INSTANCE);
        return;
    }
    // PermitAll takes precedence over RolesAllowed on the class
    if (am.isAnnotationPresent(PermitAll.class)) {
        // Do nothing.
        return;
    }
    // RolesAllowed on the class takes precedence over PermitAll
    ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class);
    if (ra != null) {
        configuration.register(AuthCheckFilter.INSTANCE);
    }
}
Also used : RolesAllowed(javax.annotation.security.RolesAllowed) AnnotatedMethod(org.glassfish.jersey.server.model.AnnotatedMethod)

Aggregations

RolesAllowed (javax.annotation.security.RolesAllowed)11 BadRequestException (javax.ws.rs.BadRequestException)4 Flight (org.glassfish.jersey.examples.flight.model.Flight)4 Annotation (java.lang.annotation.Annotation)3 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Aircraft (org.glassfish.jersey.examples.flight.model.Aircraft)3 PermitAll (javax.annotation.security.PermitAll)2 DELETE (javax.ws.rs.DELETE)2 Detail (org.glassfish.jersey.examples.flight.filtering.Detail)2 AnnotatedMethod (org.glassfish.jersey.server.model.AnnotatedMethod)2 AccessControlContext (java.security.AccessControlContext)1 AccessControlException (java.security.AccessControlException)1 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 DenyAll (javax.annotation.security.DenyAll)1