181 lines
5.1 KiB
Java
181 lines
5.1 KiB
Java
package com.sunyard.inf;
|
||
|
||
|
||
import com.sunyard.RetWrap;
|
||
import com.sunyard.cert.X509;
|
||
import com.sunyard.constant.CertUsage;
|
||
|
||
import java.io.UnsupportedEncodingException;
|
||
import java.util.List;
|
||
|
||
/**
|
||
* 证书操作相关接口
|
||
*/
|
||
public interface SydCertApi {
|
||
/**
|
||
* 通过证书的 DN,获取证书的序号。
|
||
* @param nCertType 输入 证书类型,0x00:签名证书,0x01:加密证书
|
||
* @param certDN 输入。证书 subject 的 DN。
|
||
* @return CertSerial 证书有 SN。
|
||
*/
|
||
String getX509SN(
|
||
int nCertType,
|
||
byte[] certDN
|
||
);
|
||
|
||
/**
|
||
* 通过证书 获得 DER编码的公钥。
|
||
* @param dnType 证书类型 0:签名证书, 1:加密证书
|
||
* @param dn 传入的证书
|
||
* @return 输出的公钥串,DER 编码,HEX 格式。输出的公钥串,DER 编码,HEX 格式。
|
||
*/
|
||
String GetDNPublicKey(
|
||
int dnType,
|
||
byte[] dn
|
||
);
|
||
|
||
/**
|
||
* 通过索引获取公钥
|
||
* @param userId 16位机构号
|
||
* @param nKeyTypes 密钥类型
|
||
* @return 公钥
|
||
*/
|
||
String RSAGetPublicKeyC(
|
||
String userId,
|
||
int nKeyTypes
|
||
);
|
||
|
||
/**
|
||
* 通过使用者 ID 获得使用者的 SM2 公钥(DER 编码)。
|
||
* @param userId 使用者的 ID,最大长度为 16 位数字,右对齐。
|
||
* @param nKeyTypes 密钥类型,0x00:签名公钥, 0x01:加密公钥。
|
||
* @return 输出的公钥串,DER 编码,HEX 格式。输出的公钥串,DER 编码,HEX 格式。
|
||
*/
|
||
String SM2GetPublicKeyC(
|
||
String userId,
|
||
int nKeyTypes
|
||
);
|
||
|
||
public String SM2GetPrivateKeyC(String privateKeyTag);
|
||
|
||
String SM2GetPublicKeyC_QX(
|
||
int userId,
|
||
int nKeyTypes
|
||
);
|
||
|
||
|
||
/**
|
||
* 输入 X509 格式的证书,获取证书信息。
|
||
* @param pCert base64 编码的证书
|
||
* @return 证书信息类
|
||
*/
|
||
X509 GetX509CertInfo(
|
||
String pCert
|
||
);
|
||
|
||
/**
|
||
* 通过SN获取 X509 证书信息
|
||
* @param sn sn,证书序号
|
||
* @param nCertType 证书类型,0:签名证书, 1:加密证书
|
||
* @return
|
||
*/
|
||
String GetX509CertFileBySN(String sn, int nCertType);
|
||
|
||
/**
|
||
* 通过使用者 ID 获取的 X509 证书文件。
|
||
* @param userId 使用者的 ID,最大长度为 16 位数字(要与生成实体的机构号保持一致)。
|
||
* @param nCertType 证书类型,0:签名证书, 1:加密证书
|
||
* @return base64 编码的证书
|
||
*/
|
||
String GetX509CertFileC(
|
||
String userId,
|
||
int nCertType
|
||
);
|
||
|
||
/**
|
||
* 从签名中获取证书并上载到加密机
|
||
* @param orgData 待签名的原始数据
|
||
* @param sign 签名数据
|
||
* @return 证书信息(包含公钥字段)
|
||
*/
|
||
public X509 SYD_Get_X509_CertInfo_HA(
|
||
byte[] orgData,
|
||
String sign
|
||
);
|
||
|
||
|
||
/**
|
||
* 查询所有证书
|
||
* @return
|
||
* certDNs: 证书DN
|
||
*/
|
||
List<String> getAllCert() throws UnsupportedEncodingException;
|
||
|
||
/**
|
||
* 查询所有证书
|
||
* @param dataFlag 数据包标志 0:起始包 1:中间包 2:结束包
|
||
* @return
|
||
* dataFlag: 数据包标志 0:起始包 1:中间包 2:结束包
|
||
* certAllNum: 证书总数
|
||
* realCertNum: 实际证书个数
|
||
* dataAttrFlag: 数据包属性标志
|
||
* certLenMax: 证书最大长度
|
||
* certDNs: 证书DN
|
||
*/
|
||
RetWrap getAllCert(int dataFlag) throws UnsupportedEncodingException;
|
||
|
||
|
||
/**
|
||
* 查询所有证书
|
||
* @param dataFlag 数据包标志 0:起始包 1:中间包 2:结束包
|
||
* @param sqlite 查询条件,默认查询所有"1=1"
|
||
* @return
|
||
* dataFlag: 数据包标志 0:起始包 1:中间包 2:结束包
|
||
* certAllNum: 证书总数
|
||
* realCertNum: 实际证书个数
|
||
* dataAttrFlag: 数据包属性标志
|
||
* certLenMax: 证书最大长度
|
||
* certDNs: 证书DN
|
||
*/
|
||
RetWrap getAllCert(int dataFlag,String sqlite) throws UnsupportedEncodingException;
|
||
|
||
|
||
|
||
/**
|
||
* 上传指定证书到加密设备
|
||
* @param certData 证书的字节数组
|
||
* @param organizationId 机构号的字节数组
|
||
* @param us 白名单类型
|
||
* @return
|
||
*/
|
||
RetWrap importCert(byte[] certData, byte[] organizationId, CertUsage... us);
|
||
RetWrap importCert(byte[] certData, byte[] organizationId);
|
||
|
||
String importCert(String cert);
|
||
|
||
|
||
/**
|
||
* 从加密设备中删除指定 DN 的公钥证书
|
||
* @param dn:传入的证书
|
||
*
|
||
* @return
|
||
*/
|
||
boolean deleteCert(String dn);
|
||
|
||
/**
|
||
* 上传指定证书到加密设备,并在证书前后加上begin和end
|
||
* @param certData 证书的字节数组
|
||
* @param organizationId 机构号的字节数组
|
||
* @param us 白名单类型
|
||
* @return
|
||
*/
|
||
RetWrap importCertAddHT(String certData, byte[] organizationId, CertUsage... us);
|
||
RetWrap importCertAddHT(String certData, byte[] organizationId);
|
||
|
||
|
||
String getCertByDn(String dn) throws UnsupportedEncodingException;
|
||
|
||
String getCertByDn(String dn,int type) throws UnsupportedEncodingException;
|
||
public String getCertByDn(byte[] dnBytes);
|
||
}
|