Authentication

P4 API for Java implements both the P4 Server tickets-based authentication and the P4 Server single sign on (SSO) feature. Both types of authentication are described in detail in the P4 API for Java Javadoc, but some P4 API for Java-specific issues to note include:

  • P4 API for Java manages a p4 tickets file in a matter similar to that of the P4 command line (under normal circumstances, the two can share the same tickets file). When a ticket value is requested by the P4 Server and the current ticket value in the associated IOptionsServer object is not set, an attempt is made to retrieve the ticket out of the p4 tickets file. If found, the ticket is stored on the IOptionsServer object and used as the P4 Server authentication ticket.

    A successful login causes the ticket value to be added or updated in the tickets file, and a logout causes the current ticket value in the p4 tickets file to be removed. The IOptionsServer object’s ticket should be set to null to cause a re-reading of the ticket value from the p4 tickets file.

    The p4 tickets file is usually stored in the same place the p4 command line stores it, but the PropertyDefs.TICKET_PATH_KEY property can be used to specify an alternate tickets file.

  • P4 API for Java implements P4 Server’s SSO scheme using a callback interface described in the ISSOCallback Javadoc (in the package com.perforce.p4java.server.callback). Ensure that the callback doesn’t block, and that it adheres to the expected format of the associated P4 Server.