Class ExternalAttachment


  • @Immutable
    public class ExternalAttachment
    extends Attachment
    External attachment. Provides a method to retrieve the remote content and verify its digest.

    Related specifications:

    • OpenID Connect for Identity Assurance 1.0, section 5.1.2.2.
    • Constructor Detail

      • ExternalAttachment

        public ExternalAttachment​(URI url,
                                  BearerAccessToken accessToken,
                                  long expiresIn,
                                  Digest digest,
                                  String description)
        Creates a new external attachment.
        Parameters:
        url - The attachment URL. Must not be null.
        accessToken - Optional access token of type Bearer for retrieving the attachment, null if none.
        expiresIn - Number of seconds until the attachment becomes unavailable and / or the access token becomes invalid. Zero or negative if not specified.
        digest - The cryptographic digest for the document content. Must not be null.
        description - The description, null if not specified.
    • Method Detail

      • getURL

        public URI getURL()
        Returns the attachment URL.
        Returns:
        The attachment URL.
      • getBearerAccessToken

        public BearerAccessToken getBearerAccessToken()
        Returns the optional access token of type Bearer for retrieving the attachment.
        Returns:
        The bearer access token, null if not specified.
      • getExpiresIn

        public long getExpiresIn()
        Returns the number of seconds until the attachment becomes unavailable and / or the access token becomes invalid.
        Returns:
        The number of seconds until the attachment becomes unavailable and / or the access token becomes invalid. Zero or negative if not specified.
      • getDigest

        public Digest getDigest()
        Returns the cryptographic digest for the document content.
        Returns:
        The cryptographic digest.
      • retrieveContent

        public Content retrieveContent​(int httpConnectTimeout,
                                       int httpReadTimeout)
                                throws IOException,
                                       NoSuchAlgorithmException,
                                       DigestMismatchException
        Retrieves the external attachment content and verifies its digest.
        Parameters:
        httpConnectTimeout - The HTTP connect timeout, in milliseconds. Zero implies no timeout. Must not be negative.
        httpReadTimeout - The HTTP response read timeout, in milliseconds. Zero implies no timeout. Must not be negative.
        Returns:
        The retrieved content.
        Throws:
        IOException - If retrieval of the content failed.
        NoSuchAlgorithmException - If the hash algorithm for the digest isn't supported.
        DigestMismatchException - If the computed digest for the retrieved document doesn't match the expected.
      • toJSONObject

        public net.minidev.json.JSONObject toJSONObject()
        Description copied from class: Attachment
        Returns a JSON object representation of this attachment.
        Overrides:
        toJSONObject in class Attachment
        Returns:
        The JSON object.
      • parse

        public static ExternalAttachment parse​(net.minidev.json.JSONObject jsonObject)
                                        throws ParseException
        Parses an external attachment from the specified JSON object.
        Parameters:
        jsonObject - The JSON object. Must not be null.
        Returns:
        The external attachment.
        Throws:
        ParseException - If parsing failed.