From bf39fe8445f2f506b867b0e4f4e7b19272171a84 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Wed, 25 Oct 2017 17:56:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96client=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provider/HswebResponseJudgeSupport.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseJudgeSupport.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseJudgeSupport.java index 5a1e5b441..7675ef2f5 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseJudgeSupport.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseJudgeSupport.java @@ -44,19 +44,24 @@ public class HswebResponseJudgeSupport implements ResponseJudgeForProviderDefini if (!result.trim().startsWith("{")) { return null; } - JSONObject jsonRes = JSON.parseObject(result); - Integer status = jsonRes.getInteger("status"); - if (status == null && response.status() == 200) { - return null; - } - if (status != null) { - if (status == 200) { + try { + JSONObject jsonRes = JSON.parseObject(result); + if (jsonRes.size() > 5) return null; + Integer status = jsonRes.getInteger("status"); + if (status == null && response.status() == 200) { return null; } - return ErrorType.fromCode(status).orElse(ErrorType.OTHER); - } - if (jsonRes.get("message") != null) { - return ErrorType.valueOf(jsonRes.getString("message")); + if (status != null) { + if (status == 200) { + return null; + } + return ErrorType.fromCode(status).orElse(ErrorType.OTHER); + } + if (jsonRes.get("message") != null) { + return ErrorType.valueOf(jsonRes.getString("message")); + } + } catch (Exception ignore) { + } return null; }