Class DataRecordUploadToken

    • Constructor Detail

      • DataRecordUploadToken

        public DataRecordUploadToken​(@NotNull
                                     @NotNull String blobId,
                                     @Nullable
                                     @Nullable String uploadId)
        Create an upload token from the provided blobId and uploadId. At creation time the token is not encoded or signed; to do that call getEncodedToken(byte[]) after creating the token.
        Parameters:
        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.
    • 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 to 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().

        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 by 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().

        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.
      • getUploadId

        public Optional<String> getUploadId()
        Returns the upload ID of this instance.
        Returns:
        The upload ID.