LAPTOP-SB56SG4Q\86185
3 years ago
29 changed files with 3084 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# open-JSD-8974 |
||||
|
||||
JSD-8974 飞书消息推送+单点登录 |
||||
JSD-8974 飞书消息推送+单点登录\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.eco.plugin.xxxx.fssso</id> |
||||
<name><![CDATA[飞书消息推送]]></name> |
||||
<active>yes</active> |
||||
<version>1.0.18</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[飞书消息推送]]></description> |
||||
<change-notes><![CDATA[ |
||||
]]></change-notes> |
||||
<main-package>com.eco.plugin.xxxx.fssso</main-package> |
||||
<lifecycle-monitor class="com.eco.plugin.xxxx.fssso.config.InitializeMonitor"/> |
||||
|
||||
<extra-decision> |
||||
<OutputFormulaProvider class="com.eco.plugin.xxxx.fssso.dsdd.dsdd.DSDDMsgFormula" /> |
||||
<WebResourceProvider class="com.eco.plugin.xxxx.fssso.dsdd.webresource.DsddWebResourceProvider"/> |
||||
<DecisionDBAccessProvider class="com.eco.plugin.xxxx.fssso.dsdd.db.DBAccessProvider"/> |
||||
<HttpHandlerProvider class="com.eco.plugin.xxxx.fssso.handler.ExtendAttrHandlerProvider"/> |
||||
<URLAliasProvider class="com.eco.plugin.xxxx.fssso.handler.URLAliasProvide"/> |
||||
</extra-decision> |
||||
|
||||
<extra-core> |
||||
<DBAccessProvider class="com.eco.plugin.xxxx.fssso.db.controller.DBController"/> |
||||
<LocaleFinder class="com.eco.plugin.xxxx.fssso.localejava.locale"/> |
||||
</extra-core> |
||||
|
||||
<function-recorder class="com.eco.plugin.xxxx.fssso.config.WinkSimpleConfig"/> |
||||
</plugin> |
@ -0,0 +1,32 @@
|
||||
package com.eco.plugin.xxxx.fssso.config; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.DSDDMsgFormula; |
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.TsBean; |
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.TsEntity; |
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.TsHandler; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.schedule.extension.report.job.output.formula.FormulaBox; |
||||
import com.fr.schedule.feature.ScheduleOutputActionEntityRegister; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
|
||||
/** |
||||
* @author fr.open |
||||
* @version 10.0 |
||||
* Created by fr.open on 2018-12-04 |
||||
*/ |
||||
public class InitializeMonitor extends AbstractPluginLifecycleMonitor { |
||||
@Override |
||||
public void afterRun(PluginContext pluginContext) { |
||||
OutputActionHandler.registerHandler(new TsHandler(), TsBean.class.getName()); |
||||
ScheduleOutputActionEntityRegister.getInstance().addClass(TsEntity.class); |
||||
FormulaBox.KEY.register(new DSDDMsgFormula()); |
||||
WinkSimpleConfig.getInstance(); |
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
OutputActionHandler.removeOutputHandler(TsBean.class.getName()); |
||||
ScheduleOutputActionEntityRegister.getInstance().removeClass(TsEntity.class); |
||||
} |
||||
} |
@ -0,0 +1,186 @@
|
||||
package com.eco.plugin.xxxx.fssso.config; |
||||
|
||||
import com.fr.config.*; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
|
||||
@Visualization(category = "消息推送及单点登录配置") |
||||
@EnableMetrics |
||||
public class WinkSimpleConfig extends DefaultConfiguration { |
||||
|
||||
private static volatile WinkSimpleConfig config = null; |
||||
|
||||
@Focus(id="com.eco.plugin.xxxx.idmsso.config", text = "消息推送及单点登录配置", source = Original.PLUGIN) |
||||
public static WinkSimpleConfig getInstance() { |
||||
if (config == null) { |
||||
config = ConfigContext.getConfigInstance(WinkSimpleConfig.class); |
||||
} |
||||
return config; |
||||
} |
||||
|
||||
@Identifier(value = "clientId", name = "appid", description = "appid", status = Status.SHOW) |
||||
private Conf<String> clientId = Holders.simple(""); |
||||
|
||||
@Identifier(value = "secret", name = "secret", description = "secret", status = Status.SHOW) |
||||
private Conf<String> secret = Holders.simple(""); |
||||
|
||||
@Identifier(value = "index", name = "Plugin-wink_index", description = "Plugin-wink_index", status = Status.SHOW) |
||||
private Conf<String> index = Holders.simple(""); |
||||
|
||||
@Identifier(value = "authUrl", name = "Plugin-wink_codeurl", description = "Plugin-wink_codeurl", status = Status.SHOW) |
||||
private Conf<String> authUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "tokenUrl", name = "Plugin-wink_tokenurl", description = "Plugin-wink_tokenurl", status = Status.SHOW) |
||||
private Conf<String> tokenUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "userUrl", name = "Plugin-wink_userurl", description = "Plugin-wink_userurl", status = Status.SHOW) |
||||
private Conf<String> userUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "sendMessage", name = "Plugin-wink_sendMessageUrl", description = "Plugin-wink_sendMessageUrl", status = Status.SHOW) |
||||
private Conf<String> sendMessage = Holders.simple(""); |
||||
|
||||
@Identifier(value = "cancelMessage", name = "Plugin-wink_cancelMessage", description = "Plugin-wink_cancelMessage", status = Status.SHOW) |
||||
private Conf<String> cancelMessage = Holders.simple(""); |
||||
|
||||
@Identifier(value = "sysdes", name = "Plugin-wink_sysdes", description = "Plugin-wink_sysdes", status = Status.SHOW) |
||||
private Conf<String> sysdes = Holders.simple(""); |
||||
|
||||
@Identifier(value = "syscode", name = "Plugin-wink_syscode", description = "Plugin-wink_syscode", status = Status.SHOW) |
||||
private Conf<String> syscode = Holders.simple(""); |
||||
|
||||
@Identifier(value = "mtokenUrl", name = "Plugin-wink_gettokenurl", description = "Plugin-wink_gettokenurl", status = Status.SHOW) |
||||
private Conf<String> mtokenUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "imgUrl", name = "Plugin-wink_imgurl", description = "Plugin-wink_imgurl", status = Status.SHOW) |
||||
private Conf<String> imgUrl = Holders.simple(""); |
||||
|
||||
@Identifier(value = "username", name = "Plugin-wink_pouser", description = "Plugin-wink_pouser", status = Status.SHOW) |
||||
private Conf<String> username = Holders.simple(""); |
||||
|
||||
@Identifier(value = "psd", name = "Plugin-wink_popsd", description = "Plugin-wink_popsd", status = Status.SHOW) |
||||
private Conf<String> psd = Holders.simple(""); |
||||
|
||||
|
||||
public String getSysdes() { |
||||
return sysdes.get(); |
||||
} |
||||
|
||||
public void setSysdes(String url) { |
||||
this.sysdes.set(url); |
||||
} |
||||
|
||||
public String getSyscode() { |
||||
return syscode.get(); |
||||
} |
||||
|
||||
public void setSyscode(String url) { |
||||
this.syscode.set(url); |
||||
} |
||||
|
||||
public String getSendMessage() { |
||||
return sendMessage.get(); |
||||
} |
||||
|
||||
public void setSendMessage(String url) { |
||||
this.sendMessage.set(url); |
||||
} |
||||
|
||||
public String getCancelMessage() { |
||||
return cancelMessage.get(); |
||||
} |
||||
|
||||
public void setCancelMessage(String url) { |
||||
this.cancelMessage.set(url); |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return clientId.get(); |
||||
} |
||||
|
||||
public void setClientId(String url) { |
||||
this.clientId.set(url); |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return secret.get(); |
||||
} |
||||
|
||||
public void setSecret(String url) { |
||||
this.secret.set(url); |
||||
} |
||||
|
||||
public String getAuthUrl() { |
||||
return authUrl.get(); |
||||
} |
||||
|
||||
public void setAuthUrl(String url) { |
||||
this.authUrl.set(url); |
||||
} |
||||
|
||||
public String getTokenUrl() { |
||||
return tokenUrl.get(); |
||||
} |
||||
|
||||
public void setTokenUrl(String url) { |
||||
this.tokenUrl.set(url); |
||||
} |
||||
|
||||
public String getUserUrl() { |
||||
return userUrl.get(); |
||||
} |
||||
|
||||
public void setUserUrl(String url) { |
||||
this.userUrl.set(url); |
||||
} |
||||
|
||||
public String getMtokenUrl() { |
||||
return mtokenUrl.get(); |
||||
} |
||||
|
||||
public void setMtokenUrl(String url) { |
||||
this.mtokenUrl.set(url); |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username.get(); |
||||
} |
||||
|
||||
public void setUsername(String url) { |
||||
this.username.set(url); |
||||
} |
||||
|
||||
public String getPsd() { |
||||
return psd.get(); |
||||
} |
||||
|
||||
public void setPsd(String url) { |
||||
this.psd.set(url); |
||||
} |
||||
|
||||
public String getIndex() { |
||||
return index.get(); |
||||
} |
||||
|
||||
public void setIndex(String url) { |
||||
this.index.set(url); |
||||
} |
||||
|
||||
public String getImgUrl() { |
||||
return imgUrl.get(); |
||||
} |
||||
|
||||
public void setImgUrl(String url) { |
||||
this.imgUrl.set(url); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
WinkSimpleConfig cloned = (WinkSimpleConfig) super.clone(); |
||||
|
||||
return cloned; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,173 @@
|
||||
package com.eco.plugin.xxxx.fssso.db.bean; |
||||
|
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.stable.db.entity.TableAssociation; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
/** |
||||
* @author fr.open |
||||
* @version 10.0 |
||||
* Created by fr.open on 2021-11-30 |
||||
**/ |
||||
@com.fr.third.javax.persistence.Entity |
||||
@Table(name = "plugin_message_info") |
||||
@TableAssociation(associated = true) |
||||
public class DBEntity extends BaseEntity { |
||||
|
||||
//uuid
|
||||
@Column(name = "uuid") |
||||
private String uuid = null; |
||||
|
||||
//系统编码
|
||||
@Column(name = "syscode") |
||||
private String syscode = null; |
||||
|
||||
//系统描述
|
||||
@Column(name = "sysdes") |
||||
private String sysdes = null; |
||||
|
||||
//发送时间
|
||||
@Column(name = "sendertime") |
||||
private String sendertime = null; |
||||
|
||||
//appid
|
||||
@Column(name = "appid") |
||||
private String appid = null; |
||||
|
||||
//servicename
|
||||
@Column(name = "servicename") |
||||
private String servicename = null; |
||||
|
||||
//content
|
||||
@Column(name = "content") |
||||
private String content = null; |
||||
|
||||
//msg_type
|
||||
@Column(name = "msg_type") |
||||
private String msg_type = null; |
||||
|
||||
//receive_id
|
||||
@Column(name = "receive_id") |
||||
private String receive_id = null; |
||||
|
||||
//receive_id_type
|
||||
@Column(name = "receive_id_type") |
||||
private String receive_id_type = null; |
||||
|
||||
//messageid
|
||||
@Column(name = "messageid") |
||||
private String messageid = null; |
||||
|
||||
//result
|
||||
@Column(name = "result") |
||||
private String result = null; |
||||
|
||||
//issuccess
|
||||
@Column(name = "issuccess") |
||||
private String issuccess = null; |
||||
|
||||
public String getUuid() { |
||||
return uuid; |
||||
} |
||||
|
||||
public void setUuid(String uuid) { |
||||
this.uuid = uuid; |
||||
} |
||||
|
||||
public String getSyscode() { |
||||
return syscode; |
||||
} |
||||
|
||||
public void setSyscode(String syscode) { |
||||
this.syscode = syscode; |
||||
} |
||||
|
||||
public String getSysdes() { |
||||
return sysdes; |
||||
} |
||||
|
||||
public void setSysdes(String sysdes) { |
||||
this.sysdes = sysdes; |
||||
} |
||||
|
||||
public String getSendertime() { |
||||
return sendertime; |
||||
} |
||||
|
||||
public void setSendertime(String sendertime) { |
||||
this.sendertime = sendertime; |
||||
} |
||||
|
||||
public String getAppid() { |
||||
return appid; |
||||
} |
||||
|
||||
public void setAppid(String appid) { |
||||
this.appid = appid; |
||||
} |
||||
|
||||
public String getServicename() { |
||||
return servicename; |
||||
} |
||||
|
||||
public void setServicename(String servicename) { |
||||
this.servicename = servicename; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public String getMsg_type() { |
||||
return msg_type; |
||||
} |
||||
|
||||
public void setMsg_type(String msg_type) { |
||||
this.msg_type = msg_type; |
||||
} |
||||
|
||||
public String getReceive_id() { |
||||
return receive_id; |
||||
} |
||||
|
||||
public void setReceive_id(String receive_id) { |
||||
this.receive_id = receive_id; |
||||
} |
||||
|
||||
public String getReceive_id_type() { |
||||
return receive_id_type; |
||||
} |
||||
|
||||
public void setReceive_id_type(String receive_id_type) { |
||||
this.receive_id_type = receive_id_type; |
||||
} |
||||
|
||||
public String getMessageid() { |
||||
return messageid; |
||||
} |
||||
|
||||
public void setMessageid(String messageid) { |
||||
this.messageid = messageid; |
||||
} |
||||
|
||||
public String getResult() { |
||||
return result; |
||||
} |
||||
|
||||
public void setResult(String result) { |
||||
this.result = result; |
||||
} |
||||
|
||||
public String getIssuccess() { |
||||
return issuccess; |
||||
} |
||||
|
||||
public void setIssuccess(String issuccess) { |
||||
this.issuccess = issuccess; |
||||
} |
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.eco.plugin.xxxx.fssso.db.controller; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.db.bean.DBEntity; |
||||
import com.eco.plugin.xxxx.fssso.db.dao.DBDao; |
||||
import com.eco.plugin.xxxx.fssso.utils.FRUtils; |
||||
import com.fr.db.fun.impl.AbstractDBAccessProvider; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* @author fr.open |
||||
* @version 10.0 |
||||
* Created by fr.open on 2021-11-30 |
||||
**/ |
||||
@EnableMetrics |
||||
@FunctionRecorder |
||||
public class DBController extends AbstractDBAccessProvider { |
||||
|
||||
private static DBAccessor accessor; |
||||
|
||||
public static DBAccessor getAccessor() { |
||||
return accessor; |
||||
} |
||||
|
||||
@Override |
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[]{ |
||||
DBDao.DAO |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void onDBAvailable(DBAccessor accessor) { |
||||
DBController.accessor = accessor; |
||||
} |
||||
/** |
||||
* 新增 |
||||
* @param bean |
||||
*/ |
||||
public static void add( final DBEntity bean ){ |
||||
try{ |
||||
accessor.runDMLAction(new DBAction<Boolean>() { |
||||
@Override |
||||
public Boolean run(DAOContext context) throws Exception { |
||||
bean.setId(UUID.randomUUID().toString()); |
||||
context.getDAO(DBDao.class).add(bean); |
||||
|
||||
return true; |
||||
} |
||||
}); |
||||
}catch(Throwable e){ |
||||
FRUtils.FRLogError("exception addOrUpdate:"+e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.eco.plugin.xxxx.fssso.db.dao; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.db.bean.DBEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
/** |
||||
* @author fr.open |
||||
* @version 10.0 |
||||
* Created by fr.open on 2021-11-30 |
||||
**/ |
||||
public class DBDao extends BaseDAO<DBEntity> { |
||||
|
||||
public DBDao(DAOSession session) { |
||||
super(session); |
||||
} |
||||
|
||||
@Override |
||||
protected Class<DBEntity> getEntityClass() { |
||||
return DBEntity.class; |
||||
} |
||||
|
||||
public final static DAOProvider DAO = new DAOProvider() { |
||||
@Override |
||||
public Class getEntityClass() { |
||||
return DBEntity.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return DBDao.class; |
||||
} |
||||
}; |
||||
|
||||
public void add(DBEntity entity) throws Exception { |
||||
getSession().persist(entity); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.db; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.TsEntity; |
||||
import com.fr.decision.plugin.db.AbstractDecisionDBAccessProvider; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
|
||||
public class DBAccessProvider extends AbstractDecisionDBAccessProvider { |
||||
private static DBAccessor dbAccessor = null; |
||||
|
||||
public static DBAccessor getDbAccessor(){ |
||||
return dbAccessor; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[]{ |
||||
new DAOProvider() { |
||||
@Override |
||||
public Class getEntityClass() { |
||||
return TsEntity.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return Dao.class; |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void onDBAvailable(DBAccessor dbAccessor) { |
||||
this.dbAccessor = dbAccessor; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.db; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.TsEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
/** |
||||
* Created by fr.open on 2021-12-06. |
||||
*/ |
||||
public class Dao extends BaseDAO<TsEntity> { |
||||
|
||||
public Dao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.dsdd; |
||||
|
||||
import com.fr.main.workbook.ResultWorkBook; |
||||
import com.fr.schedule.base.provider.impl.AbstractOutputFormulaProvider; |
||||
import com.fr.schedule.extension.report.util.ScheduleParameterUtils; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class DSDDMsgFormula extends AbstractOutputFormulaProvider<TsBean, ResultWorkBook> { |
||||
public DSDDMsgFormula() { |
||||
} |
||||
|
||||
public void dealWithFormulaParam(TsBean var1, ResultWorkBook var2, List<Map<String, Object>> var3) throws Exception { |
||||
var1.setTitle(ScheduleParameterUtils.dealWithParameter(var1.getTitle(), (Map)var3.get(0), var2)); |
||||
var1.setContent(ScheduleParameterUtils.dealWithParameter(var1.getContent(), (Map)var3.get(0), var2)); |
||||
|
||||
} |
||||
|
||||
public String getActionClassName() { |
||||
return TsBean.class.getName(); |
||||
} |
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.dsdd; |
||||
|
||||
import com.fr.schedule.base.bean.output.BaseOutputAction; |
||||
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||
import com.fr.schedule.base.type.RunType; |
||||
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes; |
||||
|
||||
@JsonSubTypes.Type(value = TsBean.class, name = "TsBean") |
||||
public class TsBean extends BaseOutputAction { |
||||
private static final long serialVersionUID = 8245931480823179622L; |
||||
private String content = null; |
||||
private String title = null; |
||||
|
||||
public TsBean(){ |
||||
super(); |
||||
} |
||||
|
||||
//是否受不同用户生成不同附件影响
|
||||
@Override |
||||
public boolean willExecuteByUser() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public RunType runType() { |
||||
return RunType.SEND_EMAIL; |
||||
} |
||||
|
||||
//这里直接关联第一步的entity类
|
||||
@Override |
||||
public Class<? extends AbstractScheduleEntity> outputActionEntityClass() { |
||||
return TsEntity.class; |
||||
} |
||||
|
||||
public TsBean id(String id){ |
||||
setId(id); |
||||
return this; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public TsBean content(String content){ |
||||
setContent(content); |
||||
return this; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public TsBean title(String title){ |
||||
setTitle(title); |
||||
return this; |
||||
} |
||||
|
||||
//转换成entity对象,用于数据库存储,注意属性不要漏了
|
||||
@Override |
||||
public TsEntity createOutputActionEntity() { |
||||
return new TsEntity() |
||||
.id(this.getId()) |
||||
.content(this.getContent()) |
||||
// .msgtype(this.getMsgtype())
|
||||
.title(this.getTitle()) |
||||
; |
||||
} |
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.dsdd; |
||||
|
||||
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||
import com.fr.stable.db.entity.TableAssociation; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table(name = "plugin_output_message") //表名
|
||||
@TableAssociation(associated = true) |
||||
public class TsEntity extends AbstractScheduleEntity{ |
||||
public TsEntity(){} |
||||
|
||||
@Column(name = "title") |
||||
private String title = null; |
||||
|
||||
@Column(name = "content") |
||||
private String content = null; |
||||
|
||||
public TsEntity id(String id) { |
||||
setId(id); |
||||
return this; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public TsEntity content(String content){ |
||||
setContent(content); |
||||
return this; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public TsEntity title(String title){ |
||||
setTitle(title); |
||||
return this; |
||||
} |
||||
|
||||
//转换成bean对象
|
||||
@Override |
||||
public TsBean createBean() { |
||||
return new TsBean() |
||||
.id(this.getId()) |
||||
.content(this.getContent()) |
||||
.title(this.getTitle()) |
||||
; |
||||
} |
||||
} |
@ -0,0 +1,267 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.dsdd; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.config.WinkSimpleConfig; |
||||
import com.eco.plugin.xxxx.fssso.db.bean.DBEntity; |
||||
import com.eco.plugin.xxxx.fssso.db.controller.DBController; |
||||
import com.eco.plugin.xxxx.fssso.utils.*; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.schedule.base.bean.ScheduleTask; |
||||
import com.fr.schedule.base.controller.ScheduleTaskController; |
||||
import com.fr.schedule.feature.ScheduleContext; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.net.URLEncoder; |
||||
import java.util.*; |
||||
|
||||
public class TsHandler extends OutputActionHandler<TsBean>{ |
||||
@Override |
||||
public void doAction(TsBean tsBean, Map<String, Object> map){ |
||||
sendMessage(tsBean,map); |
||||
} |
||||
|
||||
private void sendMessage(TsBean tsBean, Map<String, Object> map) { |
||||
List<DBEntity> dbEntityList = sendMessageToPo(WinkSimpleConfig.getInstance(),map,tsBean); |
||||
|
||||
for(DBEntity db : dbEntityList){ |
||||
DBController.add(db); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取定时调度 |
||||
* @param taskName |
||||
* @return |
||||
*/ |
||||
private static ScheduleTask getTask(String taskName){ |
||||
ScheduleTask scheduleTask = null; |
||||
try { |
||||
ScheduleTaskController scheduleTaskController = ScheduleContext.getInstance().getScheduleTaskController(); |
||||
scheduleTask = scheduleTaskController.getByTaskName(taskName,QueryFactory.create()); |
||||
} catch (Exception e) { |
||||
FRUtils.FRLogInfo("任务异常:"+e.getMessage()); |
||||
return null; |
||||
} |
||||
|
||||
return scheduleTask; |
||||
} |
||||
|
||||
/** |
||||
* 获取模板链接 |
||||
* @param map |
||||
* @return |
||||
*/ |
||||
private static String getTempUrl(TsBean tsBean,Map<String, Object> map){ |
||||
|
||||
String taskName = String.valueOf(map.get("taskName")); |
||||
|
||||
ScheduleTask scheduleTask = getTask(taskName); |
||||
|
||||
int showType = scheduleTask.getShowType(); |
||||
String templateName = scheduleTask.getTemplatePath(); |
||||
try { |
||||
templateName = URLEncoder.encode(templateName,"utf-8"); |
||||
} catch (UnsupportedEncodingException e) { |
||||
FRUtils.FRLogInfo("编码模板名称异常:"+e.getMessage()); |
||||
return ""; |
||||
} |
||||
|
||||
if(1 == showType){ |
||||
templateName+="&op=write"; |
||||
} |
||||
else if(2 == showType){ |
||||
templateName += "&op=view"; |
||||
} |
||||
else if(3 == showType){ |
||||
templateName += "&op=write_plus"; |
||||
} |
||||
|
||||
return tsBean.getResultURL()+"/view/report?viewlet="+templateName; |
||||
} |
||||
|
||||
/** |
||||
* 获取用户组信息 |
||||
* @param map |
||||
* @return |
||||
*/ |
||||
private static String[] getUserGroup(Map<String, Object> map){ |
||||
String taskName = String.valueOf(map.get("taskName")); |
||||
ScheduleTask scheduleTask = getTask(taskName); |
||||
|
||||
return scheduleTask.getUserGroup().createUserNameArray(); |
||||
} |
||||
|
||||
private static JSONObject getContent(String tempurl,TsBean ts){ |
||||
WinkSimpleConfig psc = WinkSimpleConfig.getInstance(); |
||||
|
||||
//帆软单点登录url
|
||||
String ssourl = WinkSimpleConfig.getInstance().getIndex()+"/url/fssso"; |
||||
// String ssourl = WinkSimpleConfig.getInstance().getIndex();
|
||||
//飞书单点url
|
||||
String url = psc.getAuthUrl()+"?app_id="+psc.getClientId()+"&redirect_uri="+ssourl+"&state="+URLEncoder.encode(tempurl); |
||||
//图片key
|
||||
String imgKey = ""; |
||||
|
||||
try{ |
||||
imgKey = getImgKey(); |
||||
}catch(Exception e){ |
||||
FRUtils.FRLogError("获取图片异常:"+e.getMessage()); |
||||
} |
||||
|
||||
|
||||
|
||||
JSONObject result = new JSONObject(); |
||||
|
||||
JSONObject zhcn = new JSONObject(); |
||||
|
||||
JSONArray content = new JSONArray(); |
||||
|
||||
if(Utils.isNotNullStr(imgKey)){ |
||||
JSONArray imgs = new JSONArray(); |
||||
JSONObject img = new JSONObject(); |
||||
img.put("tag","img"); |
||||
img.put("image_key",imgKey); |
||||
// img.put("width",300);
|
||||
// img.put("height",300);
|
||||
imgs.add(img); |
||||
content.add(imgs); |
||||
} |
||||
|
||||
|
||||
JSONArray titlea = new JSONArray(); |
||||
|
||||
JSONObject title = new JSONObject(); |
||||
title.put("tag","text"); |
||||
title.put("text",ts.getTitle()); |
||||
|
||||
titlea.add(title); |
||||
|
||||
JSONArray contenta = new JSONArray(); |
||||
|
||||
JSONObject content2 = new JSONObject(); |
||||
content2.put("tag","text"); |
||||
content2.put("text",ts.getContent()); |
||||
|
||||
contenta.add(content2); |
||||
|
||||
JSONArray linka = new JSONArray(); |
||||
|
||||
JSONObject link = new JSONObject(); |
||||
link.put("tag","a"); |
||||
link.put("href",url); |
||||
link.put("text","点击查看详情!"); |
||||
|
||||
linka.add(link); |
||||
|
||||
|
||||
content.add(titlea); |
||||
content.add(contenta); |
||||
content.add(linka); |
||||
zhcn.put("content",content); |
||||
result.put("zh_cn",zhcn); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
private static String getToken(){ |
||||
WinkSimpleConfig psc = WinkSimpleConfig.getInstance(); |
||||
String tokenUrl = psc.getMtokenUrl(); |
||||
|
||||
JSONObject json = new JSONObject(); |
||||
json.put("app_id",psc.getClientId()); |
||||
json.put("app_secret",psc.getSecret()); |
||||
|
||||
String result = HttpUtils.HttpPostJson(tokenUrl,json.toString(),null); |
||||
|
||||
if(Utils.isNullStr(result)){ |
||||
return ""; |
||||
} |
||||
|
||||
JSONObject resultj = new JSONObject(result); |
||||
|
||||
return resultj.getString("tenant_access_token"); |
||||
} |
||||
|
||||
private static String getImgKey() { |
||||
WinkSimpleConfig psc = WinkSimpleConfig.getInstance(); |
||||
String token = getToken(); |
||||
|
||||
Map<String,String> header = new HashMap<String,String>(); |
||||
header.put("Authorization","Bearer "+token); |
||||
|
||||
Map<String,Object> param = new HashMap<String,Object>(); |
||||
param.put("image_type","message"); |
||||
|
||||
String result = HttpUtils.HttpPostMultipartForm(param,psc.getImgUrl(),header); |
||||
JSONObject json = new JSONObject(result); |
||||
return json.getJSONObject("data").getString("image_key"); |
||||
} |
||||
|
||||
private static List<DBEntity> sendMessageToPo(WinkSimpleConfig psc, Map<String, Object> map, TsBean tsBean){ |
||||
List<DBEntity> dbEntityList = new ArrayList<DBEntity>(); |
||||
String tempurl = getTempUrl(tsBean, map); |
||||
|
||||
Map<String,String> header = new HashMap<String,String>(); |
||||
String auth = EncryptUtils.base64Encode(psc.getUsername()+":"+psc.getPsd()); |
||||
header.put("Authorization","Basic "+auth); |
||||
|
||||
JSONObject param = new JSONObject(); |
||||
JSONObject baseinfo = new JSONObject(); |
||||
baseinfo.put("uuid", UUID.randomUUID().toString()); |
||||
baseinfo.put("syscode",psc.getSyscode()); |
||||
baseinfo.put("sysdes",psc.getSysdes()); |
||||
baseinfo.put("sendertime", DateUtilSelf.DateToString(new Date(),"yyyy-MM-dd HH:mm:ss")); |
||||
baseinfo.put("appid",psc.getClientId()); |
||||
baseinfo.put("servicename","SI_IF1404_CMN_MSG_WDW_OUT_SYN"); |
||||
|
||||
param.put("baseinfo",baseinfo); |
||||
|
||||
String[] userid = getUserGroup(map); |
||||
JSONObject message = new JSONObject(); |
||||
message.put("content",getContent(tempurl,tsBean).toString()); |
||||
message.put("msg_type","post"); |
||||
message.put("receive_id_type","user_id"); |
||||
|
||||
for(int i = 0;i< userid.length;i++){ |
||||
message.put("receive_id",userid[i]); |
||||
param.put("message",message); |
||||
String code = "-1"; |
||||
String messageid = ""; |
||||
String result = HttpUtils.HttpPostJson(psc.getSendMessage(),param.toString(),header); |
||||
|
||||
if(!Utils.isNullStr(result)){ |
||||
JSONObject json = new JSONObject(result); |
||||
try{ |
||||
messageid = json.getJSONObject("data").getString("message_id"); |
||||
} |
||||
catch(Exception e){ |
||||
FRUtils.FRLogError("发送失败:"+e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
if(Utils.isNotNullStr(messageid)){ |
||||
code = "0"; |
||||
} |
||||
|
||||
DBEntity db = new DBEntity(); |
||||
db.setUuid(baseinfo.getString("uuid")); |
||||
db.setSyscode(psc.getSyscode()); |
||||
db.setSysdes(psc.getSysdes()); |
||||
db.setSendertime(baseinfo.getString("sendertime")); |
||||
db.setAppid(psc.getClientId()); |
||||
db.setServicename("IF1404"); |
||||
db.setContent(message.getString("content")); |
||||
db.setMsg_type(message.getString("msg_type")); |
||||
db.setReceive_id(message.getString("receive_id")); |
||||
db.setReceive_id_type(message.getString("user_id")); |
||||
db.setIssuccess(code); |
||||
db.setMessageid(messageid); |
||||
db.setResult(result); |
||||
|
||||
dbEntityList.add(db); |
||||
} |
||||
|
||||
return dbEntityList; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.eco.plugin.xxxx.fssso.dsdd.webresource; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class DsddWebResourceProvider extends AbstractWebResourceProvider { |
||||
@Override |
||||
public Atom attach() { |
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
return new Component() { |
||||
@Override |
||||
public ScriptPath script(RequestClient requestClient) { |
||||
return ScriptPath.build("/com/eco/plugin/xxxx/fssso/js/dsdd.js"); |
||||
} |
||||
|
||||
@Override |
||||
public StylePath style(RequestClient requestClient) { |
||||
return StylePath.EMPTY; |
||||
// return StylePath.build("/com/fr/plugin/jdfSSO/css/icon.css");
|
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,84 @@
|
||||
package com.eco.plugin.xxxx.fssso.handler; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.config.WinkSimpleConfig; |
||||
import com.eco.plugin.xxxx.fssso.db.bean.DBEntity; |
||||
import com.eco.plugin.xxxx.fssso.dsdd.dsdd.TsBean; |
||||
import com.eco.plugin.xxxx.fssso.utils.*; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
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.*; |
||||
|
||||
@FunctionRecorder |
||||
@Authorize(callSignKey = "com.eco.plugin.xxxx.fssso") |
||||
public class CancelMessage extends BaseHttpHandler { |
||||
|
||||
|
||||
public CancelMessage() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/cancelMessage"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse res){ |
||||
if(PluginContexts.currentContext().isAvailable()) { |
||||
String messageid = req.getParameter("msgId"); |
||||
|
||||
String[] msgs = messageid.split(","); |
||||
|
||||
for(int i=0;i<msgs.length;i++){ |
||||
String result = cancelMessage(WinkSimpleConfig.getInstance(),msgs[0]); |
||||
} |
||||
|
||||
|
||||
// String flag = result.contains("ok")?"ok":"fail";
|
||||
|
||||
ResponseUtils.failedResponse(res,"ok"); |
||||
} |
||||
} |
||||
|
||||
private static String cancelMessage(WinkSimpleConfig psc,String messageid) { |
||||
Map<String, String> header = new HashMap<String, String>(); |
||||
String auth = EncryptUtils.base64Encode(psc.getUsername() + ":" + psc.getPsd()); |
||||
header.put("Authorization", "Basic " + auth); |
||||
|
||||
JSONObject param = new JSONObject(); |
||||
JSONObject baseinfo = new JSONObject(); |
||||
baseinfo.put("uuid", UUID.randomUUID().toString()); |
||||
baseinfo.put("syscode", psc.getSyscode()); |
||||
baseinfo.put("sysdes", psc.getSysdes()); |
||||
baseinfo.put("sendertime", DateUtilSelf.DateToString(new Date(), "yyyy-MM-dd HH:mm:ss")); |
||||
baseinfo.put("appid", psc.getClientId()); |
||||
baseinfo.put("servicename", "SI_IF1405_CMN_MSG_WDW_OUT_SYN"); |
||||
|
||||
param.put("baseinfo", baseinfo); |
||||
|
||||
JSONObject message = new JSONObject(); |
||||
message.put("message_id", messageid); |
||||
param.put("message", message); |
||||
|
||||
String result = HttpUtils.HttpPostJson(psc.getCancelMessage(), param.toString(), header); |
||||
|
||||
return result; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,13 @@
|
||||
package com.eco.plugin.xxxx.fssso.handler; |
||||
|
||||
import com.fr.decision.fun.HttpHandler; |
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
|
||||
public class ExtendAttrHandlerProvider extends AbstractHttpHandlerProvider { |
||||
@Override |
||||
public HttpHandler[] registerHandlers() { |
||||
return new HttpHandler[]{ |
||||
new Login(),new CancelMessage() |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
package com.eco.plugin.xxxx.fssso.handler; |
||||
|
||||
import com.eco.plugin.xxxx.fssso.config.WinkSimpleConfig; |
||||
import com.eco.plugin.xxxx.fssso.utils.FRUtils; |
||||
import com.eco.plugin.xxxx.fssso.utils.HttpUtils; |
||||
import com.eco.plugin.xxxx.fssso.utils.ResponseUtils; |
||||
import com.eco.plugin.xxxx.fssso.utils.Utils; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
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.net.URLDecoder; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@FunctionRecorder |
||||
@Authorize(callSignKey = "com.eco.plugin.xxxx.fssso") |
||||
public class Login extends BaseHttpHandler { |
||||
|
||||
|
||||
public Login() { |
||||
} |
||||
|
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/fssso"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse res){ |
||||
if(PluginContexts.currentContext().isAvailable()) { |
||||
WinkSimpleConfig psc = WinkSimpleConfig.getInstance(); |
||||
//获取请求参数
|
||||
String code = req.getParameter("code"); |
||||
String redirecturl = req.getParameter("state"); |
||||
|
||||
if (Utils.isNullStr(code)) { |
||||
ResponseUtils.failedResponse(res, "获取授权码失败"); |
||||
return; |
||||
} |
||||
|
||||
String token = getToken(code, req, psc); |
||||
|
||||
String username = getUsername(token, req, psc); |
||||
|
||||
FRUtils.login(req, res, username, redirecturl); |
||||
} |
||||
} |
||||
|
||||
private String getUsername(String token, HttpServletRequest req, WinkSimpleConfig psc) { |
||||
String userurl = psc.getUserUrl(); |
||||
|
||||
Map<String,String> header = new HashMap<String,String>(); |
||||
header.put("Authorization","Bearer "+token); |
||||
|
||||
String result = HttpUtils.get(userurl,null,header); |
||||
|
||||
if(Utils.isNullStr(result)){ |
||||
return ""; |
||||
} |
||||
|
||||
JSONObject json = new JSONObject(result); |
||||
|
||||
return json.getJSONObject("data").getString("user_id"); |
||||
} |
||||
|
||||
private String getToken(String code, HttpServletRequest req, WinkSimpleConfig psc) { |
||||
String tokenurl = psc.getTokenUrl(); |
||||
|
||||
Map<String,String> header = new HashMap<String,String>(); |
||||
header.put("Content-Type","application/json; charset=utf-8"); |
||||
header.put("Authorization","Bearer "+getToken()); |
||||
|
||||
JSONObject param = new JSONObject(); |
||||
param.put("grant_type","authorization_code"); |
||||
param.put("code",code); |
||||
|
||||
String result = HttpUtils.HttpPostJson(tokenurl,param.toString(),header); |
||||
|
||||
if(Utils.isNullStr(result)){ |
||||
return ""; |
||||
} |
||||
|
||||
JSONObject json = new JSONObject(result); |
||||
|
||||
return json.getJSONObject("data").getString("access_token"); |
||||
} |
||||
|
||||
private static String getToken(){ |
||||
WinkSimpleConfig psc = WinkSimpleConfig.getInstance(); |
||||
String tokenUrl = psc.getMtokenUrl(); |
||||
|
||||
JSONObject json = new JSONObject(); |
||||
json.put("app_id",psc.getClientId()); |
||||
json.put("app_secret",psc.getSecret()); |
||||
|
||||
String result = HttpUtils.HttpPostJson(tokenUrl,json.toString(),null); |
||||
|
||||
if(Utils.isNullStr(result)){ |
||||
return ""; |
||||
} |
||||
|
||||
JSONObject resultj = new JSONObject(result); |
||||
|
||||
return resultj.getString("tenant_access_token"); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,15 @@
|
||||
package com.eco.plugin.xxxx.fssso.handler; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractURLAliasProvider; |
||||
import com.fr.decision.webservice.url.alias.URLAlias; |
||||
import com.fr.decision.webservice.url.alias.URLAliasFactory; |
||||
|
||||
public class URLAliasProvide extends AbstractURLAliasProvider { |
||||
@Override |
||||
public URLAlias[] registerAlias() { |
||||
return new URLAlias[]{ |
||||
URLAliasFactory.createPluginAlias("/fssso","/fssso",true), |
||||
URLAliasFactory.createPluginAlias("/cancelMessage","/cancelMessage",true), |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.plugin.slSSO.locale; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
public class locale extends AbstractLocaleFinder{ |
||||
@Override |
||||
public String find() { |
||||
return "com/eco/plugin/xxxx/fssso/locale/locale"; |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.eco.plugin.xxxx.fssso.localejava; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
public class locale extends AbstractLocaleFinder{ |
||||
@Override |
||||
public String find() { |
||||
return "com/eco/plugin/xxxx/fssso/locale/locale"; |
||||
} |
||||
} |
@ -0,0 +1,227 @@
|
||||
package com.eco.plugin.xxxx.fssso.utils; |
||||
|
||||
import java.sql.Timestamp; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
public class DateUtilSelf { |
||||
|
||||
/** |
||||
* 日期转换为日期字符串 |
||||
* @param date |
||||
* @param formatStr |
||||
* @return String |
||||
*/ |
||||
public static String DateToString(Date date,String formatStr) { |
||||
SimpleDateFormat sdf = new SimpleDateFormat(formatStr); |
||||
String dateStr = sdf.format(date).toString(); |
||||
|
||||
return dateStr; |
||||
} |
||||
|
||||
/** |
||||
* 日期字符串转换日期 |
||||
* @param dateStr |
||||
* @param formatStr |
||||
* @return Date |
||||
*/ |
||||
public static Date strToDate(String dateStr,String formatStr){ |
||||
SimpleDateFormat sdf = new SimpleDateFormat(formatStr); |
||||
Date date = null; |
||||
|
||||
try { |
||||
date = sdf.parse(dateStr); |
||||
} |
||||
catch(Exception e) { |
||||
} |
||||
|
||||
return date; |
||||
} |
||||
|
||||
/** |
||||
* Date转Timestamp |
||||
* @param date |
||||
* @return |
||||
*/ |
||||
public static Timestamp dateToTimestamp(Date date) { |
||||
Date transDate = DateUtilSelf.strToDate(DateUtilSelf.DateToString(date, "yyyy-MM-dd hh:mm:ss"),"yyyy-MM-dd hh:mm:ss"); |
||||
|
||||
Timestamp timestamp = new Timestamp(transDate.getTime()); |
||||
return timestamp; |
||||
} |
||||
|
||||
/** |
||||
* Date字符串转Timestamp |
||||
* @param dateStr |
||||
* @param format |
||||
* @return |
||||
*/ |
||||
public static Timestamp strToTimestamp(String dateStr,String format) { |
||||
Date date = strToDate(dateStr,format); |
||||
Timestamp timestamp = new Timestamp(date.getTime()); |
||||
return timestamp; |
||||
} |
||||
|
||||
/** |
||||
* 获取两个日期字符串之间的天数 |
||||
* @param startDateStr |
||||
* @param endDateStr |
||||
* @param formatStr |
||||
* @return |
||||
*/ |
||||
public static int getDays(String startDateStr,String endDateStr,String formatStr) { |
||||
|
||||
Date startDate = strToDate(startDateStr,formatStr); |
||||
Date endDate = strToDate(endDateStr,formatStr); |
||||
|
||||
long startTime = startDate.getTime(); |
||||
long endTime = endDate.getTime(); |
||||
|
||||
int days = (int) ((endTime - startTime)/(60*60*24*1000)); |
||||
|
||||
return days; |
||||
} |
||||
|
||||
/** |
||||
* 获取给定时间之前之后的时间 |
||||
* @param type |
||||
* @param dateStr |
||||
* @param count |
||||
* @param formatStr |
||||
* @return |
||||
*/ |
||||
public static String getAfterDateStr(int type,String dateStr,int count,String formatStr) { |
||||
Date startDate = strToDate(dateStr,formatStr); |
||||
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(startDate); |
||||
|
||||
calendar.add(type, count); |
||||
|
||||
String endDateStr = DateToString(calendar.getTime(),formatStr); |
||||
|
||||
return endDateStr; |
||||
} |
||||
|
||||
/** |
||||
* 获取给定时间之前之后的时间 |
||||
* @param type |
||||
* @param date |
||||
* @param count |
||||
* @param formatStr |
||||
* @return |
||||
*/ |
||||
public static String getAfterDateStr(int type,Date date,int count,String formatStr) { |
||||
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
|
||||
calendar.add(type, count); |
||||
|
||||
String endDateStr = DateToString(calendar.getTime(),formatStr); |
||||
|
||||
return endDateStr; |
||||
} |
||||
|
||||
/** |
||||
* 获取给定时间之前之后的时间 |
||||
* @param type |
||||
* @param date |
||||
* @param count |
||||
* @return |
||||
*/ |
||||
public static Date getAfterDateStr(int type,Date date,int count) { |
||||
Calendar dateResult = Calendar.getInstance(); |
||||
dateResult.setTime(date); |
||||
dateResult.add(type, count); |
||||
return dateResult.getTime(); |
||||
} |
||||
|
||||
/** |
||||
* 时间戳转日期 |
||||
* @param timestamp |
||||
* @return |
||||
*/ |
||||
public static Date timestampToDate(Timestamp timestamp) { |
||||
Date date = new Date(timestamp.getTime()); |
||||
|
||||
return date; |
||||
} |
||||
|
||||
/** |
||||
* 时间戳转时间字符串 |
||||
* @param timestamp |
||||
* @param format 日期格式 |
||||
* @return |
||||
*/ |
||||
public static String timestampToStr(Timestamp timestamp,String format) { |
||||
Date date = timestampToDate(timestamp); |
||||
|
||||
String timeStr = DateToString(date, format); |
||||
|
||||
return timeStr; |
||||
} |
||||
|
||||
/** |
||||
* 获取所给日期length天内每s一天的日期 |
||||
* @param date 所给日期(yyyy-MM-dd) |
||||
* @param length 长度 |
||||
* @return |
||||
*/ |
||||
public static List<String> getDateList(String date,int length){ |
||||
List<String> dateList = new ArrayList<String>(); |
||||
String format = "yyyy-MM-dd"; |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
||||
//获取length天后的日期
|
||||
|
||||
String targetDate = getAfterDateStr(Calendar.DATE,date,length,format); |
||||
|
||||
Date start = null; |
||||
Date end = null; |
||||
|
||||
if(length >= 0) { |
||||
start = strToDate(date,format); |
||||
end = strToDate(targetDate,format); |
||||
}else { |
||||
start = strToDate(targetDate,format); |
||||
end = strToDate(date,format); |
||||
} |
||||
|
||||
Calendar calBegin = Calendar.getInstance(); |
||||
calBegin.setTime(start); |
||||
Calendar calEnd = Calendar.getInstance(); |
||||
calEnd.setTime(end); |
||||
|
||||
while (end.after(calBegin.getTime())) { |
||||
calBegin.add(Calendar.DATE, 1); |
||||
String dayStr = sdf.format(calBegin.getTime()); |
||||
dateList.add(dayStr); |
||||
} |
||||
|
||||
return dateList; |
||||
} |
||||
|
||||
/** |
||||
* 比较startDate是否在endDate之前 |
||||
* @param startDate |
||||
* @param endDate |
||||
* @param format |
||||
* @return 0 两个日期相等 <0 开始日期在结束日期之前 >0 开始日期在结束日期之后 |
||||
*/ |
||||
public static int comparisonDate(String startDate,String endDate,String format) { |
||||
Date start = strToDate(startDate,format); |
||||
Date end = strToDate(endDate,format); |
||||
|
||||
return start.compareTo(end); |
||||
} |
||||
|
||||
//获取当前日期年、月、日、时、分、秒
|
||||
public static int getCount(int type){ |
||||
Calendar calendar = Calendar.getInstance(); |
||||
|
||||
return calendar.get(type); |
||||
} |
||||
} |
@ -0,0 +1,262 @@
|
||||
package com.eco.plugin.xxxx.fssso.utils; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import sun.misc.BASE64Decoder; |
||||
import sun.misc.BASE64Encoder; |
||||
|
||||
import javax.crypto.Cipher; |
||||
import javax.crypto.KeyGenerator; |
||||
import javax.crypto.SecretKey; |
||||
import javax.crypto.SecretKeyFactory; |
||||
import javax.crypto.spec.DESKeySpec; |
||||
import java.io.IOException; |
||||
import java.security.MessageDigest; |
||||
import java.security.SecureRandom; |
||||
|
||||
public class EncryptUtils { |
||||
|
||||
/** |
||||
* sha 加密 |
||||
* @param str |
||||
* @return |
||||
*/ |
||||
public static String sha(String str){ |
||||
String sha256Str = ""; |
||||
|
||||
try { |
||||
MessageDigest sha256Deget = MessageDigest.getInstance("SHA-256"); |
||||
byte[] sha256Encode = sha256Deget.digest(str.getBytes()); |
||||
sha256Str = ByteToHexStr(sha256Encode); |
||||
}catch (Exception e){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:SHA256加密异常:"+e.getMessage()); |
||||
} |
||||
|
||||
return sha256Str; |
||||
} |
||||
|
||||
/** |
||||
* byte数组转16进制字符串 |
||||
* @param bytes |
||||
* @return |
||||
*/ |
||||
private static String ByteToHexStr(byte[] bytes) |
||||
{ |
||||
String hexStr = ""; |
||||
|
||||
for(int i =0;i<bytes.length;i++) |
||||
{ |
||||
int temp = bytes[i] & 0xff; |
||||
String tempHex = Integer.toHexString(temp); |
||||
if(tempHex.length() < 2) |
||||
{ |
||||
hexStr += "0"+tempHex; |
||||
} |
||||
else { |
||||
hexStr += tempHex; |
||||
} |
||||
} |
||||
|
||||
return hexStr; |
||||
} |
||||
|
||||
/** |
||||
* aes 加密 |
||||
* @param str |
||||
* @param privateKey |
||||
* @return |
||||
*/ |
||||
public static String aesEncrypt(String str,String privateKey){ |
||||
try { |
||||
// 生成密钥对象
|
||||
SecretKey secKey = generateAesKey(privateKey.getBytes()); |
||||
|
||||
// 获取 AES 密码器
|
||||
Cipher cipher = Cipher.getInstance("AES"); |
||||
// 初始化密码器(加密模型)
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secKey); |
||||
|
||||
// 加密数据, 返回密文
|
||||
byte[] cipherBytes = cipher.doFinal(str.getBytes()); |
||||
return new BASE64Encoder().encodeBuffer(cipherBytes); |
||||
} catch (Throwable e) { |
||||
FRUtils.FRLogInfo("aes 加密异常 " + e.getMessage()); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 生成密钥对象 |
||||
*/ |
||||
private static SecretKey generateAesKey(byte[] key) throws Exception { |
||||
// 创建安全随机数生成器
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); |
||||
// 设置 密钥key的字节数组 作为安全随机数生成器的种子
|
||||
random.setSeed(key); |
||||
|
||||
// 创建 AES算法生成器
|
||||
KeyGenerator gen = KeyGenerator.getInstance("AES"); |
||||
// 初始化算法生成器
|
||||
gen.init(128, random); |
||||
|
||||
// 生成 AES密钥对象, 也可以直接创建密钥对象: return new SecretKeySpec(key, ALGORITHM);
|
||||
return gen.generateKey(); |
||||
} |
||||
|
||||
/** |
||||
* aes 解密 |
||||
* @param str |
||||
* @param privateKey |
||||
* @return |
||||
*/ |
||||
public static String aesDecrypt(String str,String privateKey){ |
||||
try { |
||||
// 生成密钥对象
|
||||
SecretKey secKey = generateAesKey(privateKey.getBytes()); |
||||
|
||||
// 获取 AES 密码器
|
||||
Cipher cipher = Cipher.getInstance("AES"); |
||||
// 初始化密码器(加密模型)
|
||||
cipher.init(Cipher.DECRYPT_MODE, secKey); |
||||
|
||||
// 加密数据, 返回密文
|
||||
byte[] cipherBytes = cipher.doFinal(new BASE64Decoder().decodeBuffer(str)); |
||||
return new String(cipherBytes); |
||||
} catch (Throwable e) { |
||||
FRUtils.FRLogInfo("aes 解密异常 " + e.getMessage()); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* base64加密 |
||||
* @param key |
||||
* @return |
||||
*/ |
||||
public static String base64Encode(String key){ |
||||
return (new BASE64Encoder()).encodeBuffer(key.getBytes()).trim(); |
||||
} |
||||
|
||||
/** |
||||
* base64加密 |
||||
* @param key |
||||
* @return |
||||
*/ |
||||
public static String base64Encode(byte[] key){ |
||||
return (new BASE64Encoder()).encodeBuffer(key); |
||||
} |
||||
|
||||
/** |
||||
* base64解密 |
||||
* @param key |
||||
* @return |
||||
*/ |
||||
public static String base64Decode(String key){ |
||||
String result = ""; |
||||
try { |
||||
result = new String((new BASE64Decoder()).decodeBuffer(key)); |
||||
} catch (IOException e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:BASE64解密异常:"+e.getMessage()); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* base64解密 |
||||
* @param key |
||||
* @return |
||||
*/ |
||||
public static byte[] base64DecodeB(String key){ |
||||
byte[] result = null; |
||||
try { |
||||
result = (new BASE64Decoder()).decodeBuffer(key); |
||||
} catch (IOException e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:BASE64解密异常:"+e.getMessage()); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 是否被base64加密过 |
||||
* @param str |
||||
* @return |
||||
*/ |
||||
public static boolean isBase64(String str) { |
||||
if (str == null || str.trim().length() == 0) { |
||||
return false; |
||||
} |
||||
else { |
||||
if (str.length() % 4 != 0) { |
||||
return false; |
||||
} |
||||
|
||||
char[] strChars = str.toCharArray(); |
||||
|
||||
for (char c:strChars) { |
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') |
||||
|| c == '+' || c == '/' || c == '=') { |
||||
continue; |
||||
} |
||||
else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* des加密 |
||||
* @param datasource |
||||
* @param password |
||||
* @return |
||||
*/ |
||||
public static String desEncrypt(String datasource, String password) { |
||||
try { |
||||
SecureRandom random = new SecureRandom(); |
||||
DESKeySpec desKey = new DESKeySpec(password.getBytes()); |
||||
// 创建一个密匙工厂,然后用它把DESKeySpec转换成
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); |
||||
SecretKey securekey = keyFactory.generateSecret(desKey); |
||||
// Cipher对象实际完成加密操作
|
||||
Cipher cipher = Cipher.getInstance("DES"); |
||||
// 用密匙初始化Cipher对象
|
||||
cipher.init(Cipher.ENCRYPT_MODE, securekey, random); |
||||
// 现在,获取数据并加密
|
||||
// 正式执行加密操作
|
||||
return base64Encode(cipher.doFinal(datasource.getBytes())); |
||||
} catch (Throwable e) { |
||||
FRUtils.FRLogInfo("des 加密异常 " + e.getMessage()); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* des 解密 |
||||
* @param src |
||||
* @param password |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String desDecrypt(String src, String password) throws Exception { |
||||
// DES算法要求有一个可信任的随机数源
|
||||
SecureRandom random = new SecureRandom(); |
||||
// 创建一个DESKeySpec对象
|
||||
DESKeySpec desKey = new DESKeySpec(password.getBytes("UTF-8")); |
||||
// 创建一个密匙工厂
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); |
||||
// 将DESKeySpec对象转换成SecretKey对象
|
||||
SecretKey securekey = keyFactory.generateSecret(desKey); |
||||
// Cipher对象实际完成解密操作
|
||||
Cipher cipher = Cipher.getInstance("DES"); |
||||
// 用密匙初始化Cipher对象
|
||||
cipher.init(Cipher.DECRYPT_MODE, securekey, random); |
||||
// 真正开始解密操作
|
||||
return new String(cipher.doFinal(base64DecodeB(src))); |
||||
} |
||||
} |
@ -0,0 +1,246 @@
|
||||
package com.eco.plugin.xxxx.fssso.utils; |
||||
|
||||
import com.fr.base.ServerConfig; |
||||
import com.fr.base.TableData; |
||||
import com.fr.decision.authority.AuthorityContext; |
||||
import com.fr.decision.authority.data.User; |
||||
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.decision.webservice.v10.user.UserService; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.file.TableDataConfig; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.Cookie; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.servlet.http.HttpSession; |
||||
import java.io.IOException; |
||||
import java.util.List; |
||||
|
||||
public class FRUtils { |
||||
/** |
||||
* 判断用户是否存在 |
||||
* @param userName |
||||
* @return |
||||
*/ |
||||
public static boolean isUserExist(String userName){ |
||||
if (StringUtils.isEmpty(userName)) { |
||||
return false; |
||||
} else { |
||||
try { |
||||
List var1 = AuthorityContext.getInstance().getUserController().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", userName))); |
||||
return var1 != null && !var1.isEmpty(); |
||||
} catch (Exception var2) { |
||||
FineLoggerFactory.getLogger().error(var2.getMessage()); |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 判断是否登录FR |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
public static boolean isLogin(HttpServletRequest req){ |
||||
return LoginService.getInstance().isLogged(req); |
||||
} |
||||
|
||||
/** |
||||
* 帆软登录 |
||||
* @param httpServletRequest |
||||
* @param httpServletResponse |
||||
* @param userName |
||||
* @param url |
||||
*/ |
||||
public static void login(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String userName,String url){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:用户名:"+userName + ";FRLOG:跳转链接:"+url); |
||||
|
||||
//判断用户名是否为空
|
||||
if(!Utils.isNullStr(userName)){ |
||||
if(isUserExist(userName)){ |
||||
String FRToken = ""; |
||||
|
||||
try { |
||||
HttpSession session = httpServletRequest.getSession(true); |
||||
|
||||
FRToken = LoginService.getInstance().login(httpServletRequest, httpServletResponse, userName); |
||||
|
||||
httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,FRToken); |
||||
|
||||
session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, FRToken); |
||||
EventDispatcher.fire(LogInOutEvent.LOGIN,new LogInOutResultInfo(httpServletRequest,httpServletResponse,userName,true)); |
||||
FineLoggerFactory.getLogger().info("FRLOG:登陆成功!"); |
||||
|
||||
if(!Utils.isNullStr(url)){ |
||||
httpServletResponse.sendRedirect(url); |
||||
} |
||||
} catch (Exception e) { |
||||
ResponseUtils.failedResponse(httpServletResponse,"登录异常,请联系管理员!"); |
||||
FineLoggerFactory.getLogger().info("FRLOG 登录异常,请联系管理员! Exception:"+e.getMessage()); |
||||
} |
||||
}else{ |
||||
ResponseUtils.failedResponse(httpServletResponse,"用户在报表系统中不存在!"); |
||||
} |
||||
}else{ |
||||
ResponseUtils.failedResponse(httpServletResponse,"用户名不能为空!"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 帆软登录 |
||||
* @param httpServletRequest |
||||
* @param httpServletResponse |
||||
* @param token |
||||
* @param url |
||||
*/ |
||||
public static void loginByToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String token,String url){ |
||||
|
||||
FineLoggerFactory.getLogger().info("FRLOG:token:"+token+";FRLOG:跳转链接:"+url); |
||||
|
||||
//判断用户名是否为空
|
||||
if(!Utils.isNullStr(token)){ |
||||
writeToken2Cookie(httpServletResponse,token,-1); |
||||
|
||||
HttpSession session = httpServletRequest.getSession(true); |
||||
|
||||
httpServletRequest.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME,token); |
||||
|
||||
session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token); |
||||
|
||||
if(!Utils.isNullStr(url)){ |
||||
try { |
||||
httpServletResponse.sendRedirect(url); |
||||
} catch (IOException e) { |
||||
ResponseUtils.failedResponse(httpServletResponse,"跳转异常!"); |
||||
} |
||||
} |
||||
}else{ |
||||
ResponseUtils.failedResponse(httpServletResponse,"token不能为空!"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取token |
||||
* @param httpServletRequest |
||||
* @param httpServletResponse |
||||
* @param username |
||||
* @return |
||||
*/ |
||||
public static String getToken(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,String username){ |
||||
String token = ""; |
||||
try { |
||||
token = LoginService.getInstance().login(httpServletRequest, httpServletResponse, username); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:获取token失败"+e.getMessage()); |
||||
} |
||||
|
||||
return token; |
||||
} |
||||
|
||||
private static 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); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param httpServletRequest |
||||
* @param httpServletResponse |
||||
*/ |
||||
public static void logout(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse) |
||||
{ |
||||
if(!isLogin(httpServletRequest)){ |
||||
return ; |
||||
} |
||||
|
||||
try { |
||||
LoginService.getInstance().logout(httpServletRequest,httpServletResponse); |
||||
} catch (Exception e) { |
||||
ResponseUtils.failedResponse(httpServletResponse,"登出异常,请联系管理员!"); |
||||
FineLoggerFactory.getLogger().info("FRLOG 登出异常,请联系管理员! Exception:"+e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 打印FR日志 |
||||
* @param message |
||||
*/ |
||||
public static void FRLogInfo(String message){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:"+message); |
||||
} |
||||
|
||||
/** |
||||
* 打印FR日志-error |
||||
* @param message |
||||
*/ |
||||
public static void FRLogError(String message){ |
||||
FineLoggerFactory.getLogger().error("FRLOG:"+message); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据用户名获取用户信息 |
||||
* @param userName |
||||
* @return |
||||
*/ |
||||
public static User getFRUserByUserName(String userName){ |
||||
try { |
||||
return UserService.getInstance().getUserByUserName(userName); |
||||
} catch (Exception e) { |
||||
FRLogInfo("获取用户信息异常:"+e.getMessage()); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 解密FR密码 |
||||
* @param password |
||||
* @return |
||||
*/ |
||||
// public static String decryptFRPsd(String password){
|
||||
// FRLogInfo("解密密码:"+password);
|
||||
// return TransmissionTool.decrypt(password);
|
||||
// }
|
||||
|
||||
/** |
||||
* 获取带参数的访问链接 |
||||
* @return |
||||
*/ |
||||
public static String getAllUrl(HttpServletRequest httpServletRequest){ |
||||
return WebUtils.getOriginalURL(httpServletRequest); |
||||
} |
||||
|
||||
public static TableData getTableData(String serverDataSetName){ |
||||
TableData userInfo = TableDataConfig.getInstance().getTableData("serverDataSetName"); |
||||
|
||||
// DataModel userInfoDM = userInfo.createDataModel(Calculator.createCalculator());
|
||||
return userInfo; |
||||
} |
||||
} |
@ -0,0 +1,290 @@
|
||||
package com.eco.plugin.xxxx.fssso.utils; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.third.org.apache.commons.io.FileUtils; |
||||
import com.fr.third.org.apache.http.HttpEntity; |
||||
import com.fr.third.org.apache.http.HttpResponse; |
||||
import com.fr.third.org.apache.http.HttpStatus; |
||||
import com.fr.third.org.apache.http.NameValuePair; |
||||
import com.fr.third.org.apache.http.client.CookieStore; |
||||
import com.fr.third.org.apache.http.client.HttpClient; |
||||
import com.fr.third.org.apache.http.client.entity.UrlEncodedFormEntity; |
||||
import com.fr.third.org.apache.http.client.methods.HttpGet; |
||||
import com.fr.third.org.apache.http.client.methods.HttpPost; |
||||
import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier; |
||||
import com.fr.third.org.apache.http.entity.StringEntity; |
||||
import com.fr.third.org.apache.http.entity.mime.HttpMultipartMode; |
||||
import com.fr.third.org.apache.http.entity.mime.MultipartEntityBuilder; |
||||
import com.fr.third.org.apache.http.impl.client.BasicCookieStore; |
||||
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; |
||||
import com.fr.third.org.apache.http.impl.client.HttpClients; |
||||
import com.fr.third.org.apache.http.impl.cookie.BasicClientCookie; |
||||
import com.fr.third.org.apache.http.message.BasicNameValuePair; |
||||
import com.fr.third.org.apache.http.ssl.SSLContexts; |
||||
import com.fr.third.org.apache.http.ssl.TrustStrategy; |
||||
import com.fr.third.org.apache.http.util.EntityUtils; |
||||
|
||||
import javax.net.ssl.SSLContext; |
||||
import javax.servlet.http.Cookie; |
||||
import java.io.*; |
||||
import java.security.KeyManagementException; |
||||
import java.security.KeyStoreException; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.security.cert.CertificateException; |
||||
import java.security.cert.X509Certificate; |
||||
import java.util.*; |
||||
|
||||
public class HttpUtils { |
||||
/** |
||||
* httpGet请求 |
||||
* @param url |
||||
* @return |
||||
*/ |
||||
public static String get(String url,Cookie[] cookies,Map<String,String> header){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--url:"+url); |
||||
|
||||
//创建httpClient
|
||||
CloseableHttpClient httpclient = createHttpClient(cookies); |
||||
|
||||
HttpGet getMethod = new HttpGet(url); |
||||
|
||||
if(header != null && header.size() > 0){ |
||||
Set<String> keySet = header.keySet(); |
||||
|
||||
for(String key : keySet){ |
||||
getMethod.setHeader(key,header.get(key)); |
||||
} |
||||
} |
||||
|
||||
try { |
||||
HttpResponse response = httpclient.execute(getMethod); |
||||
int status =response.getStatusLine().getStatusCode(); |
||||
HttpEntity entity = response.getEntity(); |
||||
String returnResult = EntityUtils.toString(entity, "utf-8"); |
||||
|
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--status:"+status + ";FRLOG:HttpUtils.get--returnResult:"+returnResult); |
||||
|
||||
if (status == HttpStatus.SC_OK) { |
||||
return returnResult; |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpUtils.get--exception:"+e.getMessage()); |
||||
} |
||||
|
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* HttpPost请求 |
||||
* @param postMethod |
||||
* @return |
||||
*/ |
||||
private static String HttpPost(HttpPost postMethod){ |
||||
CloseableHttpClient httpclient = createHttpClient(null); |
||||
|
||||
try { |
||||
HttpResponse response = httpclient.execute(postMethod); |
||||
int status = response.getStatusLine().getStatusCode(); |
||||
HttpEntity entity = response.getEntity(); |
||||
String returnResult = EntityUtils.toString(entity, "utf-8"); |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:status:"+status+"HttpPost:returnResult:"+returnResult); |
||||
|
||||
if (status == HttpStatus.SC_OK) { |
||||
return returnResult; |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpPost:exception:"+e.getMessage()); |
||||
} |
||||
|
||||
return ""; |
||||
} |
||||
|
||||
public static String HttpPostXML(String url, String xmlParam){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:url:"+url); |
||||
|
||||
HttpPost postMethod = new HttpPost(url); |
||||
|
||||
postMethod.setHeader("Content-type", "text/html"); |
||||
HttpEntity entity2 = null; |
||||
try { |
||||
entity2 = new StringEntity(xmlParam); |
||||
} catch (UnsupportedEncodingException e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpPostXML:参数异常:"+e.getMessage()); |
||||
return ""; |
||||
} |
||||
|
||||
postMethod.setEntity(entity2); |
||||
|
||||
return HttpPost(postMethod); |
||||
} |
||||
|
||||
public static String HttpPostJson(String url, String param,Map<String,String> header){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:url:"+url+";param="+param); |
||||
|
||||
HttpPost postMethod = new HttpPost(url); |
||||
|
||||
postMethod.setHeader("Content-Type","application/json"); |
||||
|
||||
if(header != null && header.size() > 0){ |
||||
Set<String> keySet = header.keySet(); |
||||
|
||||
for(String key : keySet){ |
||||
postMethod.setHeader(key,header.get(key)); |
||||
} |
||||
} |
||||
|
||||
if(!Utils.isNullStr(param)){ |
||||
HttpEntity entity2 = null; |
||||
try { |
||||
entity2 = new StringEntity(param,"utf-8"); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpPostJSON:参数异常:"+e.getMessage()); |
||||
return ""; |
||||
} |
||||
|
||||
postMethod.setEntity(entity2); |
||||
} |
||||
|
||||
return HttpPost(postMethod); |
||||
} |
||||
|
||||
public static String HttpPostWWWForm(String url, Map<String,String> header,Map<String,String> param){ |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpWWWForm:url:"+url); |
||||
|
||||
HttpPost postMethod = new HttpPost(url); |
||||
|
||||
if(header != null && header.size() > 0){ |
||||
Set<String> keySet = header.keySet(); |
||||
|
||||
for(String key : keySet){ |
||||
postMethod.setHeader(key,header.get(key)); |
||||
} |
||||
} |
||||
|
||||
if(param != null && param.size() > 0){ |
||||
List<NameValuePair> params = new ArrayList<NameValuePair>(param.size()); |
||||
|
||||
for(Map.Entry<String,String> map : param.entrySet()){ |
||||
params.add(new BasicNameValuePair(map.getKey(), map.getValue())); |
||||
} |
||||
|
||||
try { |
||||
postMethod.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); |
||||
} catch (UnsupportedEncodingException e) { |
||||
FineLoggerFactory.getLogger().info("FRLOG:HttpWWWForm:异常:"+e.getMessage()); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
return HttpPost(postMethod); |
||||
} |
||||
|
||||
public static String HttpPostMultipartForm(Map<String,Object> map, String url,Map<String,String> header){ |
||||
CloseableHttpClient httpClient = createHttpClient(null);//从连接池中获取
|
||||
HttpPost post = new HttpPost(url); |
||||
if(header != null && header.size() > 0){ |
||||
Set<String> keySet = header.keySet(); |
||||
|
||||
for(String key : keySet){ |
||||
post.setHeader(key,header.get(key)); |
||||
} |
||||
} |
||||
BufferedReader br = null; |
||||
String returnResult = ""; |
||||
try |
||||
{ |
||||
File file = File.createTempFile("img","png"); |
||||
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create(); |
||||
multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); |
||||
if(map!=null) { |
||||
Iterator iter = map.entrySet().iterator(); |
||||
while(iter.hasNext()){ |
||||
Map.Entry entry = (Map.Entry) iter.next(); |
||||
String key = (String) entry.getKey(); |
||||
String value = (String) entry.getValue(); |
||||
multipartEntityBuilder.addTextBody(key,value); |
||||
InputStream is = Utils.getResourcesFile("/resources/img/img.png"); |
||||
|
||||
FileUtils.copyInputStreamToFile(is,file); |
||||
multipartEntityBuilder.addBinaryBody("image",file); |
||||
} |
||||
} |
||||
HttpEntity httpEntity=multipartEntityBuilder.build(); |
||||
// 设置请求参数
|
||||
post.setEntity(httpEntity); |
||||
// 发起交易
|
||||
HttpResponse resp = httpClient.execute(post); |
||||
int ret = resp.getStatusLine().getStatusCode(); |
||||
// 响应分析
|
||||
HttpEntity entity = resp.getEntity(); |
||||
returnResult = EntityUtils.toString(entity, "utf-8"); |
||||
|
||||
FRUtils.FRLogInfo("returnResult:"+returnResult); |
||||
file.deleteOnExit(); |
||||
} catch (Exception e) |
||||
{ |
||||
FRUtils.FRLogError("上传图片:"+e.getMessage()); |
||||
} finally |
||||
{ |
||||
if (br != null) |
||||
{ |
||||
try |
||||
{ |
||||
br.close(); |
||||
} catch (Exception e) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
|
||||
return returnResult; |
||||
} |
||||
|
||||
private static CloseableHttpClient createHttpClient(Cookie[] cookies){ |
||||
|
||||
SSLContext sslContext = null; |
||||
try { |
||||
sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { |
||||
@Override |
||||
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { |
||||
return true; |
||||
} |
||||
}).build(); |
||||
} catch (Exception e) { |
||||
FRUtils.FRLogInfo("exception:"+e.getMessage()); |
||||
} |
||||
|
||||
CloseableHttpClient httpclient = null; |
||||
|
||||
if(cookies != null && cookies.length > 0){ |
||||
CookieStore cookieStore = cookieToCookieStore(cookies); |
||||
|
||||
httpclient = HttpClients.custom().setSslcontext(sslContext). |
||||
setSSLHostnameVerifier(new NoopHostnameVerifier()).setDefaultCookieStore(cookieStore).build(); |
||||
} |
||||
else{ |
||||
httpclient = HttpClients.custom().setSslcontext(sslContext). |
||||
setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); |
||||
} |
||||
|
||||
return httpclient; |
||||
} |
||||
|
||||
/** |
||||
* cookies转cookieStore |
||||
* @param cookies |
||||
* @return |
||||
*/ |
||||
public static CookieStore cookieToCookieStore(Cookie[] cookies){ |
||||
CookieStore cookieStore = new BasicCookieStore(); |
||||
|
||||
if(cookies != null && cookies.length>0){ |
||||
for(Cookie cookie : cookies){ |
||||
BasicClientCookie cookie1 = new BasicClientCookie(cookie.getName(), cookie.getValue()); |
||||
cookieStore.addCookie(cookie1); |
||||
} |
||||
} |
||||
|
||||
return cookieStore; |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
package com.eco.plugin.xxxx.fssso.utils; |
||||
|
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.PrintWriter; |
||||
|
||||
public class ResponseUtils { |
||||
private static final int SUCCESS = 200; |
||||
private static final int FAILED = -1; |
||||
|
||||
public static void successResponse(HttpServletResponse res, String body) { |
||||
response(res, body, SUCCESS); |
||||
} |
||||
|
||||
public static void failedResponse(HttpServletResponse res, String body) { |
||||
response(res, body, FAILED); |
||||
} |
||||
|
||||
private static void response(HttpServletResponse res, String body, int code) { |
||||
JSONObject object = new JSONObject(); |
||||
PrintWriter pw; |
||||
try { |
||||
object.put("code", code); |
||||
object.put("data", body); |
||||
pw = WebUtils.createPrintWriter(res); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
return; |
||||
} |
||||
res.setContentType("application/json;charset=utf-8"); |
||||
String result = object.toString(); |
||||
pw.println(result); |
||||
pw.flush(); |
||||
pw.close(); |
||||
} |
||||
|
||||
public static void response(HttpServletResponse res,JSONObject json){ |
||||
PrintWriter pw; |
||||
try { |
||||
pw = WebUtils.createPrintWriter(res); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
return; |
||||
} |
||||
res.setContentType("application/json;charset=utf-8"); |
||||
String result = json.toString(); |
||||
pw.println(result); |
||||
pw.flush(); |
||||
pw.close(); |
||||
} |
||||
|
||||
public static void responseXml(HttpServletResponse res,String xml){ |
||||
PrintWriter pw; |
||||
try { |
||||
pw = WebUtils.createPrintWriter(res); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
return; |
||||
} |
||||
res.setContentType("text/xml;charset=utf-8"); |
||||
pw.println(xml); |
||||
pw.flush(); |
||||
pw.close(); |
||||
} |
||||
|
||||
public static void setCSRFHeader(HttpServletResponse httpServletResponse){ |
||||
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*"); |
||||
httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE,HEAD,PUT,PATCH"); |
||||
httpServletResponse.setHeader("Access-Control-Max-Age", "36000"); |
||||
httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,Authorization,authorization"); |
||||
} |
||||
|
||||
public static void responseJsonp(HttpServletRequest req, HttpServletResponse res, JSONObject json){ |
||||
PrintWriter pw; |
||||
try { |
||||
pw = WebUtils.createPrintWriter(res); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
return; |
||||
} |
||||
res.setContentType("text/javascript;charset=utf-8;charset=utf-8"); |
||||
String result = json.toString(); |
||||
|
||||
String jsonp=req.getParameter("callback"); |
||||
|
||||
pw.println(jsonp+"("+result+")"); |
||||
pw.flush(); |
||||
pw.close(); |
||||
} |
||||
} |
@ -0,0 +1,226 @@
|
||||
package com.eco.plugin.xxxx.fssso.utils; |
||||
|
||||
import com.fr.base.TemplateUtils; |
||||
import com.fr.data.NetworkHelper; |
||||
import com.fr.io.utils.ResourceIOUtils; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.CodeUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.codec.digest.DigestUtils; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.Cookie; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.BufferedReader; |
||||
import java.io.InputStream; |
||||
import java.net.URLEncoder; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.UUID; |
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
public class Utils { |
||||
|
||||
/** |
||||
* 判断字符串是否为空 |
||||
* @param str |
||||
* @return true 空字符串 false 非空字符串 |
||||
*/ |
||||
public static boolean isNullStr(String str){ |
||||
return !(str != null && !str.isEmpty() && !"null".equals(str)); |
||||
} |
||||
|
||||
/** |
||||
* 判断字符串是否非空 |
||||
* @param str |
||||
* @return |
||||
*/ |
||||
public static boolean isNotNullStr(String str){ |
||||
return !isNullStr(str); |
||||
} |
||||
|
||||
/** |
||||
* MD5加密 |
||||
* @param str |
||||
* @return |
||||
*/ |
||||
public static String getMd5Str(String str) |
||||
{ |
||||
return DigestUtils.md5Hex(str); |
||||
} |
||||
|
||||
/** |
||||
* 帆软shaEncode加密 |
||||
*/ |
||||
|
||||
public static String shaEncode(String str){ |
||||
return CodeUtils.sha256Encode(str); |
||||
} |
||||
|
||||
/** |
||||
* 获取uuid |
||||
*/ |
||||
public static String uuid(){ |
||||
return UUID.randomUUID().toString(); |
||||
} |
||||
|
||||
/** |
||||
* 替换空字符串 |
||||
* @param str |
||||
* @param replace |
||||
* @return |
||||
*/ |
||||
public static String replaceNullStr(String str,String replace){ |
||||
if(isNullStr(str)){ |
||||
return replace; |
||||
} |
||||
|
||||
return str; |
||||
} |
||||
|
||||
/** |
||||
* 获取请求体 |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
public static JSONObject getRequestBody(HttpServletRequest req){ |
||||
StringBuffer sb = new StringBuffer(); |
||||
String line = null; |
||||
try { |
||||
BufferedReader reader = req.getReader(); |
||||
while ((line = reader.readLine()) != null) |
||||
sb.append(line); |
||||
} catch (Exception e) { |
||||
FRUtils.FRLogInfo("getRequestBody:exception:"+e.getMessage()); |
||||
} |
||||
//将空格和换行符替换掉避免使用反序列化工具解析对象时失败
|
||||
String jsonString = sb.toString().replaceAll("\\s","").replaceAll("\n",""); |
||||
|
||||
JSONObject json = new JSONObject(jsonString); |
||||
|
||||
return json; |
||||
} |
||||
|
||||
/** |
||||
* 获取ip |
||||
* @return |
||||
*/ |
||||
public static String getIp(HttpServletRequest req){ |
||||
String realIp = req.getHeader("X-Real-IP"); |
||||
String fw = req.getHeader("X-Forwarded-For"); |
||||
if (StringUtils.isNotEmpty(fw) && !"unKnown".equalsIgnoreCase(fw)) { |
||||
int var3 = fw.indexOf(","); |
||||
return var3 != -1 ? fw.substring(0, var3) : fw; |
||||
} else { |
||||
fw = realIp; |
||||
if (StringUtils.isNotEmpty(realIp) && !"unKnown".equalsIgnoreCase(realIp)) { |
||||
return realIp; |
||||
} else { |
||||
if (StringUtils.isBlank(realIp) || "unknown".equalsIgnoreCase(realIp)) { |
||||
fw = req.getHeader("Proxy-Client-IP"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { |
||||
fw = req.getHeader("WL-Proxy-Client-IP"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { |
||||
fw = req.getHeader("HTTP_CLIENT_IP"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { |
||||
fw = req.getHeader("HTTP_X_FORWARDED_FOR"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(fw) || "unknown".equalsIgnoreCase(fw)) { |
||||
fw = req.getRemoteAddr(); |
||||
} |
||||
|
||||
return fw; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 根据key获取cookie |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
public static String getCookieByKey(HttpServletRequest req,String key){ |
||||
Cookie[] cookies = req.getCookies(); |
||||
String cookie = ""; |
||||
|
||||
if(cookies == null || cookies.length <=0){ |
||||
return ""; |
||||
} |
||||
|
||||
for(int i = 0; i < cookies.length; i++) { |
||||
Cookie item = cookies[i]; |
||||
if (item.getName().equalsIgnoreCase(key)) { |
||||
cookie = item.getValue(); |
||||
} |
||||
} |
||||
|
||||
FRUtils.FRLogInfo("cookie:"+cookie); |
||||
|
||||
return cookie; |
||||
} |
||||
|
||||
/** |
||||
* 判断是否是手机端的链接 |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
public static boolean isMobile(HttpServletRequest req) { |
||||
String[] mobileArray = {"iPhone", "iPad", "android", "windows phone", "xiaomi"}; |
||||
String userAgent = req.getHeader("user-agent"); |
||||
if (userAgent != null && userAgent.toUpperCase().contains("MOBILE")) { |
||||
for(String mobile : mobileArray) { |
||||
if(userAgent.toUpperCase().contains(mobile.toUpperCase())) { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
return NetworkHelper.getDevice(req).isMobile(); |
||||
} |
||||
|
||||
/** |
||||
* 只编码中文 |
||||
* @param url |
||||
* @return |
||||
*/ |
||||
public static String encodeCH(String url ){ |
||||
Matcher matcher = Pattern.compile("[\\u4e00-\\u9fa5]").matcher(url); |
||||
|
||||
while(matcher.find()){ |
||||
String chn = matcher.group(); |
||||
url = url.replaceAll(chn, URLEncoder.encode(chn)); |
||||
} |
||||
|
||||
return url; |
||||
} |
||||
|
||||
/** |
||||
* 获取web-inf文件夹下的文件 |
||||
* filename /resources/ip4enc.properties |
||||
*/ |
||||
public static InputStream getResourcesFile(String filename){ |
||||
return ResourceIOUtils.read(filename); |
||||
} |
||||
|
||||
public static void toErrorPage(HttpServletResponse res,String path,Map<String, String> parameterMap){ |
||||
if(parameterMap == null){ |
||||
parameterMap = new HashMap<String, String>(); |
||||
} |
||||
|
||||
try { |
||||
String macPage = TemplateUtils.renderTemplate(path, parameterMap); |
||||
WebUtils.printAsString(res, macPage); |
||||
}catch (Exception e){ |
||||
FRUtils.FRLogError("跳转页面异常"); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,413 @@
|
||||
|
||||
BI.config("dec.provider.schedule", function (provider) { |
||||
provider.registerHandingWay({ |
||||
text: BI.i18nText("Plugin-wink_message_title"), |
||||
value:"com.eco.plugin.wink.fssso.dsdd.dsdd.TsBean", |
||||
cardType: "dec.schedule.task.file.handling.oa", |
||||
actions: [] // action
|
||||
}, [DecCst.Schedule.TaskType.DEFAULT, DecCst.Schedule.TaskType.REPORT, DecCst.Schedule.TaskType.BI]); |
||||
}); |
||||
|
||||
var Plugin = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "" |
||||
}, |
||||
_store: function () { |
||||
return BI.Models.getModel("dec.model.schedule.task.file.handling.oa") |
||||
}, |
||||
watch: { |
||||
linkType: function (e) { |
||||
this.linkGroup.setValue(e), |
||||
this.customizeLinkText.setVisible(e === DecCst.Schedule.MessageUrl.Type.OUT) |
||||
}, |
||||
type:function(e){ |
||||
this.title.setVisible(e*1 !== 1) |
||||
}, |
||||
linkGroupItems: function (e) { |
||||
this.linkGroup.populate(BI.createItems(e, { |
||||
type: "bi.single_select_radio_item", |
||||
logic: { |
||||
dynamic: !0 |
||||
} |
||||
})), |
||||
this.model.isNotReportTask && this.store.setLinkType(DecCst.Schedule.MessageUrl.Type.OUT) |
||||
} |
||||
}, |
||||
render: function () { |
||||
var t = this, |
||||
e = this.options.value[0], |
||||
n = this; |
||||
|
||||
if(e == undefined){ |
||||
e = {}; |
||||
} |
||||
|
||||
return { |
||||
type: "bi.vertical", |
||||
tgap: 15, |
||||
items: [ |
||||
{ |
||||
type: "bi.horizontal_adapt", |
||||
columnSize: [115, "fill"], |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "dec-font-weight-bold", |
||||
width: 115, |
||||
height: 24, |
||||
textAlign: "left", |
||||
text: BI.i18nText("Plugin-wink_title") |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
height: 24, |
||||
invisible: 0, |
||||
textWidth: "", |
||||
watermark: BI.i18nText("Plugin-wink_title"), |
||||
editorWidth: 300, |
||||
value: e.title, |
||||
ref: function (e) { |
||||
n.title = e |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
type: "bi.horizontal_adapt", |
||||
columnSize: [115, "fill"], |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "dec-font-weight-bold", |
||||
width: 115, |
||||
height: 24, |
||||
textAlign: "left", |
||||
text: BI.i18nText("Dec-Basic_Content") |
||||
}, { |
||||
type: "dec.error_label", |
||||
height: 100, |
||||
el: { |
||||
type: "bi.textarea_editor", |
||||
cls: "bi-border", |
||||
width: 300, |
||||
height: 98, |
||||
watermark: BI.i18nText("Dec-Basic_Content"), |
||||
ref: function (e) { |
||||
n.contentText = e |
||||
}, |
||||
value:e.content, |
||||
listeners: [{ |
||||
eventName: BI.TextAreaEditor.EVENT_FOCUS, |
||||
action: function () { |
||||
n.contentBubbles.hideError() |
||||
} |
||||
}, { |
||||
eventName: BI.TextAreaEditor.EVENT_CHANGE, |
||||
action: function () { |
||||
n.contentBubbles.hideError() |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
ref: function (e) { |
||||
n.contentBubbles = e |
||||
} |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
/** |
||||
* |
||||
* |
||||
* @returns {boolean} |
||||
*/ |
||||
validation: function () { |
||||
return true; |
||||
}, |
||||
setValue: function (e) { |
||||
var t = this; |
||||
BI.map(e, function (e, i) { |
||||
if (i.runType === DecCst.Schedule.RunType.CLIENT_NOTIFICATION) |
||||
{ |
||||
t.contentText.setValue(i.content), t.title.setValue(i.title) |
||||
} |
||||
}) |
||||
}, |
||||
|
||||
/** |
||||
* |
||||
* outputActionList |
||||
* @returns {{}} |
||||
*/ |
||||
getValue: function () { |
||||
return { |
||||
"@class": "com.eco.plugin.wink.fssso.dsdd.dsdd.TsBean", |
||||
actionName: "com.eco.plugin.wink.fssso.dsdd.dsdd.TsBean", |
||||
content: this.contentText.getValue(), |
||||
title:this.title.getValue() |
||||
} |
||||
} |
||||
}); |
||||
BI.shortcut("dec.schedule.task.file.handling.oa", Plugin); |
||||
|
||||
//数据
|
||||
var e = BI.inherit(Fix.Model, { |
||||
context: ["currTask"], |
||||
state: function () { |
||||
return { |
||||
linkType: DecCst.Schedule.MessageUrl.Type.INNER, |
||||
type:1 |
||||
} |
||||
}, |
||||
computed: { |
||||
isBITask: function () { |
||||
return this.model.currTask.taskType === DecCst.Schedule.TaskType.BI |
||||
}, |
||||
isNotReportTask: function () { |
||||
return this.model.currTask.taskType !== DecCst.Schedule.TaskType.REPORT |
||||
}, |
||||
linkGroupItems: function () { |
||||
var e = BI.deepClone(BI.Constants.getConstant("dec.constant.schedule.task.handing.client.link")); |
||||
return this.model.isNotReportTask ? (e[0].disabled = !0, e[0].selected = !1, e[1].selected = !0, this.setLinkType(DecCst.Schedule.MessageUrl.Type.OUT)) : (e[0].disabled = !1, e[0].selected = this.model.linkType === DecCst.Schedule.MessageUrl.Type.INNER, e[1].selected = this.model.linkType === DecCst.Schedule.MessageUrl.Type.OUT), |
||||
e |
||||
}, |
||||
typeGroupItems: function () { |
||||
return [{disabled:false,selected:true,text:'sendmessage',value:'1'},{disabled:false,selected:false,text:'send',value:'2'}] |
||||
} |
||||
}, |
||||
actions: { |
||||
setLinkType: function (e) { |
||||
this.model.linkType = e |
||||
}, |
||||
setType: function(e){ |
||||
this.model.type = e; |
||||
} |
||||
} |
||||
}); |
||||
BI.model("dec.model.schedule.task.file.handling.oa", e) |
||||
|
||||
|
||||
//处理空数组问题
|
||||
var e = BI.inherit(BI.Widget, { |
||||
props: { |
||||
baseCls: "dec-schedule-task-handling", |
||||
$testId: "dec-schedule-task-handling", |
||||
value: { |
||||
scheduleOutput: { |
||||
outputActionList: [] |
||||
} |
||||
} |
||||
}, |
||||
_store: function () { |
||||
return BI.Models.getModel("dec.model.schedule.task.handling", { |
||||
value: this.options.value |
||||
}) |
||||
}, |
||||
watch: { |
||||
selectedWay: function (e) { |
||||
this.leftGroup.populate(this._createLeftItems(e)), |
||||
this.leftGroup.setValue(this.model.leftTab), |
||||
this.handlingWayGroup.setValue(e) |
||||
}, |
||||
leftTab: function (e) { |
||||
this.centerTab.setSelect(e) |
||||
}, |
||||
topItems: function (e) { |
||||
this.handlingWayGroup.populate(e), |
||||
this.handlingWayGroup.setValue(this.model.selectedWay) |
||||
}, |
||||
taskType: function () { |
||||
this.centerTab.empty() |
||||
} |
||||
}, |
||||
render: function () { |
||||
var i = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.vertical", |
||||
bgap: 5, |
||||
items: [{ |
||||
type: "bi.absolute", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.horizontal", |
||||
tgap: 5, |
||||
items: [{ |
||||
type: "bi.label", |
||||
height: 24, |
||||
cls: "dec-font-weight-bold", |
||||
text: BI.i18nText("Dec-Task_Handling"), |
||||
textAlign: "left" |
||||
} |
||||
] |
||||
}, |
||||
left: 0, |
||||
top: 0 |
||||
} |
||||
] |
||||
}, { |
||||
el: { |
||||
type: "bi.button_group", |
||||
layouts: [{ |
||||
type: "bi.left", |
||||
lgap: 40, |
||||
bgap: 15 |
||||
} |
||||
], |
||||
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, |
||||
items: this.model.topItems, |
||||
value: this.model.selectedWay, |
||||
ref: function (e) { |
||||
i.handlingWayGroup = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.ButtonGroup.EVENT_CHANGE, |
||||
action: function (e, t) { |
||||
i.store.setHandlingWay(e, t.isSelected()) |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
lgap: 50 |
||||
} |
||||
] |
||||
}, |
||||
tgap: 10 |
||||
}, { |
||||
type: "bi.htape", |
||||
cls: "handling-body bi-border-top", |
||||
items: [{ |
||||
type: "bi.button_group", |
||||
cls: "bi-border-right", |
||||
width: 200, |
||||
layouts: [{ |
||||
type: "bi.vertical" |
||||
} |
||||
], |
||||
items: this._createLeftItems(this.model.selectedWay), |
||||
value: this.model.leftTab, |
||||
ref: function (e) { |
||||
i.leftGroup = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.ButtonGroup.EVENT_CHANGE, |
||||
action: function (e) { |
||||
i.store.setLeftTab(e) |
||||
} |
||||
} |
||||
] |
||||
}, { |
||||
type: "bi.absolute", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.tab", |
||||
showIndex: this.model.leftTab, |
||||
cardCreator: BI.bind(i._cardCreator, this), |
||||
ref: function (e) { |
||||
i.centerTab = e |
||||
} |
||||
}, |
||||
top: 0, |
||||
left: 15, |
||||
bottom: 0, |
||||
right: 0 |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
validation: function (e) { |
||||
var n = this, |
||||
o = [], |
||||
r = n.model.handlingItems; |
||||
BI.each(this.model.editingWay, function (e, t) { |
||||
var i = n[t + "Pane"]; |
||||
if (!BI.isFunction(i.validation) || i.validation()) { |
||||
if (!BI.isNull(i.getValue())) |
||||
return !0; |
||||
o.push(r[t].text) |
||||
} else |
||||
o.push(r[t].text) |
||||
}), |
||||
0 < BI.size(o) && BI.Msg.alert(BI.i18nText("Dec-Basic_Tips"), BI.i18nText("Dec-Error_Task_File_Handling_Value", o.join(","))), |
||||
e(0 === BI.size(o)) |
||||
}, |
||||
getValue: function () { |
||||
var i = {}; |
||||
BI.each(this.model.outputActionList, function (e, t) { |
||||
i[t.actionName] = t |
||||
}); |
||||
var o = {}, |
||||
r = [], |
||||
s = [], |
||||
a = [], |
||||
e = this.model.editingWay, |
||||
c = this, |
||||
l = c.model.handlingItems; |
||||
BI.each(e, function (e, t) { |
||||
var i, |
||||
n = c[t + "Pane"]; |
||||
n && BI.isNotEmptyObject(n.getValue()) && ((i = n.getValue(), BI.isNotNull(l[t].actions) && l[t].actions.length > 0) ? (r.push(t), BI.each(i, function (e, t) { |
||||
var i = t.actionName; |
||||
r.push(i), |
||||
o[i] = t |
||||
}), s = BI.concat(s, BI.difference(l[t].actions, r))) : (r.push(t), o[t] = i), a.push(l[t].runType)) |
||||
}); |
||||
var t = BI.filter(i, function (e, t) { |
||||
return c.store.isDefaultByRunType(t, a) || c.store.isDefaultValueItem(t, r, s) |
||||
}); |
||||
return { |
||||
scheduleOutput: BI.extend({}, this.model.currTask.scheduleOutput, { |
||||
outputActionList: BI.map(o, function (e, t) { |
||||
return delete t.runType, |
||||
BI.extend({ |
||||
resultURL: window.location.protocol + "//" + window.location.host + Dec.fineServletURL |
||||
}, t) |
||||
}).concat(t) |
||||
}) |
||||
} |
||||
}, |
||||
_cardCreator: function (i) { |
||||
var t = this, |
||||
e = BI.find(this.model.handlingItems, function (e, t) { |
||||
return t.value === i |
||||
}); |
||||
return e && BI.isKey(e.cardType) ? { |
||||
type: e.cardType, |
||||
value: this.store.findActionValue(e, BI.deepClone(this.model.outputActionList)), |
||||
ref: function (e) { |
||||
t[i + "Pane"] = e |
||||
} |
||||
} |
||||
: { |
||||
type: "bi.label", |
||||
text: i |
||||
} |
||||
}, |
||||
_createLeftItems: function (e) { |
||||
var n = this; |
||||
return BI.map(e, function (e, t) { |
||||
var i = n.model.handlingItems[t].text; |
||||
return { |
||||
type: "dec.schedule.task.file.handling.item", |
||||
text: i, |
||||
value: t, |
||||
listeners: [{ |
||||
eventName: "EVENT_DELETE", |
||||
action: function () { |
||||
n.store.deleteAction(t, i) |
||||
} |
||||
} |
||||
] |
||||
} |
||||
}) |
||||
} |
||||
}); |
||||
|
||||
BI.shortcut("dec.schedule.task.handling", e) |
||||
|
@ -0,0 +1,16 @@
|
||||
Plugin-wink_message_title=feishuMessage |
||||
Plugin-wink_title=title |
||||
Plugin-wink_content=content |
||||
|
||||
Plugin-wink_index=index |
||||
Plugin-wink_codeurl=codeurl |
||||
Plugin-wink_tokenurl=tokenurl |
||||
Plugin-wink_userurl=userurl |
||||
Plugin-wink_sendMessageUrl=sendMessageUrl |
||||
Plugin-wink_cancelMessage=cancelMessage |
||||
Plugin-wink_sysdes=sysdes |
||||
Plugin-wink_syscode=syscode |
||||
Plugin-wink_gettokenurl=gettokenurl |
||||
Plugin-wink_imgurl=imgurl |
||||
Plugin-wink_pouser=pouser |
||||
Plugin-wink_popsd=popsd |
@ -0,0 +1,16 @@
|
||||
Plugin-wink_message_title=\u98DE\u4E66\u6D88\u606F\u63A8\u9001 |
||||
Plugin-wink_title=\u6807\u9898 |
||||
Plugin-wink_content=\u5185\u5BB9 |
||||
|
||||
Plugin-wink_index=\u5E06\u8F6F\u9996\u9875 |
||||
Plugin-wink_codeurl=\u83B7\u53D6\u6388\u6743\u7801\u63A5\u53E3 |
||||
Plugin-wink_tokenurl=\u83B7\u53D6token\u63A5\u53E3 |
||||
Plugin-wink_userurl=\u83B7\u53D6\u7528\u6237\u4FE1\u606F\u63A5\u53E3 |
||||
Plugin-wink_sendMessageUrl=\u53D1\u9001\u6D88\u606F\u63A5\u53E3 |
||||
Plugin-wink_cancelMessage=\u64A4\u9500\u6D88\u606F\u63A5\u53E3 |
||||
Plugin-wink_sysdes=\u7CFB\u7EDF\u63CF\u8FF0 |
||||
Plugin-wink_syscode=\u7CFB\u7EDF\u7F16\u7801 |
||||
Plugin-wink_gettokenurl=\u83B7\u53D6\u6D88\u606Ftoken\u63A5\u53E3 |
||||
Plugin-wink_imgurl=\u4E0A\u4F20\u56FE\u7247\u63A5\u53E3 |
||||
Plugin-wink_pouser=po\u7528\u6237 |
||||
Plugin-wink_popsd=po\u5BC6\u7801 |
Loading…
Reference in new issue