mirror of
https://gitee.com/fujieid/jap.git
synced 2024-11-30 02:27:34 +08:00
📝 change: Optimize code
This commit is contained in:
parent
2c623eaeca
commit
c2dad67d5d
@ -22,6 +22,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.fujieid.jap.core.context.JapAuthentication;
|
||||
import com.fujieid.jap.core.exception.JapOauth2Exception;
|
||||
import com.fujieid.jap.core.exception.OidcException;
|
||||
import com.fujieid.jap.http.JapHttpRequest;
|
||||
import com.fujieid.jap.oauth2.pkce.PkceCodeChallengeMethod;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
@ -215,9 +216,17 @@ public class Oauth2Util {
|
||||
|
||||
SimpleHttpResponse res = null;
|
||||
if (null == endpointMethodType || Oauth2EndpointMethodType.GET == endpointMethodType) {
|
||||
res = HttpUtil.get(url, params, false).getBody();
|
||||
res = HttpUtil.get(url, params, false);
|
||||
} else {
|
||||
res = HttpUtil.post(url, params, false).getBody();
|
||||
res = HttpUtil.post(url, params, false);
|
||||
}
|
||||
|
||||
if (!res.isSuccess()) {
|
||||
throw new OidcException("Cannot access url: " + url
|
||||
+ " , method: " + endpointMethodType
|
||||
+ " , params: " + params
|
||||
+ " , error details: " + res.getError()
|
||||
);
|
||||
}
|
||||
return JsonUtil.parseKv(res.getBody());
|
||||
}
|
||||
|
@ -44,12 +44,11 @@ public class OidcUtil {
|
||||
}
|
||||
String discoveryUrl = issuer.concat(DISCOVERY_URL);
|
||||
|
||||
SimpleHttpResponse response = null;
|
||||
try {
|
||||
response = HttpUtil.get(discoveryUrl).getBody();
|
||||
} catch (Exception e) {
|
||||
throw new OidcException("Cannot access discovery url: " + discoveryUrl);
|
||||
SimpleHttpResponse response = HttpUtil.get(discoveryUrl);
|
||||
if(!response.isSuccess()) {
|
||||
throw new OidcException("Cannot access discovery url: " + discoveryUrl + ", " + response.getError());
|
||||
}
|
||||
|
||||
Kv oidcDiscoveryInfo = JsonUtil.parseKv(response.getBody());
|
||||
if (CollectionUtil.isEmpty(oidcDiscoveryInfo)) {
|
||||
throw new OidcException("Unable to parse IDP service discovery configuration information.");
|
||||
|
Loading…
Reference in New Issue
Block a user