### Question:
Credential implements ConvertJwt { @Override public Jwt buildJwt(Date issued, Date expiration) { String kid = issuerDid.getDid() + "#" + issuerDid.getKeyId(); return new Jwt.Builder() .alg(issuerDid.getAlgorithm()) .kid(kid) .version(version) .sub(targetDid) .iss(issuerDid.getDid()) .iat(issued) .exp(expiration) .type(getTypes()) .claim(claim) .nonce(nonce) .jti(jti) .build(); } Credential(IssuerDid issuerDid); void setTargetDid(String did); void addClaim(String type, String value); void setClaim(Map<String, Object> claim); void setNonce(String nonce); void setJti(String jti); void setVersion(String version); String getTargetDid(); IssuerDid getIssuerDid(); Map<String, Object> getClaim(); List<String> getTypes(); String getDid(); String getKeyId(); String getAlgorithm(); String getNonce(); String getJti(); String getVersion(); @Override int getDuration(); @Override Jwt buildJwt(Date issued, Date expiration); static Credential valueOf(String encodedJwt); static Credential valueOf(Jwt jwt); @Override String toString(); static final String DEFAULT_TYPE; }### Answer:
@Test void testBuildJwt() throws Exception { String keyId = TestKeys.ISSUER_KEY_ID; AlgorithmProvider.Type type = AlgorithmProvider.Type.ES256; Algorithm algorithm = AlgorithmProvider.create(type); PrivateKey priKey = algorithm.byteToPrivateKey(EncodeType.HEX.decode(TestKeys.PRIVATE_KEY_ES256)); String did = "did:icon:0000961b6cd64253fb28c9b0d3d224be5f9b18d49f01da390f08"; Credential credential = new Credential.Builder() .algorithm(type.getName()) .keyId(keyId) .did(did) .build(); Assertions.assertEquals(did, credential.getIssuerDid().getDid()); String owner = "did:icon:0000961b6cd64253fb28c9b0d3d224be5f9b18d49f01da390f08"; credential.setTargetDid(owner); credential.addClaim("email", "aaa@icon.foundation"); String jwt = credential.buildJwt().sign(priKey); logger.debug("jwt : {}", jwt); }