2026-02-10 23:13:58 +01:00
|
|
|
package org.openautonomousconnection.webclient;
|
2026-02-08 22:36:42 +01:00
|
|
|
|
|
|
|
|
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
2026-02-10 23:13:58 +01:00
|
|
|
import org.openautonomousconnection.infonamelib.OacWebUrlInstaller;
|
2026-02-08 22:36:42 +01:00
|
|
|
import org.openautonomousconnection.oacswing.component.OACOptionPane;
|
|
|
|
|
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
|
|
|
|
import org.openautonomousconnection.protocol.side.client.events.ConnectedToProtocolINSServerEvent;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
|
|
|
|
|
public class ClientImpl extends ProtocolClient {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean trustINS(String caFingerprint) {
|
|
|
|
|
Object[] options = {"Continue", "Cancel"};
|
|
|
|
|
int result = OACOptionPane.showOptionDialog(
|
|
|
|
|
Main.getUi(),
|
|
|
|
|
"You never connected to this INS before!\n" +
|
|
|
|
|
"Fingerprint: " + caFingerprint + "\nDo you want to connect?",
|
|
|
|
|
"INS Connection",
|
|
|
|
|
OACOptionPane.YES_NO_OPTION,
|
|
|
|
|
OACOptionPane.INFORMATION_MESSAGE,
|
|
|
|
|
null,
|
|
|
|
|
options,
|
|
|
|
|
options[0] // default button: Continue
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return result == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean trustNewINSFingerprint(String oldCAFingerprint, String newCAFingerprint) {
|
|
|
|
|
Object[] options = {"Continue", "Cancel"};
|
|
|
|
|
|
|
|
|
|
String table = String.format("""
|
|
|
|
|
Saved Fingerprint\tNew Fingerprint
|
|
|
|
|
%s\t%s
|
|
|
|
|
""", oldCAFingerprint, newCAFingerprint);
|
|
|
|
|
|
|
|
|
|
int result = OACOptionPane.showOptionDialog(
|
|
|
|
|
Main.getUi(),
|
|
|
|
|
"The fingerprint does not match with the saved fingerprint!\n" +
|
|
|
|
|
"Saved Fingerprint: " + oldCAFingerprint + "\n" +
|
|
|
|
|
"New Fingerprint: " + newCAFingerprint + "\n" +
|
|
|
|
|
"Do you want to connect?",
|
|
|
|
|
"INS Connection",
|
|
|
|
|
OACOptionPane.YES_NO_OPTION,
|
|
|
|
|
OACOptionPane.INFORMATION_MESSAGE,
|
|
|
|
|
null,
|
|
|
|
|
options,
|
|
|
|
|
options[0] // default button: Continue
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return result == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Listener
|
|
|
|
|
public void onConnected(ConnectedToProtocolINSServerEvent event) {
|
|
|
|
|
try {
|
2026-02-10 23:13:58 +01:00
|
|
|
buildServerConnection(null, getProtocolBridge().getProtocolValues().ssl);
|
2026-02-11 23:31:49 +01:00
|
|
|
|
|
|
|
|
//ProtocolHandlerPackages.installPackage("org.openautonomousconnection.infonamelib");
|
2026-02-10 23:13:58 +01:00
|
|
|
OacWebUrlInstaller.installOnce(getProtocolBridge().getProtocolValues().eventManager, this);
|
2026-02-11 23:31:49 +01:00
|
|
|
|
2026-02-10 23:13:58 +01:00
|
|
|
SwingUtilities.invokeLater(() -> Main.getUi().openNewTab("web://info.oac/"));
|
2026-02-08 22:36:42 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
Main.getClient().getProtocolBridge().getLogger().exception("Failed to build Server connection", e);
|
|
|
|
|
OACOptionPane.showMessageDialog(Main.getUi(), "Failed to connect to build Server connection:\n" + e.getMessage(),
|
|
|
|
|
"Server Connection", OACOptionPane.ERROR_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|