use of com.itrus.portal.db.ApplicationInfo in project portal by ixinportal.
the class KeySegmentationWebSocketHandler method handleMessage.
@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
logger.info("成功接收到消息");
// 把客户端的消息解析为JSON对象
if (message instanceof TextMessage) {
String appId = webSocketSession.getAttributes().get("appId").toString();
// String
// userid=webSocketSession.getAttributes().get("uid").toString();
// System.out.println(userid);
logger.info("信息为:" + message.getPayload());
MobileLogmanagementLog logmanagementLog = new MobileLogmanagementLog();
// 发送数据
webSocketSession.sendMessage(message);
logger.error("appId=" + appId);
// MobileLogmanagementLog logmanagementLog=new
// MobileLogmanagementLog();
JSONObject msg = JSON.parseObject(message.getPayload().toString());
// ApplicationInfo
// applicationInfo=applicationInfoServiceImpl.getApplicationInfo(appId);
ApplicationInfo applicationInfo = applicationInfoServiceImpl.getApplicationInfo(appId);
logger.error("msg=" + msg);
MobileLogmanagementLog log = new MobileLogmanagementLog();
if (msg.containsKey("q2")) {
String q2 = msg.getString("q2");
if (q2 != null) {
log.setUserName(msg.getString("uid"));
log.setContenu("签名成功");
log.setServiceType("签名");
log.setAppName(applicationInfo.getName());
log.setCreateTime(new Date());
mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
} else {
log.setUserName(msg.getString("uid"));
log.setContenu("签名失败");
log.setServiceType("签名");
log.setAppName(applicationInfo.getName());
log.setCreateTime(new Date());
mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
}
}
// JSONObject msg1 = JSON.parseObject(message.getPayload().toString());
if (msg.containsKey("q2")) {
// 签名计费
String q2 = msg.getString("q2");
if (/*!sign2.contains("ERROR")*/
q2 != null) {
logger.error("签名");
if (!appServiceChargingService.checkTransInfo(appId, applicationInfo)) {
// 判断是否有有效的计费
logger.error("计费规则检查失败,无可用计费规则");
} else {
logger.error("开始计费,记流水");
appServiceChargingService.charging(appId, applicationInfo, /*log.getId(),*/
"签名");
}
}
}
if (msg.containsKey("sign4")) {
String p2 = msg.getString("sign4");
if (p2 != null && !p2.equals("ERROR:-1")) {
logger.error("密钥分割");
if (!appServiceChargingService.checkTransInfo(appId, applicationInfo)) {
// 判断是否有有效的计费
logger.error("计费规则检查失败,无可用计费规则");
} else {
// 计费(记流水)
logger.error("开始计费,记流水");
appServiceChargingService.charging(appId, applicationInfo, /*log.getId(),*/
"密钥分割");
}
}
}
// log.setServiceType("2");
/*
* if(q2!=null){ log.setContenu("签名成功"); }else{
* log.setContenu("签名失败"); }
*/
// String appId=msg.getString("appId");
// ApplicationInfo applicationInfo =
// applicationInfoServiceImpl.getApplicationInfo(appId);
/*
* log.setServiceType("签名");
* log.setAppName(applicationInfo.getName()); log.setCreateTime(new
* Date());
* mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
*/
} else // else if(message instanceof BinaryMessage) {
// BinaryMessage msg = new BinaryMessage((byte[]) message.getPayload());
// this.handleBinaryMessage(session, (BinaryMessage)message);
// }
{
if (!(message instanceof PongMessage)) {
throw new IllegalStateException("Unexpected WebSocket message type: " + message);
}
this.handlePongMessage(session, (PongMessage) message);
}
}
use of com.itrus.portal.db.ApplicationInfo in project portal by ixinportal.
the class MobileApplyConfigController method updateForm.
// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) {
Map<String, Object> param = new HashMap<String, Object>();
param.put("id", id);
List<Map<String, Object>> applyConfigManages = mobileApplyConfigService.selectMobileApplyConfigManageListByMap(param);
uiModel.addAttribute("applyConfigManage", applyConfigManages.get(0));
// 得到所有应用
List<ApplicationInfo> applicationInfos = applicationInfoService.selectByExample(new ApplicationInfoExample());
uiModel.addAttribute("applicationInfos", applicationInfos);
// 得到所有RA 服务信息
List<RaAccount> accounts = raAccountService.getRaAccounts();
uiModel.addAttribute("accounts", accounts);
return "applyconfig/update";
}
use of com.itrus.portal.db.ApplicationInfo in project portal by ixinportal.
the class MobileAppserviceChargingController method createForm.
// 新建处理页面
@RequestMapping(params = "form", produces = "text/html")
public String createForm(Model uiModel) {
// 系统配置的移动端应用集合
List<ApplicationInfo> mobileApplies = new ArrayList<ApplicationInfo>();
mobileApplies = sqlSession.selectList("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", null);
uiModel.addAttribute("mobileApplies", mobileApplies);
// 移除已经存在了的应用集合
Iterator<ApplicationInfo> iterator = mobileApplies.iterator();
while (iterator.hasNext()) {
ApplicationInfo mobileApply = iterator.next();
List<MobileAppserviceCharging> appserviceChargings = appserviceChargingService.selectListByAppId(mobileApply.getId(), null);
if (null != appserviceChargings && appserviceChargings.size() > 0) {
iterator.remove();
}
}
uiModel.addAttribute("mobileApplies", mobileApplies);
return "appservicecharging/create";
}
use of com.itrus.portal.db.ApplicationInfo in project portal by ixinportal.
the class EvidenceCallbackTask method init.
public void init() {
try {
EvidenceCallbackExample callbackExample = new EvidenceCallbackExample();
EvidenceCallbackExample.Criteria criteria = callbackExample.createCriteria();
criteria.andCounntLessThan(3);
List<EvidenceCallback> callbacks = callbackService.selectAll(callbackExample);
if (callbacks == null || callbacks.isEmpty()) {
log.error("暂无需系统存证回调");
return;
}
String url = null;
String app_id = null;
String secret_key = null;
// 需要回执报告
Map<Long, String> dataRet = new HashMap<Long, String>();
Map<Long, List<String>> data = new HashMap<Long, List<String>>();
Map<String, EvidenceCallback> cacheCallBackBySnMap = new HashMap<>();
for (int i = 0; i < callbacks.size() && i < 1000; i++) {
EvidenceCallback callback = callbacks.get(i);
cacheCallBackBySnMap.put(callback.getEvidenceSn(), callback);
if (callback.getAppServiceId() == null) {
if (data.containsKey(callback.getAppId())) {
data.get(callback.getAppId()).add(callback.getEvidenceSn());
} else {
List<String> sns = new ArrayList<String>();
sns.add(callback.getEvidenceSn());
data.put(callback.getAppId(), sns);
}
} else {
dataRet.put(callback.getAppId(), callback.getEvidenceSn());
}
}
// <---------------------------- 处理data start ------------------------------>
for (Map.Entry<Long, List<String>> entry : data.entrySet()) {
ApplicationInfo applicationInfo = CacheCustomer.getAPP_INFO_MAP_BY_ID().get(entry.getKey());
if (applicationInfo == null) {
applicationInfo = infoService.selectById(entry.getKey());
}
if (applicationInfo.getAppId() != app_id || url == null || app_id == null || secret_key == null) {
if (StringUtils.isEmpty(applicationInfo.getCallback()) || StringUtils.isEmpty(applicationInfo.getAppId()) || StringUtils.isEmpty(applicationInfo.getSecretKey())) {
log.error("回调失败:缺少配置。");
return;
}
if (url == null) {
url = applicationInfo.getCallback().trim();
}
if (app_id == null) {
app_id = applicationInfo.getAppId();
}
if (secret_key == null) {
secret_key = applicationInfo.getSecretKey();
}
log.error("EvidenceQueryQueue : URL=" + url + ",APP_ID=" + app_id + ",SECRET_KEY=" + secret_key);
if (StringUtils.isEmpty(url) || StringUtils.isEmpty(app_id) || StringUtils.isEmpty(secret_key)) {
log.error("回调失败:缺少配置。");
return;
}
}
Map<String, Object> param = new HashMap<String, Object>();
param.put("status", 1);
param.put("message", "存证成功");
param.put("appId", app_id);
param.put("evidenceSns", JSONObject.toJSONString(entry.getValue()));
String header = "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(app_id + entry.getValue(), secret_key), false);
String retStr = OkHttpClientManagerCallback.post(url, header, param);
JSONObject ret_data = JSONObject.parseObject(retStr);
if (retStr == null || ret_data.getInteger("status") != 1) {
log.error("EvidenceCallbackTask failure count [" + entry.getValue().size() + "]");
for (String sn : entry.getValue()) {
EvidenceCallback callback = null;
if (cacheCallBackBySnMap.get(sn) == null) {
EvidenceCallbackExample callbackExample0 = new EvidenceCallbackExample();
EvidenceCallbackExample.Criteria criteria0 = callbackExample.createCriteria();
criteria0.andEvidenceSnEqualTo(sn);
callback = callbackService.selectAll(callbackExample0).get(0);
} else {
callback = cacheCallBackBySnMap.get(sn);
}
int counnt = callback.getCounnt() + 1;
if (counnt == 3) {
sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByPrimaryKey", callback.getId());
} else {
callback.setCounnt(counnt);
sqlSession.update("com.itrus.portal.db.EvidenceCallbackMapper.updateByPrimaryKeySelective", callback);
}
}
} else {
log.error("EvidenceCallbackTask success count [" + entry.getValue().size() + "]");
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updates", entry.getValue().toArray());
EvidenceCallbackExample callbackExample1 = new EvidenceCallbackExample();
EvidenceCallbackExample.Criteria criteria1 = callbackExample.createCriteria();
criteria1.andEvidenceSnIn(entry.getValue());
sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByExample", callbackExample1);
// for(String sn:entry.getValue()) {
// EvidenceBasicInformation basicInformation = informationService
// .getInformationBySn(sn, null);
// basicInformation.setIsCallback(1);
// sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKeySelective",
// basicInformation);
//
// EvidenceCallbackExample callbackExample1 = new EvidenceCallbackExample();
// EvidenceCallbackExample.Criteria criteria1 = callbackExample.createCriteria();
// criteria1.andEvidenceSnEqualTo(sn);
// sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByExample",
// callbackExample1);
//
// }
}
}
// <---------------------------- 处理dataRet start ------------------------------>
for (Entry<Long, String> entry : dataRet.entrySet()) {
ApplicationInfo applicationInfo = CacheCustomer.getAPP_INFO_MAP_BY_ID().get(entry.getKey());
if (applicationInfo == null) {
applicationInfo = infoService.selectById(entry.getKey());
}
if (applicationInfo.getAppId() != app_id || url == null || app_id == null || secret_key == null) {
if (StringUtils.isEmpty(applicationInfo.getCallback()) || StringUtils.isEmpty(applicationInfo.getAppId()) || StringUtils.isEmpty(applicationInfo.getSecretKey())) {
log.error("回调失败:缺少配置。");
return;
}
if (url == null) {
url = applicationInfo.getCallback().trim();
}
if (app_id == null) {
app_id = applicationInfo.getAppId();
}
if (secret_key == null) {
secret_key = applicationInfo.getSecretKey();
}
log.error("EvidenceQueryQueue : URL=" + url + ",APP_ID=" + app_id + ",SECRET_KEY=" + secret_key);
if (StringUtils.isEmpty(url) || StringUtils.isEmpty(app_id) || StringUtils.isEmpty(secret_key)) {
log.error("回调失败:缺少配置。");
return;
}
}
EvidenceBasicInformation basicInformation = informationService.getInformationBySn(entry.getValue(), null);
// 得到证据回执base64
String reportBase64 = null;
// reportBase64 = EvidenceSaveServiceApi.cacheReportBySnMap.get(basicInformation.getEvidenceSn());
if (StringUtils.isEmpty(reportBase64)) {
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
if (realNameAuthentication == null) {
try {
realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
} catch (Exception e) {
e.printStackTrace();
}
}
// 获取回执报告附件表信息
EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria ec = enclosureExample.createCriteria();
ec.andEvidenceSnEqualTo(basicInformation.getEvidenceSn());
ec.andPdfTypeEqualTo("3");
List<EvidenceEnclosure> enclosures = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample);
if (enclosures != null && !enclosures.isEmpty()) {
EvidenceEnclosure enclosure = enclosures.get(0);
// 调解密下载接口从原子服务拿到回执报告base64
reportBase64 = EvidenceSaveServiceApi.decryptedAndDownload(sqlSession, enclosure.getBuid(), realNameAuthentication.getRealNameddress());
} else {
// 调用生成回执报告方法
Map<String, Object> mapRet = null;
mapRet = reportTemplate.returnreceipt(basicInformation.getEvidenceSn(), applicationInfo, null);
if (mapRet.get("status") != null && (int) mapRet.get("status") == 0) {
// 修改证据基本信息回执状态为已出
reportBase64 = (String) mapRet.get("pdfBase64");
basicInformation.setReceiptStatus(1);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
}
}
} else {
// EvidenceSaveServiceApi.cacheReportBySnMap.remove(basicInformation.getEvidenceSn());
}
Map<String, Object> param = new HashMap<String, Object>();
param.put("status", 1);
param.put("appId", app_id);
param.put("evidenceSn", basicInformation.getEvidenceSn());
if (reportBase64 == null) {
param.put("message", "存证成功,回执报告生成失败!");
} else {
param.put("message", "存证成功");
param.put("reportBase64", reportBase64);
}
String header = "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(app_id + basicInformation.getEvidenceSn(), secret_key), false);
String retStr = OkHttpClientManagerCallback.post(url, header, param);
JSONObject ret_data = JSONObject.parseObject(retStr);
String dataSn = basicInformation.getEvidenceSn();
Long appId = entry.getKey();
// 判断是否成功 true ——> 失败
if (retStr == null || ret_data.getInteger("status") != 1) {
EvidenceCallback callback = null;
if (cacheCallBackBySnMap.get(dataSn) == null) {
EvidenceCallbackExample callbackExample0 = new EvidenceCallbackExample();
EvidenceCallbackExample.Criteria criteria0 = callbackExample.createCriteria();
criteria0.andEvidenceSnEqualTo(dataSn);
callback = callbackService.selectAll(callbackExample0).get(0);
} else {
callback = cacheCallBackBySnMap.get(dataSn);
}
int counnt = callback.getCounnt() + 1;
if (counnt == 3) {
sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByPrimaryKey", callback.getId());
} else {
callback.setCounnt(counnt);
sqlSession.update("com.itrus.portal.db.EvidenceCallbackMapper.updateByPrimaryKeySelective", callback);
}
} else {
List<String> sns = new ArrayList<>();
sns.add(dataSn);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updates", sns.toArray());
EvidenceCallbackExample callbackExample1 = new EvidenceCallbackExample();
EvidenceCallbackExample.Criteria criteria1 = callbackExample.createCriteria();
criteria1.andEvidenceSnIn(sns);
sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByExample", callbackExample1);
}
}
// <---------------------------- 处理dataRet end ------------------------------>
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
LogUtil.evidencelog(sqlSession, null, "存证回调接口", "失败原因:" + e.toString());
}
}
use of com.itrus.portal.db.ApplicationInfo in project portal by ixinportal.
the class ApplicationInfoServiceImpl method getCert.
public String getCert(Long id) {
// 声明一个map
Map<Long, String> map = new HashMap<Long, String>();
ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
appInfoExampleCriteria.andCertBase64IsNotNull();
appInfoExampleCriteria.andIdEqualTo(id);
List<ApplicationInfo> applicationInfo = sqlSession.selectList("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
if (applicationInfo.isEmpty()) {
return null;
}
EvidenceCert cert = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertMapper.selectByPrimaryKey", Long.parseLong(applicationInfo.get(0).getCertBase64()));
if (cert != null) {
return cert.getCertBase64();
}
return null;
}
Aggregations