Issuer server guide(JAVA)

This is the Issuer SDK (Java) server guide document.

Issuer API

KeyManager Unlock

The private key is readable through IWKeyManager Class.

String keyManagerFile = "key.wallet";
String keyManagerPass = "keywalletPassword";

IWKeyManager keyManager = new IWKeyManager(keyManagerFile, keyManagerPass);
keyManager.unLock(keyManagerPass, new OnUnLockListener() {
    @Override
    public void onSuccess() {
        System.out.println("KeyManager Unlock onSuccess");
    }
    
    @Override
    public void onFail(int errCode) {
        System.out.println("KeyManager Unlock onFail:" + errCode);
    }
    
    @Override
    public void onCancel() {
         System.out.println("KeyManager Unlock onCancel");       
    }
});

Read DID Document

DID document can be read through the IWDIDFile class.

Use getData() function to transfer to the Jason string.

String issuerDidFile = "issuer.did";
IWDIDFile iwdidFile = new IWDIDFile(issuerDidFile);
String didDocJson = iwdidFile.getData();

System.out.println("didDocJson:" + didDocJson);

BlockChain node settings

BlockChain node settings can be set through the ServerInfo class.

String blockChainNodeUrl = "https://testnet.omnione.net:8888";
ServerInfo serverInfo = new ServerInfo(blockChainNodeUrl);

VC Issuing API

VC issuance consists of 2 steps.

  • vcInit: Initial settings of the VC issuance.

    Depending on the issuance, if there is no token transaction by the user, vcReg will initiate internally.

  • vcReg: Register the created VC to the BlockChain

VC Init

  • VcInitParam Class

    • ServerInfo - BlockChain node server information

    • IWKeyManager - private key Wallet management

    • mainKeyId - Stored KeyID in the KeyManager for signing

    • vcRequestJson - VC creation request string(JSON)

    • issuerDidFile - Issuer DID file path

    • vcTypeCode - VC TYPE Code

//vcRequestJson sample
{
  "claim": {
    "id": "did:omn:[account]",
    "privacy": {
      "unprotected": [
        //claim datas
      ]
    }
  },
  "proof": {
    "created": "[date]",
    "creator": "did:omn:[account]",
    "nonce": "[nonce]",
    "signatureValue": "[signatureValut]",
    "type": "[type]"
  }
}
  • IssuerApi.vcInit Class - Init Api

    • vcInit(VcInitParam vcInitParam)

  • VcResult Class - Result Class

    • issueCost - VC issuance cost(optional)

    • status - status information (required)

      • 0 = VC creation incomplete

      • 1 = VC creation completed

    • vcComplete - Completed VC(required)

    • vcDefCode - VC Code(optional)

VcInitParam vcInitParam = new VcInitParam(serverInfo,
                                         keyManager,
                                         "key1",
                                         vcRequestJson,
                                         issuerDidDocuemntPath,
                                         configBean.getVcAssertionId());
        

VcResult vcResult = IssuerApi.vcInit(vcInitParam);
if(vcResult.getStatus().equals("0")) {
			//VC is created but yet has not been registered on the BlockChain(The user MUST pay a token to register)
			VerifiableClaim vcComplete = vcResult.getVcCompelete();
			String vcCompleteJson = vcComplete.toJson();
			resultVc.setClaimBase64(GDPBase64.encodeUrlString(vcCompleteJson.getBytes()));

}else{
			//VC creation completed and registered on the BlockChain
			VerifiableClaim vcComplete = vcResult.getVcCompelete();
			String vcCompleteJson = vcComplete.toJson();
			resultVc.setClaimBase64(GDPBase64.encodeUrlString(vcCompleteJson.getBytes()));
}

return vcResult;

VC Reg

An API for the VC to register finally on the Blockchain.

  • VcRegParam Class - Reg Data

    • ServerInfo - BlockChain Node server information

    • keyManager - Private key Wallet management

    • mainKeyId - Stored KeyID in the KeyManager for signing

    • vcInitResultJson - VC Init result data (Json)

    • issuerDidFile - File path Issuer DID

    • txId - Token Transfer TX ID

vcInitResultJson is a JSON string converted data of vcResult received through vcInit.

  • IssuerApi.vcReg Class - Init API

    • vcReg(VcRegParam vcRegParam)

  • VcResult Class - Result Class

    • issueCost - VC issuing cost (optional)

    • status - status info (required)

      • 0 = VC creation incomplete

      • 1 = VC creation completed

    • vcComplete - Completed VC (essensial)

    • vcDefCode - VC code (optional)

VcRegParam vcRegParam = new VcRegParam(serverInfo, 
														keyManager, 
														"key1",
														vcResultJson,
														issuerDidDocuemntPath, 
														issueRegParam.getTxId(),
														issueRegParam.getBlockNum(),
														issueRegParam.getUserDid()
														);

VcResult vcResult = IssuerApi.vcReg(vcRegParam);
VerifiableClaim vcComplete = vcResult.getVcCompelete();
String vcCompleteJson = vcComplete.toJson();

Last updated