mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-18 18:21:08 +01:00
SubkeyLookup: Return set of fingerprints instead of a single one
This commit is contained in:
parent
0e4cf1c166
commit
7b66954199
10 changed files with 95 additions and 220 deletions
|
|
@ -6,21 +6,33 @@ package pgp.cert_d;
|
|||
|
||||
import pgp.certificate_store.SubkeyLookup;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class InMemorySubkeyLookup implements SubkeyLookup {
|
||||
|
||||
private static final Map<Long, String> subkeyMap = new HashMap<>();
|
||||
private static final Map<Long, Set<String>> subkeyMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String getIdentifierForSubkeyId(long subkeyId) {
|
||||
return subkeyMap.get(subkeyId);
|
||||
public Set<String> getIdentifiersForSubkeyId(long subkeyId) {
|
||||
Set<String> identifiers = subkeyMap.get(subkeyId);
|
||||
if (identifiers == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return Collections.unmodifiableSet(identifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeIdentifierForSubkeyId(long subkeyId, String identifier) {
|
||||
subkeyMap.put(subkeyId, identifier);
|
||||
Set<String> identifiers = subkeyMap.get(subkeyId);
|
||||
if (identifiers == null) {
|
||||
identifiers = new HashSet<>();
|
||||
subkeyMap.put(subkeyId, identifiers);
|
||||
}
|
||||
identifiers.add(identifier);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package pgp.cert_d;
|
||||
|
||||
import pgp.certificate_store.SubkeyLookup;
|
||||
|
||||
public class SubkeyLookupImpl implements SubkeyLookup {
|
||||
|
||||
@Override
|
||||
public String getIdentifierForSubkeyId(long subkeyId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeIdentifierForSubkeyId(long subkeyId, String identifier) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue