1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 22:32:07 +01:00

Use String-formatting in Logger statements

This commit is contained in:
Paul Schaub 2021-08-15 15:36:37 +02:00
parent 485666c72a
commit e5b15fe0c2
4 changed files with 13 additions and 13 deletions

View file

@ -182,7 +182,7 @@ public final class DecryptionStreamFactory {
private InputStream processPGPCompressedData(PGPCompressedData pgpCompressedData, int depth) private InputStream processPGPCompressedData(PGPCompressedData pgpCompressedData, int depth)
throws PGPException, IOException { throws PGPException, IOException {
CompressionAlgorithm compressionAlgorithm = CompressionAlgorithm.fromId(pgpCompressedData.getAlgorithm()); CompressionAlgorithm compressionAlgorithm = CompressionAlgorithm.fromId(pgpCompressedData.getAlgorithm());
LOGGER.log(LEVEL, "Encountered PGPCompressedData: " + compressionAlgorithm); LOGGER.log(LEVEL, "Encountered PGPCompressedData: {}", compressionAlgorithm);
resultBuilder.setCompressionAlgorithm(compressionAlgorithm); resultBuilder.setCompressionAlgorithm(compressionAlgorithm);
InputStream inflatedDataStream = pgpCompressedData.getDataStream(); InputStream inflatedDataStream = pgpCompressedData.getDataStream();
@ -194,7 +194,7 @@ public final class DecryptionStreamFactory {
private InputStream processOnePassSignatureList(@Nonnull PGPObjectFactory objectFactory, PGPOnePassSignatureList onePassSignatures, int depth) private InputStream processOnePassSignatureList(@Nonnull PGPObjectFactory objectFactory, PGPOnePassSignatureList onePassSignatures, int depth)
throws PGPException, IOException { throws PGPException, IOException {
LOGGER.log(LEVEL, "Encountered PGPOnePassSignatureList of size " + onePassSignatures.size()); LOGGER.log(LEVEL, "Encountered PGPOnePassSignatureList of size {}", onePassSignatures.size());
initOnePassSignatures(onePassSignatures); initOnePassSignatures(onePassSignatures);
return processPGPPackets(objectFactory, ++depth); return processPGPPackets(objectFactory, ++depth);
} }
@ -261,12 +261,12 @@ public final class DecryptionStreamFactory {
if (!options.getDecryptionKeys().isEmpty()) { if (!options.getDecryptionKeys().isEmpty()) {
// Known key id // Known key id
if (keyId != 0) { if (keyId != 0) {
LOGGER.log(LEVEL, "PGPEncryptedData is encrypted for key " + Long.toHexString(keyId)); LOGGER.log(LEVEL, "PGPEncryptedData is encrypted for key {}", Long.toHexString(keyId));
resultBuilder.addRecipientKeyId(keyId); resultBuilder.addRecipientKeyId(keyId);
PGPSecretKeyRing decryptionKeyRing = findDecryptionKeyRing(keyId); PGPSecretKeyRing decryptionKeyRing = findDecryptionKeyRing(keyId);
if (decryptionKeyRing != null) { if (decryptionKeyRing != null) {
PGPSecretKey secretKey = decryptionKeyRing.getSecretKey(keyId); PGPSecretKey secretKey = decryptionKeyRing.getSecretKey(keyId);
LOGGER.log(LEVEL, "Found respective secret key " + Long.toHexString(keyId)); LOGGER.log(LEVEL, "Found respective secret key {}", Long.toHexString(keyId));
// Watch out! This assignment is possibly done multiple times. // Watch out! This assignment is possibly done multiple times.
encryptedSessionKey = publicKeyEncryptedData; encryptedSessionKey = publicKeyEncryptedData;
decryptionKey = UnlockSecretKey.unlockSecretKey(secretKey, options.getSecretKeyProtector(decryptionKeyRing)); decryptionKey = UnlockSecretKey.unlockSecretKey(secretKey, options.getSecretKeyProtector(decryptionKeyRing));
@ -290,7 +290,7 @@ public final class DecryptionStreamFactory {
PublicKeyDataDecryptorFactory decryptorFactory = ImplementationFactory.getInstance().getPublicKeyDataDecryptorFactory(privateKey); PublicKeyDataDecryptorFactory decryptorFactory = ImplementationFactory.getInstance().getPublicKeyDataDecryptorFactory(privateKey);
try { try {
publicKeyEncryptedData.getSymmetricAlgorithm(decryptorFactory); // will only succeed if we have the right secret key publicKeyEncryptedData.getSymmetricAlgorithm(decryptorFactory); // will only succeed if we have the right secret key
LOGGER.log(LEVEL, "Found correct key " + Long.toHexString(key.getKeyID()) + " for hidden recipient decryption."); LOGGER.log(LEVEL, "Found correct key {} for hidden recipient decryption.", Long.toHexString(key.getKeyID()));
decryptionKey = privateKey; decryptionKey = privateKey;
resultBuilder.setDecryptionKey(new SubkeyIdentifier(ring, decryptionKey.getKeyID())); resultBuilder.setDecryptionKey(new SubkeyIdentifier(ring, decryptionKey.getKeyID()));
encryptedSessionKey = publicKeyEncryptedData; encryptedSessionKey = publicKeyEncryptedData;
@ -321,7 +321,7 @@ public final class DecryptionStreamFactory {
if (symmetricKeyAlgorithm == SymmetricKeyAlgorithm.NULL) { if (symmetricKeyAlgorithm == SymmetricKeyAlgorithm.NULL) {
LOGGER.log(LEVEL, "Message is unencrypted"); LOGGER.log(LEVEL, "Message is unencrypted");
} else { } else {
LOGGER.log(LEVEL, "Message is encrypted using " + symmetricKeyAlgorithm); LOGGER.log(LEVEL, "Message is encrypted using {}", symmetricKeyAlgorithm);
} }
throwIfAlgorithmIsRejected(symmetricKeyAlgorithm); throwIfAlgorithmIsRejected(symmetricKeyAlgorithm);
resultBuilder.setSymmetricKeyAlgorithm(symmetricKeyAlgorithm); resultBuilder.setSymmetricKeyAlgorithm(symmetricKeyAlgorithm);
@ -359,12 +359,12 @@ public final class DecryptionStreamFactory {
private void processOnePassSignature(PGPOnePassSignature signature) throws PGPException { private void processOnePassSignature(PGPOnePassSignature signature) throws PGPException {
final long keyId = signature.getKeyID(); final long keyId = signature.getKeyID();
LOGGER.log(LEVEL, "Message contains OnePassSignature from " + Long.toHexString(keyId)); LOGGER.log(LEVEL, "Message contains OnePassSignature from {}", Long.toHexString(keyId));
// Find public key // Find public key
PGPPublicKeyRing verificationKeyRing = findSignatureVerificationKeyRing(keyId); PGPPublicKeyRing verificationKeyRing = findSignatureVerificationKeyRing(keyId);
if (verificationKeyRing == null) { if (verificationKeyRing == null) {
LOGGER.log(LEVEL, "Missing verification key from " + Long.toHexString(keyId)); LOGGER.log(LEVEL, "Missing verification key from {}", Long.toHexString(keyId));
return; return;
} }
PGPPublicKey verificationKey = verificationKeyRing.getPublicKey(keyId); PGPPublicKey verificationKey = verificationKeyRing.getPublicKey(keyId);
@ -390,7 +390,7 @@ public final class DecryptionStreamFactory {
for (PGPPublicKeyRing publicKeyRing : options.getCertificates()) { for (PGPPublicKeyRing publicKeyRing : options.getCertificates()) {
PGPPublicKey verificationKey = publicKeyRing.getPublicKey(keyId); PGPPublicKey verificationKey = publicKeyRing.getPublicKey(keyId);
if (verificationKey != null) { if (verificationKey != null) {
LOGGER.log(LEVEL, "Found public key " + Long.toHexString(keyId) + " for signature verification"); LOGGER.log(LEVEL, "Found public key {} for signature verification", Long.toHexString(keyId));
verificationKeyRing = publicKeyRing; verificationKeyRing = publicKeyRing;
break; break;
} }

View file

@ -126,7 +126,7 @@ public class SignatureVerifyingInputStream extends FilterInputStream {
if (!onePassSignature.verify(signature)) { if (!onePassSignature.verify(signature)) {
throw new SignatureException("Bad Signature of key " + signature.getKeyID()); throw new SignatureException("Bad Signature of key " + signature.getKeyID());
} else { } else {
LOGGER.log(LEVEL, "Verified signature of key " + Long.toHexString(signature.getKeyID())); LOGGER.log(LEVEL, "Verified signature of key {}", Long.toHexString(signature.getKeyID()));
} }
} }

View file

@ -99,7 +99,7 @@ public final class EncryptionStream extends OutputStream {
SymmetricKeyAlgorithm encryptionAlgorithm = EncryptionBuilder.negotiateSymmetricEncryptionAlgorithm(encryptionOptions); SymmetricKeyAlgorithm encryptionAlgorithm = EncryptionBuilder.negotiateSymmetricEncryptionAlgorithm(encryptionOptions);
resultBuilder.setEncryptionAlgorithm(encryptionAlgorithm); resultBuilder.setEncryptionAlgorithm(encryptionAlgorithm);
LOGGER.log(LEVEL, "Encrypt message using " + encryptionAlgorithm); LOGGER.log(LEVEL, "Encrypt message using {}", encryptionAlgorithm);
PGPDataEncryptorBuilder dataEncryptorBuilder = PGPDataEncryptorBuilder dataEncryptorBuilder =
ImplementationFactory.getInstance().getPGPDataEncryptorBuilder(encryptionAlgorithm); ImplementationFactory.getInstance().getPGPDataEncryptorBuilder(encryptionAlgorithm);
dataEncryptorBuilder.setWithIntegrityPacket(true); dataEncryptorBuilder.setWithIntegrityPacket(true);
@ -127,7 +127,7 @@ public final class EncryptionStream extends OutputStream {
return; return;
} }
LOGGER.log(LEVEL, "Compress using " + compressionAlgorithm); LOGGER.log(LEVEL, "Compress using {}", compressionAlgorithm);
basicCompressionStream = new BCPGOutputStream(compressedDataGenerator.open(outermostStream)); basicCompressionStream = new BCPGOutputStream(compressedDataGenerator.open(outermostStream));
outermostStream = basicCompressionStream; outermostStream = basicCompressionStream;
} }

View file

@ -140,7 +140,7 @@ public final class SignatureChainValidator {
if (!userIdSignatures.get(userId).isEmpty()) { if (!userIdSignatures.get(userId).isEmpty()) {
PGPSignature current = userIdSignatures.get(userId).get(0); PGPSignature current = userIdSignatures.get(userId).get(0);
if (current.getSignatureType() == SignatureType.CERTIFICATION_REVOCATION.getCode()) { if (current.getSignatureType() == SignatureType.CERTIFICATION_REVOCATION.getCode()) {
LOGGER.log(Level.FINE, "User-ID '" + userId + "' is revoked."); LOGGER.log(Level.FINE, "User-ID '{}' is revoked.", userId);
} else { } else {
anyUserIdValid = true; anyUserIdValid = true;
} }