泽西JAX-RS服务和Tomcat 6.0中的BASIC身份validation失败
我正在尝试使用Tomcat 6.0和JAX-RS jersey实现在我的服务中进行BASIC身份validation。
以下是我遵循的实施步骤:
1)在server.xml中添加了Realm,如下所示:
我在其他JSP应用程序中使用的相同领域,它在那里工作正常。
2)下面是web.xml
jersey-serlvet com.sun.jersey.spi.container.servlet.ServletContainer com.sun.jersey.config.property.packages com.infy.security com.sun.jersey.spi.container.ResourceFilters com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory 1 jersey-serlvet /* BasicDemo /* * <!-- CONFIDENTIAL --> BASIC Login
以下是服务:
@Path("/authenticate") @RolesAllowed({"Admin","Guest"}) public class BasicAuthenticationSecurity { @GET @Path("/wbiPing") @Produces(MediaType.TEXT_PLAIN) @RolesAllowed("Admin") public Response wbiPing(){ System.out.println("Pinged!!!"); return Response.ok("Pinged!!!").build(); } }
实现后,无论登录validation弹出窗口中的输入是什么(即使用户是“管理员”),我都会收到unauthentication错误页面。 以下是url:
http://localhost:8002/BASICAuthentication/rest/authenticate/wbiping
如果我误入歧途,请告诉我。
谢谢,
我有同样的问题,我无法使用server.xml中的域定义运行它。
它一移动就开始工作了
进入context.xml。 TomCat的日志记录使我发现服务器没有使用JDBC领域。