-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de96258
commit f6b9e9a
Showing
14 changed files
with
143 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
models/src/main/kotlin/io/provenance/api/models/p8e/tx/permissions/DataAccessChangeType.kt
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
models/src/main/kotlin/io/provenance/api/models/p8e/tx/permissions/authz/AuthzChange.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.provenance.api.models.p8e.tx.permissions.authz | ||
|
||
import java.time.OffsetDateTime | ||
|
||
data class AuthzChange( | ||
val type: AuthzChangeType, | ||
val envelopeState: String, | ||
val expiration: OffsetDateTime = OffsetDateTime.now().plusHours(1), | ||
) |
6 changes: 6 additions & 0 deletions
6
models/src/main/kotlin/io/provenance/api/models/p8e/tx/permissions/authz/AuthzChangeType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.provenance.api.models.p8e.tx.permissions.authz | ||
|
||
enum class AuthzChangeType { | ||
ADD, | ||
REMOVE | ||
} |
12 changes: 12 additions & 0 deletions
12
...s/src/main/kotlin/io/provenance/api/models/p8e/tx/permissions/authz/UpdateAuthzRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.provenance.api.models.p8e.tx.permissions.authz | ||
|
||
import io.provenance.api.models.account.AccountInfo | ||
import io.provenance.api.models.eos.ObjectStoreConfig | ||
import io.provenance.api.models.p8e.ProvenanceConfig | ||
|
||
data class UpdateAuthzRequest( | ||
val client: ObjectStoreConfig, | ||
val account: AccountInfo = AccountInfo(), | ||
val provenanceConfig: ProvenanceConfig, | ||
val changes: List<AuthzChange> | ||
) |
6 changes: 6 additions & 0 deletions
6
...ain/kotlin/io/provenance/api/models/p8e/tx/permissions/dataAccess/DataAccessChangeType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.provenance.api.models.p8e.tx.permissions.dataAccess | ||
|
||
enum class DataAccessChangeType { | ||
ADD, | ||
REMOVE | ||
} |
2 changes: 1 addition & 1 deletion
2
...ls/p8e/tx/permissions/DataAccessUpdate.kt → ...ermissions/dataAccess/DataAccessUpdate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rmissions/UpdateScopeDataAccessRequest.kt → ...ataAccess/UpdateScopeDataAccessRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...tlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/UpdateAuthzGrant.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.provenance.api.domain.usecase.provenance.tx.permissions.authz | ||
|
||
import io.provenance.api.domain.usecase.AbstractUseCase | ||
import io.provenance.api.domain.usecase.cee.common.client.CreateClient | ||
import io.provenance.api.domain.usecase.cee.common.client.model.CreateClientRequest | ||
import io.provenance.api.domain.usecase.provenance.account.GetSigner | ||
import io.provenance.api.domain.usecase.provenance.account.models.GetSignerRequest | ||
import io.provenance.api.domain.usecase.provenance.tx.permissions.authz.models.UpdateAuthzRequestWrapper | ||
import io.provenance.api.frameworks.provenance.ProvenanceService | ||
import io.provenance.api.frameworks.provenance.extensions.toTxResponse | ||
import io.provenance.api.models.p8e.TxResponse | ||
import io.provenance.api.models.p8e.tx.permissions.authz.AuthzChangeType | ||
import io.provenance.client.protobuf.extensions.toAny | ||
import io.provenance.client.protobuf.extensions.toTxBody | ||
import io.provenance.scope.contract.proto.Envelopes | ||
import java.util.Base64 | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class UpdateAuthzGrant( | ||
private val createClient: CreateClient, | ||
private val provenanceService: ProvenanceService, | ||
private val getSigner: GetSigner | ||
) : AbstractUseCase<UpdateAuthzRequestWrapper, TxResponse>() { | ||
override suspend fun execute(args: UpdateAuthzRequestWrapper): TxResponse { | ||
val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) | ||
val messages = createClient.execute(CreateClientRequest(args.uuid, args.request.account, args.request.client)).let { client -> | ||
args.request.changes.flatMap { change -> | ||
when (change.type) { | ||
AuthzChangeType.ADD -> { | ||
client.approveScopeUpdate(Envelopes.EnvelopeState.newBuilder().mergeFrom(Base64.getDecoder().decode(change.envelopeState)).build(), change.expiration).map { it.toAny() } | ||
} | ||
AuthzChangeType.REMOVE -> { | ||
client.revokeScopeUpdate(Envelopes.EnvelopeState.newBuilder().mergeFrom(Base64.getDecoder().decode(change.envelopeState)).build()).map { it.toAny() } | ||
} | ||
} | ||
}.toTxBody() | ||
} | ||
|
||
return provenanceService.executeTransaction(args.request.provenanceConfig, messages, signer).toTxResponse() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...ce/api/domain/usecase/provenance/tx/permissions/authz/models/UpdateAuthzRequestWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.provenance.api.domain.usecase.provenance.tx.permissions.authz.models | ||
|
||
import io.provenance.api.models.p8e.tx.permissions.authz.UpdateAuthzRequest | ||
import java.util.UUID | ||
|
||
data class UpdateAuthzRequestWrapper( | ||
val uuid: UUID, | ||
val request: UpdateAuthzRequest | ||
) |
6 changes: 3 additions & 3 deletions
6
...e/tx/permissions/UpdateScopeDataAccess.kt → ...sions/dataAccess/UpdateScopeDataAccess.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ls/UpdateScopeDataAccessRequestWrapper.kt → ...ls/UpdateScopeDataAccessRequestWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters