Search in sources :

Example 1 with UserAPIServicePortTypeProxy

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

the class RaService method enrollCertAA.

/**
 * AA模式申请证书或PASSCODE模式申请证书
 *
 * @Title: enrollCert
 * @Description: TODO(申请个人用户证书)
 * @param userInfo
 *            证书用户信息
 * @param certReqBuf
 *            证书请求,使用客户端的加密服务提供者来产生PKCS10格式的证书申请请求信息
 * @param passCode
 *            通行码,若使用通行码模式签发证书时则需要录入得到的通行码信息,缺省为""
 * @param certValidity
 *            证书有效期 ,若传入0,则默认使用services.properties配置的值
 * @return CertInfo 返回签发的证书信息
 * @throws JSONException
 */
public JSONObject enrollCertAA(UserInfo userInfo, String certReqBuf, String passCode, Integer certValidity) throws JSONException {
    CertInfo certInfo = new CertInfo();
    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();
        certInfo = proxy.enrollCertAA(userInfo, certReqBuf, ACCOUNT_HASH, CERT_REQ_CHALLENGE, passCode, json);
        if (CERT_ENROLL_MODEL.equals("AA")) {
            ret.put("code", "0");
            ret.put("certInfo", certInfo);
            ret.put("msg", "");
        } else {
            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 : 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 2 with UserAPIServicePortTypeProxy

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

the class RaService method downloadDeltaCRL.

/**
 * 下载增量CRL
 *
 * @Title: downloadCACrl
 * @Description: TODO(下载增量CRL)
 * @return JSONObject
 * @throws JSONException
 */
public JSONObject downloadDeltaCRL() throws JSONException {
    JSONObject ret = new JSONObject();
    try {
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        String deltaCRL = proxy.downloadDeltaCRL(ACCOUNT_HASH);
        ret.put("code", "0");
        ret.put("msg", "");
        ret.put("result", deltaCRL);
    } 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 3 with UserAPIServicePortTypeProxy

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

the class RaService method queryCertBySerialNumber.

/**
 * 通过序列号查询证书
 *
 * @Title: unsuspendCert
 * @Description: TODO(恢复证书 )
 * @param serialNumber
 *            证书序列号
 * @return JSONObject 返回结果信息
 * @throws JSONException
 */
public JSONObject queryCertBySerialNumber(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();
        QueryCertResult result = proxy.queryCertBySerialNumber(serialNumber, 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 4 with UserAPIServicePortTypeProxy

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

the class RaService method queryCerts.

/**
 * 查询个人用户证书信息
 *
 * @Title: queryCerts
 * @Description: TODO(查询个人用户证书信息)
 * @param userInfo
 *            证书用户信息
 * @param certInfo
 *            证书信息
 * @param currentPage
 *            页数[从第几页开始查询],若为空,默认从第一页开始
 * @parm pageSize 每页显示的数据条数
 * @return QueryCertResult 证书对象
 */
public QueryCertResult queryCerts(UserInfo userInfo, CertInfo certInfo, int currentPage, int pageSize) {
    try {
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        if (null != certInfo.getCertSerialNumber() && !"".equals(certInfo.getCertSerialNumber())) {
            QueryCertResult quertResult = proxy.queryCertBySerialNumber(certInfo.getCertSerialNumber().trim(), ACCOUNT_HASH.toString().trim(), null);
            return quertResult;
        }
        if (null != certInfo.getCertNotAfter() && !"".equals(certInfo.getCertNotAfter())) {
            String notAfterTime = DateUtil.convertBeginTimeToDBDate(certInfo.getCertNotAfter());
            certInfo.setCertNotAfter(notAfterTime);
        }
        if (null != certInfo.getCertNotBefore() && !"".equals(certInfo.getCertNotBefore())) {
            String notAfterTime = DateUtil.convertBeginTimeToDBDate(certInfo.getCertNotBefore());
            certInfo.setCertNotAfter(notAfterTime);
        }
        if (null == certInfo.getCertStatus() || "".equals(certInfo.getCertStatus())) {
            certInfo.setCertStatus("ALL");
        }
        QueryCertResult queryResult = proxy.queryCerts(userInfo, certInfo, currentPage - 1, pageSize, "selectValidCert", null, null, ACCOUNT_HASH);
        return queryResult;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : UserAPIServicePortTypeProxy(com.liumapp.digitalsign.test.ca.tianwei.proxy.UserAPIServicePortTypeProxy) QueryCertResult(com.liumapp.digitalsign.test.ca.tianwei.query.QueryCertResult) JSONException(org.json.JSONException)

Example 5 with UserAPIServicePortTypeProxy

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

the class RaService method renewCert.

/**
 * 更新个人用户证书
 *
 * @Title: renewCert
 * @Description: TODO(更新个人用户证书 )
 * @param certInfo
 *            旧证书对象
 * @param csrSignedData
 *            原证书的CSR签名信息
 * @param passCode
 *            通行码,在passcode更新模式下此项必填,在普通模式下此项可为空
 * @param certValidity
 *            证书有效期
 * @return JSONObject 返回结果信息
 * @throws JSONException
 */
public JSONObject renewCert(CertInfo certInfo, String csrSignedData, String passCode, Integer certValidity) throws JSONException {
    JSONObject ret = new JSONObject();
    if (null == certInfo.getCertReqBuf() || certInfo.getCertReqBuf().equals("")) {
        ret.put("code", "30010101");
        ret.put("msg", errorCode.getErrorCode().get(30010101));
        return ret;
    }
    if (null == certInfo.getCertSignBuf() && certInfo.getCertSignBuf().equals("")) {
        ret.put("code", "30010102");
        ret.put("msg", errorCode.getErrorCode().get(30010102));
        return ret;
    }
    String json = "";
    try {
        UserAPIServicePortTypeProxy proxy = axisUtil.getProxyNow();
        if ("passCodeModel".equals(CERT_RENEW_MODEL)) {
            // passcode模式
            if (passCode == null || passCode.trim().length() == 0) {
                ret.put("code", "10010104");
                ret.put("code", errorCode.getErrorCode().get(10010104));
                return ret;
            }
            json = "{'PKCSINFORMATION':'" + csrSignedData + "','CERT_REQ_BUF':'" + certInfo.getCertReqBuf() + "','certValidity':'" + certValidity + "'}";
            CertInfo certInfoRes = proxy.renewCertAA(null, certInfo, ACCOUNT_HASH, null, passCode, json);
            ret.put("certInfo", certInfoRes);
            ret.put("code", "0");
            ret.put("msg", "");
        } else if (CERT_ENROLL_MODEL.equals("AA")) {
            // AA模式
            json = "{'PKCSINFORMATION':'" + csrSignedData + "','CERT_REQ_BUF':'" + certInfo.getCertReqBuf() + "','certValidity':'" + certValidity + "'}";
            CertInfo certInfoRes = proxy.renewCertAA(null, certInfo, ACCOUNT_HASH, null, passCode, json);
            ret.put("certInfo", certInfoRes);
            ret.put("code", "0");
            ret.put("msg", "");
        } else {
            proxy.renewCert(null, certInfo, 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;
}
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)

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