Search in sources :

Example 1 with RaCertManager

use of com.itrus.raapi.RaCertManager in project portal by ixinportal.

the class MobileCertificateService method revokeCertByApi.

// api方式吊销证书
private void revokeCertByApi(RaAccount raAccount, MobileCertificate mobileCert) throws RaServiceUnavailable_Exception {
    // 创建RaCertManagerRaCertManager raCertManager = RaFactory.getRaCertManager(raAccount.getAccountOrganization(), raAccount.getAccountOrgUnit());
    raCertManager.setAccountHash(raAccount.getAccountHash());
    // 设置RA服务IP地址、端口号和协议等
    raCertManager.addRaService(raAccount.getServiceUrl());
    RevokeResult revokeResult = null;
    try {
        // 对证书序列号进行一次转换,适应ICA的证书序列号方式
        revokeResult = raCertManager.revokeCert(CertUtils.getICAValidSerialNumber(mobileCert.getSequenceNumber()), ComNames.AA_PASS_PORT, RevokeReasonEnum.KeyCompromise);
        if (!revokeResult.isSuccess())
            throw new RaServiceUnavailable_Exception(revokeResult.getMessage());
    } catch (RaServiceUnavailable e) {
        // 服务全部停止
        throw new RaServiceUnavailable_Exception(e.getMessage());
    }
}
Also used : RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) RaCertManager(com.itrus.raapi.RaCertManager) RaServiceUnavailable(com.itrus.raapi.exception.RaServiceUnavailable) RevokeResult(com.itrus.raapi.result.RevokeResult)

Example 2 with RaCertManager

use of com.itrus.raapi.RaCertManager in project portal by ixinportal.

the class EnrolCertTest method iceCert.

public static void iceCert() throws Exception {
    String accountOrgUnit = "测试RA";
    String accountOrganization = "天威诚信数字认证中心";
    String serviceUrl = "http://topca-ra.itrus.com.cn/services/userAPI?wsdl";
    // 计算ra账户hash
    String accountHash = CipherUtils.md5((accountOrganization + accountOrgUnit.getBytes("GBK")).toUpperCase());
    // 创建RaCertManagerRaCertManager raCertManager = RaFactory.getRaCertManager(accountOrganization, accountOrgUnit);
    raCertManager.setAccountHash(accountHash);
    // 设置RA服务IP地址、端口号和协议等
    raCertManager.addRaService(serviceUrl);
    // 创建用户信息类
    com.itrus.raapi.info.UserInfo userInfo = new com.itrus.raapi.info.UserInfo();
    userInfo.setUserName("cceshi");
    userInfo.setUserEmail("test@itrus.com.cn");
    userInfo.setCertReqChallenge("itrusyes");
    // 申请证书
    CertInfo certInfo = null;
    OperationResult operationResult = null;
    operationResult = raCertManager.enrollCert(userInfo);
    if (operationResult instanceof PickupResult) {
        PickupResult pickupResult = (PickupResult) operationResult;
        if (pickupResult.isSuccess()) {
            certInfo = apiCertToWsCert(pickupResult);
        } else {
            System.out.println(operationResult.getMessage());
            System.out.println(pickupResult.getMessage());
        }
    } else if (operationResult != null) {
        System.out.println(operationResult.getMessage());
    }
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) PickupResult(com.itrus.raapi.result.PickupResult) RaCertManager(com.itrus.raapi.RaCertManager) UserInfo(cn.topca.tca.ra.service.UserInfo) OperationResult(com.itrus.raapi.result.OperationResult)

Aggregations

RaCertManager (com.itrus.raapi.RaCertManager)2 CertInfo (cn.topca.tca.ra.service.CertInfo)1 RaServiceUnavailable_Exception (cn.topca.tca.ra.service.RaServiceUnavailable_Exception)1 UserInfo (cn.topca.tca.ra.service.UserInfo)1 RaServiceUnavailable (com.itrus.raapi.exception.RaServiceUnavailable)1 OperationResult (com.itrus.raapi.result.OperationResult)1 PickupResult (com.itrus.raapi.result.PickupResult)1 RevokeResult (com.itrus.raapi.result.RevokeResult)1