Add the JitPack repository to build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add dependency
<dependency>
<groupId>com.github.METADIUM</groupId>
<artifactId>identity-hub-client-java</artifactId>
<version>0.1.9</version>
</dependency>
Add root build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add dependency
dependencies {
implementation 'com.github.METADIUM:identity-hub-client-java:0.1.9'
}
String did = "{did of client}";
String keyId = "{id of key to sign}";
BCECPrivateKey privateKey = ..;
ECDSASigner signer = new ECDSASigner(privateKey); // signer with client private key
IdentityHub hubClient = new IdentityHub(true, did, keyId, signer);
String did = "{did of user}";
// Get verifiable credential
List<String> typesOfCrendential = Arrays.asList("VerifiableCredential", "NameCredential");
List<CommitObject> commitObjects = hubClient.getDecryptedCommitsOfObjects(did, typesOfCrendential, privateKey);
SignedJWT signedVc = commitObjects.get(0).getPayload().toSignedJWT();
VerifiableCrendentail vc = (VerifiableCrendentail)VerifiableSignedJWT.toVerifiable(signedVc);
// Get verifiable presentation
List<String> typesOfPresentation = Arrays.asList("VerifiablePresentation", "ServicePresentation");
List<CommitObject> commitObjects = hubClient.getDecryptedCommitsOfObjects(did, typesOfPresentation, privateKey);
SignedJWT signedVp = commitObject.get(0).getPayload().toSignedJWT();
VerifiablePresentation vp = (VerifiablePresentation)VerifiableSignedJWT.toVerifiable(signedVp);
// Get verifiable credential of verifiable presentation
for (Object vc : verifiedVp.getVerifiableCredentials()) {
SignedJWT signedVc = SignedJWT.parse((String)vc);
VerifiableCredential vc = (VerifiableCredential)VerifiableSignedJWT.toVerifiable(signedVc);
}