Java 正在授予JAAS中策略文件中的URL权限
我已经做了一个rest应用程序,它本身运行良好Java 正在授予JAAS中策略文件中的URL权限,java,rest,permissions,jaas,Java,Rest,Permissions,Jaas,我已经做了一个rest应用程序,它本身运行良好 import javax.ws.rs.GET; import javax.ws.rs.Path; @Path("/helloworld") public class HelloWorldResource { @GET public String getMessage() { return "Hello World!"; } } 我想从使用JAAS的客户端调用它。有两个主体,即UserPrin
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/helloworld")
public class HelloWorldResource
{
@GET
public String getMessage()
{
return "Hello World!";
}
}
我想从使用JAAS的客户端调用它。有两个主体,即UserPrincipal和SystemAdminPrincipal。我想在主体为SystemAdminPrincipal时调用web服务。我使用URLPermission授予权限,使用apache HttpClient执行get方法。策略文件是
grant Principal UserPrincipal "user"
{
};
grant Principal SysAdminPrincipal "sysadmin"
{
permission java.net.URLPermission "http://localhost:8080/HelloWorldREST/helloworld","GET";
};
但即使对于SystemAdminPrincipal,我也遇到了安全性异常。我的情况可能是URLPermission的使用有问题。有人能指出如何正确使用URLPermission吗?请提前感谢。策略文件应在授予URLPermission之前授予socket权限。策略文件应为
grant Principal SysAdminPrincipal "sysadmin"
{
permission java.net.SocketPermission "127.0.0.1:8080","connect,resolve";
permission java.net.URLPermission "http://localhost:8080/HelloWorldREST/helloworld","GET";
};
grant Principal UserPrincipal "user"
{
};