Package ghidra.framework.client
Class ClientUtil
- java.lang.Object
-
- ghidra.framework.client.ClientUtil
-
public class ClientUtil extends java.lang.ObjectClientUtilallows a user to connect to a Repository Server and obtain its handle.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidchangePassword(java.awt.Component parent, RepositoryServerHandle handle, java.lang.String serverInfo)Prompt user and change password on server (not initiated by user).static voidcheckGhidraServer(java.lang.String host, int port)Connect to a Ghidra Server and verify compatibility.static voidclearRepositoryAdapter(java.lang.String host, int port)Eliminate the specified repository server from the connection cachestatic ClientAuthenticatorgetClientAuthenticator()Get the currently installed client authenticator.static RepositoryServerAdaptergetRepositoryServer(java.lang.String host, int port)Connect to a Repository Server and obtain a handle to it.static RepositoryServerAdaptergetRepositoryServer(java.lang.String host, int port, boolean forceConnect)Connect to a Repository Server and obtain a handle to it.static java.lang.StringgetUserName()Returns default user login name.static voidhandleException(RepositoryAdapter repository, java.lang.Exception exc, java.lang.String operation, boolean mustRetry, java.awt.Component parent)Displays an error dialog appropriate for the given exception.static voidhandleException(RepositoryAdapter repository, java.lang.Exception exc, java.lang.String operation, java.awt.Component parent)Displays an error dialog appropriate for the given exception.static booleanisSSHKeyAvailable()static voidpromptForReconnect(RepositoryAdapter repository, java.awt.Component parent)Prompt the user to reconnect to the Ghidra Server.static voidsetClientAuthenticator(ClientAuthenticator authenticator)Set client authenticator
-
-
-
Method Detail
-
setClientAuthenticator
public static void setClientAuthenticator(ClientAuthenticator authenticator)
Set client authenticator- Parameters:
authenticator-
-
getClientAuthenticator
public static ClientAuthenticator getClientAuthenticator()
Get the currently installed client authenticator. If one has not been installed, this will trigger the installation of a default instance.- Returns:
- current client authenticator
-
getRepositoryServer
public static RepositoryServerAdapter getRepositoryServer(java.lang.String host, int port)
Connect to a Repository Server and obtain a handle to it. Based upon the server authentication requirements, the user may be prompted for a password via a Swing dialog. If a previous connection attempt to this server failed, the adapter may be returned in a disconnected state.- Parameters:
host- server name or addressport- server port, 0 indicates that default port should be used.- Returns:
- repository server adapter
-
getRepositoryServer
public static RepositoryServerAdapter getRepositoryServer(java.lang.String host, int port, boolean forceConnect)
Connect to a Repository Server and obtain a handle to it. Based upon the server authentication requirements, the user may be prompted for a password via a Swing dialog.- Parameters:
host- server name or addressport- server port, 0 indicates that default port should be used.forceConnect- if true and the server adapter is disconnected, an attempt will be made to reconnect.- Returns:
- repository server handle
-
clearRepositoryAdapter
public static void clearRepositoryAdapter(java.lang.String host, int port) throws java.io.IOExceptionEliminate the specified repository server from the connection cache- Parameters:
host- host name or IP addressport- port (0: use default port)- Throws:
java.io.IOException
-
getUserName
public static java.lang.String getUserName()
Returns default user login name. Actual user name used by repository should be obtained from RepositoryServerAdapter.getUser
-
handleException
public static void handleException(RepositoryAdapter repository, java.lang.Exception exc, java.lang.String operation, boolean mustRetry, java.awt.Component parent)
Displays an error dialog appropriate for the given exception. If the exception is a ConnectException or NotConnectedException, a prompt to reconnect to the Ghidra Server is displayed.- Parameters:
repository- may be null if the exception is not a RemoteExceptionexc- exception that occurredoperation- operation that was being done when the exception occurred; this string is be used in the message for the error dialog if one should be displayedmustRetry- true if the message should state that the user should retry the operation because it may not have succeeded (if the exception was because a RemoteException); there may be cases where the operation succeeded; as a result of the operation, a bad connection to the server was detected (e.g., save a file). Note: this parameter is ignored if the exception is not a ConnectException or NotConnectedException.parent- parent of the error dialog
-
handleException
public static void handleException(RepositoryAdapter repository, java.lang.Exception exc, java.lang.String operation, java.awt.Component parent)
Displays an error dialog appropriate for the given exception. If the exception is a ConnectException or NotConnectedException, a prompt to reconnect to the Ghidra Server is displayed. The message states that the operation may have to be retried due to the failed connection.- Parameters:
repository- may be null if the exception is not a RemoteExceptionexc- exception that occurredoperation- operation that was being done when the exception occurred; this string is be used in the message for the error dialog if one should be displayedparent- parent of the error dialog
-
promptForReconnect
public static void promptForReconnect(RepositoryAdapter repository, java.awt.Component parent)
Prompt the user to reconnect to the Ghidra Server.- Parameters:
repository- repository to connect toparent- parent of the dialog
-
checkGhidraServer
public static void checkGhidraServer(java.lang.String host, int port) throws java.io.IOExceptionConnect to a Ghidra Server and verify compatibility. This method can be used to affectively "ping" the Ghidra Server to verify the ability to connect. NOTE: Use of this method when PKI authentication is enabled is not supported.- Parameters:
host- server hostnameport- first Ghidra Server port (0=use default)- Throws:
java.io.IOException- thrown if an IO Error occurs (e.g., server not found).java.rmi.RemoteException- if server interface is incompatible or another server-side error occurs.
-
changePassword
public static void changePassword(java.awt.Component parent, RepositoryServerHandle handle, java.lang.String serverInfo) throws java.io.IOExceptionPrompt user and change password on server (not initiated by user).- Parameters:
parent- dialog parenthandle- server handleserverInfo- server information- Throws:
java.io.IOException
-
isSSHKeyAvailable
public static boolean isSSHKeyAvailable()
-
-