小编Kir*_*mar的帖子

基于注释的安全性限制不适用于Web套接字触发的方法调用

我对此做了一些研究,但我找不到解决方案.

我有这样的课

@Stateless
class ConfigBean {
  @RequiresRole("administrator")
  public void reloadConfiguration(){
     ......
  }
}
Run Code Online (Sandbox Code Playgroud)

我有一个JAX-RS(平针织)服务如下.

@Path("config")
class ConfigService{

  @EJB
  ConfigBean config;

  @Get
  @Path("reload")
  public void reload(){ 
     config.reloadConfiguration();
  }
}
Run Code Online (Sandbox Code Playgroud)

这将在调用API时正常工作/Test/config/relaod(即仅与管理员用户一起工作).

但是下面的代码没有按预期工作(即普通用户可以触发重载配置方法),

@ServerEndpoint("/socket") 
public class EchoServer {
/**
 * @OnOpen allows us to intercept the creation of a new session.
 * The session class allows us to send data to the user.
 * In the method onOpen, we'll let the user know that the handshake was 
 * successful.
 */

@EJB …
Run Code Online (Sandbox Code Playgroud)

java security annotations websocket shiro

8
推荐指数
1
解决办法
158
查看次数

标签 统计

annotations ×1

java ×1

security ×1

shiro ×1

websocket ×1