mirror of
https://codeberg.org/PGPainless/cert-d-java.git
synced 2025-09-09 03:09:39 +02:00
Make Key and Certificate extend KeyMaterial,
get rid of CertificateReader
This commit is contained in:
parent
2b5da18fc6
commit
942b287beb
7 changed files with 55 additions and 62 deletions
|
@ -11,14 +11,7 @@ import java.util.Set;
|
|||
/**
|
||||
* OpenPGP certificate (public key).
|
||||
*/
|
||||
public abstract class Certificate {
|
||||
/**
|
||||
* Return the fingerprint of the certificate as 40 lowercase hex characters.
|
||||
* TODO: Allow OpenPGP V5 fingerprints
|
||||
*
|
||||
* @return fingerprint
|
||||
*/
|
||||
public abstract String getFingerprint();
|
||||
public abstract class Certificate implements KeyMaterial {
|
||||
|
||||
/**
|
||||
* Return an {@link InputStream} of the binary representation of the certificate.
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package pgp.certificate_store;
|
||||
|
||||
import pgp.certificate_store.exception.BadDataException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Interface definition for a class that can read {@link Certificate Certificates} from binary
|
||||
* {@link InputStream InputStreams}.
|
||||
*/
|
||||
public interface CertificateReaderBackend {
|
||||
|
||||
/**
|
||||
* Read a {@link Certificate} from the given {@link InputStream}.
|
||||
*
|
||||
* @param inputStream input stream containing the binary representation of the certificate.
|
||||
* @return certificate object
|
||||
*
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws BadDataException in case that the input stream does not contain OpenPGP certificate data
|
||||
*/
|
||||
Certificate readCertificate(InputStream inputStream) throws IOException, BadDataException;
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import java.io.InputStream;
|
|||
/**
|
||||
* OpenPGP key (secret key).
|
||||
*/
|
||||
public abstract class Key {
|
||||
public abstract class Key implements KeyMaterial {
|
||||
|
||||
/**
|
||||
* Return the certificate part of this OpenPGP key.
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package pgp.certificate_store;
|
||||
|
||||
public interface KeyMaterial {
|
||||
|
||||
/**
|
||||
* Return the fingerprint of the certificate as 40 lowercase hex characters.
|
||||
* TODO: Allow OpenPGP V5 fingerprints
|
||||
*
|
||||
* @return fingerprint
|
||||
*/
|
||||
String getFingerprint();
|
||||
|
||||
}
|
|
@ -12,13 +12,13 @@ import java.io.InputStream;
|
|||
public interface KeyReaderBackend {
|
||||
|
||||
/**
|
||||
* Read a {@link Key} from the given {@link InputStream}.
|
||||
* Read a {@link KeyMaterial} (either {@link Key} or {@link Certificate}) from the given {@link InputStream}.
|
||||
*
|
||||
* @param data input stream containing the binary representation of the key.
|
||||
* @return key object
|
||||
* @return key or certificate object
|
||||
*
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws BadDataException in case that the data stream does not contain a valid OpenPGP key
|
||||
* @throws BadDataException in case that the data stream does not contain a valid OpenPGP key/certificate
|
||||
*/
|
||||
Key readKey(InputStream data) throws IOException, BadDataException;
|
||||
KeyMaterial read(InputStream data) throws IOException, BadDataException;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue