|
@@ -42,15 +42,19 @@ public class XiedingLoginServiceImpl implements ThirdPartyLoginService {
|
|
|
|
|
|
@Override
|
|
|
public String getToken(LoginQueryDto queryDto) {
|
|
|
- return this.httpInfo(queryDto).getToken();
|
|
|
+ return this.httpInfo(queryDto).getData().getToken();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getLoginUrl(LoginQueryDto queryDto) {
|
|
|
- XieDingResultDto resultDto = this.httpInfo(queryDto);
|
|
|
- String token = resultDto.getToken();
|
|
|
- String prefixUrl = resultDto.getPrefixUrl();
|
|
|
- return String.format(ssoConfig.getLoginUrl(), prefixUrl, token, queryDto.getSystemType());
|
|
|
+ try {
|
|
|
+ XieDingResultDto resultDto = this.httpInfo(queryDto);
|
|
|
+ String token = resultDto.getData().getToken();
|
|
|
+ String prefixUrl = resultDto.getPrefixUrl();
|
|
|
+ return String.format(ssoConfig.getLoginUrl(), prefixUrl, token, queryDto.getSystemType());
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ throw new ServiceException(ResultStatus.ERROR.getStatus(), "获取第三登录请求出错!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -79,24 +83,24 @@ public class XiedingLoginServiceImpl implements ThirdPartyLoginService {
|
|
|
// 1.根据账户获取密码
|
|
|
String result = HttpClientPoolUtil.sendGet(String.format(ssoConfig.getPwdUrl(), prefixUrl, account, orgCode), charset);
|
|
|
XieDingResultDto resultDto = JSONObject.parseObject(result, XieDingResultDto.class);
|
|
|
- if (StringUtils.isEmpty(resultDto.getPassword())) {
|
|
|
- throw new ServiceException(ResultStatus.ERROR.getStatus(), resultDto.getMsg());
|
|
|
+ if (StringUtils.isEmpty(resultDto.getData().getPassword())) {
|
|
|
+ throw new ServiceException(ResultStatus.ERROR.getStatus(), resultDto.getMessage());
|
|
|
}
|
|
|
|
|
|
// 2.绑定单点登陆用户
|
|
|
- result = HttpClientPoolUtil.sendGet(String.format(ssoConfig.getBindSingleUrl(), prefixUrl, account, resultDto.getPassword(), orgCode), charset);
|
|
|
+ result = HttpClientPoolUtil.sendGet(String.format(ssoConfig.getBindSingleUrl(), prefixUrl, account, resultDto.getData().getPassword(), orgCode), charset);
|
|
|
resultDto = JSONObject.parseObject(result, XieDingResultDto.class);
|
|
|
- if (!resultDto.isStatus()) {
|
|
|
- throw new ServiceException(ResultStatus.ERROR.getStatus(), resultDto.getMsg());
|
|
|
+ if (!resultDto.isSuccess()) {
|
|
|
+ throw new ServiceException(ResultStatus.ERROR.getStatus(), resultDto.getMessage());
|
|
|
}
|
|
|
// 3.获取token
|
|
|
- String singleKey = resultDto.getSingleKey();
|
|
|
+ String singleKey = resultDto.getData().getSingleKey();
|
|
|
Long timestamp = System.currentTimeMillis();
|
|
|
- String sign = MD5Util.digest(resultDto.getSingleKey() + timestamp + secretKey);
|
|
|
+ String sign = MD5Util.digest(resultDto.getData().getSingleKey() + timestamp + secretKey);
|
|
|
result = HttpClientPoolUtil.sendGet(String.format(ssoConfig.getTokenUrl(), prefixUrl, singleKey, timestamp, sign, code), charset);
|
|
|
resultDto = JSONObject.parseObject(result, XieDingResultDto.class);
|
|
|
- if (!resultDto.isStatus()) {
|
|
|
- throw new ServiceException(ResultStatus.ERROR.getStatus(), resultDto.getMsg());
|
|
|
+ if (!resultDto.isSuccess()) {
|
|
|
+ throw new ServiceException(ResultStatus.ERROR.getStatus(), resultDto.getMessage());
|
|
|
}
|
|
|
// 设置请求的前缀
|
|
|
resultDto.setPrefixUrl(prefixUrl);
|