2. serialize

基本信息

  1. 接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.serialize
  2. 接口定义: <T extends JsonSerializer> ResponseData<byte[]> serialize(T object, ProtocolProperty property, WeIdAuthentication weIdAuthentication);
  3. 接口描述: 用于序列化对象,要求对象实现JsonSerializer接口

接口入参:

名称类型非空说明备注
object<T extends JsonSerializer>Y待序列化对象
propertyProtocolPropertyY协议配置
weIdAuthenticationWeIdAuthenticationYWeID公私钥信息

接口返回: com.webank.weid.protocol.response.ResponseData<byte[]>;

名称类型说明备注
errorCodeInteger返回结果码
errorMessageString返回结果描述
resultbyte[]序列化后PDF文件的byte数组业务数据

此方法返回code

enumcodedesc
SUCCESS0成功
CREDENTIAL_ISSUER_MISMATCH100403issuerWeId跟Credential中的issuer不匹配
CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN100431存证签名异常
CREDENTIAL_EVIDENCE_BASE_ERROR100500Evidence标准错误
CREDENTIAL_EVIDENCE_HASH_MISMATCH100501Evidence Hash不匹配
TRANSPORTATION_BASE_ERROR100800transportation基本未知异常
TRANSPORTATION_PROTOCOL_PROPERTY_ERROR100801协议配置异常
TRANSPORTATION_PROTOCOL_ENCODE_ERROR100803协议配置Encode异常
TRANSPORTATION_ENCODE_BASE_ERROR100807Encode基本未知异常
TRANSPORTATION_PDF_TRANSFER_ERROR100808Pdf转换异常
WEID_AUTHORITY_INVALID100109授权信息无效
WEID_PRIVATEKEY_DOES_NOT_MATCH100106私钥与WeIdentity DID不匹配
WEID_DOES_NOT_EXIST100104WeIdentity DID不存在
PRESISTENCE_DATA_KEY_INVALID100901dataKey无效
DATA_TYPE_CASE_ERROR160008数据转换异常
SQL_EXECUTE_FAILED160011SQL执行异常
SQL_GET_CONNECTION_ERROR160013获取数据源连接异常

调用示例

  1. String weId = "did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f";
  2. List<String> verifierWeIdList = new ArrayList<String>();
  3. verifierWeIdList.add(weId);
  4.  
  5. PresentationE presentation;
  6. WeIdAuthentication weIdAuthentication = new WeIdAuthentication();;
  7.  
  8. //原文方式调用
  9. ResponseData<byte[]> result1 =
  10. TransportationFactory
  11. .newPdfTransportation()
  12. .specify(verifierWeIdList)
  13. .serialize(presentation,new ProtocolProperty(EncodeType.ORIGINAL),weIdAuthentication);
  14.  
  15. //密文方式调用
  16. ResponseData<byte[]> result2 =
  17. TransportationFactory
  18. .newPdfTransportation()
  19. .specify(verifierWeIdList)
  20. .serialize(presentation,new ProtocolProperty(EncodeType.CIPHER),weIdAuthentication);