Commit 7dc59e2e authored by gaoyingwei's avatar gaoyingwei

update:修改日志、短信平台单点登录、发短信接口

parent 54c1c5fc
...@@ -2024,6 +2024,8 @@ public class ColManagerImpl implements ColManager { ...@@ -2024,6 +2024,8 @@ public class ColManagerImpl implements ColManager {
// 从request对象中对象中获取意见 // 从request对象中对象中获取意见
Comment comment = ContentUtil.getCommnetFromRequest(ContentUtil.OperationType.finish, affair.getMemberId(), Comment comment = ContentUtil.getCommnetFromRequest(ContentUtil.OperationType.finish, affair.getMemberId(),
affair.getObjectId()); affair.getObjectId());
User user = AppContext.getCurrentUser();
appLogManager.insertLog(user, AppLogAction.Coll_Tranfer, user.getName(), affair.getSubject());
// 调用公用方法 // 调用公用方法
transFinishWorkItemPublic(affair, summary, comment, ColHandleType.finish, params); transFinishWorkItemPublic(affair, summary, comment, ColHandleType.finish, params);
} }
......
package com.seeyon.ctp.portal.sso; package com.seeyon.ctp.portal.sso;
import com.eetrust.security.plugin.MessageConstants;
import com.eetrust.security.plugin.SIDPlugin;
import com.seeyon.ctp.common.SystemEnvironment; import com.seeyon.ctp.common.SystemEnvironment;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate;
import java.io.*; import java.io.*;
import java.util.Properties; import java.net.URLDecoder;
import java.util.*;
public class MySSOLoginHandshake extends SSOLoginHandshakeAbstract { public class MySSOLoginHandshake extends SSOLoginHandshakeAbstract {
private static final Log log = LogFactory.getLog(MySSOLoginHandshake.class); private static final Log log = LogFactory.getLog(MySSOLoginHandshake.class);
// “ticket” 就是ticket取得的参数值 // “ticket” 就是ticket取得的参数值
public String handshake(String ticket) { public String handshake(String code){
if (StringUtils.isEmpty(ticket)) JSONObject jsonObject = new JSONObject();
String decodeRs = null ;
if (StringUtils.isEmpty(code))
{ {
log.error( "单点登录缺少登录票据[ticket]信息!"); log.error( "单点登录缺少登录票据[ticket]信息!");
return null; return null;
} }
// 认证服务器地址 // 认证服务器地址
String authServerIp = ""; String ssoUrl = "";
String clientId = "";
// 认证服务器端口 String redirectUri = "";
String authServerPort = ""; String clientSecret = "";
// 业务系统编码
String authAppCode = "";
String filePath = SystemEnvironment.getApplicationFolder() + File.separator + "fkmap" + File.separator + "url.properties" ; String filePath = SystemEnvironment.getApplicationFolder() + File.separator + "fkmap" + File.separator + "url.properties" ;
InputStream in = null; InputStream in = null;
try { try {
in = new BufferedInputStream(new FileInputStream(filePath)); in = new BufferedInputStream(new FileInputStream(filePath));
Properties p = new Properties(); Properties p = new Properties();
p.load(in); p.load(in);
authServerIp = p.getProperty("authServerIp"); ssoUrl = p.getProperty("ssoUrl");
authServerPort = p.getProperty("authServerPort"); clientId = p.getProperty("clientId");
authAppCode = p.getProperty("authAppCode"); redirectUri = p.getProperty("redirectUri");
clientSecret = p.getProperty("clientSecret");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
log.info("sso code: " + code);
SIDPlugin sid = new SIDPlugin(authServerIp, Integer.parseInt(authServerPort)); String grantType = "authorization_code"; //必填 常量
int result = sid.Security_VerifyTicket(authAppCode, ticket); String userName = "";
// log.info("ticket:"+ticket); String token = "";
if (result == MessageConstants.SECURITY_SERVICE_SUCCESS) //使用认证中心的code获取token
{ String getSSOTokenUrl = ssoUrl + "accessToken?" +
// 票据验证成功, 获取用户唯一标识 "client_id=" + clientId +
String passport = sid.getPassport(); "&grant_type=" + grantType +
log.info("系统获取到的ticket:"+ticket); "&redirect_uri=" + redirectUri +
log.info("单点登录成功! 用户唯一标识: " + passport); "&oauth_timestamp="+ (new Date()).getTime() +
return passport; "&code=" + code +
"&client_secret=" + clientSecret;
log.info("get sso token url: "+getSSOTokenUrl);
RestTemplate rest = new RestTemplate();
String respnose = rest.postForObject(getSSOTokenUrl,null, String.class);
// String code = "";
if(StringUtils.isNotBlank(respnose)){
try {
decodeRs = URLDecoder.decode(respnose, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
log.error("error");
}
jsonObject = JSONObject.fromObject(decodeRs.replace("\r\n",""));
} }
else log.info("sso token: " + respnose);
{ token = (String) jsonObject.get("access_token");
// 认证失败, 获取错误编码 log.info("sso token1: " + token);
String errorCode = sid.getErrorCode();
// 认证失败, 获取错误信息 //使用token获取用户信息
String errorMsg = sid.getErrorMsg(); String getUserUrl = ssoUrl + "profile?access_token=" + token;
log.error( "单点登录失败! 错误编码: " + errorCode + ", 错误信息: " + errorMsg); log.info("get user url: "+getUserUrl);
return null; RestTemplate rest1 = new RestTemplate();
respnose = rest1.getForObject(getUserUrl,String.class);
if(StringUtils.isNotBlank(respnose)){
try {
decodeRs = URLDecoder.decode(respnose, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
log.error("error1");
}
jsonObject = JSONObject.fromObject(decodeRs.replace("\r\n",""));
} }
log.info("user info: " + respnose);
// JSONObject userObj = JSONObject.fromObject(userResult);
userName = (String) jsonObject.get("id");
log.info("userName info: " + userName);
return userName;
} }
public void logoutNotify(String ticket) { public void logoutNotify(String ticket) {
log.info("退出登录:"+ticket); log.info("退出登录:"+ticket);
......
package com.seeyon.ctp.portal.sso;
public class SSOLoginContext {
private String name;
private String ticketName = "code";
private String destination = "/seeyon/main.do?method=main";
private String topFrameName = null;
private SSOLoginHandshakeInterface handshake;
private String exAuthType;
private boolean isForward = true;
private boolean isEnableTrustAddress = false;
private String tourl;
public SSOLoginContext() {
}
public SSOLoginHandshakeInterface getHandshake() {
return this.handshake;
}
public void setHandshake(SSOLoginHandshakeInterface handshake) {
this.handshake = handshake;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getTicketName() {
return this.ticketName;
}
public void setTicketName(String ticketName) {
this.ticketName = ticketName;
}
public String getDestination() {
return this.destination;
}
public void setDestination(String val) {
this.destination = val;
}
public String getTopFrameName() {
return this.topFrameName;
}
public void setTopFrameName(String val) {
this.topFrameName = val;
}
public String getExAuthType() {
return this.exAuthType;
}
public void setExAuthType(String val) {
this.exAuthType = val;
}
public boolean isForward() {
return this.isForward;
}
public void setForward(boolean isForward) {
this.isForward = isForward;
}
public boolean isEnableTrustAddress() {
return this.isEnableTrustAddress;
}
public void setEnableTrustAddress(boolean isEnableTrustAddress) {
this.isEnableTrustAddress = isEnableTrustAddress;
}
public String toString() {
return "[" + this.name + "," + this.ticketName + "," + this.handshake + "]";
}
public String getTourl() {
return this.tourl;
}
public void setTourl(String tourl) {
this.tourl = tourl;
}
}
package com.seeyon.v3x.mobile.adapter.demo;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import com.seeyon.ctp.common.SystemEnvironment;
import com.seeyon.ctp.util.Strings;
import com.seeyon.ctp.util.json.JSONUtil;
import org.apache.log4j.Logger;
import com.seeyon.v3x.mobile.adapter.AdapterMobileMessageManger;
import com.seeyon.v3x.mobile.message.domain.MobileReciver;
import org.springframework.web.client.RestTemplate;
/**
* DEMO短信
*/
public class AdaptMobileDEMOImpl implements AdapterMobileMessageManger {
private static final Logger LOGGER = Logger.getLogger(AdaptMobileDEMOImpl.class);
/** 短信插件是否启动 */
/** 用户账号 */
private String userName;
/** 用户密码 */
private String password;
/**签名***/
private String sign ;
@Override
public String getName() {
return "测试";
}
@Override
public boolean isAvailability() {
String filePath = SystemEnvironment.getApplicationFolder() + File.separator + "fkmap" + File.separator + "url.properties";
InputStream in = null;
String messageUrl;
try {
in = new BufferedInputStream(new FileInputStream(filePath));
Properties p = new Properties();
BufferedReader bf = new BufferedReader(new InputStreamReader(in, "utf-8"));
p.load(bf);
this.userName = p.getProperty("userName");
this.password = p.getProperty("password");
this.sign = p.getProperty("sign");
LOGGER.info("------"+this.userName+"---"+this.password+"---"+this.sign);
if (Strings.isNotBlank(this.userName) && Strings.isNotBlank(this.password) && Strings.isNotBlank(this.sign)) {
LOGGER.info("----------初始化短信插件------------");
System.out.println("---------------初始化短信插件--------------");
return true;
} else {
LOGGER.info("----------短信系统参数配置不全------------");
System.out.println("---------------短信系统参数配置不全--------------");
return false;
}
}catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean isSupportQueueSend() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isSupportRecive() {
// TODO Auto-generated method stub
return false;
}
@Override
public List<MobileReciver> recive() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean sendMessage(Long messageId, String srcPhone, String destPhone, String content) {
LOGGER.info("----------开始发送短信------------");
String filePath = SystemEnvironment.getApplicationFolder() + File.separator + "fkmap" + File.separator + "url.properties";
InputStream in = null;
String messageUrl;
try {
content = URLEncoder.encode(content,"utf-8");
LOGGER.info("content=" + content);
LOGGER.info("destPhone=" + destPhone);
in = new BufferedInputStream(new FileInputStream(filePath));
Properties p = new Properties();
BufferedReader bf = new BufferedReader(new InputStreamReader(in, "utf-8"));
p.load(bf);
messageUrl = p.getProperty("messageUrl");
this.userName = p.getProperty("userName");
this.password = p.getProperty("password");
this.sign = p.getProperty("sign");
LOGGER.info("------"+this.userName+"---"+this.password+"---"+this.sign);
messageUrl = messageUrl +
"?userName="+this.userName+"&password="+this.password+"&sign="+this.sign+"&phoneList="+destPhone
+"&content="+content;
RestTemplate template = new RestTemplate();
String response = template.postForObject(messageUrl, null, String.class);
LOGGER.info("response=" + response);
Map<String, Object> json = (Map<String, Object>) JSONUtil.parseJSONString(response);
String code = json.get("code").toString();
if (!"200".equals(code)) {
LOGGER.error("msg:"+json.get("msg").toString());
return false;
}
LOGGER.info("----------发送短信结束------------");
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean sendMessage(Long messageId, String srcPhone,Collection<String> destPhoneList, String content) {
String phone = null;
Iterator var6 = destPhoneList.iterator();
LOGGER.info("-------------------------------群发短信=");
while(var6.hasNext()) {
String str = (String)var6.next();
if (phone != null) {
phone = phone + "," + str;
} else {
phone = str;
}
}
return this.sendMessage(messageId, srcPhone, phone, content);
}
}
...@@ -7,20 +7,6 @@ ...@@ -7,20 +7,6 @@
<!-- 单点登录成功是否跳转到首页 --> <!-- 单点登录成功是否跳转到首页 -->
<property name="forward" value="true"/> <property name="forward" value="true"/>
<!-- 握手配置 --> <!-- 握手配置 -->
<!-- <property name="handshake">-->
<!-- 使用系统实现的缺省握手类 -->
<!-- <bean class="com.seeyon.ctp.portal.sso.SSOLoginHandshakeServletImpl">-->
<!-- &lt;!&ndash; 第三方系统页面,传入ticket,返回协同登录名 &ndash;&gt;-->
<!-- <property name="url" value="http://第三方系统:8080/checkTicket"/>-->
<!-- &lt;!&ndash; 第三方系统页面单点登录登出地址 &ndash;&gt;-->
<!-- <property name="logoutUrl" value="http://第三方系统:8080/ssologout"/>-->
<!-- </bean>-->
<!-- </property>-->
<!-- <property name="name" value="sample"/>-->
<!-- <property name="forward" value="true"/>-->
<!-- <property name="ticketName" value="ticket" />-->
<property name="handshake"> <property name="handshake">
<!-- 使用自己的握手实现 --> <!-- 使用自己的握手实现 -->
<bean class="com.seeyon.ctp.portal.sso.MySSOLoginHandshake" /> <bean class="com.seeyon.ctp.portal.sso.MySSOLoginHandshake" />
......
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>sso</id>
<name>单点短信平台</name>
<category>759439</category>
</plugin>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<!-- id必须唯一 -->
<bean id="sinaNewsSpace" class="com.seeyon.ctp.portal.sso.thirdpartyintegration.ThirdpartySpace" init-method="init">
<!--注意如果OA的版本是V6.0及其以上,上面class修正为:com.seeyon.ctp.portal.sso.thirdpartyintegration.ThirdpartySpace -->
<!-- id必须唯一或者不写后台自动生成,必须为数字 -->
<property name="id" value="-2327812443752403806"/>
<!-- 页签上显示的名称 -->
<property name="name" value="短信平台"/>
<!-- 插件id,必须存在,如果不存在,请按下面的步骤定义一个新的插件 -->
<property name="pluginId" value="sso"/>
<!-- 第三方系统登录地址,如果合并3、4步,可以省略 -->
<property name="loginURL" value="http://192.168.10.23:8090/afterLogin2"/>
<!-- 点击页签要打开的第三方系统页面地址 -->
<property name="pageURL" value="http://192.168.10.159:8081/jump"/>
<!-- 打开方式,值为open时在新窗口打开,为workspace时在协同页面能打开 -->
<property name="openType" value="open"/>
<!-- 排序号 -->
<property name="index" value="4"/>
<!-- 授权 accessRoles与accessCheck选择其中一个即可-->
<property name="accessRoles">
<list>
<!-- <value>GeneralStaff</value>-->
<value>Message</value>
</list>
</property>
<!-- <property name="accessCheck" ref="accessCheck"/> -->
</bean>
<!-- <bean id="accessCheck" class="com.seeyon.ctp.ext.Tab.TestThirdpartyAccessCheck"></bean> -->
</beans>
\ No newline at end of file
...@@ -9,26 +9,35 @@ ...@@ -9,26 +9,35 @@
--%> --%>
<%@ page language="java" contentType="text/html; charset=UTF-8" <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%> <%--<%@ include file="/WEB-INF/jsp/common/common.jsp"%>--%>
<!DOCTYPE html> <!DOCTYPE html>
<html class="h100b over_hidden"> <html class="h100b over_hidden">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>印刷管理</title> <title>印刷管理</title>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { <%--$(document).ready(function () {--%>
<%--alert("${ctp:escapeJavascript(code)}")--%> <%-- &lt;%&ndash;alert("${ctp:escapeJavascript(code)}")&ndash;%&gt;--%>
<%--alert("${ctp:escapeJavascript(token)}")--%> <%-- &lt;%&ndash;alert("${ctp:escapeJavascript(token)}")&ndash;%&gt;--%>
if ("${ctp:escapeJavascript(token)}" == null || "${ctp:escapeJavascript(token)}" === "") <%-- if ("${ctp:escapeJavascript(token)}" == null || "${ctp:escapeJavascript(token)}" === "")--%>
alert("该用户没有权限!"); <%-- alert("该用户没有权限!");--%>
else { <%-- else {--%>
if ("${ctp:escapeJavascript(code)}" === "erp") <%-- if ("${ctp:escapeJavascript(code)}" === "erp")--%>
window.location.href="http://192.168.3.49/login-validate?appCode=oasystem&uniTicket=${ctp:escapeJavascript(token)}"; <%-- window.location.href="http://192.168.3.49/login-validate?appCode=oasystem&uniTicket=${ctp:escapeJavascript(token)}";--%>
if ("${ctp:escapeJavascript(code)}" === "doc") <%-- if ("${ctp:escapeJavascript(code)}" === "doc")--%>
window.location.href="http://192.168.3.49/login-validate?appCode=oasystem&uniTicket=${ctp:escapeJavascript(token)}"; <%-- window.location.href="http://192.168.3.49/login-validate?appCode=oasystem&uniTicket=${ctp:escapeJavascript(token)}";--%>
} <%-- }--%>
}); <%--});--%>
window.onload = function(){
alert("denglu")
let ssoUrl = "http://127.0.0.1:10080/esc-sso/"; //单点登录SSO URL地址 由统一身份认证系统提供
let appKey = "demo1"; //注册应用系统的KEY 由统一身份认证系统后台管理注册应用时生成
let appRedirectUrl = "http://127.0.0.1:8081/eic-demo/oauth2.0/authorize"; //应用单点登录回调地址 单点登录验证通过后跳转到集成应用的地址(由应用系统集成商提供)
let oauth_timestamp = (new Date()).getTime(); //当前时间戳 当前时间戳,单位:毫秒(13位)
let url = ssoUrl+"/oauth2.0/authorize?client_id="+appKey+"&response_type=code&redirect_uri="+appRedirectUrl+"&oauth_timestamp="+oauth_timestamp
console.log(url)
window.location.replace(url)
}
</script> </script>
</head> </head>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment