1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-17 00:54:50 +02:00
pgpainless/pgpainless-core/src/main/java/org/pgpainless/policy/NotationRegistry.java
Paul Schaub 68575f9f1e
Reorganize classes in packages
Move ArmorUtils to org.pgpainless.ascii_armor
Move Armored*StreamFactory to org.pgpainless.ascii_armor
Move CRCingArmoredInputStreamWrapper to org.pgpainless.ascii_armor
Move SessionKey to org.pgpainless.s2k
Move RevocationAttributes to org.pgpainless.key
Move UserId to org.pgpainless.key
Move Passphrase to org.pgpainless.s2k
Move NotationRegistry to org.pgpainless.policy
2022-09-07 13:35:58 +02:00

51 lines
1.5 KiB
Java

// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.policy;
import java.util.HashSet;
import java.util.Set;
/**
* Registry for known notations.
* Since signature verification must reject signatures with critical notations that are not known to the application,
* there must be some way to tell PGPainless which notations actually are known.
*
* To add a notation name, call {@link #addKnownNotation(String)}.
*/
public class NotationRegistry {
private final Set<String> knownNotations = new HashSet<>();
/**
* Add a known notation name into the registry.
* This will cause critical notations with that name to no longer invalidate the signature.
*
* @param notationName name of the notation
*/
public void addKnownNotation(String notationName) {
if (notationName == null) {
throw new NullPointerException("Notation name MUST NOT be null.");
}
knownNotations.add(notationName);
}
/**
* Return true if the notation name is registered in the registry.
*
* @param notationName name of the notation
* @return true if notation is known, false otherwise.
*/
public boolean isKnownNotation(String notationName) {
return knownNotations.contains(notationName);
}
/**
* Clear all known notations from the registry.
*/
public void clear() {
knownNotations.clear();
}
}