Class DataRecordUploadToken

    • Constructor Summary

      Constructors 
      Constructor Description
      DataRecordUploadToken​(@NotNull java.lang.String blobId, @Nullable java.lang.String uploadId)
      Create an upload token from the provided blobId and uploadId.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static DataRecordUploadToken fromEncodedToken​(@NotNull java.lang.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.
      java.lang.String getBlobId()
      Returns the blob ID of this instance.
      java.lang.String getEncodedToken​(@org.jetbrains.annotations.NotNull byte[] secret)
      Generate an encoded, signed token string from this instance.
      java.util.Optional<java.lang.String> getUploadId()
      Returns the upload ID of this instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DataRecordUploadToken

        public DataRecordUploadToken​(@NotNull
                                     @NotNull java.lang.String blobId,
                                     @Nullable
                                     @Nullable java.lang.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 java.lang.String encoded,
                                                             @NotNull
                                                             @org.jetbrains.annotations.NotNull byte[] secret)
                                                      throws java.lang.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:
        java.lang.IllegalArgumentException - if the token string cannot be parsed or if validation fails.
      • getEncodedToken

        public java.lang.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 java.lang.String getBlobId()
        Returns the blob ID of this instance.
        Returns:
        The blob ID.
      • getUploadId

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