我应该写什么到'getNewXsrfToken'方法

时间:2019-04-29 13:25:44

标签: gwt csrf rpc

我正在尝试使用GWT代码为远程服务创建xsrf保护

static {
         CommonUtils.setProperServiceEntryPoint((ServiceDefTarget) ourInstance);
        ((XsrfTokenServiceAsync)ourInstance).getNewXsrfToken(new AsyncCallback<XsrfToken>() {

            public void onSuccess(XsrfToken token) {
                CommonUtils.consoleInfo("token success");
                CommonRemoteServiceAsync rpc = (CommonRemoteServiceAsync)GWT.create(CommonRemoteService.class);
                ((HasRpcToken) rpc).setRpcToken(token);

                // WHAT SHOULD I WRITE HERE ???

            }

            public void onFailure(Throwable caught) {
                CommonUtils.consoleInfo("token Failure");
                try {
                    throw caught;
                } catch (RpcTokenException e) {
                    // Can be thrown for several reasons:
                    //   - duplicate session cookie, which may be a sign of a cookie
                    //     overwrite attack
                    //   - XSRF token cannot be generated because session cookie isn't
                    //     present
                } catch (Throwable e) {
                    // unexpected
                }
            }});
     }

但是我不明白我应该写什么到getNewXsrfToken :: onSuccess方法中。在文档中调用doStuff方法。

rpc.doStuff(new AsyncCallback<Void>() {
  // ...
});

我了解它应该是我在服务中的自定义方法,但是如果我的异步服务中有50多个方法。我应该给所有人打电话吗?

0 个答案:

没有答案