Package ghidra.framework.client

# Class RepositoryServerAdapter

java.lang.Object
ghidra.framework.client.RepositoryServerAdapter

public class RepositoryServerAdapter extends Object
`RepositoryServerAdapter` provides a persistent wrapper for a `RepositoryServerHandle` which may become invalid if the remote connection were to fail.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `RepositoryServerAdapter(RepositoryServerHandle serverHandle, String serverInfoString)`
  Construct a repository server interface adapter.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addListener(RemoteAdapterListener listener)`
  Add a listener to this remote adapter
  `boolean`
  `anonymousAccessAllowed()`
  `boolean`
  `canSetPassword()`
  Returns true if this server allows the user to change their password.
  `boolean`
  `connect()`
  Attempt to connect or re-connect to the server.
  `RepositoryAdapter`
  `createRepository(String name)`
  Create a new repository on the server.
  `void`
  `deleteRepository(String name)`
  Delete a repository.
  `void`
  `disconnect()`
  Force disconnect with server
  `String[]`
  `getAllUsers()`
  Returns a list of all known users.
  `Throwable`
  `getLastConnectError()`
  Returns the last error associated with a failed connection attempt.
  `RepositoryAdapter`
  `getRepository(String name)`
  Get a handle to an existing repository.
  `String[]`
  `getRepositoryNames()`
  Returns a list of all repository names defined to the server.
  `ServerInfo`
  `getServerInfo()`
  Returns server information.
  `String`
  `getUser()`
  Returns user's server login identity
  `boolean`
  `isCancelled()`
  Returns true if the connection was cancelled by the user.
  `boolean`
  `isConnected()`
  Returns true if connected.
  `boolean`
  `isReadOnly()`
  `void`
  `removeListener(RemoteAdapterListener listener)`
  Remove a listener from this remote adapter
  `boolean`
  `setPassword(char[] saltedSHA256PasswordHash)`
  Set the simple password for the user.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### RepositoryServerAdapter

    protected RepositoryServerAdapter(RepositoryServerHandle serverHandle, String serverInfoString)
    Construct a repository server interface adapter.
    Parameters:
      `serverHandle` - associated server handle (reconnect not supported)

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### addListener

    public void addListener(RemoteAdapterListener listener)
    Add a listener to this remote adapter
    Parameters:
      `listener` -

  - ### removeListener

    public void removeListener(RemoteAdapterListener listener)
    Remove a listener from this remote adapter
    Parameters:
      `listener` -

  - ### isCancelled

    public boolean isCancelled()
    Returns true if the connection was cancelled by the user.
    Returns:
      try if cancelled by user

  - ### getLastConnectError

    public Throwable getLastConnectError()
    Returns the last error associated with a failed connection attempt.
    Returns:
      last connect error or null

  - ### isConnected

    public boolean isConnected()
    Returns true if connected.

  - ### connect

    public boolean connect() throws NotConnectedException
    Attempt to connect or re-connect to the server.
    Returns:
      true if connect successful, false if cancelled by user
    Throws:
      `NotConnectedException` - if connect failed (error will be displayed to user)

  - ### createRepository

    public RepositoryAdapter createRepository(String name) throws DuplicateNameException, UserAccessException, IOException, NotConnectedException
    Create a new repository on the server.
    Parameters:
      `name` - repository name.
    Returns:
      handle to new repository.
    Throws:
      `DuplicateNameException`
      `UserAccessException`
      `IOException`
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.createRepository(String)`

  - ### getRepository

    public RepositoryAdapter getRepository(String name)
    Get a handle to an existing repository. The repository adapter is initially disconnected - the connect() method or another repository action method must be invoked to establish a repository connection.
    Parameters:
      `name` - repository name.
    Returns:
      repository handle or null if repository not found.

  - ### deleteRepository

    public void deleteRepository(String name) throws UserAccessException, IOException, NotConnectedException
    Delete a repository.
    Parameters:
      `name` - repository name.
    Throws:
      `UserAccessException`
      `IOException`
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.deleteRepository(java.lang.String)`

  - ### getRepositoryNames

    public String[] getRepositoryNames() throws IOException, NotConnectedException
    Returns a list of all repository names defined to the server.
    Throws:
      `IOException`
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.getRepositoryNames()`

  - ### anonymousAccessAllowed

    public boolean anonymousAccessAllowed() throws IOException, NotConnectedException
    Returns:
      true if server allows anonymous access. Individual repositories must grant anonymous access separately.
    Throws:
      `IOException`
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.anonymousAccessAllowed()`

  - ### isReadOnly

    public boolean isReadOnly() throws IOException, NotConnectedException
    Returns:
      true if user has restricted read-only access to server (e.g., anonymous user)
    Throws:
      `IOException`
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.isReadOnly()`

  - ### getUser

    public String getUser()
    Returns user's server login identity

  - ### getAllUsers

    public String[] getAllUsers() throws IOException, NotConnectedException
    Returns a list of all known users.
    Throws:
      `IOException`
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.getAllUsers()`

  - ### setPassword

    public boolean setPassword(char[] saltedSHA256PasswordHash) throws IOException, NotConnectedException
    Set the simple password for the user.
    Parameters:
      `saltedSHA256PasswordHash` - hex character representation of salted SHA256 hash of the password
    Returns:
      true if password changed
    Throws:
      `IOException` - if user data can't be written to file
      `NotConnectedException` - if server connection is down (user already informed)
    See Also:
      - `RemoteRepositoryServerHandle.setPassword(char[])`
      - `HashUtilities.getSaltedHash("SHA-256", char[])`

  - ### canSetPassword

    public boolean canSetPassword()
    Returns true if this server allows the user to change their password.
    See Also:
      - `RemoteRepositoryServerHandle.canSetPassword()`

  - ### getServerInfo

    public ServerInfo getServerInfo()
    Returns server information. May be null if using fixed RepositoryServerHandle.

  - ### disconnect

    public void disconnect()
    Force disconnect with server