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 amethod
to 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 boolean
equals(Object o)
BearerAccessToken
getBearerAccessToken()
Returns the optional access token of type Bearer for retrieving the attachment.Digest
getDigest()
Returns the cryptographic digest for the document content.long
getExpiresIn()
Returns the number of seconds until the attachment becomes unavailable and / or the access token becomes invalid.URI
getURL()
Returns the attachment URL.int
hashCode()
static ExternalAttachment
parse(net.minidev.json.JSONObject jsonObject)
Parses an external attachment from the specified JSON object.Content
retrieveContent(int httpConnectTimeout, int httpReadTimeout)
Retrieves the external attachment content and verifies its digest.net.minidev.json.JSONObject
toJSONObject()
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,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 benull
.description
- The description,null
if 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,
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 classAttachment
- Returns:
- The JSON object.
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classAttachment
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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.
-
-