use of com.itrus.portal.db.RealNameAuthentication in project portal by ixinportal.
the class BasicInformationController method download.
/**
* 下载回执报告
*
* @param evidenceSn
* @param request
* @param response
* @param uiModel
* @return
* @throws Exception
*/
@RequestMapping(value = "outpdf/{evidenceSn}")
public String download(@PathVariable("evidenceSn") String evidenceSn, HttpServletRequest request, HttpServletResponse response, Model uiModel) throws Exception {
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
String fileName = null;
if (realNameAuthentication == null) {
realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
}
try {
if (realNameAuthentication == null) {
String oper = "下载回执报告失败";
String info = "失败原因:服务器出错,请联系管理员";
LogUtil.evidencelog(sqlSession, null, oper, info);
return "服务器出错,请联系管理员";
}
// 得到接口路径
String urlAgent = realNameAuthentication.getRealNameddress();
EvidenceEnclosureExample enclo = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria enclosureEx = enclo.createCriteria();
enclosureEx.andEvidenceSnEqualTo(evidenceSn);
enclosureEx.andPdfTypeEqualTo("3");
EvidenceEnclosure enclosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclo);
if (enclosure == null) {
return "未找到该证据编号的信息";
}
String base64 = EvidenceSaveServiceApi.decryptedAndDownload(sqlSession, enclosure.getBuid(), urlAgent);
response.reset();
fileName = Calendar.getInstance().getTimeInMillis() + "";
fileName = reportTemplate.chineseUtf(fileName, request);
response.addHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".pdf").getBytes("utf-8"), "iso-8859-1"));
response.setCharacterEncoding("utf-8");
response.setContentType("application/pdf");
if (base64 == null || base64.contains("exception")) {
String oper = "下载回执报告失败";
String info = "失败原因:base64为空";
LogUtil.evidencelog(sqlSession, null, oper, info);
return "base64为空";
}
BASE64Decoder decoder = new BASE64Decoder();
try {
// Base64解码
byte[] bytes = decoder.decodeBuffer(base64);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {
// 调整异常数据
bytes[i] += 256;
}
}
// FileOutputStream out = new
// FileOutputStream("D:/test/itext/123.pdf");
// 生成文件的路径
OutputStream out = response.getOutputStream();
// OutputStream os = new
// BufferedOutputStream(response.getOutputStream());
out.write(bytes);
out.flush();
out.close();
String oper = "下载回执报告成功";
String info = "报告名称:" + fileName + ".pdf";
LogUtil.evidencelog(sqlSession, null, oper, info);
} catch (Exception e) {
String oper = "下载回执报告失败";
String info = "失败原因:" + e.getMessage();
LogUtil.evidencelog(sqlSession, null, oper, info);
return e.getMessage();
}
} catch (Exception e) {
// TODO Auto-generated catch
e.printStackTrace();
String oper = "下载回执报告失败";
String info = "失败原因:" + e.getMessage();
LogUtil.evidencelog(sqlSession, null, oper, info);
}
return null;
}
use of com.itrus.portal.db.RealNameAuthentication in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method getRealNameAuthenticationByTwo.
/**
* 获取密码服务配置
* @return
* @throws Exception
*/
public RealNameAuthentication getRealNameAuthenticationByTwo() throws Exception {
RealNameAuthenticationExample re = new RealNameAuthenticationExample();
RealNameAuthenticationExample.Criteria rec = re.createCriteria();
rec.andTypeEqualTo(2);
RealNameAuthentication realname = this.getRealNameAuthenticationExample(re);
return realname;
}
use of com.itrus.portal.db.RealNameAuthentication in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method getRealNameAuthenticationByThree.
/**
* 获取时间戳服务配置
* @return
* @throws Exception
*/
public RealNameAuthentication getRealNameAuthenticationByThree() throws Exception {
RealNameAuthenticationExample re = new RealNameAuthenticationExample();
RealNameAuthenticationExample.Criteria rec = re.createCriteria();
rec.andTypeEqualTo(3);
RealNameAuthentication realname = this.getRealNameAuthenticationExample(re);
return realname;
}
use of com.itrus.portal.db.RealNameAuthentication in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method getRealNameAuthenticationByOne.
/**
* 获取原子服务配置
* @return
* @throws Exception
*/
public RealNameAuthentication getRealNameAuthenticationByOne() throws Exception {
RealNameAuthenticationExample re = new RealNameAuthenticationExample();
RealNameAuthenticationExample.Criteria rec = re.createCriteria();
rec.andTypeEqualTo(1);
RealNameAuthentication realname = this.getRealNameAuthenticationExample(re);
return realname;
}
use of com.itrus.portal.db.RealNameAuthentication in project portal by ixinportal.
the class AuthService method getToken.
// @Autowired
// private static RealNameAuthenticationSerivceImpl authenticationSerivceImpl = new RealNameAuthenticationSerivceImpl();
/**
* 获得token
* 访问其他接口的时候 在头信息增加 Authorization :bear+token bear和token之间加个空格
*/
private static String getToken() {
// client_secret:43b484748d3a936330bc50da70d6ce69e1dfef90
try {
// RealNameAuthentication realNameAuthentication = authenticationSerivceImpl.getRealNameAuthenticationExample(new RealNameAuthenticationExample());
long nowDate = System.currentTimeMillis();
if (ACCESS_TOKEN != null && new Date(nowDate + inDateTime).before(inDate)) {
return ACCESS_TOKEN;
}
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
if (realNameAuthentication == null) {
List<RealNameAuthentication> list = SpringContextHolder.getBean(SqlSession.class).selectList("com.itrus.portal.db.RealNameAuthenticationMapper.selectByExample", new RealNameAuthenticationExample());
if (list == null || list.isEmpty()) {
return null;
}
for (RealNameAuthentication nameAuthentication : list) {
if (nameAuthentication.getType() == 2)
realNameAuthentication = nameAuthentication;
}
if (realNameAuthentication == null) {
return null;
}
}
Map params = new HashMap();
params.put("grant_type", "client_credentials");
params.put("client_id", realNameAuthentication.getIdCode());
params.put("client_secret", realNameAuthentication.getKeyCode());
String rep = HttpClientUtil.postForm(realNameAuthentication.getAccessTokenaddress() + TOKEN, null, params);
// System.out.println("AuthService getToken()_rep : " + rep);
JSONObject data = JSON.parseObject(rep);
ACCESS_TOKEN = data.getString("access_token");
inDate = new Date(nowDate + data.getLongValue("expires_in"));
return ACCESS_TOKEN;
} catch (RestClientException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations