import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicReference;
import net.pterodactylus.fcp.FcpKeyPair;
import net.pterodactylus.fcp.GenerateSSK;
@Override
public ListenableFuture<FcpKeyPair> execute() {
- return threadPool.submit(this::executeSequence);
+ return threadPool.submit(this::executeDialog);
}
- private FcpKeyPair executeSequence() throws InterruptedException, ExecutionException, IOException {
+ private FcpKeyPair executeDialog() throws InterruptedException, ExecutionException, IOException {
try (FcpKeyPairDialog fcpKeyPairDialog = new FcpKeyPairDialog()) {
return fcpKeyPairDialog.send(new GenerateSSK()).get();
}
private class FcpKeyPairDialog extends FcpDialog<FcpKeyPair> {
- private AtomicReference<FcpKeyPair> keyPair = new AtomicReference<>();
-
public FcpKeyPairDialog() throws IOException {
- super(GenerateKeypairCommandImpl.this.threadPool, GenerateKeypairCommandImpl.this.connectionSupplier.get());
- }
-
- @Override
- protected boolean isFinished() {
- return keyPair.get() != null;
- }
-
- @Override
- protected FcpKeyPair getResult() {
- return keyPair.get();
+ super(GenerateKeypairCommandImpl.this.threadPool, GenerateKeypairCommandImpl.this.connectionSupplier.get(), null);
}
@Override
protected void consumeSSKKeypair(SSKKeypair sskKeypair) {
- keyPair.set(new FcpKeyPair(sskKeypair.getRequestURI(), sskKeypair.getInsertURI()));
+ setResult(new FcpKeyPair(sskKeypair.getRequestURI(), sskKeypair.getInsertURI()));
}
}