use of com.itrus.portal.db.RaAccountInfoExample in project portal by ixinportal.
the class PasscodeController method list.
// 2.统计passcode情况
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
if (page == null || page < 1) {
page = 1;
}
if (size == null || size < 1) {
size = 10;
}
RaAccountInfoExample raiExample = new RaAccountInfoExample();
// RaAccountInfoExample.Criteria raiCriteria = raiExample.or();
Integer count = sqlSession.selectOne("com.itrus.portal.db.RaAccountInfoMapper.countByExample", raiExample);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
Integer offset = size * (page - 1);
raiExample.setOffset(offset);
raiExample.setLimit(size);
raiExample.setOrderByClause("create_time desc");
List<RaAccountInfo> raAccountInfos = sqlSession.selectList("com.itrus.portal.db.RaAccountInfoMapper.selectByExample", raiExample);
List<RaCaPassCode> racaPassCodes = new ArrayList<RaCaPassCode>();
for (RaAccountInfo rai : raAccountInfos) {
RaCaPassCode raca = new RaCaPassCode();
// 设置部门
raca.setOrganization(rai.getOrganization());
// 设置单位
raca.setOrgUnit(rai.getOrgUnit());
// 设置ra部门id
raca.setRaAccountInfoId(rai.getId());
CaPasscodeExample cpExample = new CaPasscodeExample();
CaPasscodeExample.Criteria caCriteria = cpExample.or();
caCriteria.andRaAccountInfoEqualTo(rai.getId());
Integer caPasscodeNum = sqlSession.selectOne("com.itrus.portal.db.CaPasscodeMapper.countByExample", cpExample);
// 设置总数量
raca.setCaPasscodeNum(caPasscodeNum);
// 2表示已使用的passcode
caCriteria.andStatusEqualTo(2);
Integer usedCodeNum = sqlSession.selectOne("com.itrus.portal.db.CaPasscodeMapper.countByExample", cpExample);
// 设置已使用的数量
raca.setUsedCodeNum(usedCodeNum);
// if (caPasscodeNum != 0)// 显示passcode总数不为0的记录
racaPassCodes.add(raca);
}
uiModel.addAttribute("racaPassCodes", racaPassCodes);
uiModel.addAttribute("itemcount", racaPassCodes.size());
return "passcode/list";
}
use of com.itrus.portal.db.RaAccountInfoExample in project portal by ixinportal.
the class CaPasscodeService method insertToDB.
/**
* 插入数据库<br>
* O , OU , AccountHash , 通行码 , 创建日期 , 截止日期 , 状态 , 描述 ,
*
* @param lists
*/
public void insertToDB(List<String[]> lists) {
SimpleDateFormat sim = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
// 将表头放入一个map集合
Map<String, Integer> titleMap = getColumnNum(lists.get(0));
for (int i = 1; i < lists.size(); i++) {
// 每一行的数据
String[] str = lists.get(i);
// 验证passcode是否已经存在数据库中
CaPasscodeExample caPasscodeExample = new CaPasscodeExample();
CaPasscodeExample.Criteria capaCriteria = caPasscodeExample.or();
capaCriteria.andPasscodeEqualTo(str[titleMap.get("通行码")]);
// capaCriteria.andStatusEqualTo(1);
CaPasscode caPa = sqlSession.selectOne("com.itrus.portal.db.CaPasscodeMapper.selectByExample", caPasscodeExample);
if (caPa == null) {
// passcode不存在数据库中,进行添加
// 获取RA账号的hash,根据hash值在RA账号信息表查询该RA账号是否存在,若不存在,则添加RA信息
RaAccountInfoExample raiExample = new RaAccountInfoExample();
RaAccountInfoExample.Criteria raiCriteria = raiExample.or();
raiCriteria.andHashValEqualTo(str[titleMap.get("AccountHash")]);
RaAccountInfo raAccountInfo = sqlSession.selectOne("com.itrus.portal.db.RaAccountInfoMapper.selectByExample", raiExample);
if (raAccountInfo == null) {
// 插入ra账户信息
raAccountInfo = new RaAccountInfo();
raAccountInfo.setCreateTime(new Date());
raAccountInfo.setHashVal(str[titleMap.get("AccountHash")]);
raAccountInfo.setOrganization(str[titleMap.get("O")]);
raAccountInfo.setOrgUnit(str[titleMap.get("OU")]);
sqlSession.insert("com.itrus.portal.db.RaAccountInfoMapper.insertSelective", raAccountInfo);
}
// 插入ca的passcode信息
CaPasscode caPasscode = new CaPasscode();
String start = str[titleMap.get("创建日期")] + " 23:59:59";
String end = str[titleMap.get("截止日期")] + " 00:00:00";
Date startTime;
try {
startTime = sim.parse(start);
Date endTime = sim.parse(end);
caPasscode.setStartTime(startTime);
caPasscode.setEndTime(endTime);
} catch (ParseException e) {
lists.clear();
e.printStackTrace();
}
caPasscode.setCreateTime(new Date());
// 通行码
caPasscode.setPasscode(str[titleMap.get("通行码")]);
// 假如不等于valid,则设置该passcode为无效,默认无效
int status = 3;
if ("VALID".equals(str[titleMap.get("状态")]))
// VALID用1代替:有效
status = 1;
// 设置passcode的状态
caPasscode.setStatus(status);
caPasscode.setRaAccountInfo(raAccountInfo.getId());
if (null != titleMap.get("IP地址")) {
// 描述
caPasscode.setIpAdd(str[titleMap.get("IP地址")]);
}
sqlSession.insert("com.itrus.portal.db.CaPasscodeMapper.insertSelective", caPasscode);
}
}
}
use of com.itrus.portal.db.RaAccountInfoExample in project portal by ixinportal.
the class CertUtlis method enrollCertByWS.
public CertInfo enrollCertByWS(String csr, RaAccount raAccount, UserInfo userInfo, Integer certValidity) throws MalformedURLException, RaServiceUnavailable_Exception, TerminalServiceException {
String json = "{\"certValidity\":" + certValidity + "}";
CertInfo certInfo = null;
UserAPIService service = new UserAPIService(new URL(raAccount.getServiceUrl()));
UserAPIServicePortType client = service.getUserAPIServicePort();
// 用户信息
try {
logger.error("***判断是什么模式***" + raAccount.getCertSignType());
// 判断是什么模式
if (raAccount.getCertSignType() == null || (raAccount.getCertSignType() != null && raAccount.getCertSignType() == 1)) {
// AA模式
logger.error("*****userInfo=" + userInfo + "***csr***=" + csr + "***raAccount.getAccountHash()**=" + raAccount.getAccountHash() + "***raAccount.getAaPassword()**=" + raAccount.getAaPassword() + "**json**=" + json);
certInfo = client.enrollCertAA(userInfo, csr, raAccount.getAccountHash(), raAccount.getAaPassword(), "", json);
} else {
// passcord模式
logger.error("输出hash*****raAccount.getAccountHash()========" + raAccount.getAccountHash());
// 判断是否为passcord模式
CaPasscode passcode = new CaPasscode();
// 获取对应ra账号的passcode
RaAccountInfoExample raInfoExample = new RaAccountInfoExample();
RaAccountInfoExample.Criteria raInfoCriteria = raInfoExample.createCriteria();
raInfoCriteria.andHashValEqualTo(raAccount.getAccountHash());
raInfoExample.setOrderByClause("create_time desc");
raInfoExample.setLimit(1);
RaAccountInfo raAccountInfo = raAccountInfoService.getRaAccountInfo(raInfoExample);
// 获取对应passcode
try {
passcode = codeService.IssuedCode4Cert(raAccountInfo);
if (passcode == null) {
logger.error("******passcode为空***********");
throw new TerminalServiceException("passcode为空");
}
} catch (TerminalServiceException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
throw e1;
}
logger.error("******passcode=" + passcode.getPasscode());
certInfo = client.enrollCertAA(userInfo, csr, raAccount.getAccountHash(), raAccount.getAaPassword(), passcode.getPasscode(), json);
}
} catch (RaServiceUnavailable_Exception e) {
logger.error("userInfo:" + ToStringBuilder.reflectionToString(userInfo));
logger.error("csr:" + csr);
logger.error("raAccount:" + ToStringBuilder.reflectionToString(raAccount));
logger.error("json:" + json);
throw e;
}
return certInfo;
}
Aggregations