Class HeadlessClientAuthenticator

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.Authenticator getAuthenticator()
      Get a standard Java authenticator for HTTP and other standard network connections
      char[] getKeyStorePassword​(java.lang.String keystorePath, boolean passwordError)
      Requests password for keystore file
      char[] getNewPassword​(java.awt.Component parent, java.lang.String serverInfo, java.lang.String username)
      Get new user password
      static void installHeadlessClientAuthenticator​(java.lang.String username, java.lang.String keystorePath, boolean allowPasswordPrompt)
      Install headless client authenticator for Ghidra Server
      boolean isSSHKeyAvailable()  
      boolean processPasswordCallbacks​(java.lang.String title, java.lang.String serverType, java.lang.String serverName, javax.security.auth.callback.NameCallback nameCb, javax.security.auth.callback.PasswordCallback passCb, javax.security.auth.callback.ChoiceCallback choiceCb, AnonymousCallback anonymousCb, java.lang.String loginError)
      Process Ghidra Server password authentication callbacks.
      boolean processSSHSignatureCallbacks​(java.lang.String serverName, javax.security.auth.callback.NameCallback nameCb, SSHSignatureCallback sshCb)
      Process Ghidra Server SSH authentication callbacks.
      boolean promptForReconnect​(java.awt.Component parent, java.lang.String message)
      Prompt user for reconnect
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAuthenticator

        public java.net.Authenticator getAuthenticator()
        Description copied from interface: ClientAuthenticator
        Get a standard Java authenticator for HTTP and other standard network connections
        Specified by:
        getAuthenticator in interface ClientAuthenticator
        Returns:
        authenticator object
      • installHeadlessClientAuthenticator

        public static void installHeadlessClientAuthenticator​(java.lang.String username,
                                                              java.lang.String keystorePath,
                                                              boolean allowPasswordPrompt)
                                                       throws java.io.IOException
        Install headless client authenticator for Ghidra Server
        Parameters:
        username - optional username to be used with a Ghidra Server which allows username to be specified
        keystorePath - optional PKI or SSH keystore path. May also be specified as resource path for SSH key.
        allowPasswordPrompt - if true the user may be prompted for passwords via the console (stdin). Please note that the Java console will echo the password entry to the terminal which may be undesirable.
        Throws:
        java.io.IOException - if error occurs while opening specified keystorePath
      • getNewPassword

        public char[] getNewPassword​(java.awt.Component parent,
                                     java.lang.String serverInfo,
                                     java.lang.String username)
        Description copied from interface: ClientAuthenticator
        Get new user password
        Specified by:
        getNewPassword in interface ClientAuthenticator
        Parameters:
        parent - dialog parent component or null if not applicable
        serverInfo - server host info
        Returns:
        new password or null if password should not be changed, if not null array will be cleared by caller
      • processPasswordCallbacks

        public boolean processPasswordCallbacks​(java.lang.String title,
                                                java.lang.String serverType,
                                                java.lang.String serverName,
                                                javax.security.auth.callback.NameCallback nameCb,
                                                javax.security.auth.callback.PasswordCallback passCb,
                                                javax.security.auth.callback.ChoiceCallback choiceCb,
                                                AnonymousCallback anonymousCb,
                                                java.lang.String loginError)
        Description copied from interface: ClientAuthenticator
        Process Ghidra Server password authentication callbacks.
        Specified by:
        processPasswordCallbacks in interface ClientAuthenticator
        Parameters:
        title - password prompt title if GUI is used
        serverType - type of server (label associated with serverName)
        serverName - name of server
        nameCb - provides storage for user login name. A null indicates that the default user name will be used, @see ClientUtil#getUserName()
        passCb - provides storage for user password, @see PasswordCallback#setPassword(char[])
        choiceCb - specifies choice between NT Domain authentication (index=0) and local password file authentication (index=1). Set selected index to specify authenticator to be used,
        anonymousCb - may be used to request anonymous read-only access to the server. A null is specified if anonymous access has not been enabed on the server.
        loginError - previous login error message or null for first attempt
        Returns:
        See Also:
        A null is specified if no choice is available (password authenticator determined by server configuration)., AnonymousCallback.setAnonymousAccessRequested(boolean)
      • promptForReconnect

        public boolean promptForReconnect​(java.awt.Component parent,
                                          java.lang.String message)
        Description copied from interface: ClientAuthenticator
        Prompt user for reconnect
        Specified by:
        promptForReconnect in interface ClientAuthenticator
        Parameters:
        parent - dialog parent component or null if not applicable
        Returns:
        return true if reconnect should be attempted
      • getKeyStorePassword

        public char[] getKeyStorePassword​(java.lang.String keystorePath,
                                          boolean passwordError)
        Description copied from interface: KeyStorePasswordProvider
        Requests password for keystore file
        Specified by:
        getKeyStorePassword in interface KeyStorePasswordProvider
        Parameters:
        keystorePath - keystore file path
        passwordError - if true this is a repeated prompt due to a password use failure
        Returns:
        password or null, if not null caller will clear array when no longer needed.
      • processSSHSignatureCallbacks

        public boolean processSSHSignatureCallbacks​(java.lang.String serverName,
                                                    javax.security.auth.callback.NameCallback nameCb,
                                                    SSHSignatureCallback sshCb)
        Description copied from interface: ClientAuthenticator
        Process Ghidra Server SSH authentication callbacks.
        Specified by:
        processSSHSignatureCallbacks in interface ClientAuthenticator
        Parameters:
        serverName - name of server
        nameCb - provides storage for user login name. A null indicates that the default user name will be used, @see ClientUtil#getUserName().
        sshCb - provides authentication token to be signed with private key, @see SSHAuthenticationCallback#sign(SSHPrivateKey)
        Returns:
      • isSSHKeyAvailable

        public boolean isSSHKeyAvailable()
        Specified by:
        isSSHKeyAvailable in interface ClientAuthenticator
        Returns:
        true if SSH private key is available for authentication