Create an ArbitraryDataResource object when building. Eventually this could be passed in to the reader instead of the individual components (service, name, identifier, etc)

This is now used to improve logging when extracting.
This commit is contained in:
CalDescent 2023-01-27 16:55:43 +00:00
parent 8c708558cb
commit bf06d47842

View File

@ -60,6 +60,9 @@ public class ArbitraryDataReader {
private int layerCount; private int layerCount;
private byte[] latestSignature; private byte[] latestSignature;
// The resource being read
ArbitraryDataResource arbitraryDataResource = null;
public ArbitraryDataReader(String resourceId, ResourceIdType resourceIdType, Service service, String identifier) { public ArbitraryDataReader(String resourceId, ResourceIdType resourceIdType, Service service, String identifier) {
// Ensure names are always lowercase // Ensure names are always lowercase
if (resourceIdType == ResourceIdType.NAME) { if (resourceIdType == ResourceIdType.NAME) {
@ -116,6 +119,11 @@ public class ArbitraryDataReader {
return new ArbitraryDataBuildQueueItem(this.resourceId, this.resourceIdType, this.service, this.identifier); return new ArbitraryDataBuildQueueItem(this.resourceId, this.resourceIdType, this.service, this.identifier);
} }
private ArbitraryDataResource createArbitraryDataResource() {
return new ArbitraryDataResource(this.resourceId, this.resourceIdType, this.service, this.identifier);
}
/** /**
* loadAsynchronously * loadAsynchronously
* *
@ -163,6 +171,8 @@ public class ArbitraryDataReader {
return; return;
} }
this.arbitraryDataResource = this.createArbitraryDataResource();
this.preExecute(); this.preExecute();
this.deleteExistingFiles(); this.deleteExistingFiles();
this.fetch(); this.fetch();
@ -436,7 +446,7 @@ public class ArbitraryDataReader {
byte[] secret = this.secret58 != null ? Base58.decode(this.secret58) : null; byte[] secret = this.secret58 != null ? Base58.decode(this.secret58) : null;
if (secret != null && secret.length == Transformer.AES256_LENGTH) { if (secret != null && secret.length == Transformer.AES256_LENGTH) {
try { try {
LOGGER.info("Decrypting using algorithm {}...", algorithm); LOGGER.info("Decrypting {} using algorithm {}...", this.arbitraryDataResource, algorithm);
Path unencryptedPath = Paths.get(this.workingPath.toString(), "zipped.zip"); Path unencryptedPath = Paths.get(this.workingPath.toString(), "zipped.zip");
SecretKey aesKey = new SecretKeySpec(secret, 0, secret.length, "AES"); SecretKey aesKey = new SecretKeySpec(secret, 0, secret.length, "AES");
AES.decryptFile(algorithm, aesKey, this.filePath.toString(), unencryptedPath.toString()); AES.decryptFile(algorithm, aesKey, this.filePath.toString(), unencryptedPath.toString());