You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.4 KiB
69 lines
2.4 KiB
package com.eco.plugin.xx.kksso.controller; |
|
|
|
import com.eco.plugin.xx.kksso.config.PluginSimpleConfig; |
|
import com.eco.plugin.xx.kksso.utils.FRUtils; |
|
import com.eco.plugin.xx.kksso.utils.RSAUtil; |
|
import com.eco.plugin.xx.kksso.utils.ResponseUtils; |
|
import com.eco.plugin.xx.kksso.utils.Utils; |
|
import com.fr.decision.webservice.annotation.LoginStatusChecker; |
|
import com.fr.plugin.context.PluginContexts; |
|
import com.fr.stable.fun.Authorize; |
|
import com.fr.third.springframework.stereotype.Controller; |
|
import com.fr.third.springframework.web.bind.annotation.GetMapping; |
|
import com.fr.third.springframework.web.bind.annotation.ResponseBody; |
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
@Controller |
|
@LoginStatusChecker(required = false) |
|
@Authorize(callSignKey = "com.eco.plugin.xx.kksso") |
|
public class ControllerSelf { |
|
|
|
@GetMapping(value = "/mobileSSOLogin") |
|
@ResponseBody |
|
public void ssologin(HttpServletRequest request,HttpServletResponse response){ |
|
if(!PluginContexts.currentContext().isAvailable()){ |
|
ResponseUtils.failedResponse(response,"插件授权过期,请联系管理员!"); |
|
return ; |
|
} |
|
|
|
PluginSimpleConfig psc = PluginSimpleConfig.getInstance(); |
|
//获取token |
|
String token = request.getParameter(psc.getParamname()); |
|
|
|
if(Utils.isNullStr(token)){ |
|
ResponseUtils.failedResponse(response,"token不能为空!"); |
|
return ; |
|
} |
|
//解密token |
|
String plaintext = null; |
|
try { |
|
plaintext = RSAUtil.decrypt(token,psc.getSecret()); |
|
} catch (Exception e) { |
|
ResponseUtils.failedResponse(response,"解析token失败!"+e.getMessage()); |
|
return ; |
|
} |
|
|
|
if(Utils.isNullStr(plaintext)){ |
|
ResponseUtils.failedResponse(response,"解析token失败!"); |
|
return ; |
|
} |
|
//验证时间戳 |
|
String[] data = plaintext.split("_"); |
|
String username = data[0]; |
|
Long timestamp = Long.parseLong(data[1]); |
|
Long now = System.currentTimeMillis(); |
|
|
|
FRUtils.FRLogInfo("timestamp:"+timestamp+";now:"+now); |
|
|
|
if((now - timestamp)/1000 > Long.parseLong(psc.getTimeout())){ |
|
ResponseUtils.failedResponse(response,"token超时,请重新生成!"); |
|
return ; |
|
} |
|
|
|
//登陆 |
|
FRUtils.login(request,response,username,psc.getIndex()); |
|
} |
|
|
|
|
|
}
|
|
|