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.
90 lines
2.7 KiB
90 lines
2.7 KiB
4 years ago
|
package com.fr.plugin.zjsso.handler;
|
||
|
|
||
|
import com.fr.base.ServerConfig;
|
||
|
import com.fr.decision.fun.impl.BaseHttpHandler;
|
||
|
import com.fr.decision.webservice.login.LogInOutResultInfo;
|
||
|
import com.fr.decision.webservice.utils.DecisionServiceConstants;
|
||
|
import com.fr.decision.webservice.v10.login.LoginService;
|
||
|
import com.fr.decision.webservice.v10.login.event.LogInOutEvent;
|
||
|
import com.fr.event.EventDispatcher;
|
||
|
import com.fr.log.FineLoggerFactory;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.plugin.transform.FunctionRecorder;
|
||
|
import com.fr.plugin.zjsso.utils.FRUtils;
|
||
|
import com.fr.plugin.zjsso.utils.ResponseUtils;
|
||
|
import com.fr.plugin.zjsso.utils.Utils;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
import com.fr.stable.fun.Authorize;
|
||
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
|
||
|
|
||
|
import javax.servlet.http.Cookie;
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import javax.servlet.http.HttpSession;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
@FunctionRecorder
|
||
|
@Authorize(callSignKey = "com.fr.plugin.xxxx.ccsso")
|
||
|
public class Login extends BaseHttpHandler {
|
||
|
|
||
|
|
||
|
public Login() {
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public RequestMethod getMethod() {
|
||
|
return RequestMethod.GET;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getPath() {
|
||
|
return "/login";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean isPublic() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void handle(HttpServletRequest req, HttpServletResponse res) throws IOException {
|
||
|
if(PluginContexts.currentContext().isAvailable()) {
|
||
|
|
||
|
String tokne = req.getParameter("token");
|
||
|
String rUrl = req.getParameter("redirectUrl");
|
||
|
rUrl = Utils.encodeCH(rUrl);
|
||
|
|
||
|
FRUtils.loginByToken(req, res, tokne, "");
|
||
|
res.sendRedirect(rUrl);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void writeToken2Cookie(HttpServletResponse var1, String var2, int var3) {
|
||
|
try {
|
||
|
if (StringUtils.isNotEmpty(var2)) {
|
||
|
Cookie var4 = new Cookie("fine_auth_token", var2);
|
||
|
long var5 = var3 == -2 ? 1209600000L : (long)var3;
|
||
|
var4.setMaxAge((int)var5);
|
||
|
var4.setPath(ServerConfig.getInstance().getCookiePath());
|
||
|
var1.addCookie(var4);
|
||
|
Cookie var7 = new Cookie("fine_remember_login", String.valueOf(var3 == -2 ? -2 : -1));
|
||
|
var7.setMaxAge((int)var5);
|
||
|
var7.setPath(ServerConfig.getInstance().getCookiePath());
|
||
|
var1.addCookie(var7);
|
||
|
} else {
|
||
|
FineLoggerFactory.getLogger().error("empty token cannot save.");
|
||
|
}
|
||
|
} catch (Exception var8) {
|
||
|
FineLoggerFactory.getLogger().error(var8.getMessage(), var8);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|