Class 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.
    • 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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FingerprintsHelper

        public FingerprintsHelper()
    • 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 - userName
        serverAddress - serverAddress
        trustFilePath - 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 fingerprints
        serverAddress - - non-null server address
        trustFilePath - - 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 address
        trustFilePath - - 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 fingerprint
        trustFilePath - - 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 fingerprint
        trustFile - - 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 name
        serverAddress - - non-null server address
        fingerprintValue - - non-null fingerprint value
        trustFilePath - - 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 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:
        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 name
        serverAddress - - non-null server address
        fingerprintValue - - possibly null fingerprint value
        trustFile - - 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 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:
        java.io.IOException - on error