use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class UnlockKeyBillController method loadProxyPdf.
@RequestMapping("/loadPorxyZSJSPdf")
public String loadProxyPdf(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "mPhone", required = false) String mPhone, HttpSession session, HttpServletRequest request, HttpServletResponse response) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
UserInfo webuserInfo = null;
if (null != userCert && null != userCert.getUserinfo()) {
webuserInfo = userInfoService.getUserInfoById(userCert.getUserinfo());
}
String firstMphone = "";
// 手机号处理,如果用户第一次申请解锁,而且没有绑定手机号,则先取用户输入的,再取证书绑定的,实在没有就放空
if (StringUtils.isNotBlank(mPhone)) {
firstMphone = mPhone;
} else if (null != webuserInfo) {
firstMphone = webuserInfo.getmPhone();
}
try {
enterpriseName = URLDecoder.decode(enterpriseName, "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
InputStream proxyIn = null;
// 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
try {
proxyIn = UserInfoWebController.class.getClassLoader().getResourceAsStream("/porxyZSJS.pdf");
response.reset();
String filename = "授权书.pdf";
filename = encodeFilename(filename, request);
response.setHeader("Content-disposition", "attachment;filename=" + filename);
response.setCharacterEncoding("utf-8");
// 由于导出格式是excel的文件,设置导出文件的响应头部信息
response.setContentType("application/pdf");
// 生成excel,传递输出流
// 用response对象获取输出流
OutputStream os = response.getOutputStream();
byte[] bos = PDFUtils.readPDF2(proxyIn, enterpriseName, keySn, certSn, firstMphone).toByteArray();
os.write(bos);
os.flush();
// 关闭os
if (os != null) {
os.close();
}
if (null != proxyIn) {
proxyIn.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class UnlockKeyBillController method getUnlockProducts.
/**
* 返回key对应的解锁产品列表
* 1.证书有绑定的用户,用户选择自助解锁,不需要进行短信码校验,直接提交
* 2.证书有绑定的用户,用户选择人工解锁(因为之前绑定的手机号可能没有了),进行短信校验后提交
* 3.证书没有绑定的用户,用户只能选择人工解锁(后台不返回自助解锁的产品了),进行短信码校验后,直接提交
* @param CertSn
* @param keySn
* @param uiModel
* @param request
* @return
*/
@RequestMapping("/getUnlockProducts")
public String getUnlockProducts(@RequestParam(value = "certBase64", required = true) String certBase64, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel, HttpServletRequest request) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
uiModel.addAttribute("errorMsg", "该证书尚未注册,请先注册后在使用");
return ComNames.CLIENTFW_ERRORPAGE;
}
// if (null == userCert.getUserinfo()) {
// uiModel.addAttribute("errorMsg", "该证书尚未绑定用户,请先绑定后再使用");
// return ComNames.CLIENTFW_ERRORPAGE;
// }
UserInfo webUserInfo = null;
uiModel.addAttribute("has_userInfo", 0);
if (null != userCert.getUserinfo()) {
webUserInfo = userInfoService.selectByPrimaryKey(userCert.getUserinfo());
uiModel.addAttribute("userInfo", webUserInfo);
uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
uiModel.addAttribute("has_userInfo", 1);
}
Enterprise enterprise = enterpriseService.getEntByName(enterpriseName);
uiModel.addAttribute("has_enterpriseInfo", 0);
if (null != enterprise) {
uiModel.addAttribute("enterprise", enterprise);
uiModel.addAttribute("has_enterpriseInfo", 1);
}
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
uiModel.addAttribute("errorMsg", "无法识别该key:" + keySn + ", 请联系系统管理员");
return ComNames.CLIENTFW_ERRORPAGE;
}
Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
List<Product> products = productService.getKeyUnlockProducts(project.getId(), userCert.getUserinfo());
if (null == products || products.isEmpty()) {
uiModel.addAttribute("errorMsg", "key序列号为:" + keySn + " 对应的解锁产品不存在, 请联系系统管理员进行处理");
return ComNames.CLIENTFW_ERRORPAGE;
}
uiModel.addAttribute("products", products);
// 电子开票服务
Long[] ereceiptIds = StringTools.getLong(products.get(0).geteBill());
Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
if (null == products.get(0).geteBill()) {
uiModel.addAttribute("ereceiptMapSize", 0);
}
uiModel.addAttribute("ereceiptMap", ereceiptMap);
return "clientFW/unlock_out";
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class UnlockKeyBillController method getUnlockProductsByLogin.
/**
* 用户登录后点击解锁,返回key对应的解锁产品列表
* @param CertSn
* @param keySn
* @param uiModel
* @param request
* @return
*/
@RequestMapping(value = "/getUnlockProductsByLogin")
public String getUnlockProductsByLogin(@RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, Model uiModel, HttpServletRequest request) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
uiModel.addAttribute("errorMsg", "该证书尚未注册,请先注册后在使用");
return ComNames.CLIENTFW_ERRORPAGE;
}
UserInfo webUserInfo = (UserInfo) request.getSession().getAttribute(ComNames.WEB_USER_INFO);
if (null == webUserInfo) {
uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
return ComNames.CLIENTFW_ERRORPAGE;
}
Enterprise enterprise = (Enterprise) request.getSession().getAttribute(ComNames.WEB_ENTERPRISE);
if (null == enterprise) {
uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
return ComNames.CLIENTFW_ERRORPAGE;
}
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
uiModel.addAttribute("errorMsg", "无法识别该key:" + keySn + ", 请联系系统管理员");
return ComNames.CLIENTFW_ERRORPAGE;
}
HttpSession session = request.getSession();
Integer has_enterpriseInfoInsession = (Integer) session.getAttribute("has_enterpriseInfo");
Integer hhas_userInfoInsession = (Integer) session.getAttribute("has_userInfo");
if (null == hhas_userInfoInsession) {
uiModel.addAttribute("has_userInfo", 0);
if (null != userCert.getUserinfo()) {
webUserInfo = userInfoService.selectByPrimaryKey(userCert.getUserinfo());
uiModel.addAttribute("userInfo", webUserInfo);
uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
uiModel.addAttribute("has_userInfo", 1);
}
}
if (null == has_enterpriseInfoInsession) {
uiModel.addAttribute("has_enterpriseInfo", 0);
if (null != enterprise) {
uiModel.addAttribute("enterprise", enterprise);
uiModel.addAttribute("has_enterpriseInfo", 1);
}
}
Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
List<Product> products = productService.getKeyUnlockProducts(project.getId(), userCert.getUserinfo());
if (null == products || products.isEmpty()) {
uiModel.addAttribute("errorMsg", "key序列号为:" + keySn + " 对应的解锁产品不存在, 请联系系统管理员进行处理");
return ComNames.CLIENTFW_ERRORPAGE;
}
uiModel.addAttribute("products", products);
uiModel.addAttribute("mPhone", webUserInfo.getmPhone());
// 电子开票服务
Long[] ereceiptIds = StringTools.getLong(products.get(0).geteBill());
Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
if (null == products.get(0).geteBill()) {
uiModel.addAttribute("ereceiptMapSize", 0);
}
uiModel.addAttribute("ereceiptMap", ereceiptMap);
return "clientFW/unlock_out";
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class UnlockKeyBillController method loadPorxy.
/**
* 加载授权书
*
* @return
*/
@RequestMapping("/loadPorxyZSJS")
public String loadPorxy(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "mPhone", required = false) String mPhone, HttpSession session, HttpServletResponse response) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
UserInfo webuserInfo = null;
if (null != userCert && null != userCert.getUserinfo()) {
webuserInfo = userInfoService.getUserInfoById(userCert.getUserinfo());
}
String firstMphone = "";
// 手机号处理,如果用户第一次申请解锁,而且没有绑定手机号,则先取用户输入的,再取证书绑定的,实在没有就放空
if (StringUtils.isNotBlank(mPhone)) {
firstMphone = mPhone;
} else if (null != webuserInfo) {
firstMphone = webuserInfo.getmPhone();
}
OutputStream os = null;
InputStream proxyIn = null;
InputStream streamTemp = null;
try {
proxyIn = UserInfoWebController.class.getClassLoader().getResourceAsStream("/porxy_ZSJS.html");
String proxyHtml = StringTools.readTextFile2(proxyIn, "UTF-8", enterpriseName, keySn, certSn, firstMphone);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("text/html; charset=utf-8");
os = response.getOutputStream();
os.write(proxyHtml.getBytes("UTF-8"));
os.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 关闭流!
try {
if (null != proxyIn) {
proxyIn.close();
}
if (null != streamTemp) {
streamTemp.close();
}
if (null != os) {
os.close();
}
} catch (IOException e) {
}
}
return null;
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class CertificateServiceController method securityCenter.
// 选出当前用户当前企业的所有证书和证书所绑定的用户信息
@RequestMapping("/securityCenter")
public String securityCenter(@RequestParam(value = "certSn", required = false) String certSn, HttpSession session, Model uiModel) {
UserInfo userInfos = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
if (null == userInfos || null == enterprise) {
// 登录状态失效,跳转到注册页面
return ComNames.DENG_LU_CLIENT;
}
if (StringUtils.isNotBlank(certSn) && certSn.length() > 10) {
uiModel.addAttribute("certSn", certSn);
} else if (null != session.getAttribute(ComNames.WEB_USER_CERT_SN)) {
uiModel.addAttribute("certSn", session.getAttribute(ComNames.WEB_USER_CERT_SN));
}
Map param = new HashMap();
param.put("userinfoid", userInfos.getId());
param.put("enterpriseid", enterprise.getId());
uiModel.addAttribute("userInfos", userInfos);
uiModel.addAttribute("enterprise", enterprise);
List<Map<String, Object>> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoAndEnterprise", param);
if (null != userCertList && !userCertList.isEmpty()) {
for (int i = 0; i < userCertList.size(); i++) {
if (null != userCertList.get(i).get("bill_status") && (userCertList.get(i).get("bill_status").equals(ComNames.BILL_STATUS_8) || userCertList.get(i).get("bill_status").equals(ComNames.BILL_STATUS_7) || userCertList.get(i).get("bill_status").equals(ComNames.BILL_STATUS_6)) && userCertList.get(i).containsKey("renewBillId")) {
// 状态为已完成的订单并且订单包含旧证书id
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", userCertList.get(i).get("renewBillId"));
if (null != bill.getOldUserCert()) {
UserCert oldUserCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", bill.getOldUserCert());
userCertList.get(i).put("oldCertSn", oldUserCert.getCertSn());
}
}
}
}
Map<Long, List<Map<String, Object>>> userCertMap = new HashMap();
for (Map<String, Object> map : userCertList) {
Long key = (Long) map.get("product");
List<Map<String, Object>> list = null;
if (userCertMap.containsKey(key)) {
list = userCertMap.get(key);
} else {
list = new ArrayList<>();
}
list.add(map);
userCertMap.put(key, list);
}
uiModel.addAttribute("userCertMap", userCertMap);
try {
String usercertsString = jsonTool.writeValueAsString(userCertList);
uiModel.addAttribute("usercerts", usercertsString);
List<String> allIssUerDn = new ArrayList<String>();
allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "clientFW/zhengshufuwu";
}
Aggregations