|
@@ -13,7 +13,6 @@ import com.qmth.teachcloud.exchange.common.service.CommonService;
|
|
import com.qmth.teachcloud.exchange.common.util.Base64Util;
|
|
import com.qmth.teachcloud.exchange.common.util.Base64Util;
|
|
import com.qmth.teachcloud.exchange.common.util.JacksonUtil;
|
|
import com.qmth.teachcloud.exchange.common.util.JacksonUtil;
|
|
import com.qmth.teachcloud.exchange.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.exchange.common.util.ServletUtil;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -60,11 +59,11 @@ public class CommonServiceImpl implements CommonService {
|
|
Optional.ofNullable(basicSchool).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("学校信息不存在"));
|
|
Optional.ofNullable(basicSchool).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("学校信息不存在"));
|
|
Map<String, SimpleObject> mapSetting = commonCacheService.getSysSetting(basicSchool.getId());
|
|
Map<String, SimpleObject> mapSetting = commonCacheService.getSysSetting(basicSchool.getId());
|
|
String teachcloudLoginUrl = null;
|
|
String teachcloudLoginUrl = null;
|
|
- log.info("mapSetting1 value:{}", JSONObject.toJSONString(mapSetting));
|
|
|
|
if (!CollectionUtils.isEmpty(mapSetting)) {
|
|
if (!CollectionUtils.isEmpty(mapSetting)) {
|
|
|
|
+ log.info("mapSetting1 value:{}", JSONObject.toJSONString(mapSetting));
|
|
SimpleObject simpleObject = mapSetting.get(SystemConstant.TEACH_CLOUD_PRINT);
|
|
SimpleObject simpleObject = mapSetting.get(SystemConstant.TEACH_CLOUD_PRINT);
|
|
- log.info("simpleObject1 value:{}", JSONObject.toJSONString(simpleObject));
|
|
|
|
Objects.requireNonNull(simpleObject, "未配置知学知考地址");
|
|
Objects.requireNonNull(simpleObject, "未配置知学知考地址");
|
|
|
|
+ log.info("simpleObject1 value:{}", JSONObject.toJSONString(simpleObject));
|
|
String teachCloudPrint = simpleObject.getValue();
|
|
String teachCloudPrint = simpleObject.getValue();
|
|
if (Objects.nonNull(teachCloudPrint) && !Objects.equals(teachCloudPrint.trim(), "")) {
|
|
if (Objects.nonNull(teachCloudPrint) && !Objects.equals(teachCloudPrint.trim(), "")) {
|
|
teachcloudLoginUrl = teachCloudPrint.replace("/login", SystemConstant.CAS_VUE_LOGIN_PATH);
|
|
teachcloudLoginUrl = teachCloudPrint.replace("/login", SystemConstant.CAS_VUE_LOGIN_PATH);
|
|
@@ -80,31 +79,35 @@ public class CommonServiceImpl implements CommonService {
|
|
throw ExceptionResultEnum.PARAMS_ERROR.exception("学校code不存在");
|
|
throw ExceptionResultEnum.PARAMS_ERROR.exception("学校code不存在");
|
|
}
|
|
}
|
|
|
|
|
|
- long timestamp = System.currentTimeMillis();
|
|
|
|
|
|
+ HttpServletResponse response = ServletUtil.getResponse();
|
|
|
|
+ response.setHeader(SystemConstant.ACCESS_CONTROL_ALLOW_ORIGIN, SystemConstant.PATH_MATCH);
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(params)) {
|
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
// String path = teachcloudLoginUrl.substring(teachcloudLoginUrl.indexOf(SystemConstant.PATH_SUBSTR), teachcloudLoginUrl.length());
|
|
// String path = teachcloudLoginUrl.substring(teachcloudLoginUrl.indexOf(SystemConstant.PATH_SUBSTR), teachcloudLoginUrl.length());
|
|
- String signature = SignatureEntity.build(SignatureType.SECRET, SystemConstant.GET, SystemConstant.CAS_VUE_LOGIN_PATH, timestamp, basicSchool.getAccessKey(), basicSchool.getAccessSecret());
|
|
|
|
|
|
+ String signature = SignatureEntity.build(SignatureType.SECRET, SystemConstant.GET, SystemConstant.CAS_VUE_LOGIN_PATH, timestamp, basicSchool.getAccessKey(), basicSchool.getAccessSecret());
|
|
|
|
|
|
- StringJoiner stringJoiner = new StringJoiner("")
|
|
|
|
- .add(teachcloudLoginUrl)
|
|
|
|
- .add(SystemConstant.GET_UNKNOWN).add(SystemConstant.HEADER_TIME).add(SystemConstant.GET_EQUAL).add(String.valueOf(timestamp))
|
|
|
|
- .add(SystemConstant.GET_SYMBOL).add(SystemConstant.SIGNATURE).add(SystemConstant.GET_EQUAL).add(Base64Util.encode(signature.getBytes(StandardCharsets.UTF_8)))
|
|
|
|
- .add(SystemConstant.GET_SYMBOL).add(SystemConstant.USER).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(account, SystemConstant.CHARSET_NAME))
|
|
|
|
- .add(SystemConstant.GET_SYMBOL).add(SystemConstant.FUNCTIONAL_TYPE).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(functionalType, SystemConstant.CHARSET_NAME));
|
|
|
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("")
|
|
|
|
+ .add(teachcloudLoginUrl)
|
|
|
|
+ .add(SystemConstant.GET_UNKNOWN).add(SystemConstant.HEADER_TIME).add(SystemConstant.GET_EQUAL).add(String.valueOf(timestamp))
|
|
|
|
+ .add(SystemConstant.GET_SYMBOL).add(SystemConstant.SIGNATURE).add(SystemConstant.GET_EQUAL).add(Base64Util.encode(signature.getBytes(StandardCharsets.UTF_8)))
|
|
|
|
+ .add(SystemConstant.GET_SYMBOL).add(SystemConstant.USER).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(account, SystemConstant.CHARSET_NAME))
|
|
|
|
+ .add(SystemConstant.GET_SYMBOL).add(SystemConstant.FUNCTIONAL_TYPE).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(functionalType, SystemConstant.CHARSET_NAME));
|
|
|
|
|
|
- if (Objects.nonNull(returnUrl) && !Objects.equals(returnUrl, "")) {
|
|
|
|
- stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(returnUrl, SystemConstant.CHARSET_NAME));
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(params) && !Objects.equals(params, "")) {
|
|
|
|
- String decodeJson = URLDecoder.decode(params, SystemConstant.CHARSET_NAME);
|
|
|
|
- OpenParams openParams = JacksonUtil.readJson(decodeJson, OpenParams.class);
|
|
|
|
- stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.PARAMS).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(JacksonUtil.parseJson(openParams), SystemConstant.CHARSET_NAME));
|
|
|
|
- }
|
|
|
|
|
|
+ if (Objects.nonNull(returnUrl) && !Objects.equals(returnUrl, "")) {
|
|
|
|
+ stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(returnUrl, SystemConstant.CHARSET_NAME));
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(params) && !Objects.equals(params, "")) {
|
|
|
|
+ String decodeJson = URLDecoder.decode(params, SystemConstant.CHARSET_NAME);
|
|
|
|
+ OpenParams openParams = JacksonUtil.readJson(decodeJson, OpenParams.class);
|
|
|
|
+ stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.PARAMS).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(JacksonUtil.parseJson(openParams), SystemConstant.CHARSET_NAME));
|
|
|
|
+ }
|
|
// String redirectUrl = URLEncoder.encode(stringJoiner.toString(), SystemConstant.CHARSET);
|
|
// String redirectUrl = URLEncoder.encode(stringJoiner.toString(), SystemConstant.CHARSET);
|
|
// log.info("path:{},timestamp:{},account:{},signature:{},redirectUrl:{},redirectUrl_urlencode:{}", path, timestamp, account, signature, stringJoiner.toString(), redirectUrl);
|
|
// log.info("path:{},timestamp:{},account:{},signature:{},redirectUrl:{},redirectUrl_urlencode:{}", path, timestamp, account, signature, stringJoiner.toString(), redirectUrl);
|
|
- log.info("path:{},timestamp:{},account:{},functionalType:{},signature:{}, redirectUrl:{}", SystemConstant.CAS_VUE_LOGIN_PATH, timestamp, account,functionalType, signature, stringJoiner.toString());
|
|
|
|
-
|
|
|
|
- HttpServletResponse response = ServletUtil.getResponse();
|
|
|
|
- response.setHeader("Access-Control-Allow-Origin", SystemConstant.PATH_MATCH);
|
|
|
|
- response.sendRedirect(stringJoiner.toString());
|
|
|
|
|
|
+ log.info("path:{},timestamp:{},account:{},functionalType:{},signature:{}, redirectUrl:{}", SystemConstant.CAS_VUE_LOGIN_PATH, timestamp, account, functionalType, signature, stringJoiner.toString());
|
|
|
|
+ response.sendRedirect(stringJoiner.toString());
|
|
|
|
+ } else {
|
|
|
|
+ response.sendRedirect(returnUrl);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|