Class VerifiableCredential
-
- All Implemented Interfaces:
public final class VerifiableCredentialVerifiableCredentialrepresents a digitally verifiable credential according to the W3C Verifiable Credentials Data Model.It provides functionalities to sign, verify, and create credentials, offering a concise API to work with JWT representations of verifiable credentials and ensuring that the signatures and claims within those JWTs can be validated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classVerifiableCredential.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Stringtypeprivate final Stringissuerprivate final Stringsubjectprivate final List<Object>evidenceprivate final CredentialSchemacredentialSchemaprivate final VerifiableCredentialvcDataModelpublic final static VerifiableCredential.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final StringgetType()final StringgetIssuer()final StringgetSubject()final List<Object>getEvidence()final CredentialSchemagetCredentialSchema()final VerifiableCredentialgetVcDataModel()The VcDataModel instance representing the core data model of a verifiable credential. final Stringsign(BearerDid did, String assertionMethodId)Sign a verifiable credential using a specified decentralized identifier (did) with the private key that pairs with the public key identified by assertionMethodId. final Stringsign(BearerDid did)Sign a verifiable credential using a specified decentralized identifier (did) with the private key that pairs with the public key identified by assertionMethodId. final StringgetFieldByJsonPath(String path)Retrieves a field from a verifiable credential by its JSON path. StringtoString()Converts the current object to its JSON representation. -
-
Method Detail
-
getSubject
final String getSubject()
-
getEvidence
final List<Object> getEvidence()
-
getCredentialSchema
final CredentialSchema getCredentialSchema()
-
getVcDataModel
final VerifiableCredential getVcDataModel()
The VcDataModel instance representing the core data model of a verifiable credential.
-
sign
@JvmOverloads() final String sign(BearerDid did, String assertionMethodId)
Sign a verifiable credential using a specified decentralized identifier (did) with the private key that pairs with the public key identified by assertionMethodId.
If the assertionMethodId is null, the function will attempt to use the first available verification method from the did. The result is a String in a JWT format.
- Parameters:
did- The BearerDid used to sign the credential.assertionMethodId- An optional identifier for the assertion method that will be used for verification of the produced signature.- Returns:
The JWT representing the signed verifiable credential.
Example:
val signedVc = verifiableCredential.sign(myDid)
-
sign
@JvmOverloads() final String sign(BearerDid did)
Sign a verifiable credential using a specified decentralized identifier (did) with the private key that pairs with the public key identified by assertionMethodId.
If the assertionMethodId is null, the function will attempt to use the first available verification method from the did. The result is a String in a JWT format.
- Parameters:
did- The BearerDid used to sign the credential.- Returns:
The JWT representing the signed verifiable credential.
Example:
val signedVc = verifiableCredential.sign(myDid)
-
getFieldByJsonPath
final String getFieldByJsonPath(String path)
Retrieves a field from a verifiable credential by its JSON path.
- Parameters:
path- The JSON path to the desired field.- Returns:
The field's value if found, or null if the field is not present.
-
-
-
-