Class FingerprintsHelper

java.lang.Object
com.perforce.p4java.server.AbstractAuthHelper
com.perforce.p4java.server.FingerprintsHelper

public class FingerprintsHelper extends AbstractAuthHelper
This class is designed to lookup fingerprints from a trust file or the in-memory fingerprints map. If a null trust file parameter is passed to the methods, the in-memory fingerprints map will be used instead.
  • Constructor Details

    • FingerprintsHelper

      public FingerprintsHelper()
  • Method Details

    • getFingerprintValue

      public static String getFingerprintValue(String userName, String serverAddress, String trustFilePath) throws IOException
      Get the first found fingerprint value that matches the specified user name and server address. The user name be non-null and the server address must be non-null and be of the form server:port.
      Parameters:
      userName - userName
      serverAddress - serverAddress
      trustFilePath - trustFilePath
      Returns:
      - fingerprint value or null if not found
      Throws:
      IOException - - io exception from reading trust file
    • getFingerprints

      public static Fingerprint[] getFingerprints(String trustFilePath) throws IOException
      Get all the fingerprints found in the file at the specified file path.
      Parameters:
      trustFilePath - trustFilePath
      Returns:
      - array of fingerprints found in the specified trust file at the specified path
      Throws:
      IOException - - io exception from reading trust file
    • getFingerprints

      public static Fingerprint[] getFingerprints(File trustFile) throws IOException
      Get all the fingerprints found in the specified file.
      Parameters:
      trustFile - trustFile
      Returns:
      - array of fingerprints found in the specified trust file
      Throws:
      IOException - - io exception from reading trust file
    • getFingerprint

      public static Fingerprint getFingerprint(String userName, String serverAddress, String trustFilePath) throws IOException
      Get the first found fingerprint in the specified trust file that matches the specified user name and server address. The server address must be non-null and be of the form server:port. The user name may be null and if that is the case the found first fingerprint for the specified server address will be returned.
      Parameters:
      userName - - possibly null user name to match against the found fingerprints
      serverAddress - - non-null server address
      trustFilePath - - path to trust file to search
      Returns:
      - found fingerprint or null if not found
      Throws:
      IOException - - io exception from reading trust file
    • getFingerprint

      public static Fingerprint getFingerprint(String serverAddress, String trustFilePath) throws IOException
      Get the first found fingerprint in the specified fingerprint file that matches the specified server address. The server address must be non-null and be of the form server:port.
      Parameters:
      serverAddress - - non-null server address
      trustFilePath - - path to trust file to search
      Returns:
      - found fingerprint or null if not found
      Throws:
      IOException - - io exception from reading trust file
    • saveFingerprint

      public static void saveFingerprint(Fingerprint fingerprint, String trustFilePath) throws IOException
      Save the specified fingerprint as an entry into the specified trust file. This method will replace the current entry for the user name and server address in the trust file. If a current entry is not found then the specified entry will be appended to the file.
      Parameters:
      fingerprint - - non-null fingerprint
      trustFilePath - - non-null path
      Throws:
      IOException - on error
    • saveFingerprint

      public static void saveFingerprint(Fingerprint fingerprint, File trustFile) throws IOException
      Save the specified fingerprint as an entry into the specified trust file. This method will replace the current entry for the user name and server address in the trust file. If a current entry is not found then the specified entry will be appended to the file.
      Parameters:
      fingerprint - - non-null fingerprint
      trustFile - - non-null file
      Throws:
      IOException - on error
    • saveFingerprint

      public static void saveFingerprint(String userName, String serverAddress, String fingerprintValue, String trustFilePath) throws IOException
      Save the specified parameters as an entry into the specified trust file. This method will replace the current entry for the user name and server address in the trust file. If a current entry is not found then the specified entry will be appended to the file.
      Parameters:
      userName - - non-null user name
      serverAddress - - non-null server address
      fingerprintValue - - non-null fingerprint value
      trustFilePath - - non-null file path
      Throws:
      IOException - on error
    • saveFingerprint

      public static void saveFingerprint(String userName, String serverAddress, String fingerprintValue, String trustFilePath, int lockTry, long lockDelay, long lockWait) throws IOException
      Save the specified parameters as an entry into the specified trust file. This method will replace the current entry for the user name and server address in the trust file. If a current entry is not found then the specified entry will be appended to the file.
      Parameters:
      userName - - non-null user name
      serverAddress - - non-null server address
      fingerprintValue - - non-null fingerprint value
      trustFilePath - - non-null file path
      lockTry - - number of tries for locking
      lockDelay - - delay time (ms) for locking
      lockWait - - wait time (ms) for other process/thread to finish locking
      Throws:
      IOException - on error
    • saveFingerprint

      public static void saveFingerprint(String userName, String serverAddress, String fingerprintValue, File trustFile) throws IOException
      Save the specified parameters as an entry into the specified trust file. This method will replace the current entry for the user name and server address in the trust file. If a current entry is not found then the specified entry will be appended to the file. If the specified fingerprint value is null then the current entry in the specified file will be removed if found.
      Parameters:
      userName - - non-null user name
      serverAddress - - non-null server address
      fingerprintValue - - possibly null fingerprint value
      trustFile - - non-null file
      Throws:
      IOException - on error
    • saveFingerprint

      public static void saveFingerprint(String userName, String serverAddress, String fingerprintValue, File trustFile, int lockTry, long lockDelay, long lockWait) throws IOException
      Save the specified parameters as an entry into the specified trust file. This method will replace the current entry for the user name and server address in the trust file. If a current entry is not found then the specified entry will be appended to the file. If the specified fingerprint value is null then the current entry in the specified file will be removed if found.
      Parameters:
      userName - - non-null user name
      serverAddress - - non-null server address
      fingerprintValue - - possibly null fingerprint value
      trustFile - - non-null file
      lockTry - - number of tries for locking
      lockDelay - - delay time (ms) for locking
      lockWait - - wait time (ms) for other process/thread to finish locking
      Throws:
      IOException - on error