diff --git a/src/main/java/org/pgpainless/pgpainless/KeyFilter.java b/src/main/java/org/pgpainless/pgpainless/KeyFilter.java deleted file mode 100644 index 54f931f7..00000000 --- a/src/main/java/org/pgpainless/pgpainless/KeyFilter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2018 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.pgpainless; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.bouncycastle.openpgp.PGPPublicKey; -import org.bouncycastle.openpgp.PGPPublicKeyRing; -import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; - -public abstract class KeyFilter { - - public Set filter(Set initialIdSet, PGPPublicKeyRingCollection collection) { - Set rings = new HashSet<>(); - for (Iterator i = collection.getKeyRings(); i.hasNext();) { - rings.add(i.next()); - } - return filter(initialIdSet, rings, false); - } - - public Set filter(Set initialIdSet, Set rings, boolean boolToAvoidSameMethodErasure) { - Set keys = new HashSet<>(); - for (PGPPublicKeyRing ring : rings) { - for (Iterator i = ring.getPublicKeys(); i.hasNext();) { - keys.add(i.next()); - } - } - return filter(initialIdSet, keys); - } - - public Set filter(Set initialIdSet, Set keys) { - Set filteredIds = new HashSet<>(); - for (Long id : initialIdSet) { - for (PGPPublicKey key : keys) { - if (key.getKeyID() == id && filter(key)) { - filteredIds.add(id); - } - } - } - return filteredIds; - } - - public abstract boolean filter(PGPPublicKey key); -} diff --git a/src/main/java/org/pgpainless/pgpainless/PGPv4Fingerprint.java b/src/main/java/org/pgpainless/pgpainless/PGPv4Fingerprint.java deleted file mode 100644 index 246788f7..00000000 --- a/src/main/java/org/pgpainless/pgpainless/PGPv4Fingerprint.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2018 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.pgpainless; - -import java.util.Arrays; - -import org.bouncycastle.openpgp.PGPPublicKey; -import org.bouncycastle.openpgp.PGPSecretKey; - -public class PGPv4Fingerprint { - - private final byte[] fingerprintBytes; - - public PGPv4Fingerprint(PGPPublicKey publicKey) { - if (publicKey.getVersion() != 4) { - throw new IllegalArgumentException("PublicKey is not a OpenPGP v4 Public Key."); - } - this.fingerprintBytes = publicKey.getFingerprint(); - } - - public PGPv4Fingerprint(PGPSecretKey secretKey) { - this(secretKey.getPublicKey()); - } - - @Override - public boolean equals(Object o) { - if (o == null) { - return false; - } - - if (!(o instanceof PGPv4Fingerprint)) { - return false; - } - - return Arrays.equals(fingerprintBytes, ((PGPv4Fingerprint) o).fingerprintBytes); - } - - @Override - public int hashCode() { - return Arrays.hashCode(fingerprintBytes); - } -} diff --git a/src/main/java/org/pgpainless/pgpainless/PainlessStream.java b/src/main/java/org/pgpainless/pgpainless/PainlessStream.java deleted file mode 100644 index 8773570c..00000000 --- a/src/main/java/org/pgpainless/pgpainless/PainlessStream.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 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.pgpainless; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -public interface PainlessStream { - - boolean isClosed(); - - class In extends InputStream implements PainlessStream { - private final InputStream inputStream; - - private boolean isClosed = false; - - public In(InputStream inputStream) { - this.inputStream = inputStream; - } - - @Override - public int read() throws IOException { - return inputStream.read(); - } - - @Override - public void close() throws IOException { - inputStream.close(); - isClosed = true; - } - - @Override - public boolean isClosed() { - return isClosed; - } - } - - class Out extends OutputStream implements PainlessStream { - - private final OutputStream outputStream; - private boolean isClosed = false; - - public Out(OutputStream outputStream) { - this.outputStream = outputStream; - } - - @Override - public boolean isClosed() { - return isClosed; - } - - @Override - public void write(int i) throws IOException { - outputStream.write(i); - } - - @Override - public void close() throws IOException { - outputStream.close(); - this.isClosed = true; - } - } -}