com.perforce.p4java.impl.mapbased.rpc.func.client
Class ClientUserInteraction

java.lang.Object
  extended by com.perforce.p4java.impl.mapbased.rpc.func.client.ClientUserInteraction

public class ClientUserInteraction
extends 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.


Field Summary
protected static int RESP_LENGTH
           
static String TRACE_PREFIX
           
protected static int TRUNCATE_LENGTH
           
 
Constructor Summary
protected ClientUserInteraction(Properties props, RpcServer server)
           
 
Method Summary
protected  RpcPacketDispatcher.RpcPacketDispatcherResult clientAck(RpcConnection rpcConnection, CommandEnv cmdEnv, Map<String,Object> resultsMap)
          Respond back to the server with what amounts to a yes / no response in the face of errors or success.
protected  RpcPacketDispatcher.RpcPacketDispatcherResult clientCrypto(RpcConnection rpcConnection, CommandEnv cmdEnv, Map<String,Object> resultsMap)
          Process the client-Crypto command from the Perforce server.
protected  RpcPacketDispatcher.RpcPacketDispatcherResult clientInputData(RpcConnection rpcConnection, CommandEnv cmdEnv, Map<String,Object> resultsMap)
          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.
protected  RpcPacketDispatcher.RpcPacketDispatcherResult clientPrompt(RpcConnection rpcConnection, CommandEnv cmdEnv, Map<String,Object> resultsMap)
          Prompt the end-user (i.e.
protected  RpcPacketDispatcher.RpcPacketDispatcherResult clientSetPassword(RpcConnection rpcConnection, CommandEnv cmdEnv, Map<String,Object> resultsMap)
          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.
protected  RpcPacketDispatcher.RpcPacketDispatcherResult clientSingleSignon(RpcConnection rpcConnection, CommandEnv cmdEnv, Map<String,Object> resultsMap)
          Implements the client-side of the Perforce single sign on (SSO) protocol.
protected  byte[] getStreamBytes(String cmdName, InputStream inStream)
          Get bytes from the stream passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_PREFIX

public static final String TRACE_PREFIX
See Also:
Constant Field Values

RESP_LENGTH

protected static final int RESP_LENGTH
See Also:
Constant Field Values

TRUNCATE_LENGTH

protected static final int TRUNCATE_LENGTH
See Also:
Constant Field Values
Constructor Detail

ClientUserInteraction

protected ClientUserInteraction(Properties props,
                                RpcServer server)
Method Detail

clientPrompt

protected RpcPacketDispatcher.RpcPacketDispatcherResult clientPrompt(RpcConnection rpcConnection,
                                                                     CommandEnv cmdEnv,
                                                                     Map<String,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.

Throws:
ConnectionException

clientSetPassword

protected RpcPacketDispatcher.RpcPacketDispatcherResult clientSetPassword(RpcConnection rpcConnection,
                                                                          CommandEnv cmdEnv,
                                                                          Map<String,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...

Throws:
ConnectionException

clientSingleSignon

protected RpcPacketDispatcher.RpcPacketDispatcherResult clientSingleSignon(RpcConnection rpcConnection,
                                                                           CommandEnv cmdEnv,
                                                                           Map<String,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.

Throws:
ConnectionException

clientAck

protected RpcPacketDispatcher.RpcPacketDispatcherResult clientAck(RpcConnection rpcConnection,
                                                                  CommandEnv cmdEnv,
                                                                  Map<String,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.

Throws:
ConnectionException

clientCrypto

protected RpcPacketDispatcher.RpcPacketDispatcherResult clientCrypto(RpcConnection rpcConnection,
                                                                     CommandEnv cmdEnv,
                                                                     Map<String,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.

Throws:
ConnectionException

clientInputData

protected RpcPacketDispatcher.RpcPacketDispatcherResult clientInputData(RpcConnection rpcConnection,
                                                                        CommandEnv cmdEnv,
                                                                        Map<String,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.

Throws:
ConnectionException

getStreamBytes

protected byte[] getStreamBytes(String cmdName,
                                InputStream inStream)
Get bytes from the stream passed in.



Copyright © 2015 Perforce Software. All Rights Reserved.