mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-12 23:42:06 +01:00
Delete redundant classes
This commit is contained in:
parent
21f2a732ee
commit
6f0cf35e31
5 changed files with 0 additions and 195 deletions
|
@ -1,32 +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.exception;
|
|
||||||
|
|
||||||
public class SecretKeyNotFoundException extends Exception {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private long keyId;
|
|
||||||
|
|
||||||
public SecretKeyNotFoundException(long keyId) {
|
|
||||||
super("No PGPSecretKey with id " + Long.toHexString(keyId) + " (" + keyId + ") found.");
|
|
||||||
this.keyId = keyId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getKeyId() {
|
|
||||||
return keyId;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 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;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|
||||||
import org.bouncycastle.openpgp.PGPSignature;
|
|
||||||
import org.pgpainless.algorithm.SignatureType;
|
|
||||||
import org.pgpainless.signature.SelectSignatureFromKey;
|
|
||||||
|
|
||||||
public class KeyValidator {
|
|
||||||
|
|
||||||
public PGPPublicKeyRing validatePublicKeyRing(PGPPublicKeyRing publicKeys) throws PGPException {
|
|
||||||
PGPPublicKey primaryKey = publicKeys.getPublicKey();
|
|
||||||
if (!isValidPrimaryKey(primaryKey, publicKeys)) {
|
|
||||||
throw new PGPException("Primary key is not valid");
|
|
||||||
}
|
|
||||||
return publicKeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isValidPrimaryKey(PGPPublicKey publicKey, PGPPublicKeyRing keyRing) {
|
|
||||||
if (!publicKey.isMasterKey()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyRing.getPublicKey().getKeyID() != publicKey.getKeyID()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<PGPSignature> signatures = publicKey.getSignatures();
|
|
||||||
while (signatures.hasNext()) {
|
|
||||||
PGPSignature signature = signatures.next();
|
|
||||||
SignatureType signatureType = SignatureType.valueOf(signature.getSignatureType());
|
|
||||||
switch (signatureType) {
|
|
||||||
case KEY_REVOCATION:
|
|
||||||
if (SelectSignatureFromKey.isValidKeyRevocationSignature(publicKey).accept(signature, publicKey, keyRing)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 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;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.pgpainless.key.protection.passphrase_provider.SecretKeyPassphraseProvider;
|
|
||||||
import org.pgpainless.util.Passphrase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stub class for API backwards compatibility.
|
|
||||||
* @deprecated use {@link CachingSecretKeyRingProtector} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class PassphraseMapKeyRingProtector extends CachingSecretKeyRingProtector {
|
|
||||||
|
|
||||||
public PassphraseMapKeyRingProtector(@Nonnull Map<Long, Passphrase> passphrases, @Nonnull KeyRingProtectionSettings protectionSettings, @Nullable SecretKeyPassphraseProvider missingPassphraseCallback) {
|
|
||||||
super(passphrases, protectionSettings, missingPassphraseCallback);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 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.util;
|
|
||||||
|
|
||||||
public class SignatureTree {
|
|
||||||
|
|
||||||
public interface Node {
|
|
||||||
long getKeyId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface PrimaryKeyNode extends Node {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SubkeyNode extends Node {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SignatureNode extends Node {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 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.util;
|
|
||||||
|
|
||||||
public class Tuple<A, B> {
|
|
||||||
private final A first;
|
|
||||||
private final B second;
|
|
||||||
|
|
||||||
public Tuple(A first, B second) {
|
|
||||||
this.first = first;
|
|
||||||
this.second = second;
|
|
||||||
}
|
|
||||||
|
|
||||||
public A getFirst() {
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
|
|
||||||
public B getSecond() {
|
|
||||||
return second;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue