DID Store provides a series of reading and writing methods for stored objects, which can be divided into the following categories:
The store series method saves the DID object
The load series method reads the DID object
The contains series method tests whether the DID object is stored in the store
List series method list specific DID object set
The delete series method deletes the DID object
Ordinarily, only the document and Private Key of personal DID, as well as the associated verifiable credentials, are kept in DID Store. DID Document objects of others can be parsed and obtained from the ID sidechain and do not need to be saved in DID Store.
Related Operation of DID
DIDStore store; // an opened store instance
DIDDocument doc; // a DIDDoucment instance// Save the DID document to the storestore.storeDid(doc);// Load the DID document from the storeDIDDocument myDoc =store.loadDid("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq");// Check the store has this DID documentboolean exists =store.containsDid("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq");// Check the store has any DIDs existboolean exists =store.containsDid();// Delete the specific DIDstore.deleteDid("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq");// List all DIDs in the storeList<DID> dids =store.listDids();// Or list DIDs with a customized filterList<DID> dids =store.listDids((did) -> {// return true if include this DID, otherwise return false.returntrue; });
Related Operation of Verifiable Credentials
DIDStore store; // an opened store instanceVerifiableCredential vc; // a VerifiableCredential instance// Save the credential to the storestore.storeCredential(vc);// Load the credential from the storeVerifiableCredential myVc =store.loadCredential("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq#profile");// Check the store has this credentialboolean exists =store.containsCredential("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq#profile");// Check the store has any credential exists for specific DIDboolean exists =store.containsCredentials("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq");// Delete the specific credentialstore.deleteCredential("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq#profile");// List all credentials for specific DID in the storeList<DIDURL> vcIds =store.listCredentials("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq");// Or list credenitals with a customized filterList<DIDURL> vcIds =store.listCredentials("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq", (vcId) -> {// return true if include this credential, otherwise return false.returntrue; });
Related Operations of Root Identity
Related Operations of Private Key
DIDStore store; // an opened store instancebyte[] privateKey; // the plain binary private keyDIDURL keyId =newDIDURL("did:elastos:ihQQhyf6PW4YEc8mRi8AWmitCcMxz5kiBq#official");String storePasswd ="secret"; // should be your store password// Save the private key to the storestore.storePrivateKey(keyId, privateKey, storePasswd);// Check the private key exists in the storeboolean exists =store.containsPrivateKey(keyId);// Delete the specific private keystore.deletePrivateKey(keyId);