I am trying to implement my own ContainerRequestFilter
and configure SecurityContext
. It works well on jax-rs resources but EJB jax-rs throws javax.ejb.AccessLocalException
Only relevant thing I found is 4 years old and the workaround doesn't seem pretty. https://java.net/projects/jersey/lists/users/archive/2010-05/message/265
My custom SecurityContext:
@Provider
@PreMatching
public class SecurityFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext filterContext) throws IOException {
filterContext.setSecurityContext(new Authorizer());
}
public class Authorizer implements SecurityContext {
public Principal getUserPrincipal() {
return null;
}
public boolean isUserInRole(String role) {
return true;
}
public boolean isSecure() {
return false;
}
public String getAuthenticationScheme() {
return null;
}
}
Tested resource (works without @Stateless)
@Path("test")
@Stateless
public class TestSecureResource {
@GET
@RolesAllowed("admin")
@Path("admin")
public Response secureTest() {
return Response.status(200).entity("admin").build();
}
}
Does someone know how to make this work?