From 82014ef6e5aad7cc9b5298ad13d160b7400359fb Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 3 Jan 2021 15:52:18 +0100 Subject: [PATCH] Fix checkstyle issues --- .../implementation/package-info.java | 19 +++++++++++++++++++ .../CallbackBasedKeyringProtector.java | 15 +++++++++++++++ .../protection/SecretKeyRingProtector.java | 2 ++ .../protection/SecretKeyRingProtector2.java | 15 +++++++++++++++ .../SecretKeyRingProtectorAdapter.java | 15 +++++++++++++++ .../MapBasedPassphraseProvider.java | 1 - .../PassphraseProtectedKeyTest.java | 1 - .../java/org/pgpainless/sop/SopKeyUtil.java | 17 ++++++++++++++++- .../org/pgpainless/sop/commands/Decrypt.java | 1 - 9 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 pgpainless-core/src/main/java/org/pgpainless/implementation/package-info.java diff --git a/pgpainless-core/src/main/java/org/pgpainless/implementation/package-info.java b/pgpainless-core/src/main/java/org/pgpainless/implementation/package-info.java new file mode 100644 index 00000000..b3e8787e --- /dev/null +++ b/pgpainless-core/src/main/java/org/pgpainless/implementation/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2020 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Implementation factory classes to be able to switch out the underlying crypto engine implementation. + */ +package org.pgpainless.implementation; diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/protection/CallbackBasedKeyringProtector.java b/pgpainless-core/src/main/java/org/pgpainless/key/protection/CallbackBasedKeyringProtector.java index 4e8ad59b..75677bbe 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/protection/CallbackBasedKeyringProtector.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/protection/CallbackBasedKeyringProtector.java @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.pgpainless.key.protection; import java.util.Map; diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector.java b/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector.java index 7a48d740..f75bff25 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector.java @@ -26,6 +26,8 @@ import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor; import org.pgpainless.util.Passphrase; /** + * Interface that is used to provide secret key ring encryptors and decryptors. + * * @deprecated use {@link SecretKeyRingProtector2} instead. */ public interface SecretKeyRingProtector { diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector2.java b/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector2.java index 61c68f19..f215641a 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector2.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtector2.java @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.pgpainless.key.protection; import org.bouncycastle.openpgp.PGPException; diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtectorAdapter.java b/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtectorAdapter.java index 4252231f..b9e46896 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtectorAdapter.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/protection/SecretKeyRingProtectorAdapter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.pgpainless.key.protection; import org.bouncycastle.openpgp.PGPException; diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/protection/passphrase_provider/MapBasedPassphraseProvider.java b/pgpainless-core/src/main/java/org/pgpainless/key/protection/passphrase_provider/MapBasedPassphraseProvider.java index a1e1d865..24ea569d 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/protection/passphrase_provider/MapBasedPassphraseProvider.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/protection/passphrase_provider/MapBasedPassphraseProvider.java @@ -18,7 +18,6 @@ package org.pgpainless.key.protection.passphrase_provider; import java.util.Map; import javax.annotation.Nullable; -import org.bouncycastle.openpgp.PGPSecretKey; import org.pgpainless.util.Passphrase; /** diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java index ac317740..437ef12f 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java @@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import javax.annotation.Nullable; import org.bouncycastle.openpgp.PGPException; -import org.bouncycastle.openpgp.PGPSecretKey; import org.junit.jupiter.api.Test; import org.pgpainless.key.TestKeys; import org.pgpainless.key.protection.passphrase_provider.SecretKeyPassphraseProvider; diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/SopKeyUtil.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/SopKeyUtil.java index 551f4532..082bdc62 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/SopKeyUtil.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/SopKeyUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Paul Schaub. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.pgpainless.sop; import static org.pgpainless.sop.Print.err_ln; @@ -17,7 +32,7 @@ public class SopKeyUtil { public static List loadKeysFromFiles(File... files) throws IOException, PGPException { List secretKeyRings = new ArrayList<>(); for (File file : files) { - try(FileInputStream in = new FileInputStream(file)) { + try (FileInputStream in = new FileInputStream(file)) { secretKeyRings.add(PGPainless.readKeyRing().secretKeyRing(in)); } catch (PGPException | IOException e) { err_ln("Could not load secret key " + file.getName() + ": " + e.getMessage()); diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/Decrypt.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/Decrypt.java index bb5022ea..4be22ebb 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/Decrypt.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/Decrypt.java @@ -16,7 +16,6 @@ package org.pgpainless.sop.commands; import org.bouncycastle.openpgp.PGPException; -import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRingCollection; import org.pgpainless.PGPainless;