Class ClientUserInteraction


  • public class ClientUserInteraction
    extends java.lang.Object
    Class for Perforce client end-user interaction commands like prompting or password-setting ("end-user interaction" is being rather broadly-defined here...).

    Note that in general we don't actually do any end-user interaction in P4Java -- it's all done before a call by the app that P4Java's been embedded in.

    • Constructor Detail

      • ClientUserInteraction

        protected ClientUserInteraction​(java.util.Properties props,
                                        RpcServer server)
    • Method Detail

      • clientPrompt

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientPrompt​(RpcConnection rpcConnection,
                                                                             CommandEnv cmdEnv,
                                                                             java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                      throws ConnectionException
        Prompt the end-user (i.e. the upper-levels of P4Java...) in response to a server request. The various parameters in resultsMap determine things like whether the prompt uses echoing, what digest to use (if any), what prompt string to use, etc., many of which aren't relevant in our context.

        In the most common usage -- password extraction from the user -- we follow a fairly simple scheme where we first hash the password with an MD5 digest, then pass the results of that operation through a new MD5 cycle and hash it against the "digest" string passed in from the server. Everything else that's sent to us from the server is simply echoed for the server's own purposes (i.e. I still don't know what some of this stuff does...).

        Note that we have to do what the C++ API does in the same circumstances; this means converting the hash hex string results into upper-case, etc., and several other mild quirks whose use or motivation aren't always obvious.

        Note also that we're not currently implementing the full panoply of possible processing here, just the subset that's useful to us for P4WSAD and that presumes a 2003.2 or later server in not-too-strict mode.

        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • clientSetPassword

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientSetPassword​(RpcConnection rpcConnection,
                                                                                  CommandEnv cmdEnv,
                                                                                  java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                           throws ConnectionException
        Set the client-side password in response to a Perforce server command telling us to do just that, usually as a result of an earlier successful login attempt in the same session.

        In this context setting the password really just means performing a few sanity and consistency checks, then returning a suitable ticket for use with the -P option in future commands. This can be an arbitrarily complex process...

        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • clientSingleSignon

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientSingleSignon​(RpcConnection rpcConnection,
                                                                                   CommandEnv cmdEnv,
                                                                                   java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                            throws ConnectionException
        Implements the client-side of the Perforce single sign on (SSO) protocol. Basically defers to the registered SSO callback (if it exists) and simply responds back to the server appropriately.
        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • clientAck

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientAck​(RpcConnection rpcConnection,
                                                                          CommandEnv cmdEnv,
                                                                          java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                   throws ConnectionException
        Respond back to the server with what amounts to a yes / no response in the face of errors or success. Intended for interactive clients, I guess; we just decline automatically if anything went wrong, and say yes ("dm-OpenFile") if things went fine... in effect, we just do a pass-through. This may change as we gain experience.
        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • clientCrypto

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientCrypto​(RpcConnection rpcConnection,
                                                                             CommandEnv cmdEnv,
                                                                             java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                      throws ConnectionException
        Process the client-Crypto command from the Perforce server. This is typically called in response to an earlier login using the ticket feature (which is how we normally do logins in P4Java).

        In the P4Java context, this really means first MD5-hashing the incoming token, then hashing the previously-returned ticket, then returning the results to the server for inspection.

        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • clientInputData

        protected RpcPacketDispatcher.RpcPacketDispatcherResult clientInputData​(RpcConnection rpcConnection,
                                                                                CommandEnv cmdEnv,
                                                                                java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                                                         throws ConnectionException
        Get some requested data (typically something like a submit form) from somewhere (typically a map passed in from the upper levels of the API) and pass it back to the server, properly munged.
        Parameters:
        rpcConnection - rpcConnection
        cmdEnv - cmdEnv
        resultsMap - resultsMap
        Returns:
        RpcPacketDispatcherResult
        Throws:
        ConnectionException - on error
      • getStreamBytes

        protected byte[] getStreamBytes​(java.lang.String cmdName,
                                        java.io.InputStream inStream)
        Get bytes from the stream passed in.
        Parameters:
        cmdName - cmdName
        inStream - inStream
        Returns:
        bytes