-
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.
Adding in client side keypair encryption
- Loading branch information
1 parent
fc62e0e
commit 249fdd0
Showing
10 changed files
with
166 additions
and
10 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
36 changes: 36 additions & 0 deletions
36
src/main/java/com/uid2/admin/job/EncryptionJob/ClientSideKeypairEncryptionJob.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,36 @@ | ||
package com.uid2.admin.job.EncryptionJob; | ||
|
||
import com.uid2.admin.job.model.Job; | ||
import com.uid2.admin.model.PrivateSiteDataMap; | ||
import com.uid2.admin.store.MultiScopeStoreWriter; | ||
import com.uid2.admin.util.PublicSiteUtil; | ||
import com.uid2.shared.auth.OperatorKey; | ||
import com.uid2.shared.model.ClientSideKeypair; | ||
|
||
import java.util.Collection; | ||
|
||
public class ClientSideKeypairEncryptionJob extends Job { | ||
private final Collection<OperatorKey> globalOperators; | ||
private final Collection<ClientSideKeypair> globalClientSideKeypairs; | ||
|
||
private final MultiScopeStoreWriter<Collection<ClientSideKeypair>> multiScopeStoreWriter; | ||
|
||
public ClientSideKeypairEncryptionJob(Collection<OperatorKey> globalOperators, Collection<ClientSideKeypair> globalClientSideKeypairs, | ||
MultiScopeStoreWriter<Collection<ClientSideKeypair>> multiScopeStoreWriter) { | ||
this.globalOperators = globalOperators; | ||
this.globalClientSideKeypairs = globalClientSideKeypairs; | ||
this.multiScopeStoreWriter = multiScopeStoreWriter; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return "cloud-encryption-sync-clientside-keypair"; | ||
} | ||
|
||
@Override | ||
public void execute() throws Exception { | ||
// Only public operators support clientside keypair | ||
PrivateSiteDataMap<ClientSideKeypair> desiredPublicState = PublicSiteUtil.getPublicClientKeypairs(globalClientSideKeypairs, globalOperators); | ||
multiScopeStoreWriter.uploadPublicWithEncryption(desiredPublicState, null); | ||
} | ||
} |
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
79 changes: 79 additions & 0 deletions
79
src/main/java/com/uid2/admin/store/factory/ClientSideKeypairStoreFactory.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,79 @@ | ||
package com.uid2.admin.store.factory; | ||
|
||
import com.uid2.admin.store.writer.ClientSideKeypairStoreWriter; | ||
import com.uid2.admin.store.writer.StoreWriter; | ||
import com.uid2.shared.model.ClientSideKeypair; | ||
import com.uid2.shared.store.reader.RotatingClientSideKeypairStore; | ||
import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider; | ||
import com.uid2.shared.store.reader.StoreReader; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
import com.uid2.admin.store.Clock; | ||
import com.uid2.admin.store.FileManager; | ||
import com.uid2.admin.store.version.VersionGenerator; | ||
import com.uid2.shared.cloud.ICloudStorage; | ||
import com.uid2.shared.store.CloudPath; | ||
import com.uid2.shared.store.scope.EncryptedScope; | ||
import com.uid2.shared.store.scope.GlobalScope; | ||
import com.uid2.shared.store.scope.SiteScope; | ||
|
||
import java.util.Collection; | ||
|
||
public class ClientSideKeypairStoreFactory implements EncryptedStoreFactory<Collection<ClientSideKeypair>> { | ||
private final ICloudStorage fileStreamProvider; | ||
private final CloudPath rootMetadataPath; | ||
private final VersionGenerator versionGenerator; | ||
private final Clock clock; | ||
private final FileManager fileManager; | ||
private final RotatingClientSideKeypairStore globalReader; | ||
private final RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider; | ||
|
||
public ClientSideKeypairStoreFactory( | ||
ICloudStorage fileStreamProvider, | ||
CloudPath rootMetadataPath, | ||
VersionGenerator versionGenerator, | ||
Clock clock, | ||
RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider, | ||
FileManager fileManager) { | ||
this.fileStreamProvider = fileStreamProvider; | ||
this.rootMetadataPath = rootMetadataPath; | ||
this.versionGenerator = versionGenerator; | ||
this.clock = clock; | ||
this.cloudEncryptionKeyProvider = cloudEncryptionKeyProvider; | ||
this.fileManager = fileManager; | ||
GlobalScope globalScope = new GlobalScope(rootMetadataPath); | ||
globalReader = new RotatingClientSideKeypairStore(fileStreamProvider, globalScope); | ||
} | ||
|
||
public RotatingClientSideKeypairStore getGlobalReader() { | ||
return globalReader; | ||
} | ||
|
||
@Override | ||
public StoreWriter<Collection<ClientSideKeypair>> getEncryptedWriter(Integer siteId, boolean isPublic) { | ||
return new ClientSideKeypairStoreWriter(getEncryptedReader(siteId, isPublic), | ||
fileManager, | ||
versionGenerator, | ||
clock, | ||
new EncryptedScope(rootMetadataPath, siteId, isPublic)); | ||
} | ||
|
||
@Override | ||
public StoreReader<Collection<ClientSideKeypair>> getEncryptedReader(Integer siteId, boolean isPublic) { | ||
return new RotatingClientSideKeypairStore(fileStreamProvider, new EncryptedScope(rootMetadataPath, siteId, isPublic)); | ||
} | ||
|
||
@Override | ||
public RotatingCloudEncryptionKeyProvider getCloudEncryptionProvider() { | ||
return cloudEncryptionKeyProvider; | ||
} | ||
|
||
@Override | ||
public StoreReader<Collection<ClientSideKeypair>> getReader(Integer siteId) { | ||
return new RotatingClientSideKeypairStore(fileStreamProvider, new SiteScope(rootMetadataPath, siteId)); | ||
} | ||
|
||
@Override | ||
public StoreWriter<Collection<ClientSideKeypair>> getWriter(Integer siteId) { | ||
return new ClientSideKeypairStoreWriter(getReader(siteId), fileManager, versionGenerator, clock, new SiteScope(rootMetadataPath, siteId)); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/test/java/com/uid2/admin/store/writer/SaltStoreWriterTest.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,5 @@ | ||
package com.uid2.admin.store.writer; | ||
|
||
public class SaltStoreWriterTest { | ||
|
||
} |