Class DataRecordUploadToken
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.blob.datastore.directaccess.DataRecordUploadToken
-
public class DataRecordUploadToken extends Object
Represents an upload token returned byDataRecordAccessProvider.initiateDataRecordUpload(long, int)
and used in subsequent calls toDataRecordAccessProvider.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 Summary
Constructors Constructor Description DataRecordUploadToken(@NotNull String blobId, @Nullable String uploadId)
Create an upload token from the providedblobId
anduploadId
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataRecordUploadToken
fromEncodedToken(@NotNull String encoded, @org.jetbrains.annotations.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(@org.jetbrains.annotations.NotNull byte[] secret)
Generate an encoded, signed token string from this instance.Optional<String>
getUploadId()
Returns the upload ID of this instance.
-
-
-
Constructor Detail
-
DataRecordUploadToken
public DataRecordUploadToken(@NotNull @NotNull String blobId, @Nullable @Nullable String uploadId)
Create an upload token from the providedblobId
anduploadId
. At creation time the token is not encoded or signed; to do that callgetEncodedToken(byte[])
after creating the token.- Parameters:
blobId
- The blob ID, usually aDataIdentifier
.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 benull
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.
-
-
Method Detail
-
fromEncodedToken
public static DataRecordUploadToken fromEncodedToken(@NotNull @NotNull String encoded, @NotNull @org.jetbrains.annotations.NotNull byte[] secret) throws IllegalArgumentException
Create an upload token instance from the provided encoded token string, using the provided secret key to verify the string. The encoded token string should have been created originally by a prior call togetEncodedToken(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()
.- Parameters:
encoded
- The encoded, signed token string.secret
- The secret key to be used to verify the contents of the token string.- Returns:
- A new instance containing the parsed upload token propreties.
- Throws:
IllegalArgumentException
- if the token string cannot be parsed or if validation fails.
-
getEncodedToken
public String getEncodedToken(@NotNull @org.jetbrains.annotations.NotNull byte[] secret)
Generate an encoded, signed token string from this instance. The resulting token can later be parsed and validated byfromEncodedToken(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()
.- Parameters:
secret
- The secret key used to sign the contents of the token.- Returns:
- An encoded token string that can later be used to uniquely and securely identify an upload.
-
getBlobId
public String getBlobId()
Returns the blob ID of this instance.- Returns:
- The blob ID.
-
-