public class DataRecordUploadToken extends Object
DataRecordAccessProvider.initiateDataRecordUpload(long, int) and
used in subsequent calls to DataRecordAccessProvider.completeDataRecordUpload(String). This class
handles creation, signing, and parsing of the token and uses a provided
secret key to sign the contents of the token and to validate contents of
tokens.| Constructor and Description |
|---|
DataRecordUploadToken(@NotNull String blobId,
@Nullable String uploadId)
Create an upload token from the provided
blobId and uploadId. |
| Modifier and Type | Method and Description |
|---|---|
static DataRecordUploadToken |
fromEncodedToken(@NotNull String encoded,
@NotNull byte[] secret)
Create an upload token instance from the provided encoded token string,
using the provided secret key to verify the string.
|
String |
getBlobId()
Returns the blob ID of this instance.
|
String |
getEncodedToken(@NotNull byte[] secret)
Generate an encoded, signed token string from this instance.
|
Optional<String> |
getUploadId()
Returns the upload ID of this instance.
|
public DataRecordUploadToken(@NotNull
@NotNull String blobId,
@Nullable
@Nullable String uploadId)
blobId and uploadId. At creation time the token is not encoded or signed; to do
that call getEncodedToken(byte[]) after creating the token.blobId - The blob ID, usually a DataIdentifier.uploadId - A free-form string used to identify this upload. This
may be provided by the service provider; if not a free-form
upload ID generated by the implementation will suffice. May be
null if no upload ID is available. However, some service
providers will require an upload ID to complete the upload so be
sure to check whether the service provider API provides one and
use that if it is available.public static DataRecordUploadToken fromEncodedToken(@NotNull @NotNull String encoded, @NotNull @NotNull byte[] secret) throws IllegalArgumentException
getEncodedToken(byte[]).
This method will parse and validate the contents of the provided encoded token string. An instance of this class is returned if the parsing and validation is successful.
A secret key is required to verify the encoded token. You are strongly
encouraged to use the secret key used by the data store backend
implementation. This key can be obtained by calling AbstractSharedBackend.getOrCreateReferenceKey().
encoded - The encoded, signed token string.secret - The secret key to be used to verify the contents of the
token string.IllegalArgumentException - if the token string cannot be parsed or
if validation fails.public String getEncodedToken(@NotNull @NotNull byte[] secret)
fromEncodedToken(String, byte[]).
A secret key is required to generate the encoded token. You are strongly
encouraged to use the secret key used by the data store backend
implementation. This key can be obtained by calling AbstractSharedBackend.getOrCreateReferenceKey().
secret - The secret key used to sign the contents of the token.public String getBlobId()
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.