5. serializeWithTemplate

基本信息

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

接口入参:

名称类型非空说明备注
object<T extends JsonSerializer>Y待序列化对象
propertyProtocolPropertyY协议配置
weIdAuthenticationWeIdAuthenticationYWeID公私钥信息
inputPdfTemplatePathStringY指定模板位置
outputPdfFilePathStringY输出PDF文件位置

接口返回: com.webank.weid.protocol.response.ResponseData<Boolean>;

名称类型说明备注
errorCodeInteger返回结果码
errorMessageString返回结果描述
resultBoolean序列化生成文件的结果

此方法返回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无效
ILLEGAL_INPUT160004参数非法
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. .serializeWithTemplate(
  14. presentation,
  15. new ProtocolProperty(EncodeType.ORIGINAL),
  16. weIdAuthentication,
  17. "./test-template.pdf",
  18. "./");
  19.  
  20. //密文方式调用
  21. ResponseData<byte[]> result2 =
  22. TransportationFactory
  23. .newPdfTransportation()
  24. .specify(verifierWeIdList)
  25. .serializeWithTemplate(
  26. presentation,
  27. new ProtocolProperty(EncodeType.CIPHER),
  28. weIdAuthentication,
  29. "./test-template.pdf",
  30. "./");