com.perforce.p4java.server
Class FingerprintsHelper

java.lang.Object
  extended by com.perforce.p4java.server.AbstractAuthHelper
      extended by 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.


Field Summary
 
Fields inherited from class com.perforce.p4java.server.AbstractAuthHelper
AUTH_VALUE_MAP_KEY, SERVER_ADDRESS_MAP_KEY, USER_NAME_MAP_KEY
 
Constructor Summary
FingerprintsHelper()
           
 
Method Summary
static Fingerprint getFingerprint(String serverAddress, String trustFilePath)
          Get the first found fingerprint in the specified fingerprint file that matches the specified server address.
static Fingerprint getFingerprint(String userName, String serverAddress, String trustFilePath)
          Get the first found fingerprint in the specified trust file that matches the specified user name and server address.
static Fingerprint[] getFingerprints(File trustFile)
          Get all the fingerprints found in the specified file.
static Fingerprint[] getFingerprints(String trustFilePath)
          Get all the fingerprints found in the file at the specified file path.
static String getFingerprintValue(String userName, String serverAddress, String trustFilePath)
          Get the first found fingerprint value that matches the specified user name and server address.
static void saveFingerprint(Fingerprint fingerprint, File trustFile)
          Save the specified fingerprint as an entry into the specified trust file.
static void saveFingerprint(Fingerprint fingerprint, String trustFilePath)
          Save the specified fingerprint as an entry into the specified trust file.
static void saveFingerprint(String userName, String serverAddress, String fingerprintValue, File trustFile)
          Save the specified parameters as an entry into the specified trust file.
static void saveFingerprint(String userName, String serverAddress, String fingerprintValue, String trustFilePath)
          Save the specified parameters as an entry into the specified trust file.
 
Methods inherited from class com.perforce.p4java.server.AbstractAuthHelper
getFileEntries, getMemoryEntries, getMemoryEntry, saveFileEntry, saveMemoryEntry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FingerprintsHelper

public FingerprintsHelper()
Method Detail

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 -
serverAddress -
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 -
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 -
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

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

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

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


Copyright © 2015 Perforce Software. All Rights Reserved.