-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cbc UI d2 4454 cloud encryption operator #1175
Open
cody-constine-ttd
wants to merge
34
commits into
main
Choose a base branch
from
cbc-UID2-4454-cloud-encryption-operator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
0a1154c
configs+initiate s3 key provider
lizk886 582ea54
small changes
lizk886 590b67e
update client
lizk886 e06509a
update shared repo
lizk886 275e5cb
keep origional constuctor
lizk886 4ef6e87
fix https
lizk886 7c25f1c
working
lizk886 12131f9
clean up
lizk886 1d85892
clean up
lizk886 08bf71a
clean up
lizk886 4c10d2d
clean up
lizk886 d106180
clean up
lizk886 195ec0d
push pom
lizk886 8700b1f
update configs to extreme big number
lizk886 20481ef
refactor
lizk886 88f2716
refactor'
lizk886 8975886
update shared
lizk886 fc96012
only be able to decrypt keyset and keyset_keys, needs to figure out w…
lizk886 1083e59
update
lizk886 18ccab1
update with unit tests
lizk886 578992c
update site
lizk886 264eefe
Merging up to main
cody-constine-ttd 3343974
Merge branch 'wzh-uid2-3573-call-endpoint-for-s3encyrptionkeys-list' …
cody-constine-ttd a0a099c
Merging
cody-constine-ttd 07f4da8
Catching up to rename changes
cody-constine-ttd eb0fd11
Renaming + adding get version for api key class
cody-constine-ttd aad4592
Renaming and adding small fixes
cody-constine-ttd bc2d667
Catching up to main
cody-constine-ttd 5922a29
Updated the API readed to make simplier
cody-constine-ttd 5383c0b
Adding new readers for salts and client side keypairs
cody-constine-ttd bfe7849
Finishing salts and clientside keys
cody-constine-ttd 9c9b1b9
Adding new constructor to rotatingCloudEncryptionProvider
cody-constine-ttd 3452457
Updating shared
cody-constine-ttd fd2c0c5
[CI Pipeline] Released Snapshot version: 5.42.1-alpha-144-SNAPSHOT
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
57 changes: 57 additions & 0 deletions
57
src/main/java/com/uid2/operator/reader/ApiStoreReader.java
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,57 @@ | ||
package com.uid2.operator.reader; | ||
|
||
import com.uid2.shared.cloud.DownloadCloudStorage; | ||
import com.uid2.shared.store.ScopedStoreReader; | ||
import com.uid2.shared.store.parser.Parser; | ||
import com.uid2.shared.store.parser.ParsingResult; | ||
import com.uid2.shared.store.scope.StoreScope; | ||
import io.vertx.core.json.JsonArray; | ||
import io.vertx.core.json.JsonObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class ApiStoreReader<T> extends ScopedStoreReader<T> { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ApiStoreReader.class); | ||
|
||
public ApiStoreReader(DownloadCloudStorage fileStreamProvider, StoreScope scope, Parser<T> parser, String dataTypeName) { | ||
super(fileStreamProvider, scope, parser, dataTypeName); | ||
} | ||
|
||
|
||
public long loadContent(JsonObject contents) throws Exception { | ||
return loadContent(contents, dataTypeName); | ||
} | ||
|
||
@Override | ||
public long loadContent(JsonObject contents, String dataType) throws IOException { | ||
if (contents == null) { | ||
throw new IllegalArgumentException(String.format("No contents provided for loading data type %s, cannot load content", dataType)); | ||
} | ||
|
||
try { | ||
JsonArray dataArray = contents.getJsonArray(dataType); | ||
if (dataArray == null) { | ||
throw new IllegalArgumentException("No array found in the contents"); | ||
} | ||
|
||
String jsonString = dataArray.toString(); | ||
InputStream inputStream = new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8)); | ||
|
||
ParsingResult<T> parsed = parser.deserialize(inputStream); | ||
latestSnapshot.set(parsed.getData()); | ||
|
||
final int count = parsed.getCount(); | ||
latestEntryCount.set(count); | ||
LOGGER.info(String.format("Loaded %d %s", count, dataType)); | ||
return count; | ||
} catch (Exception e) { | ||
LOGGER.error(String.format("Unable to load %s", dataType)); | ||
throw e; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/uid2/operator/reader/RotatingCloudEncryptionKeyApiProvider.java
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,32 @@ | ||
package com.uid2.operator.reader; | ||
|
||
import com.uid2.shared.cloud.DownloadCloudStorage; | ||
import com.uid2.shared.model.CloudEncryptionKey; | ||
import com.uid2.shared.store.CloudPath; | ||
import com.uid2.shared.store.parser.CloudEncryptionKeyParser; | ||
import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider; | ||
import com.uid2.shared.store.scope.StoreScope; | ||
import io.vertx.core.json.JsonObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.time.Instant; | ||
import java.util.*; | ||
|
||
public class RotatingCloudEncryptionKeyApiProvider extends RotatingCloudEncryptionKeyProvider { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(RotatingCloudEncryptionKeyApiProvider.class); | ||
|
||
public RotatingCloudEncryptionKeyApiProvider(DownloadCloudStorage fileStreamProvider, StoreScope scope) { | ||
super(fileStreamProvider, scope, new ApiStoreReader<>(fileStreamProvider, scope, new CloudEncryptionKeyParser(), "cloud_encryption_keys")); | ||
} | ||
|
||
public RotatingCloudEncryptionKeyApiProvider(DownloadCloudStorage fileStreamProvider, StoreScope scope, ApiStoreReader<Map<Integer, CloudEncryptionKey>> reader) { | ||
super(fileStreamProvider, scope, reader); | ||
} | ||
|
||
|
||
@Override | ||
public long getVersion(JsonObject metadata) { | ||
return Instant.now().getEpochSecond(); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/resources/com.uid2.core/test/cloud_encryption_keys/cloud_encryption_keys.json
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,73 @@ | ||
[ { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation format like this: https://github.com/IABTechLab/uid2-admin/blob/main/src/main/resources/localstack/s3/core/keys/keys.json? |
||
"id" : 1, | ||
"siteId" : 999, | ||
"activates" : 1720641670, | ||
"created" : 1720641670, | ||
"secret" : "mydrCudb2PZOm01Qn0SpthltmexHUAA11Hy1m+uxjVw=" | ||
}, { | ||
"id" : 2, | ||
"siteId" : 999, | ||
"activates" : 1720728070, | ||
"created" : 1720641670, | ||
"secret" : "FtdslrFSsvVXOuhOWGwEI+0QTkCvM8SGZAP3k2u3PgY=" | ||
}, { | ||
"id" : 3, | ||
"siteId" : 999, | ||
"activates" : 1720814470, | ||
"created" : 1720641670, | ||
"secret" : "/7zO6QbKrhZKIV36G+cU9UR4hZUVg5bD+KjbczICjHw=" | ||
}, { | ||
"id" : 4, | ||
"siteId" : 123, | ||
"activates" : 1720641671, | ||
"created" : 1720641671, | ||
"secret" : "XjiqRlWQQJGLr7xfV1qbueKwyzt881GVohuUkQt/ht4=" | ||
}, { | ||
"id" : 5, | ||
"siteId" : 123, | ||
"activates" : 1720728071, | ||
"created" : 1720641671, | ||
"secret" : "QmpIf5NzO+UROjl5XjB/BmF6paefM8n6ub9B2plC9aI=" | ||
}, { | ||
"id" : 6, | ||
"siteId" : 123, | ||
"activates" : 1720814471, | ||
"created" : 1720641671, | ||
"secret" : "40w9UMSYxGm+KldOWOXhBGI8QgjvUUQjivtkP4VpKV8=" | ||
}, { | ||
"id" : 7, | ||
"siteId" : 124, | ||
"activates" : 1720641671, | ||
"created" : 1720641671, | ||
"secret" : "QdwD0kQV1BwmLRD0PH1YpqgaOrgpVTfu08o98mSZ6uE=" | ||
}, { | ||
"id" : 8, | ||
"siteId" : 124, | ||
"activates" : 1720728071, | ||
"created" : 1720641671, | ||
"secret" : "yCVCM/HLf9/6k+aUNrx7w17VbyfSzI8JykLQLSR+CW0=" | ||
}, { | ||
"id" : 9, | ||
"siteId" : 124, | ||
"activates" : 1720814471, | ||
"created" : 1720641671, | ||
"secret" : "JqHl8BrTyx9XpR2lYj/5xvUpzgnibGeomETTwF4rn1U=" | ||
}, { | ||
"id" : 10, | ||
"siteId" : 127, | ||
"activates" : 1720641671, | ||
"created" : 1720641671, | ||
"secret" : "JqiG1b34AvrdO3Aj6cCcjOBJMijrDzTmrR+p9ZtP2es=" | ||
}, { | ||
"id" : 11, | ||
"siteId" : 127, | ||
"activates" : 1720728072, | ||
"created" : 1720641672, | ||
"secret" : "lp1CyHdfc7K0aO5JGpA+Ve5Z/V5LImtGEQwCg/YB0kY=" | ||
}, { | ||
"id" : 12, | ||
"siteId" : 127, | ||
"activates" : 1720814472, | ||
"created" : 1720641672, | ||
"secret" : "G99rFYJF+dnSlk/xG6fuC3WNqQxTLJbDIdVyPMbGQ6s=" | ||
} ] |
7 changes: 7 additions & 0 deletions
7
src/main/resources/com.uid2.core/test/cloud_encryption_keys/metadata.json
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,7 @@ | ||
{ | ||
"version": 1, | ||
"generated": 1620253519, | ||
"cloud_encryption_keys": { | ||
"location": "/com.uid2.core/test/cloud_encryption_keys/cloud_encryption_keys.json" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't it metadata.getLong("version") ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is using an API to get the data not a file, so there is no metadata to look the version up in. So I just used the time here to force a refresh everytime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs a comment explaining why you are doing this as I feel we will forget