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.
68 lines
1.6 KiB
68 lines
1.6 KiB
4 years ago
|
package com.fr.plugin.zjsso.handler;
|
||
|
|
||
|
import com.fr.decision.fun.impl.BaseHttpHandler;
|
||
|
import com.fr.decision.webservice.v10.login.LoginService;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.plugin.transform.FunctionRecorder;
|
||
|
import com.fr.plugin.zjsso.config.PluginSimpleConfig;
|
||
|
import com.fr.plugin.zjsso.utils.*;
|
||
|
import com.fr.stable.fun.Authorize;
|
||
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
@FunctionRecorder
|
||
|
@Authorize(callSignKey = "com.fr.plugin.xxxx.ccsso")
|
||
|
public class GetToken extends BaseHttpHandler {
|
||
|
|
||
|
|
||
|
public GetToken() {
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public RequestMethod getMethod() {
|
||
|
return RequestMethod.GET;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getPath() {
|
||
|
return "/getToken";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean isPublic() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||
|
String token = "";
|
||
|
|
||
|
if(PluginContexts.currentContext().isAvailable()){
|
||
|
String username = req.getParameter("username");
|
||
|
|
||
|
FRUtils.FRLogInfo("username: " + username);
|
||
|
|
||
|
try{
|
||
|
token = LoginService.getInstance().login(req, res, username);
|
||
|
}catch(Exception e){
|
||
|
FRUtils.FRLogError("获取token失败:"+e.getMessage());
|
||
|
ResponseUtils.failedResponse(res,"获取token失败!");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ResponseUtils.successResponse(res,token);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|