test_class.declarator: BLOB_ID = "blob"
test_class.modifier: private static final
test_class.original_string: private static final String BLOB_ID = "blob";
test_class.type: String
test_class.var_name: BLOB_ID
test_class.declarator: UPLOAD_ID = "upload"
test_class.modifier: private static final
test_class.original_string: private static final String UPLOAD_ID = "upload";
test_class.type: String
test_class.var_name: UPLOAD_ID
test_class.declarator: SECRET = "1234567890".getBytes(StandardCharsets.UTF_8)
test_class.modifier: private static final
test_class.original_string: private static final byte[] SECRET = "1234567890".getBytes(StandardCharsets.UTF_8);
test_class.type: byte[]
test_class.var_name: SECRET
test_class.file: oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/directaccess/DataRecordUploadTokenTest.java
test_class.identifier: DataRecordUploadTokenTest
test_case.body: @Test
      public void testUploadTokenSignature() {
          // simple test to check the signature is present and validated
          String spoofedToken = Base64.encodeBase64String((BLOB_ID + "#" + UPLOAD_ID).getBytes(StandardCharsets.UTF_8));
  
          try {
              DataRecordUploadToken.fromEncodedToken(spoofedToken, SECRET);
          } catch (IllegalArgumentException expected) {
          }
      }
test_case.class_method_signature: DataRecordUploadTokenTest.testUploadTokenSignature()
test_case.full_signature: @Test public void testUploadTokenSignature()
test_case.identifier: testUploadTokenSignature
test_case.invocations: encodeBase64String getBytes fromEncodedToken
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUploadTokenSignature()
focal_class.declarator: LOG = LoggerFactory.getLogger(DataRecordUploadToken.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger LOG = LoggerFactory.getLogger(DataRecordUploadToken.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: blobId
focal_class.modifier: private
focal_class.original_string: private String blobId;
focal_class.type: String
focal_class.var_name: blobId
focal_class.declarator: uploadId
focal_class.modifier: private
focal_class.original_string: private Optional<String> uploadId;
focal_class.type: Optional<String>
focal_class.var_name: uploadId
focal_class.file: oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/directaccess/DataRecordUploadToken.java
focal_class.identifier: DataRecordUploadToken
focal_class.class_method_signature: DataRecordUploadToken.DataRecordUploadToken(@NotNull String blobId, @Nullable String uploadId)
focal_class.full_signature: public  DataRecordUploadToken(@NotNull String blobId, @Nullable String uploadId)
focal_class.identifier: DataRecordUploadToken
focal_class.modifiers: public
focal_class.parameters: (@NotNull String blobId, @Nullable String uploadId)
focal_class.signature:  DataRecordUploadToken(@NotNull String blobId, @Nullable String uploadId)
focal_class.class_method_signature: DataRecordUploadToken.fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)
focal_class.full_signature: public static DataRecordUploadToken fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)
focal_class.identifier: fromEncodedToken
focal_class.modifiers: public static
focal_class.parameters: (@NotNull String encoded, @NotNull byte[] secret)
focal_class.return: DataRecordUploadToken
focal_class.signature: DataRecordUploadToken fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)
focal_class.class_method_signature: DataRecordUploadToken.getEncodedToken(@NotNull byte[] secret)
focal_class.full_signature: public String getEncodedToken(@NotNull byte[] secret)
focal_class.identifier: getEncodedToken
focal_class.modifiers: public
focal_class.parameters: (@NotNull byte[] secret)
focal_class.return: String
focal_class.signature: String getEncodedToken(@NotNull byte[] secret)
focal_class.class_method_signature: DataRecordUploadToken.getSignedString(String toBeSigned, byte[] secret)
focal_class.full_signature: private static String getSignedString(String toBeSigned, byte[] secret)
focal_class.identifier: getSignedString
focal_class.modifiers: private static
focal_class.parameters: (String toBeSigned, byte[] secret)
focal_class.return: String
focal_class.signature: String getSignedString(String toBeSigned, byte[] secret)
focal_class.class_method_signature: DataRecordUploadToken.encodeBase64(String string)
focal_class.full_signature: private static String encodeBase64(String string)
focal_class.identifier: encodeBase64
focal_class.modifiers: private static
focal_class.parameters: (String string)
focal_class.return: String
focal_class.signature: String encodeBase64(String string)
focal_class.class_method_signature: DataRecordUploadToken.encodeBase64(byte[] bytes)
focal_class.full_signature: private static String encodeBase64(byte[] bytes)
focal_class.identifier: encodeBase64
focal_class.modifiers: private static
focal_class.parameters: (byte[] bytes)
focal_class.return: String
focal_class.signature: String encodeBase64(byte[] bytes)
focal_class.class_method_signature: DataRecordUploadToken.decodeBase64(String encodedString)
focal_class.full_signature: private static String decodeBase64(String encodedString)
focal_class.identifier: decodeBase64
focal_class.modifiers: private static
focal_class.parameters: (String encodedString)
focal_class.return: String
focal_class.signature: String decodeBase64(String encodedString)
focal_class.class_method_signature: DataRecordUploadToken.getBlobId()
focal_class.full_signature: public String getBlobId()
focal_class.identifier: getBlobId
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getBlobId()
focal_class.class_method_signature: DataRecordUploadToken.getUploadId()
focal_class.full_signature: public Optional<String> getUploadId()
focal_class.identifier: getUploadId
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getUploadId()
focal_method.body: public static DataRecordUploadToken fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)
              throws IllegalArgumentException {
          final String[] parts = encoded.split("#", 2);
          if (parts.length < 2) {
              throw new IllegalArgumentException("Invalid upload token");
          }
  
          final String toBeDecoded = parts[0];
          final String expectedSig = parts[1];
          final String actualSig = getSignedString(toBeDecoded, secret);
          if (!expectedSig.equals(actualSig)) {
              throw new IllegalArgumentException("Invalid upload token");
          }
  
          String decoded = decodeBase64(toBeDecoded);
          String decodedParts[] = decoded.split("#");
          if (decodedParts.length < 2) {
              throw new IllegalArgumentException("Invalid upload token");
          }
  
          return new DataRecordUploadToken(decodedParts[0], decodedParts.length > 2 ? decodedParts[2] : null);
      }
focal_method.class_method_signature: DataRecordUploadToken.fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)
focal_method.full_signature: public static DataRecordUploadToken fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)
focal_method.identifier: fromEncodedToken
focal_method.invocations: split getSignedString equals decodeBase64 split
focal_method.modifiers: public static
focal_method.parameters: (@NotNull String encoded, @NotNull byte[] secret)
focal_method.return: DataRecordUploadToken
focal_method.signature: DataRecordUploadToken fromEncodedToken(@NotNull String encoded, @NotNull byte[] secret)