Index: ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml
===================================================================
diff -u -r30753 -r31212
--- ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml (.../applicationContext-acegi-security.xml) (revision 30753)
+++ ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml (.../applicationContext-acegi-security.xml) (revision 31212)
@@ -43,6 +43,7 @@
+
Index: ssts-web/src/main/webapp/logonSSOForDgszyy.jsp
===================================================================
diff -u
--- ssts-web/src/main/webapp/logonSSOForDgszyy.jsp (revision 0)
+++ ssts-web/src/main/webapp/logonSSOForDgszyy.jsp (revision 31212)
@@ -0,0 +1,185 @@
+<%@page import="com.itextpdf.text.log.SysoLogger"%>
+<%@page import="com.forgon.security.model.User"%>
+<%@page import="com.forgon.disinfectsystem.common.CssdUtils"%>
+<%@page import="com.forgon.security.service.UserManager"%>
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@page import="com.forgon.tools.SpringBeanManger"%>
+<%@page import="com.forgon.tools.Constants"%>
+<%@page import="net.sf.json.JSONObject" %>
+<%@page import="java.io.File" %>
+<%@page import="java.util.ArrayList" %>
+<%@page import="org.apache.commons.lang.StringUtils"%>
+
+<%
+ArrayList message = new ArrayList();
+String appId = request.getParameter("appId");
+String token = request.getParameter("token");
+if(StringUtils.isNotBlank(appId) && StringUtils.isNotBlank(token)){
+ UserManager userManager=(UserManager)SpringBeanManger.getBean("userManager");
+ String url = "http://10.12.88.167:8085/api/userByPortal"
+ try{
+ User user = userManager.SSOLoginPortal(url, appId, token);
+ if(user==null){
+ message.add("用户不存在");
+ }else{
+ session.setAttribute("barcode", user.getBarcode());
+ }
+ } catch (Exception e) {
+ message.add(e.getMessage());
+ }
+
+}else{
+ message.add("appId和token不能为空");
+}
+pageContext.setAttribute("message", message);
+
+String companyName = CssdUtils.getSystemSetConfigByName("companyName");
+String companyNameStr = "";
+if(companyName == null || companyName.equals("forgon")){
+ companyNameStr = "©2021 广州孚峻信息技术有限公司 版权所有";
+}else if(companyName.equals("dingxiang")){
+ companyNameStr = "©2021 广州丁香软件有限公司 版权所有";
+}
+session.setAttribute("companyName", companyNameStr);
+String project = CssdUtils.getConfigProperty("project");
+session.setAttribute("profile", project);
+
+String imgPath = "disinfectsystem/config/" + project + "/img/logo_" + project +".png";
+File file = new File(application.getRealPath("/") + imgPath);
+if(file.exists()){
+ request.setAttribute("logoPath",imgPath);
+}else{
+ if(companyName == null || companyName.equals("forgon")){
+ request.setAttribute("logoPath","themes/portalPage/img/logo_Forgon.png");
+ }else if(companyName.equals("dingxiang")){
+ request.setAttribute("logoPath","themes/portalPage/img/logo_dingxiangsoft.png");
+ }
+}
+
+%>
+
+
+
+
+
+
+
+
+消毒供应质量追溯管理系统
+<%-- --%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: forgon-core/src/main/java/com/forgon/security/service/UserManagerImpl.java
===================================================================
diff -u -r30237 -r31212
--- forgon-core/src/main/java/com/forgon/security/service/UserManagerImpl.java (.../UserManagerImpl.java) (revision 30237)
+++ forgon-core/src/main/java/com/forgon/security/service/UserManagerImpl.java (.../UserManagerImpl.java) (revision 31212)
@@ -16,6 +16,14 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
@@ -703,5 +711,72 @@
}
});
}
+
+ @Override
+ public User SSOLoginPortal(String url, String appId, String token) {
+ if(StringUtils.isBlank(url) || StringUtils.isBlank(appId) || StringUtils.isBlank(token)){
+ throw new RuntimeException("参数不能为空!");
+ }
+ // 创建HttpClientBuilder
+ HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
+ // HttpClient
+ CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
+ CloseableHttpResponse response = null;
+ String result = "";
+ try{
+ HttpPost httpPost = new HttpPost(url);
+ // 设置请求和传输超时时间
+ RequestConfig requestConfig = RequestConfig.custom()
+ .setSocketTimeout(3000000)
+ .setConnectTimeout(3000000).build();
+ httpPost.setConfig(requestConfig);
+ httpPost.addHeader("appId", appId);
+ httpPost.addHeader("token", token);
+ StringEntity data = new StringEntity("");
+ httpPost.setEntity(data);
+ response = closeableHttpClient.execute(httpPost);
+ if(response != null){
+ HttpEntity resEntity = response.getEntity();
+ if(resEntity != null){
+ result = EntityUtils.toString(resEntity,"UTF-8");
+ }
+ }
+ }catch(Exception ex){
+ ex.printStackTrace();
+ }finally{
+ //关闭资源
+ if(response != null){
+ try {
+ response.close();
+ }catch (Exception ioe){
+ ioe.printStackTrace();
+ }
+ }
+ if(closeableHttpClient != null){
+ try{
+ closeableHttpClient.close();
+ }catch (Exception ioe){
+ ioe.printStackTrace();
+ }
+ }
+ }
+
+ appLogManager = (LogManager) SpringBeanManger.getBean("appLogManager");
+ appLogManager.saveLog(AcegiHelper.getLoginUser(), Log.MODEL_LOGIN, Log.TYPE_QUERY, result);
+
+ if(StringUtils.isBlank(result)){
+ return null;
+ }
+
+ JSONObject jsonObject = JSONObject.fromObject(result);
+ String status = jsonObject.optString("status");
+ String staffCode = jsonObject.optString("staffCode");
+ String message = jsonObject.optString("message");
+ if(!StringUtils.equals(status, "0")){
+ throw new RuntimeException(message);
+ }
+ return getFirst("name", staffCode);
+ }
+
}
Index: forgon-core/src/main/java/com/forgon/security/service/UserManager.java
===================================================================
diff -u -r29915 -r31212
--- forgon-core/src/main/java/com/forgon/security/service/UserManager.java (.../UserManager.java) (revision 29915)
+++ forgon-core/src/main/java/com/forgon/security/service/UserManager.java (.../UserManager.java) (revision 31212)
@@ -136,5 +136,14 @@
* @param user
*/
public void modifyUserLockEndDateWithTransNewManager(User user);
+
+ /**
+ * 单点登录接口(DGZYY-184)
+ * @param url
+ * @param appId
+ * @param token
+ * @return
+ */
+ public User SSOLoginPortal(String url, String appId, String token);
}