Search in sources :

Example 11 with UserInfo

use of cn.topca.tca.ra.service.UserInfo 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());
    // 创建RaCertManager类
    RaCertManager 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

UserInfo (cn.topca.tca.ra.service.UserInfo)11 CertInfo (cn.topca.tca.ra.service.CertInfo)10 JSONObject (com.alibaba.fastjson.JSONObject)6 ParseException (java.text.ParseException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 HashMap (java.util.HashMap)5 RaServiceUnavailable_Exception (cn.topca.tca.ra.service.RaServiceUnavailable_Exception)4 InvalidKeyException (java.security.InvalidKeyException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 Date (java.util.Date)4 UserAPIService (cn.topca.tca.ra.service.UserAPIService)3 UserAPIServicePortType (cn.topca.tca.ra.service.UserAPIServicePortType)3 CertUtlis (com.itrus.portal.utils.CertUtlis)3 URL (java.net.URL)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 RaAccount (com.itrus.portal.db.RaAccount)2 TerminalServiceException (com.itrus.portal.exception.TerminalServiceException)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 JSONArray (com.alibaba.fastjson.JSONArray)1 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)1