|
|
|
@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.Base64;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -65,7 +66,8 @@ public class SingleLoginController {
|
|
|
|
|
@Resource
|
|
|
|
|
private BmsEnterpriseBasicInfoMapper bmsEnterpriseBasicInfoMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${enterpriseAppId}")
|
|
|
|
|
private String enterpriseAppId;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 统一登陆
|
|
|
|
@ -76,7 +78,7 @@ public class SingleLoginController {
|
|
|
|
|
@GetMapping("/login")
|
|
|
|
|
public void login(HttpServletResponse response) throws IOException {
|
|
|
|
|
//变成参数模式,appid 用于校验提交的来源地址,生产环境会校验,试用环境暂不校验
|
|
|
|
|
String scUrl = "clientUrl=" + URLEncoder.encode(returnUrl, "UTF-8") + "?appid=BwAWS8uh";
|
|
|
|
|
String scUrl = "clientUrl=" + URLEncoder.encode(returnUrl, "UTF-8") + "?appid="+enterpriseAppId;
|
|
|
|
|
//加密后的客户端地址
|
|
|
|
|
scUrl = Base64.getEncoder().encodeToString(scUrl.getBytes());
|
|
|
|
|
//最终跳转地址
|
|
|
|
@ -84,7 +86,10 @@ public class SingleLoginController {
|
|
|
|
|
// 添加请求头
|
|
|
|
|
response.setHeader("Content-Type", "application/json");
|
|
|
|
|
response.setHeader("X-Requested-With", "XMLHttpRequest");
|
|
|
|
|
|
|
|
|
|
// Map<String, String> stringStringMap = singleLoginService.generationHeader();
|
|
|
|
|
// response.setHeader("time",stringStringMap.get("time"));
|
|
|
|
|
// response.setHeader("appid",stringStringMap.get("appid"));
|
|
|
|
|
// response.setHeader("sign",stringStringMap.get("sign"));
|
|
|
|
|
response.sendRedirect(jumpurl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -98,7 +103,9 @@ public class SingleLoginController {
|
|
|
|
|
@GetMapping("/getInfo")
|
|
|
|
|
public AjaxResult getInfo(@RequestParam("clientToken") String clientToken) throws Exception {
|
|
|
|
|
String url = infoUrl + "?clienttoken=" + clientToken;
|
|
|
|
|
HttpResponse response = HttpUtil.createGet(url).execute();
|
|
|
|
|
HttpResponse response = HttpUtil.createGet(url)
|
|
|
|
|
// .addHeaders(singleLoginService.generationHeader())
|
|
|
|
|
.execute();
|
|
|
|
|
String responseBody = null;
|
|
|
|
|
// 获取响应状态码
|
|
|
|
|
int statusCode = response.getStatus();
|
|
|
|
@ -148,7 +155,9 @@ public class SingleLoginController {
|
|
|
|
|
@GetMapping("/enterpriseLogout")
|
|
|
|
|
public AjaxResult enterpriseLogout(@RequestParam("clienttoken") String clienttoken) {
|
|
|
|
|
String url = logoutUrl + "?clienttoken=" + clienttoken;
|
|
|
|
|
HttpResponse execute = HttpUtil.createGet(url).execute();
|
|
|
|
|
HttpResponse execute = HttpUtil.createGet(url)
|
|
|
|
|
// .addHeaders(singleLoginService.generationHeader())
|
|
|
|
|
.execute();
|
|
|
|
|
String str;
|
|
|
|
|
// 获取响应状态码
|
|
|
|
|
int statusCode = execute.getStatus();
|
|
|
|
@ -160,4 +169,5 @@ public class SingleLoginController {
|
|
|
|
|
return AjaxResult.success(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|