mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 20:47:49 +01:00
don't call getPeerDirectory on every call
This commit is contained in:
@@ -219,6 +219,10 @@ public class PersistentRemoteHostsService {
|
|||||||
return getPeerDirectory().runReadLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (m, d) -> d.getPeers().contains(uuid));
|
return getPeerDirectory().runReadLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (m, d) -> d.getPeers().contains(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PersistentPeerInfo getHost(UUID uuid) {
|
||||||
|
return getPeer(uuid).runReadLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (m, d) -> d);
|
||||||
|
}
|
||||||
|
|
||||||
public KeyPair getSelfKeypair() {
|
public KeyPair getSelfKeypair() {
|
||||||
return _persistentData.runReadLocked(PersistentRemoteHostsData::getSelfKeyPair);
|
return _persistentData.runReadLocked(PersistentRemoteHostsData::getSelfKeyPair);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.smallrye.mutiny.Uni;
|
|||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
@@ -28,17 +29,19 @@ public class PeerRolesAugmentor implements SecurityIdentityAugmentor {
|
|||||||
} else {
|
} else {
|
||||||
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder(identity);
|
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder(identity);
|
||||||
|
|
||||||
var entry = persistentRemoteHostsService.getHosts().stream()
|
var uuid = identity.getPrincipal().getName().substring(3);
|
||||||
.filter(i -> i.getUuid().toString()
|
|
||||||
.equals(identity.getPrincipal().getName().substring(3)))
|
|
||||||
.findFirst();
|
|
||||||
if (entry.isEmpty()) return () -> identity;
|
|
||||||
|
|
||||||
if (!entry.get().getCertificate().equals(identity.getCredential(CertificateCredential.class).getCertificate()))
|
try {
|
||||||
|
var entry = persistentRemoteHostsService.getHost(UUID.fromString(uuid));
|
||||||
|
|
||||||
|
if (!entry.getCertificate().equals(identity.getCredential(CertificateCredential.class).getCertificate()))
|
||||||
|
return () -> identity;
|
||||||
|
|
||||||
|
builder.addRole("cluster-member");
|
||||||
|
return builder::build;
|
||||||
|
} catch (Exception e) {
|
||||||
return () -> identity;
|
return () -> identity;
|
||||||
|
}
|
||||||
builder.addRole("cluster-member");
|
|
||||||
return builder::build;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user