【问题标题】:how to authenticate REST in play framework 1.2.5如何在 play framework 1.2.5 中验证 REST
【发布时间】:2013-10-14 07:58:29
【问题描述】:

我有一个需要安全的游戏应用程序。我尝试安全地导入模块,它工作的应用程序现在需要登录,现在我遇到了另一个问题。我想从 REST 进行身份验证。我的意思是客户端如何请求我的应用程序进行身份验证?,我尝试过这样

public static Response logIn(){
    DataInputStream dis = new DataInputStream(request.body);
    String request;
    response.status = 400;
    try {
        while(null != ((request = dis.readLine()))){
            JSONObject jsonObject = new JSONObject(request);
            String username = jsonObject.getString("username");
            String password = jsonObject.getString("password");
            boolean authenticated = Security.authenticate(username, password);
            if(authenticated){
                response.status = 200;
                return response;
            }else{
                response.status = 400;
                return response;
            }
        }
    } catch (IOException | JSONException e) {
        e.printStackTrace();
    }
    return response;
}

但是当我用休息客户端测试它时,它出错了,它说服务器重定向太多。对不起我的英语不好,如果可能的话,我想要一个例子

【问题讨论】:

    标签: java rest playframework-1.x


    【解决方案1】:

    您可以尝试一种现成的决定,例如play authenticate plugin 或使用this article

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-09
      • 1970-01-01
      • 2016-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多