Package com.perforce.p4java.server
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.
-
-
Field Summary
-
Fields inherited from class com.perforce.p4java.server.AbstractAuthHelper
AUTH_VALUE_MAP_KEY, DEFAULT_LOCK_DELAY, DEFAULT_LOCK_TRY, DEFAULT_LOCK_WAIT, SERVER_ADDRESS_MAP_KEY, USER_NAME_MAP_KEY
-
-
Constructor Summary
Constructors Constructor Description FingerprintsHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Fingerprint
getFingerprint(java.lang.String serverAddress, java.lang.String trustFilePath)
Get the first found fingerprint in the specified fingerprint file that matches the specified server address.static Fingerprint
getFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String trustFilePath)
Get the first found fingerprint in the specified trust file that matches the specified user name and server address.static Fingerprint[]
getFingerprints(java.io.File trustFile)
Get all the fingerprints found in the specified file.static Fingerprint[]
getFingerprints(java.lang.String trustFilePath)
Get all the fingerprints found in the file at the specified file path.static java.lang.String
getFingerprintValue(java.lang.String userName, java.lang.String serverAddress, java.lang.String trustFilePath)
Get the first found fingerprint value that matches the specified user name and server address.static void
saveFingerprint(Fingerprint fingerprint, java.io.File trustFile)
Save the specified fingerprint as an entry into the specified trust file.static void
saveFingerprint(Fingerprint fingerprint, java.lang.String trustFilePath)
Save the specified fingerprint as an entry into the specified trust file.static void
saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.io.File trustFile)
Save the specified parameters as an entry into the specified trust file.static void
saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.io.File trustFile, int lockTry, long lockDelay, long lockWait)
Save the specified parameters as an entry into the specified trust file.static void
saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.lang.String trustFilePath)
Save the specified parameters as an entry into the specified trust file.static void
saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.lang.String trustFilePath, int lockTry, long lockDelay, long lockWait)
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
-
-
-
-
Method Detail
-
getFingerprintValue
public static java.lang.String getFingerprintValue(java.lang.String userName, java.lang.String serverAddress, java.lang.String trustFilePath) throws java.io.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
- userNameserverAddress
- serverAddresstrustFilePath
- trustFilePath- Returns:
- - fingerprint value or null if not found
- Throws:
java.io.IOException
- - io exception from reading trust file
-
getFingerprints
public static Fingerprint[] getFingerprints(java.lang.String trustFilePath) throws java.io.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:
java.io.IOException
- - io exception from reading trust file
-
getFingerprints
public static Fingerprint[] getFingerprints(java.io.File trustFile) throws java.io.IOException
Get all the fingerprints found in the specified file.- Parameters:
trustFile
- trustFile- Returns:
- - array of fingerprints found in the specified trust file
- Throws:
java.io.IOException
- - io exception from reading trust file
-
getFingerprint
public static Fingerprint getFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String trustFilePath) throws java.io.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 fingerprintsserverAddress
- - non-null server addresstrustFilePath
- - path to trust file to search- Returns:
- - found fingerprint or null if not found
- Throws:
java.io.IOException
- - io exception from reading trust file
-
getFingerprint
public static Fingerprint getFingerprint(java.lang.String serverAddress, java.lang.String trustFilePath) throws java.io.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 addresstrustFilePath
- - path to trust file to search- Returns:
- - found fingerprint or null if not found
- Throws:
java.io.IOException
- - io exception from reading trust file
-
saveFingerprint
public static void saveFingerprint(Fingerprint fingerprint, java.lang.String trustFilePath) throws java.io.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 fingerprinttrustFilePath
- - non-null path- Throws:
java.io.IOException
- on error
-
saveFingerprint
public static void saveFingerprint(Fingerprint fingerprint, java.io.File trustFile) throws java.io.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 fingerprinttrustFile
- - non-null file- Throws:
java.io.IOException
- on error
-
saveFingerprint
public static void saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.lang.String trustFilePath) throws java.io.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 nameserverAddress
- - non-null server addressfingerprintValue
- - non-null fingerprint valuetrustFilePath
- - non-null file path- Throws:
java.io.IOException
- on error
-
saveFingerprint
public static void saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.lang.String trustFilePath, int lockTry, long lockDelay, long lockWait) throws java.io.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 nameserverAddress
- - non-null server addressfingerprintValue
- - non-null fingerprint valuetrustFilePath
- - non-null file pathlockTry
- - number of tries for lockinglockDelay
- - delay time (ms) for lockinglockWait
- - wait time (ms) for other process/thread to finish locking- Throws:
java.io.IOException
- on error
-
saveFingerprint
public static void saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.io.File trustFile) throws java.io.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 nameserverAddress
- - non-null server addressfingerprintValue
- - possibly null fingerprint valuetrustFile
- - non-null file- Throws:
java.io.IOException
- on error
-
saveFingerprint
public static void saveFingerprint(java.lang.String userName, java.lang.String serverAddress, java.lang.String fingerprintValue, java.io.File trustFile, int lockTry, long lockDelay, long lockWait) throws java.io.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 nameserverAddress
- - non-null server addressfingerprintValue
- - possibly null fingerprint valuetrustFile
- - non-null filelockTry
- - number of tries for lockinglockDelay
- - delay time (ms) for lockinglockWait
- - wait time (ms) for other process/thread to finish locking- Throws:
java.io.IOException
- on error
-
-