2015-01-08 35 views
1

我試圖在Jersey中使用嵌入式JettyHttpContainer。我用BasicAuthenticator,一切似乎工作:Jersey SecurityContext.isUserInRole在Jetty嵌入式上運行時總是爲false

@GET 
@Produces(MediaType.APPLICATION_JSON) 
@PermitAll 
public Response getData(@Context SecurityContext securityContext) { 
    if (securityContext.isUserInRole(Roles.ADMIN)) { 
     do something... 

的問題是,securityContext.isUserInRole(Request)永遠是假的,看着源,這是顯而易見的,爲什麼:

JettyHttpContainer:214 ...

private SecurityContext getSecurityContext(final Request request) { 
    return new SecurityContext() { 

     @Override 
     public boolean isUserInRole(String role) { 
      return false; 
     } 

有沒有人知道如何正確使用JettyHttpContainer和Jersey SecurityContext?

回答

相關問題