From e8d7d1b5f4a2736b135710207b46f8ac1b954e3e Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 24 May 2022 21:36:02 +0200 Subject: [PATCH] Move withKeyPassword method in Sign around --- .../main/java/sop/operation/InlineSign.java | 9 ++++++ .../src/main/java/sop/operation/Sign.java | 28 +++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 sop-java/src/main/java/sop/operation/InlineSign.java diff --git a/sop-java/src/main/java/sop/operation/InlineSign.java b/sop-java/src/main/java/sop/operation/InlineSign.java new file mode 100644 index 0000000..ed1f90b --- /dev/null +++ b/sop-java/src/main/java/sop/operation/InlineSign.java @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2022 Paul Schaub +// +// SPDX-License-Identifier: Apache-2.0 + +package sop.operation; + +public interface InlineSign { + +} diff --git a/sop-java/src/main/java/sop/operation/Sign.java b/sop-java/src/main/java/sop/operation/Sign.java index 931c80a..f02e709 100644 --- a/sop-java/src/main/java/sop/operation/Sign.java +++ b/sop-java/src/main/java/sop/operation/Sign.java @@ -46,6 +46,20 @@ public interface Sign { */ Sign key(InputStream key) throws SOPGPException.KeyIsProtected, SOPGPException.BadData, IOException; + /** + * Add one or more signing keys. + * + * @param key byte array containing encoded keys + * @return builder instance + * + * @throws sop.exception.SOPGPException.KeyIsProtected if the key is password protected + * @throws sop.exception.SOPGPException.BadData if the byte array does not contain an OpenPGP key + * @throws IOException in case of an IO error + */ + default Sign key(byte[] key) throws SOPGPException.KeyIsProtected, SOPGPException.BadData, IOException { + return key(new ByteArrayInputStream(key)); + } + /** * Provide the decryption password for the secret key. * @@ -64,20 +78,6 @@ public interface Sign { */ Sign withKeyPassword(byte[] password); - /** - * Add one or more signing keys. - * - * @param key byte array containing encoded keys - * @return builder instance - * - * @throws sop.exception.SOPGPException.KeyIsProtected if the key is password protected - * @throws sop.exception.SOPGPException.BadData if the byte array does not contain an OpenPGP key - * @throws IOException in case of an IO error - */ - default Sign key(byte[] key) throws SOPGPException.KeyIsProtected, SOPGPException.BadData, IOException { - return key(new ByteArrayInputStream(key)); - } - /** * Signs data. *