mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 12:37:48 +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));
|
||||
}
|
||||
|
||||
public PersistentPeerInfo getHost(UUID uuid) {
|
||||
return getPeer(uuid).runReadLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (m, d) -> d);
|
||||
}
|
||||
|
||||
public KeyPair getSelfKeypair() {
|
||||
return _persistentData.runReadLocked(PersistentRemoteHostsData::getSelfKeyPair);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.smallrye.mutiny.Uni;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ApplicationScoped
|
||||
@@ -28,17 +29,19 @@ public class PeerRolesAugmentor implements SecurityIdentityAugmentor {
|
||||
} else {
|
||||
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder(identity);
|
||||
|
||||
var entry = persistentRemoteHostsService.getHosts().stream()
|
||||
.filter(i -> i.getUuid().toString()
|
||||
.equals(identity.getPrincipal().getName().substring(3)))
|
||||
.findFirst();
|
||||
if (entry.isEmpty()) return () -> identity;
|
||||
var uuid = identity.getPrincipal().getName().substring(3);
|
||||
|
||||
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;
|
||||
|
||||
builder.addRole("cluster-member");
|
||||
return builder::build;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user