Commit 5f4d6506 by eguven Committed by Oliver Woodman

Add argument checks and some javadoc to CachedContentIndex

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144430372
parent 0c53a4e9
...@@ -67,14 +67,25 @@ import javax.crypto.spec.SecretKeySpec; ...@@ -67,14 +67,25 @@ import javax.crypto.spec.SecretKeySpec;
private boolean changed; private boolean changed;
private ReusableBufferedOutputStream bufferedOutputStream; private ReusableBufferedOutputStream bufferedOutputStream;
/** Creates a CachedContentIndex which works on the index file in the given cacheDir. */ /**
* Creates a CachedContentIndex which works on the index file in the given cacheDir.
*
* @param cacheDir Directory where the index file is kept.
*/
public CachedContentIndex(File cacheDir) { public CachedContentIndex(File cacheDir) {
this(cacheDir, null); this(cacheDir, null);
} }
/** Creates a CachedContentIndex which works on the index file in the given cacheDir. */ /**
* Creates a CachedContentIndex which works on the index file in the given cacheDir.
*
* @param cacheDir Directory where the index file is kept.
* @param secretKey If not null, cache keys will be stored encrypted on filesystem using AES/CBC.
* The key must be 16 bytes long.
*/
public CachedContentIndex(File cacheDir, byte[] secretKey) { public CachedContentIndex(File cacheDir, byte[] secretKey) {
if (secretKey != null) { if (secretKey != null) {
Assertions.checkArgument(secretKey.length == 16);
try { try {
cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
secretKeySpec = new SecretKeySpec(secretKey, "AES"); secretKeySpec = new SecretKeySpec(secretKey, "AES");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment