Issue a Self-Proclaimed Credential

A self-proclaimed credential is one issued by oneself for self-declaration of specific information. An example of creating self-proclaimed credential is as follows:

DIDStore store; // an opened DIDStore instance
String storePasswd = "secret";
DID did = new DID("did:elastos:iaurnSo71QStq2vXdJCWiqXYZWmR499pjn");

DIDDocument doc = store.loadDid(doc);
Issuer selfIssuer = new Issuer(doc);

// Create a credential builder for self-proclaimed credential
VerifiableCredential.Builder cb = selfIssuer.issueFor(did);
// Create the credential
VerifiableCredential vc ="#profile")
    .type("EmailCredential", "")
    .type("SocialCredential", "")
    .property("name", "John");
    .property("gender", "Male");
    .property("nationality", "Singapore");
    .property("email", "");
    .property("twitter", "@john");

// Save the credential to the store for later usage

The credential issued by customized DID is consistent with primitive DID.

Last updated