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.
71 lines
2.6 KiB
71 lines
2.6 KiB
package com.fr.plugin.web.hander; |
|
|
|
import com.fr.decision.authority.data.User; |
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.decision.webservice.v10.user.UserService; |
|
import com.fr.log.FineLoggerFactory; |
|
import com.fr.plugin.utils.xxUtils; |
|
import com.fr.stable.StringUtils; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
public class SingleLoginHandler extends BaseHttpHandler { |
|
@Override |
|
public RequestMethod getMethod() { |
|
return null; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/yt/login"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return true; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
|
try { |
|
//先做登录 |
|
if (!autoLogin(req, res)) { |
|
FineLoggerFactory.getLogger().error("==================== xx user login to FS failed!"); |
|
FineLoggerFactory.getLogger().error("==================== xx user login to FS failed!"); |
|
|
|
} |
|
String originalUrl = WebUtils.getOriginalURL(req); |
|
|
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
} |
|
} |
|
|
|
|
|
private boolean autoLogin(HttpServletRequest req, HttpServletResponse res) throws Exception { |
|
String authCode = WebUtils.getHTTPRequestParameter(req, "authCode"); |
|
String clientId = WebUtils.getHTTPRequestParameter(req, "clientId"); |
|
if (StringUtils.isEmpty(authCode)) { |
|
FineLoggerFactory.getLogger().error("==================== 获取xx码authCode失败!"); |
|
FineLoggerFactory.getLogger().error("==================== 获取xx码authCode失败!"); |
|
return false; |
|
} |
|
String access_token = xxUtils.getAccessToken(clientId); |
|
String xxUserId = xxUtils.getCurrentUserId(clientId,authCode, access_token); |
|
FineLoggerFactory.getLogger().info("==================== 获取xx码用户ID:" + xxUserId); |
|
FineLoggerFactory.getLogger().info("==================== 获取xx码用户ID:" + xxUserId); |
|
String username = null; |
|
if (StringUtils.isNotEmpty(xxUserId)) { |
|
FineLoggerFactory.getLogger().info("==================== 识别BI用户为:" + username); |
|
FineLoggerFactory.getLogger().info("==================== 识别BI用户为:" + username); |
|
User user = UserService.getInstance().getUserByUserName(username); |
|
if (user != null) { |
|
|
|
} |
|
} |
|
return false; |
|
} |
|
}
|
|
|