2. serialize
基本信息
- 接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.serialize
- 接口定义: <T extends JsonSerializer> ResponseData<byte[]> serialize(T object, ProtocolProperty property, WeIdAuthentication weIdAuthentication);
- 接口描述: 用于序列化对象,要求对象实现JsonSerializer接口
接口入参:
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
object | <T extends JsonSerializer> | Y | 待序列化对象 | |
property | ProtocolProperty | Y | 协议配置 | |
weIdAuthentication | WeIdAuthentication | Y | WeID公私钥信息 |
接口返回: com.webank.weid.protocol.response.ResponseData<byte[]>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | byte[] | 序列化后PDF文件的byte数组 | 业务数据 |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
CREDENTIAL_ISSUER_MISMATCH | 100403 | issuerWeId跟Credential中的issuer不匹配 |
CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN | 100431 | 存证签名异常 |
CREDENTIAL_EVIDENCE_BASE_ERROR | 100500 | Evidence标准错误 |
CREDENTIAL_EVIDENCE_HASH_MISMATCH | 100501 | Evidence Hash不匹配 |
TRANSPORTATION_BASE_ERROR | 100800 | transportation基本未知异常 |
TRANSPORTATION_PROTOCOL_PROPERTY_ERROR | 100801 | 协议配置异常 |
TRANSPORTATION_PROTOCOL_ENCODE_ERROR | 100803 | 协议配置Encode异常 |
TRANSPORTATION_ENCODE_BASE_ERROR | 100807 | Encode基本未知异常 |
TRANSPORTATION_PDF_TRANSFER_ERROR | 100808 | Pdf转换异常 |
WEID_AUTHORITY_INVALID | 100109 | 授权信息无效 |
WEID_PRIVATEKEY_DOES_NOT_MATCH | 100106 | 私钥与WeIdentity DID不匹配 |
WEID_DOES_NOT_EXIST | 100104 | WeIdentity DID不存在 |
PRESISTENCE_DATA_KEY_INVALID | 100901 | dataKey无效 |
DATA_TYPE_CASE_ERROR | 160008 | 数据转换异常 |
SQL_EXECUTE_FAILED | 160011 | SQL执行异常 |
SQL_GET_CONNECTION_ERROR | 160013 | 获取数据源连接异常 |
调用示例
- String weId = "did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f";
- List<String> verifierWeIdList = new ArrayList<String>();
- verifierWeIdList.add(weId);
- PresentationE presentation;
- WeIdAuthentication weIdAuthentication = new WeIdAuthentication();;
- //原文方式调用
- ResponseData<byte[]> result1 =
- TransportationFactory
- .newPdfTransportation()
- .specify(verifierWeIdList)
- .serialize(presentation,new ProtocolProperty(EncodeType.ORIGINAL),weIdAuthentication);
- //密文方式调用
- ResponseData<byte[]> result2 =
- TransportationFactory
- .newPdfTransportation()
- .specify(verifierWeIdList)
- .serialize(presentation,new ProtocolProperty(EncodeType.CIPHER),weIdAuthentication);