-
Notifications
You must be signed in to change notification settings - Fork 9
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
3a808a2
commit e741256
Showing
9 changed files
with
448 additions
and
93 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/com/uid2/shared/store/EncryptedRotatingSaltProvider.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,33 @@ | ||
package com.uid2.shared.store; | ||
|
||
import com.uid2.shared.cloud.DownloadCloudStorage; | ||
import com.uid2.shared.model.SaltEntry; | ||
import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Collection; | ||
|
||
import static com.uid2.shared.util.CloudEncryptionHelpers.decryptInputStream; | ||
|
||
public class EncryptedRotatingSaltProvider extends RotatingSaltProvider { | ||
private final RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider; | ||
|
||
public EncryptedRotatingSaltProvider(DownloadCloudStorage fileStreamProvider, String metadataPath, RotatingCloudEncryptionKeyProvider cloudEncryptionKeyProvider) { | ||
super(fileStreamProvider, metadataPath); | ||
this.cloudEncryptionKeyProvider = cloudEncryptionKeyProvider; | ||
} | ||
|
||
@Override | ||
protected SaltEntry[] readInputStream(InputStream inputStream, SaltEntryBuilder entryBuilder, Integer size) throws IOException { | ||
String decrypted = decryptInputStream(inputStream, cloudEncryptionKeyProvider); | ||
SaltEntry[] entries = new SaltEntry[size]; | ||
int idx = 0; | ||
for (String line : decrypted.split("\n")) { | ||
final SaltEntry entry = entryBuilder.toEntry(line); | ||
entries[idx] = entry; | ||
idx++; | ||
} | ||
return entries; | ||
} | ||
} |
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
Oops, something went wrong.