|
@@ -31,6 +31,9 @@ import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
+import java.net.URLEncoder;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -79,9 +82,13 @@ public class WudaOpenApiController {
|
|
if (Objects.isNull(uid)) {
|
|
if (Objects.isNull(uid)) {
|
|
throw ExceptionResultEnum.NOT_LOGIN.exception();
|
|
throw ExceptionResultEnum.NOT_LOGIN.exception();
|
|
}
|
|
}
|
|
- BasicSchool basicSchool = cacheService.schoolCache(SystemConstant.SCHOOL_CODE);
|
|
|
|
|
|
+ UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
|
|
|
|
+ WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
|
|
|
|
+ String pattern = "{0}{1}{2}";
|
|
|
|
+ String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
|
|
|
|
+ log.info("code:{}", code);
|
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
|
- response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid);
|
|
|
|
|
|
+ response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + "/" + code);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "cas用户鉴权测试接口")
|
|
@ApiOperation(value = "cas用户鉴权测试接口")
|
|
@@ -92,19 +99,19 @@ public class WudaOpenApiController {
|
|
String uid = "yz1";
|
|
String uid = "yz1";
|
|
UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
|
|
UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
|
|
WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
|
|
WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
|
|
- String PATTERN = "{0}{1}{2}";
|
|
|
|
- String code = MessageFormat.format(PATTERN, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode()));
|
|
|
|
|
|
+ String pattern = "{0}{1}{2}";
|
|
|
|
+ String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
|
|
log.info("code:{}", code);
|
|
log.info("code:{}", code);
|
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
|
- response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + code);
|
|
|
|
|
|
+ response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + code);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "cas用户临时授权登录接口")
|
|
@ApiOperation(value = "cas用户临时授权登录接口")
|
|
@RequestMapping(value = "/user/authentication/login", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/user/authentication/login", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = LoginResult.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = LoginResult.class)})
|
|
@Aac(auth = BOOL.FALSE)
|
|
@Aac(auth = BOOL.FALSE)
|
|
- public Result login(@ApiParam(value = "授权码信息", required = true) @RequestParam String code) throws NoSuchAlgorithmException {
|
|
|
|
- String[] values = StringUtils.split(code, SignatureEntityTest.FIELD_JOINER);
|
|
|
|
|
|
+ public Result login(@ApiParam(value = "授权码信息", required = true) @RequestParam String code) throws NoSuchAlgorithmException, UnsupportedEncodingException {
|
|
|
|
+ String[] values = StringUtils.split(URLDecoder.decode(code, SystemConstant.CHARSET_NAME), SignatureEntityTest.FIELD_JOINER);
|
|
if (Objects.isNull(values) || values.length != 2) {
|
|
if (Objects.isNull(values) || values.length != 2) {
|
|
throw ExceptionResultEnum.ERROR.exception("临时授权码出错,请重新获取");
|
|
throw ExceptionResultEnum.ERROR.exception("临时授权码出错,请重新获取");
|
|
}
|
|
}
|