Authentication

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

  • P4Java 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 Helix 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 Helix 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.

  • P4Java implements Helix 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 Helix Server.