我有一个需要安全的游戏应用程序。我已经尝试导入模块安全,它正在运行应用程序需要立即登录,现在我有另一个问题。我想从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;
}
但是当我用rest客户端测试它时,它出错了,它说服务器重定向太多了。抱歉我的英语不好,我想要一个如果那个可能的例子