Class ExternalAttachment
- java.lang.Object
-
- com.nimbusds.openid.connect.sdk.assurance.evidences.attachment.Attachment
-
- com.nimbusds.openid.connect.sdk.assurance.evidences.attachment.ExternalAttachment
-
@Immutable public class ExternalAttachment extends Attachment
External attachment. Provides amethodto retrieve the remote content and verify its digest.Related specifications:
- OpenID Connect for Identity Assurance 1.0, section 5.1.2.2.
-
-
Constructor Summary
Constructors Constructor Description ExternalAttachment(URI url, BearerAccessToken accessToken, long expiresIn, Digest digest, String description)Creates a new external attachment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)BearerAccessTokengetBearerAccessToken()Returns the optional access token of type Bearer for retrieving the attachment.DigestgetDigest()Returns the cryptographic digest for the document content.longgetExpiresIn()Returns the number of seconds until the attachment becomes unavailable and / or the access token becomes invalid.URIgetURL()Returns the attachment URL.inthashCode()static ExternalAttachmentparse(net.minidev.json.JSONObject jsonObject)Parses an external attachment from the specified JSON object.ContentretrieveContent(int httpConnectTimeout, int httpReadTimeout)Retrieves the external attachment content and verifies its digest.net.minidev.json.JSONObjecttoJSONObject()Returns a JSON object representation of this attachment.-
Methods inherited from class com.nimbusds.openid.connect.sdk.assurance.evidences.attachment.Attachment
getDescriptionString, getType, parseList, toEmbeddedAttachment, toExternalAttachment
-
-
-
-
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 benull.accessToken- Optional access token of type Bearer for retrieving the attachment,nullif 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 benull.description- The description,nullif not specified.
-
-
Method Detail
-
getBearerAccessToken
public BearerAccessToken getBearerAccessToken()
Returns the optional access token of type Bearer for retrieving the attachment.- Returns:
- The bearer access token,
nullif 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:AttachmentReturns a JSON object representation of this attachment.- Overrides:
toJSONObjectin classAttachment- Returns:
- The JSON object.
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classAttachment
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAttachment
-
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 benull.- Returns:
- The external attachment.
- Throws:
ParseException- If parsing failed.
-
-