Skip to content

Commit

Permalink
file updates (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
cworsnop-figure authored Jul 13, 2022
1 parent 65efc06 commit 9200b51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import io.provenance.api.domain.objectStore.ObjectStore
import io.provenance.api.domain.usecase.AbstractUseCase
import io.provenance.api.domain.usecase.common.originator.EntityManager
import io.provenance.api.domain.usecase.common.originator.models.KeyManagementConfigWrapper
import io.provenance.api.frameworks.config.ObjectStoreConfig
import io.provenance.api.domain.usecase.objectStore.get.models.RetrieveAndDecryptRequest
import io.provenance.api.frameworks.config.ObjectStoreConfig
import io.provenance.scope.objectstore.client.OsClient
import java.lang.IllegalStateException
import java.net.URI
import java.security.PrivateKey
import java.security.PublicKey
import org.apache.commons.codec.binary.Base64
import org.springframework.stereotype.Component
import java.util.Base64

@Component
class RetrieveAndDecrypt(
Expand All @@ -29,7 +28,12 @@ class RetrieveAndDecrypt(
?: throw IllegalStateException("Private key was not present for originator: ${args.uuid}")

OsClient(URI.create(args.objectStoreAddress), objectStoreConfig.timeoutMs).use { osClient ->
return objectStore.retrieveAndDecrypt(osClient, Base64.getUrlDecoder().decode(args.hash), publicKey, privateKey)
return objectStore.retrieveAndDecrypt(osClient, decodeBase64(args.hash), publicKey, privateKey)
}
}

private fun decodeBase64(string: String): ByteArray =
string.replace(' ', '+').let {
Base64.decodeBase64(it)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StoreFile(
URI.create(args.request.getAsType<FormFieldPart>("objectStoreAddress").value()),
objectStoreConfig.timeoutMs,
).use { osClient ->
if (!args.storeRawBytes) {
if (!args.request.getAsType<FormFieldPart>("storeRawBytes").value().toBoolean()) {
message = AssetOuterClassBuilders.Asset {
idBuilder.value = args.request.getAsType<FormFieldPart>("id").value()
type = FileNFT.ASSET_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import org.springframework.http.codec.multipart.Part

data class StoreFileRequestWrapper(
val uuid: UUID,
val request: Map<String, Part>,
val storeRawBytes: Boolean = false,
val request: Map<String, Part>
)

data class SwaggerStoreFileRequestWrapper(
Expand Down

0 comments on commit 9200b51

Please sign in to comment.