mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-24 03:47:57 +01:00
Please checkstyle
This commit is contained in:
parent
65356ae3ae
commit
8afad6cea8
31 changed files with 172 additions and 20 deletions
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot;
|
||||
|
||||
import pgp.cert_d.PGPCertificateDirectory;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* PGPainless API for Web of Trust.
|
||||
*/
|
||||
package org.pgpainless.wot;
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
public class Cost {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
public abstract class Edge<T, C extends Cost> implements Comparable<C> {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
public final class IntegerUtils {
|
||||
|
||||
private IntegerUtils() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Backported method from Java 8.
|
||||
*
|
||||
* @param x x
|
||||
* @param y y
|
||||
* @return result of comparison
|
||||
*/
|
||||
public static int compare(int x, int y) {
|
||||
// noinspection UseCompareMethod
|
||||
return x < y ? -1 : (x == y ? 0 : 1);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
public class Node<T> {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
public class SimpleEdge<T> extends Edge<T, Cost.SimpleCost> {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -12,7 +16,7 @@ public class TrustEdge<T> extends Edge<T, Cost.TrustCost> {
|
|||
public int compareTo(@Nonnull Cost.TrustCost o) {
|
||||
int depthCompare = Double.compare(cost.getDepth(), o.getDepth());
|
||||
if (depthCompare != 0) {
|
||||
return - depthCompare;
|
||||
return -depthCompare;
|
||||
}
|
||||
return Double.compare(cost.getAmount(), o.getAmount());
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Dijkstra-based WoT implementation using a flow network.
|
||||
*/
|
||||
package org.pgpainless.wot.dijkstra;
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import org.pgpainless.algorithm.RevocationState;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -38,7 +42,7 @@ public class Certification {
|
|||
this.creationTime = creationTime;
|
||||
this.expirationTime = expirationTime;
|
||||
this.exportable = exportable;
|
||||
this.trustAmount= trustAmount;
|
||||
this.trustAmount = trustAmount;
|
||||
this.trustDepth = trustDepth;
|
||||
this.regex = regex;
|
||||
}
|
||||
|
@ -110,7 +114,7 @@ public class Certification {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the creation time of the certification,
|
||||
* Get the creation time of the certification.
|
||||
*
|
||||
* @return creation time
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -9,7 +13,7 @@ import org.bouncycastle.openpgp.PGPSignature;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CertificationSet {
|
||||
public final class CertificationSet {
|
||||
|
||||
private final CertSynopsis issuer;
|
||||
private final CertSynopsis target;
|
||||
|
@ -98,7 +102,7 @@ public class CertificationSet {
|
|||
}
|
||||
|
||||
List<Certification> certificationsForUserId = certifications.get(certification.getUserId());
|
||||
//noinspection Java8MapApi
|
||||
// noinspection Java8MapApi
|
||||
if (certificationsForUserId == null) {
|
||||
certificationsForUserId = new ArrayList<>();
|
||||
certifications.put(certification.getUserId(), certificationsForUserId);
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import org.pgpainless.wot.dijkstra.IntegerUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class Depth implements Comparable<Depth> {
|
||||
public final class Depth implements Comparable<Depth> {
|
||||
|
||||
private final Optional<Integer> depth;
|
||||
|
||||
|
@ -55,7 +61,7 @@ public class Depth implements Comparable<Depth> {
|
|||
if (o.isUnconstrained()) {
|
||||
return -1;
|
||||
} else {
|
||||
return Integer.compare(getLimit().get(), o.getLimit().get());
|
||||
return IntegerUtils.compare(getLimit().get(), o.getLimit().get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,7 +16,6 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.algorithm.RevocationState;
|
||||
import org.pgpainless.algorithm.RevocationStateType;
|
||||
import org.pgpainless.key.OpenPgpFingerprint;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.key.util.RevocationAttributes;
|
||||
|
@ -96,13 +99,13 @@ public class Network {
|
|||
Map<OpenPgpFingerprint, CertSynopsis> certSynopsisMap = new HashMap<>();
|
||||
|
||||
for (KeyRingInfo cert : validatedCertificates) {
|
||||
//noinspection Java8MapApi
|
||||
// noinspection Java8MapApi
|
||||
if (byFingerprint.get(cert.getFingerprint()) == null) {
|
||||
byFingerprint.put(cert.getFingerprint(), cert);
|
||||
}
|
||||
List<KeyRingInfo> byKeyIdEntry = byKeyId.get(cert.getKeyId());
|
||||
|
||||
//noinspection Java8MapApi
|
||||
// noinspection Java8MapApi
|
||||
if (byKeyIdEntry == null) {
|
||||
byKeyIdEntry = new ArrayList<>();
|
||||
byKeyId.put(cert.getKeyId(), byKeyIdEntry);
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class Optional<T> {
|
||||
public final class Optional<T> {
|
||||
|
||||
private final T item;
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -10,7 +14,7 @@ import javax.annotation.Nonnull;
|
|||
|
||||
import org.bouncycastle.bcpg.sig.RegularExpression;
|
||||
|
||||
public class RegexSet {
|
||||
public final class RegexSet {
|
||||
|
||||
private final Set<String> regexStrings;
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Web of Trust implementation.
|
||||
*/
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class NetworkTest {
|
||||
|
||||
|
@ -29,6 +25,7 @@ public class NetworkTest {
|
|||
@Test
|
||||
public void testNetworkFromCertificates() {
|
||||
ReferenceTime referenceTime = ReferenceTime.now();
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -249,6 +253,7 @@ public class WotTestVectors {
|
|||
})
|
||||
.getCertifiedCertificate();
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println("Foo Employee");
|
||||
System.out.println(PGPainless.asciiArmor(caCertifiedFooBankEmployeeCert));
|
||||
|
||||
|
@ -263,6 +268,7 @@ public class WotTestVectors {
|
|||
|
||||
System.out.println("Bar Employee");
|
||||
System.out.println(PGPainless.asciiArmor(barCaCertifiedEmployeeCert));
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
|
||||
private static InputStream getTestResourceInputStream(String resource) {
|
||||
|
|
Loading…
Reference in a new issue