Search in sources :

Example 11 with UserAPIServicePortTypeProxy

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

the class RaService method queryCertByCertId.

/**
 * 通过CERT_ID查询证书
 *
 * @Title: queryCertByCertId
 * @Description: TODO(通过CERT_ID查询证书 )
 * @param certId
 *            证书ID
 * @return JSONObject 返回结果信息
 * @throws JSONException
 */
public JSONObject queryCertByCertId(int certId) throws JSONException {
    JSONObject ret = new JSONObject();
    String json = "";
    if (certId == 0) {
        ret.put("code", "10010107");
        ret.put("msg", errorCode.getErrorCode().get(10010107));
        return ret;
    }
    try {
        if (CERT_ISKMC != null) {
            json = "{'certKmcReq2':'" + (CERT_ISKMC.equals("false") ? "" : "kmcClientVersion=20150130") + "','certValidity':'" + CERT_REQ_CHALLENGE + "'}";
        }
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        QueryCertResult result = proxy.queryCertByCertId(certId, ACCOUNT_HASH, json);
        ret.put("code", "0");
        ret.put("msg", "");
        ret.put("result", result);
    } catch (Exception e) {
        ret.put("code", "20010101");
        ret.put("msg", errorCode.getErrorCode().get(20010101) + ":" + e.getMessage());
        return ret;
    }
    return ret;
}
Also used : JSONObject(org.json.JSONObject) UserAPIServicePortTypeProxy(com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy) QueryCertResult(com.liumapp.digitalsign.test.ca.tianwei.query.QueryCertResult) JSONException(org.json.JSONException)

Example 12 with UserAPIServicePortTypeProxy

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

the class RaService method enrollCert.

/**
 * ENROLL模式 申请个人用户证书
 *
 * @Title: enrollCert
 * @Description: TODO(申请个人用户证书)
 * @param userInfo
 *            证书用户信息
 * @param certReqBuf
 *            证书请求,使用客户端的加密服务提供者来产生PKCS10格式的证书申请请求信息
 * @param passCode
 *            通行码,若使用通行码模式签发证书时则需要录入得到的通行码信息,缺省为""
 * @param certValidity
 *            证书有效期 ,若传入0,则默认使用services.properties配置的值
 * @return CertInfo 返回签发的证书信息
 * @throws JSONException
 */
public JSONObject enrollCert(UserInfo userInfo, String certReqBuf, String passCode, Integer certValidity) throws JSONException {
    JSONObject ret = new JSONObject();
    String json = "";
    // 用户名不能为空
    if (StringUtils.isEmpty(userInfo.getUserName())) {
        ret.put("code", "10010101");
        ret.put("msg", errorCode.getErrorCode().get(10010101));
        return ret;
    }
    // 用户邮箱不能为空
    if (StringUtils.isEmpty(userInfo.getUserEmail())) {
        ret.put("code", "10010102");
        ret.put("msg", errorCode.getErrorCode().get(10010102));
        return ret;
    }
    if (StringUtils.isEmpty(certReqBuf)) {
        ret.put("code", "10010103");
        ret.put("msg", errorCode.getErrorCode().get(10010103));
        return ret;
    }
    // 有效期为空
    if (certValidity == 0) {
        certValidity = CERT_VALIDITY;
    }
    try {
        if (CERT_ISKMC != null) {
            json = "{'certKmcReq2':'" + (CERT_ISKMC.equals("false") ? "" : "kmcClientVersion=20150130") + "','certValidity':'" + certValidity + "'}";
        }
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        proxy.enrollCert(userInfo, certReqBuf, ACCOUNT_HASH, CERT_REQ_CHALLENGE, json);
        ret.put("code", "0");
        ret.put("msg", "PassCode模式申请证书成功,请等待管理员批准......");
    } catch (Exception e) {
        ret.put("code", "20010101");
        ret.put("msg", errorCode.getErrorCode().get(20010101) + ":" + e.getMessage());
        return ret;
    }
    return ret;
}
Also used : JSONObject(org.json.JSONObject) UserAPIServicePortTypeProxy(com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy) JSONException(org.json.JSONException)

Example 13 with UserAPIServicePortTypeProxy

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

the class RaService method unsuspendCert.

/**
 * 恢复证书
 *
 * @Title: unsuspendCert
 * @Description: TODO(恢复证书 )
 * @param serialNumber
 *            证书序列号
 * @return JSONObject 返回结果信息
 * @throws JSONException
 */
public JSONObject unsuspendCert(String serialNumber) throws JSONException {
    JSONObject ret = new JSONObject();
    String json = "";
    if (StringUtils.isBlank(serialNumber)) {
        ret.put("code", "10010106");
        ret.put("msg", errorCode.getErrorCode().get(10010106));
        return ret;
    }
    try {
        if (CERT_ISKMC != null) {
            json = "{'certKmcReq2':'" + (CERT_ISKMC.equals("false") ? "" : "kmcClientVersion=20150130") + "','certValidity':'" + CERT_REQ_CHALLENGE + "'}";
        }
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        proxy.unsuspendCert(serialNumber, ACCOUNT_HASH, json);
        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 : JSONObject(org.json.JSONObject) UserAPIServicePortTypeProxy(com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy) JSONException(org.json.JSONException)

Example 14 with UserAPIServicePortTypeProxy

use of com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy 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 15 with UserAPIServicePortTypeProxy

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

the class RaService method suspendCert.

/**
 * 挂起证书
 *
 * @Title: suspendCert
 * @Description: TODO(挂起证书 )
 * @param serialNumber
 *            证书序列号
 * @return JSONObject 返回结果信息
 * @throws JSONException
 */
public JSONObject suspendCert(String serialNumber) throws JSONException {
    JSONObject ret = new JSONObject();
    String json = "";
    if (StringUtils.isBlank(serialNumber)) {
        ret.put("code", "10010106");
        ret.put("msg", errorCode.getErrorCode().get(10010106));
        return ret;
    }
    try {
        if (CERT_ISKMC != null) {
            json = "{'certKmcReq2':'" + (CERT_ISKMC.equals("false") ? "" : "kmcClientVersion=20150130") + "','certValidity':'" + CERT_REQ_CHALLENGE + "'}";
        }
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        proxy.suspendCert(serialNumber, ACCOUNT_HASH, json);
        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 : JSONObject(org.json.JSONObject) UserAPIServicePortTypeProxy(com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy) JSONException(org.json.JSONException)

Aggregations

UserAPIServicePortTypeProxy (com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy)16 JSONException (org.json.JSONException)15 JSONObject (org.json.JSONObject)14 CertInfo (com.liumapp.digitalsign.test.ca.tianwei.cert.CertInfo)3 QueryCertResult (com.liumapp.digitalsign.test.ca.tianwei.query.QueryCertResult)3 AccountConfigResult (com.liumapp.digitalsign.test.ca.tianwei.user.AccountConfigResult)1