|
@@ -9,20 +9,18 @@ import com.qmth.teachcloud.exchange.common.entity.BasicSchool;
|
|
import com.qmth.teachcloud.exchange.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.exchange.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.exchange.common.service.BasicSchoolService;
|
|
import com.qmth.teachcloud.exchange.common.service.BasicSchoolService;
|
|
import com.qmth.teachcloud.exchange.common.service.CommonService;
|
|
import com.qmth.teachcloud.exchange.common.service.CommonService;
|
|
-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.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.util.UriUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
-import java.net.URLEncoder;
|
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
import java.util.StringJoiner;
|
|
import java.util.StringJoiner;
|
|
@@ -90,23 +88,45 @@ public class CommonServiceImpl implements CommonService {
|
|
StringJoiner stringJoiner = new StringJoiner("")
|
|
StringJoiner stringJoiner = new StringJoiner("")
|
|
.add(teachcloudLoginUrl)
|
|
.add(teachcloudLoginUrl)
|
|
.add(SystemConstant.GET_UNKNOWN).add(SystemConstant.HEADER_TIME).add(SystemConstant.GET_EQUAL).add(String.valueOf(timestamp))
|
|
.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.SIGNATURE).add(SystemConstant.GET_EQUAL).add(UriUtils.encode(signature, SystemConstant.CHARSET_NAME))
|
|
|
|
+ .add(SystemConstant.GET_SYMBOL).add(SystemConstant.USER).add(SystemConstant.GET_EQUAL).add(UriUtils.encode(account, SystemConstant.CHARSET_NAME));
|
|
|
|
|
|
if (Objects.nonNull(returnUrl) && !Objects.equals(returnUrl, "")) {
|
|
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));
|
|
|
|
|
|
+ stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL).add(SystemConstant.GET_EQUAL).add(UriUtils.encode(returnUrl, SystemConstant.CHARSET_NAME));
|
|
}
|
|
}
|
|
if (Objects.nonNull(params) && !Objects.equals(params, "")) {
|
|
if (Objects.nonNull(params) && !Objects.equals(params, "")) {
|
|
String decodeJson = URLDecoder.decode(params, SystemConstant.CHARSET_NAME);
|
|
String decodeJson = URLDecoder.decode(params, SystemConstant.CHARSET_NAME);
|
|
OpenParams openParams = JacksonUtil.readJson(decodeJson, OpenParams.class);
|
|
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));
|
|
|
|
|
|
+ stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.PARAMS).add(SystemConstant.GET_EQUAL).add(UriUtils.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:{},signature:{},base64 redirectUrl:{}", path, timestamp, account, signature, stringJoiner.toString());
|
|
|
|
|
|
+ log.info("path:{},timestamp:{},account:{},signature:{},UriUtils redirectUrl:{}", path, timestamp, account, signature, stringJoiner.toString());
|
|
|
|
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
response.setHeader("Access-Control-Allow-Origin", SystemConstant.PATH_MATCH);
|
|
response.setHeader("Access-Control-Allow-Origin", SystemConstant.PATH_MATCH);
|
|
response.sendRedirect(stringJoiner.toString());
|
|
response.sendRedirect(stringJoiner.toString());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// public static void main(String[] args) throws UnsupportedEncodingException {
|
|
|
|
+// String signature = "Secret caabd6ddde7d4b0ca98cfd2109f14d95:j6p z/ebmCABEJXWPOYRrG96hwM";
|
|
|
|
+//// String a = URLEncoder.encode(Base64Util.encode(signature.getBytes(StandardCharsets.UTF_8)), SystemConstant.CHARSET_NAME);
|
|
|
|
+//// System.out.println(a);
|
|
|
|
+//// System.out.println(URLDecoder.decode(new String(Base64Util.decode(a), SystemConstant.CHARSET_NAME), SystemConstant.CHARSET_NAME));
|
|
|
|
+//
|
|
|
|
+// String a2 = UriUtils.encode(signature, StandardCharsets.UTF_8);
|
|
|
|
+// System.out.println(a2);
|
|
|
|
+// String b2 = UriUtils.decode(a2, SystemConstant.CHARSET_NAME);
|
|
|
|
+// System.out.println(b2);
|
|
|
|
+//
|
|
|
|
+// String a = Base64Util.encode(signature.getBytes(StandardCharsets.UTF_8));
|
|
|
|
+// System.out.println(a);
|
|
|
|
+// String b = new String(Base64Util.decode(a), SystemConstant.CHARSET_NAME);
|
|
|
|
+// System.out.println(b);
|
|
|
|
+//
|
|
|
|
+// String a1 = URLEncoder.encode(Base64Util.encodeMime(signature.getBytes(StandardCharsets.UTF_8)), SystemConstant.CHARSET_NAME);
|
|
|
|
+// String b1 = new String(Base64Util.decodeMime(a1), SystemConstant.CHARSET_NAME);
|
|
|
|
+// System.out.println(b1);
|
|
|
|
+// System.out.println(URLDecoder.decode(b1, SystemConstant.CHARSET_NAME));
|
|
|
|
+// }
|
|
}
|
|
}
|