Class VerifiableCredential

  • All Implemented Interfaces:

    
    public final class VerifiableCredential
    
                        

    VerifiableCredential represents 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.

    • Constructor Detail

    • Method Detail

      • 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.

      • toString

         String toString()

        Converts the current object to its JSON representation.

        Returns:

        The JSON representation of the object.