use of cn.topca.tca.ra.service.UserAPIService in project portal by ixinportal.
the class CertUtlis method enrollCertByWS.
// @Autowired
// private CaPasscodeService codeService;
public CertInfo enrollCertByWS(String csr, RaAccount raAccount, String uid) throws MalformedURLException, RaServiceUnavailable_Exception {
String json = "{\"certValidity\":" + 60 + "}";
CertInfo certInfo = null;
UserAPIService service = new UserAPIService(new URL(raAccount.getServiceUrl()));
UserAPIServicePortType client = service.getUserAPIServicePort();
// 用户信息
UserInfo userInfo = new UserInfo();
userInfo.setUserEmail("test@itrus.com.cn");
userInfo.setUserName("cceshi");
userInfo.setUserOrgunit(raAccount.getAccountOrgUnit());
userInfo.setUserOrganization(raAccount.getAccountOrganization());
userInfo.setUserAdditionalField1("123");
certInfo = client.enrollCertAA(userInfo, csr, raAccount.getAccountHash(), "itrusyes", "", json);
return certInfo;
}
use of cn.topca.tca.ra.service.UserAPIService in project portal by ixinportal.
the class EnrolCertTest method topcaCert.
public static void topcaCert(String accountOrgUnit, String accountOrganization, String serviceUrl, String accountHash, String csr) throws Exception {
String json = "{\"certValidity\":" + 60 + "}";
json = "{'certKmcReq2':'','certValidity':'12'}";
UserAPIService service = new UserAPIService(new URL(serviceUrl));
UserAPIServicePortType client = service.getUserAPIServicePort();
// 用户信息
UserInfo userInfo = new UserInfo();
userInfo.setUserEmail("test@itrus.com.cn");
userInfo.setUserName("cceshi");
userInfo.setUserOrgunit(accountOrgUnit);
userInfo.setUserOrganization(accountOrganization);
userInfo.setUserAdditionalField1("123");
CertInfo certInfo = client.enrollCertAA(userInfo, csr, accountHash, "itrusyes", "", json);
System.out.println(certInfo.getCertSerialNumber());
}
use of cn.topca.tca.ra.service.UserAPIService in project portal by ixinportal.
the class CertUtlis method renewAA.
/**
* 证书更新工具类
*
* @param serialnumber
* //旧的证书序列号
* @param csr
* //旧的证书的请求
* @param crt
* //旧的证书base64
* @param challenge
* //签发的RA口令,aapassword
* @param accountHash
* //RA的哈希值
* @param checkpoint
* //RA的服务密码
* @param passcode
* //passCode是一种申请证书的方式,不是以passCode方式申请,则填写""
* @param newCSR
* //新的证书请求
* @param pkcs7
* //浏览器产生的字符串
* @param raAccount
* //ra对象
* @return
* @throws javax.xml.ws.WebServiceException
* @throws RaServiceUnavailable_Exception
* @throws MalformedURLException
*/
public static CertInfo renewAA(String serialnumber, String crt, String challenge, String accountHash, String checkpoint, String passcode, String newCSR, String pkcs7, RaAccount raAccount) throws javax.xml.ws.WebServiceException, RaServiceUnavailable_Exception, MalformedURLException {
UserAPIService service = new UserAPIService(new URL(raAccount.getServiceUrl()));
UserAPIServicePortType client = service.getUserAPIServicePort();
// 新建一个空的用户信息传递过去
UserInfo raUserInfo = new UserInfo();
// 新建一个用户证书,并设置
CertInfo raCertInfo = new CertInfo();
raCertInfo.setCertSerialNumber(serialnumber);
// 签发的RA口令,先随便写一些进去
raCertInfo.setCertReqChallenge(challenge);
// raCertInfo.setCertReqBuf(csr);//旧的证书的请求
// 证书base64
raCertInfo.setCertSignBuf(crt);
String json = "{PKCSINFORMATION:'" + pkcs7 + "', certReqBuf:'" + newCSR + "'}";
return client.renewCertAA(raUserInfo, raCertInfo, accountHash, checkpoint, passcode, json);
}
use of cn.topca.tca.ra.service.UserAPIService 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