Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2022-02-15 08:04:54 +0000
committerEd Merks2022-02-15 08:40:59 +0000
commit2b6d277e425dab6d0a07d0422274e5dce4222813 (patch)
tree2fa352ea90629dd12a2ae31c18f85be399f20523
parent7f82c5c53d2fbbe0a4fc81d7f94db118e0c4ddc2 (diff)
downloadrt.equinox.p2-I20220223-0600.tar.gz
rt.equinox.p2-I20220223-0600.tar.xz
rt.equinox.p2-I20220223-0600.zip
PGP public keys Delegate to DefaultPGPPublicKeyService.getLocalKeyCache(long) when looking up a key so that even without a key server or when offline, previously cached keys can be found if present in the local cache. Change-Id: If45f9871bdaf7507370e0170d49392c2fc356f1c Signed-off-by: Ed Merks <ed.merks@gmail.com> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.p2/+/190804
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/provisional/p2/repository/DefaultPGPPublicKeyService.java44
1 files changed, 23 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/provisional/p2/repository/DefaultPGPPublicKeyService.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/provisional/p2/repository/DefaultPGPPublicKeyService.java
index 6ec663206..3aa501986 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/provisional/p2/repository/DefaultPGPPublicKeyService.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/provisional/p2/repository/DefaultPGPPublicKeyService.java
@@ -191,10 +191,7 @@ public class DefaultPGPPublicKeyService extends PGPPublicKeyService {
keys.addAll(keyServer.getKeys(keyID));
}
- LocalKeyCache localKeyCache = localKeys.get(keyID);
- if (localKeyCache != null) {
- keys.addAll(localKeyCache.get());
- }
+ keys.addAll(getLocalKeyCache(keyID).get());
keys.addAll(getDefaultKeys(keyID));
@@ -300,23 +297,7 @@ public class DefaultPGPPublicKeyService extends PGPPublicKeyService {
@Override
public PGPPublicKey addKey(PGPPublicKey key) {
long keyID = key.getKeyID();
- LocalKeyCache localKeyCache = localKeys.get(keyID);
- if (localKeyCache == null) {
- String hexKeyID = toHex(keyID);
- Path cache = keyCache.resolve(hexKeyID + ".asc"); //$NON-NLS-1$
- localKeyCache = new LocalKeyCache(cache) {
- @Override
- protected List<PGPPublicKey> reconcileKeys(List<PGPPublicKey> keys) {
- return DefaultPGPPublicKeyService.this.reconcileKeys(keys);
- }
-
- @Override
- protected void log(Throwable throwable) {
- DefaultPGPPublicKeyService.this.log(throwable);
- }
- };
- localKeys.put(keyID, localKeyCache);
- }
+ LocalKeyCache localKeyCache = getLocalKeyCache(keyID);
localKeyCache.add(key);
Collection<PGPPublicKey> keys = getKeys(keyID);
@@ -414,6 +395,27 @@ public class DefaultPGPPublicKeyService extends PGPPublicKeyService {
return null;
}
+ private LocalKeyCache getLocalKeyCache(long keyID) {
+ LocalKeyCache localKeyCache = localKeys.get(keyID);
+ if (localKeyCache == null) {
+ String hexKeyID = toHex(keyID);
+ Path cache = keyCache.resolve(hexKeyID + ".asc"); //$NON-NLS-1$
+ localKeyCache = new LocalKeyCache(cache) {
+ @Override
+ protected List<PGPPublicKey> reconcileKeys(List<PGPPublicKey> keys) {
+ return DefaultPGPPublicKeyService.this.reconcileKeys(keys);
+ }
+
+ @Override
+ protected void log(Throwable throwable) {
+ DefaultPGPPublicKeyService.this.log(throwable);
+ }
+ };
+ localKeys.put(keyID, localKeyCache);
+ }
+ return localKeyCache;
+ }
+
protected Collection<PGPPublicKey> fetchKeys(URI uri, Path cache) throws IOException {
try {
ByteArrayOutputStream reciever = new ByteArrayOutputStream();

Back to the top