Search in sources :

Example 1 with UserAPIServicePortType

use of cn.topca.tca.ra.service.UserAPIServicePortType 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;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) UserAPIServicePortType(cn.topca.tca.ra.service.UserAPIServicePortType) UserInfo(cn.topca.tca.ra.service.UserInfo) UserAPIService(cn.topca.tca.ra.service.UserAPIService) URL(java.net.URL)

Example 2 with UserAPIServicePortType

use of cn.topca.tca.ra.service.UserAPIServicePortType 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());
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) UserAPIServicePortType(cn.topca.tca.ra.service.UserAPIServicePortType) UserInfo(cn.topca.tca.ra.service.UserInfo) UserAPIService(cn.topca.tca.ra.service.UserAPIService) URL(java.net.URL)

Example 3 with UserAPIServicePortType

use of cn.topca.tca.ra.service.UserAPIServicePortType in project portal by ixinportal.

the class MobileCertificateService method revokeCertByWs.

// webService方式吊销证书
private void revokeCertByWs(RaAccount raAccount, MobileCertificate mobileCert) throws MalformedURLException, RaServiceUnavailable_Exception {
    UserAPIServicePortType userApi = getWsService(raAccount);
    // 对证书序列号进行一次转换,变为window的证书序列号格式
    userApi.revokeCert(CertUtilsOfUkey.getValidSerialNumber(mobileCert.getSequenceNumber()), ComNames.AA_PASS_PORT, RevokeReasonEnum.KeyCompromise, raAccount.getAccountHash(), null);
}
Also used : UserAPIServicePortType(cn.topca.tca.ra.service.UserAPIServicePortType)

Example 4 with UserAPIServicePortType

use of cn.topca.tca.ra.service.UserAPIServicePortType 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);
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) UserAPIServicePortType(cn.topca.tca.ra.service.UserAPIServicePortType) UserInfo(cn.topca.tca.ra.service.UserInfo) UserAPIService(cn.topca.tca.ra.service.UserAPIService) URL(java.net.URL)

Example 5 with UserAPIServicePortType

use of cn.topca.tca.ra.service.UserAPIServicePortType 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;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) RaAccountInfo(com.itrus.portal.db.RaAccountInfo) RaAccountInfoExample(com.itrus.portal.db.RaAccountInfoExample) TerminalServiceException(com.itrus.portal.exception.TerminalServiceException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) UserAPIServicePortType(cn.topca.tca.ra.service.UserAPIServicePortType) CaPasscode(com.itrus.portal.db.CaPasscode) UserAPIService(cn.topca.tca.ra.service.UserAPIService) URL(java.net.URL)

Aggregations

UserAPIServicePortType (cn.topca.tca.ra.service.UserAPIServicePortType)5 CertInfo (cn.topca.tca.ra.service.CertInfo)4 UserAPIService (cn.topca.tca.ra.service.UserAPIService)4 URL (java.net.URL)4 UserInfo (cn.topca.tca.ra.service.UserInfo)3 RaServiceUnavailable_Exception (cn.topca.tca.ra.service.RaServiceUnavailable_Exception)1 CaPasscode (com.itrus.portal.db.CaPasscode)1 RaAccountInfo (com.itrus.portal.db.RaAccountInfo)1 RaAccountInfoExample (com.itrus.portal.db.RaAccountInfoExample)1 TerminalServiceException (com.itrus.portal.exception.TerminalServiceException)1