Search in sources :

Example 6 with CertInfo

use of com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo in project spring-cloud-digital-sign by SpringForAll.

the class UserAPIServiceSoapBindingStub method renewCertAA.

public CertInfo renewCertAA(UserInfo userInfo, CertInfo origin, String accountHash, String aaCheckPoint, String passCode, String json) throws java.rmi.RemoteException, RaServiceUnavailable {
    if (super.cachedEndpoint == null) {
        throw new org.apache.axis.NoEndPointException();
    }
    org.apache.axis.client.Call _call = createCall();
    _call.setOperation(_operations[5]);
    _call.setUseSOAPAction(true);
    _call.setSOAPActionURI("");
    _call.setEncodingStyle(null);
    _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
    _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
    _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
    _call.setOperationName(new QName("http://service.ra.tca.topca.cn/", "renewCertAA"));
    setRequestHeaders(_call);
    setAttachments(_call);
    try {
        java.lang.Object _resp = _call.invoke(new java.lang.Object[] { userInfo, origin, accountHash, aaCheckPoint, passCode, json });
        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException) _resp;
        } else {
            extractAttachments(_call);
            try {
                return (CertInfo) _resp;
            } catch (java.lang.Exception _exception) {
                return (CertInfo) org.apache.axis.utils.JavaUtils.convert(_resp, CertInfo.class);
            }
        }
    } catch (org.apache.axis.AxisFault axisFaultException) {
        if (axisFaultException.detail != null) {
            if (axisFaultException.detail instanceof java.rmi.RemoteException) {
                throw (java.rmi.RemoteException) axisFaultException.detail;
            }
            if (axisFaultException.detail instanceof RaServiceUnavailable) {
                throw (RaServiceUnavailable) axisFaultException.detail;
            }
        }
        throw axisFaultException;
    }
}
Also used : CertInfo(com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo) QName(javax.xml.namespace.QName) RaServiceUnavailable(com.liumapp.digitalsign.test.ca.tianwei.error.RaServiceUnavailable)

Example 7 with CertInfo

use of com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo in project spring-cloud-digital-sign by SpringForAll.

the class UserAPIServiceSoapBindingStub method enrollCertAA.

public CertInfo enrollCertAA(UserInfo userInfo, String certReqBuf, String accountHash, String aaCheckPoint, String passCode, String json) throws java.rmi.RemoteException, RaServiceUnavailable {
    if (super.cachedEndpoint == null) {
        throw new org.apache.axis.NoEndPointException();
    }
    org.apache.axis.client.Call _call = createCall();
    _call.setOperation(_operations[15]);
    _call.setUseSOAPAction(true);
    _call.setSOAPActionURI("");
    _call.setEncodingStyle(null);
    _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
    _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
    _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
    _call.setOperationName(new QName("http://service.ra.tca.topca.cn/", "enrollCertAA"));
    setRequestHeaders(_call);
    setAttachments(_call);
    try {
        java.lang.Object _resp = _call.invoke(new java.lang.Object[] { userInfo, certReqBuf, accountHash, aaCheckPoint, passCode, json });
        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException) _resp;
        } else {
            extractAttachments(_call);
            try {
                return (CertInfo) _resp;
            } catch (java.lang.Exception _exception) {
                return (CertInfo) org.apache.axis.utils.JavaUtils.convert(_resp, CertInfo.class);
            }
        }
    } catch (org.apache.axis.AxisFault axisFaultException) {
        if (axisFaultException.detail != null) {
            if (axisFaultException.detail instanceof java.rmi.RemoteException) {
                throw (java.rmi.RemoteException) axisFaultException.detail;
            }
            if (axisFaultException.detail instanceof RaServiceUnavailable) {
                throw (RaServiceUnavailable) axisFaultException.detail;
            }
        }
        throw axisFaultException;
    }
}
Also used : CertInfo(com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo) QName(javax.xml.namespace.QName) RaServiceUnavailable(com.liumapp.digitalsign.test.ca.tianwei.error.RaServiceUnavailable)

Example 8 with CertInfo

use of com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo in project spring-cloud-digital-sign by SpringForAll.

the class UserAPIServiceSoapBindingStub method _initOperationDesc1.

private static void _initOperationDesc1() {
    OperationDesc oper;
    ParameterDesc param;
    oper = new OperationDesc();
    oper.setName("queryCertByCertId");
    param = new ParameterDesc(new QName("", "certId"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "json"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://service.ra.tca.topca.cn/", "queryCertResult"));
    oper.setReturnClass(QueryCertResult.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[0] = oper;
    oper = new OperationDesc();
    oper.setName("downloadCRL");
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://www.w3.org/2001/XMLSchema", "string"));
    oper.setReturnClass(String.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[1] = oper;
    oper = new OperationDesc();
    oper.setName("enrollCert");
    param = new ParameterDesc(new QName("", "userInfo"), ParameterDesc.IN, new QName("http://service.ra.tca.topca.cn/", "userInfo"), UserInfo.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "certReqBuf"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "certReqChallenge"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "json"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[2] = oper;
    oper = new OperationDesc();
    oper.setName("unsuspendCert");
    param = new ParameterDesc(new QName("", "serialNumber"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "json"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[3] = oper;
    oper = new OperationDesc();
    oper.setName("queryCerts");
    param = new ParameterDesc(new QName("", "userInfo"), ParameterDesc.IN, new QName("http://service.ra.tca.topca.cn/", "userInfo"), UserInfo.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "certInfo"), ParameterDesc.IN, new QName("http://service.ra.tca.topca.cn/", "certInfo"), CertInfo.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "pageIndex"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "pageSize"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "int"), int.class, false, false);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "sqlTemplateFileName"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "nextResultTag"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "totalTag"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://service.ra.tca.topca.cn/", "queryCertResult"));
    oper.setReturnClass(QueryCertResult.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[4] = oper;
    oper = new OperationDesc();
    oper.setName("renewCertAA");
    param = new ParameterDesc(new QName("", "userInfo"), ParameterDesc.IN, new QName("http://service.ra.tca.topca.cn/", "userInfo"), UserInfo.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "origin"), ParameterDesc.IN, new QName("http://service.ra.tca.topca.cn/", "certInfo"), CertInfo.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "aaCheckPoint"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "passCode"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "json"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://service.ra.tca.topca.cn/", "certInfo"));
    oper.setReturnClass(CertInfo.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[5] = oper;
    oper = new OperationDesc();
    oper.setName("downloadDeltaCRL");
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://www.w3.org/2001/XMLSchema", "string"));
    oper.setReturnClass(String.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[6] = oper;
    oper = new OperationDesc();
    oper.setName("downloadCA");
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://www.w3.org/2001/XMLSchema", "string"));
    oper.setReturnClass(String.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[7] = oper;
    oper = new OperationDesc();
    oper.setName("doScript");
    param = new ParameterDesc(new QName("", "scriptName"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "jsonMap"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://www.w3.org/2001/XMLSchema", "string"));
    oper.setReturnClass(String.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[8] = oper;
    oper = new OperationDesc();
    oper.setName("pickupCert");
    param = new ParameterDesc(new QName("", "certPin"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "certReqChallenge"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "certReqBuf"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "accountHash"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    param = new ParameterDesc(new QName("", "json"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
    param.setOmittable(true);
    oper.addParameter(param);
    oper.setReturnType(new QName("http://service.ra.tca.topca.cn/", "certInfo"));
    oper.setReturnClass(CertInfo.class);
    oper.setReturnQName(new QName("", "return"));
    oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
    oper.setUse(org.apache.axis.constants.Use.LITERAL);
    oper.addFault(new org.apache.axis.description.FaultDesc(new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), "RaServiceUnavailable", new QName("http://service.ra.tca.topca.cn/", "RaServiceUnavailable"), true));
    _operations[9] = oper;
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) CertInfo(com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo) QName(javax.xml.namespace.QName) OperationDesc(org.apache.axis.description.OperationDesc)

Example 9 with CertInfo

use of com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo in project spring-cloud-digital-sign by SpringForAll.

the class RaService method pickupCert.

/**
 * 获取证书 *
 *
 * @Title: pickupCert
 *
 * @Description: TODO(申请个人用户证书)
 * @param pinCode
 *            PIN码
 * @param certReqBuf
 *            证书请求,使用客户端的加密服务提供者来产生PKCS10格式的证书申请请求信息
 * @return CertInfo 返回签发的证书信息
 * @throws JSONException
 */
public JSONObject pickupCert(String pinCode, String certReqBuf) throws JSONException {
    JSONObject ret = new JSONObject();
    String json = "";
    if (StringUtils.isBlank(pinCode)) {
        ret.put("code", "10010105");
        ret.put("msg", errorCode.getErrorCode().get("10010105"));
        return ret;
    }
    if (StringUtils.isBlank(certReqBuf)) {
        ret.put("code", "10010103");
        ret.put("msg", errorCode.getErrorCode().get(10010103));
        return ret;
    }
    try {
        if (CERT_ISKMC != null) {
            json = "{'certKmcReq2':'" + (CERT_ISKMC.equals("false") ? "" : "kmcClientVersion=20150130") + "','certValidity':'" + CERT_REQ_CHALLENGE + "'}";
        }
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        CertInfo certInfo = proxy.pickupCert(pinCode, CERT_REQ_CHALLENGE, certReqBuf, ACCOUNT_HASH, json);
        ret.put("certInfo", certInfo);
        ret.put("code", "0");
        ret.put("msg", "");
    } catch (Exception e) {
        ret.put("code", "20010101");
        ret.put("msg", errorCode.getErrorCode().get(20010101) + ":" + e.getMessage());
        return ret;
    }
    return ret;
}
Also used : CertInfo(com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo) JSONObject(org.json.JSONObject) UserAPIServicePortTypeProxy(com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy) JSONException(org.json.JSONException)

Example 10 with CertInfo

use of com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo in project spring-cloud-digital-sign by SpringForAll.

the class Certificate method installIntoJKS.

@RequestMapping("/jks")
public String installIntoJKS() {
    /**
     * 服务端生成证书,并保存成Pfx文件格式 *
     */
    String userName = "test_ca_002";
    String userEmail = "test@szitrus.com.cn";
    /**
     * 扩展字段是针对证书做扩展,即在证书的属性内增加如下内容,详细请联系天威诚信技术做解答 *
     */
    // String userAdditionalField1 = "";
    // String userAdditionalField2 = "";
    // String userAdditionalField3 = "";
    // String userAdditionalField4 = "";
    // String userAdditionalField5 = "";
    // String userAdditionalField6 = "";
    // String userAdditionalField7 = "";
    // String userAdditionalField8 = "";
    // String userAdditionalField9 = "";
    // String userAdditionalField10 = "";
    UserInfo userInfo = new UserInfo();
    // 证书名称
    userInfo.setUserName(userName);
    // 证书所有者Email
    userInfo.setUserEmail(userEmail);
    // userInfo.setUserAdditionalField1(userAdditionalField1); // 扩展字段1
    // userInfo.setUserAdditionalField2(userAdditionalField2); // 扩展字段2
    // userInfo.setUserAdditionalField3(userAdditionalField3); // 扩展字段3
    // userInfo.setUserAdditionalField4(userAdditionalField4); // 扩展字段4
    // userInfo.setUserAdditionalField5(userAdditionalField5); // 扩展字段5
    // userInfo.setUserAdditionalField6(userAdditionalField6); // 扩展字段6
    // userInfo.setUserAdditionalField7(userAdditionalField7); // 扩展字段7
    // userInfo.setUserAdditionalField8(userAdditionalField8); // 扩展字段8
    // userInfo.setUserAdditionalField9(userAdditionalField9); // 扩展字段9
    // userInfo.setUserAdditionalField10(userAdditionalField10); // 扩展字段10
    /**
     * 调用接口制作证书 *
     */
    String passCode = "";
    // 不设置证书有效期,默认读取services.properties的属性值
    Integer certValidity = 0;
    JSONObject jsonObject = new JSONObject();
    try {
        licenseUtil.registry();
        /**
         * 产生CSR(证书请求 即 p10) *
         */
        String certReqBuf = "";
        String csrType = "RSA1024";
        // keystore的alias名称
        String keystore = "demo.ks";
        if (csrType.equalsIgnoreCase("RSA1024")) {
            certReqBuf = CertStore.byName(keystore).genCsr(TCA.RSA1024).toBase64();
        } else if (csrType.equalsIgnoreCase("RSA2048")) {
            certReqBuf = CertStore.byName(keystore).genCsr(TCA.RSA2048).toBase64();
        } else {
            certReqBuf = CertStore.byName(keystore).genCsr(TCA.SM2).toBase64();
        }
        jsonObject = raService.enrollCertAA(userInfo, certReqBuf, passCode, certValidity);
        CertInfo certInfo = new CertInfo();
        if (jsonObject.get("certInfo") != null) {
            certInfo = (CertInfo) jsonObject.get("certInfo");
        }
        // 安装证书
        CertStore.installCert(certInfo.getCertSignBuf());
        // KeyStoreUtils.getPublicKeyAlias()
        System.out.println("当前申请的证书序列号是:[" + certInfo.getCertSerialNumber() + "]");
        System.out.println("当前存入JKS的证书别名为:[" + certInfo.getCertSerialnumberKmc() + "]");
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (CertApiException e) {
        e.printStackTrace();
    }
    return "success";
}
Also used : CertInfo(com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo) CertApiException(cn.topca.api.cert.CertApiException) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) UserInfo(com.liumapp.digitalsign.test.ca.tianwei.user.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CertInfo (com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo)10 QName (javax.xml.namespace.QName)5 JSONException (org.json.JSONException)5 JSONObject (org.json.JSONObject)5 RaServiceUnavailable (com.liumapp.digitalsign.test.ca.tianwei.error.RaServiceUnavailable)3 UserAPIServicePortTypeProxy (com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy)3 UserInfo (com.liumapp.digitalsign.test.ca.tianwei.user.UserInfo)2 OperationDesc (org.apache.axis.description.OperationDesc)2 ParameterDesc (org.apache.axis.description.ParameterDesc)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CertApiException (cn.topca.api.cert.CertApiException)1 ServerPKCSUtil (com.liumapp.digitalsign.test.ca.tianwei.utils.ServerPKCSUtil)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1