Class AuthTicketsHelper


  • public class AuthTicketsHelper
    extends AbstractAuthHelper
    This class is designed to lookup authentication tickets from a tickets file or the in-memory tickets map. If a null tickets file parameter is passed to the methods, the in-memory tickets map will be used instead.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static AuthTicket getTicket​(java.lang.String serverAddress, java.lang.String ticketsFilePath)
      Get the first found ticket in the specified ticket file that matches the specified server address.
      static AuthTicket getTicket​(java.lang.String userName, java.lang.String serverAddress, java.lang.String ticketsFilePath)
      Get the first found ticket in the specified ticket file that matches the specified user name and server address.
      static AuthTicket[] getTickets​(java.io.File ticketsFile)
      Get all the tickets found in the specified file.
      static AuthTicket[] getTickets​(java.lang.String ticketsFilePath)
      Get all the tickets found in the file at the specified file path.
      static java.lang.String getTicketValue​(java.lang.String userName, java.lang.String serverAddress, java.lang.String ticketsFilePath)
      Get the first found ticket value that matches the specified user name and server address.
      static void saveTicket​(AuthTicket ticket, java.io.File ticketsFile)
      Save the specified ticket as an entry into the specified tickets file.
      static void saveTicket​(AuthTicket ticket, java.lang.String ticketsFilePath)
      Save the specified ticket as an entry into the specified tickets file.
      static void saveTicket​(java.lang.String userName, java.lang.String serverAddress, java.lang.String ticketValue, java.io.File ticketsFile)
      Save the specified parameters as an entry into the specified tickets file.
      static void saveTicket​(java.lang.String userName, java.lang.String serverAddress, java.lang.String ticketValue, java.io.File ticketsFile, int lockTry, long lockDelay, long lockWait)
      Save the specified parameters as an entry into the specified tickets file.
      static void saveTicket​(java.lang.String userName, java.lang.String serverAddress, java.lang.String ticketValue, java.lang.String ticketsFilePath)
      Save the specified parameters as an entry into the specified tickets file.
      static void saveTicket​(java.lang.String userName, java.lang.String serverAddress, java.lang.String ticketValue, java.lang.String ticketsFilePath, int lockTry, long lockDelay, long lockWait)
      Save the specified parameters as an entry into the specified tickets file.
      • Methods inherited from class java.lang.Object

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

      • AuthTicketsHelper

        public AuthTicketsHelper()
    • Method Detail

      • getTicketValue

        public static java.lang.String getTicketValue​(java.lang.String userName,
                                                      java.lang.String serverAddress,
                                                      java.lang.String ticketsFilePath)
                                               throws java.io.IOException
        Get the first found ticket 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
        ticketsFilePath - ticketsFilePath
        Returns:
        - ticket value or null if not found
        Throws:
        java.io.IOException - - io exception from reading tickets file
      • getTicket

        public static AuthTicket getTicket​(java.lang.String userName,
                                           java.lang.String serverAddress,
                                           java.lang.String ticketsFilePath)
                                    throws java.io.IOException
        Get the first found ticket in the specified ticket 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 ticket for the specified server address will be returned.
        Parameters:
        userName - - possibly null user name to match against the found tickets
        serverAddress - - non-null server address
        ticketsFilePath - - path to tickets file to search
        Returns:
        - found ticket or null if not found
        Throws:
        java.io.IOException - - io exception from reading tickets file
      • getTickets

        public static AuthTicket[] getTickets​(java.lang.String ticketsFilePath)
                                       throws java.io.IOException
        Get all the tickets found in the file at the specified file path.
        Parameters:
        ticketsFilePath - ticketsFilePath
        Returns:
        - array of tickets found in the specified tickets file at the specified path
        Throws:
        java.io.IOException - - io exception from reading tickets file
      • getTickets

        public static AuthTicket[] getTickets​(java.io.File ticketsFile)
                                       throws java.io.IOException
        Get all the tickets found in the specified file.
        Parameters:
        ticketsFile - ticketsFile
        Returns:
        - array of tickets found in the specified tickets file
        Throws:
        java.io.IOException - - io exception from reading tickets file
      • getTicket

        public static AuthTicket getTicket​(java.lang.String serverAddress,
                                           java.lang.String ticketsFilePath)
                                    throws java.io.IOException
        Get the first found ticket in the specified ticket 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
        ticketsFilePath - - path to tickets file to search
        Returns:
        - found ticket or null if not found
        Throws:
        java.io.IOException - - io exception from reading tickets file
      • saveTicket

        public static void saveTicket​(AuthTicket ticket,
                                      java.lang.String ticketsFilePath)
                               throws java.io.IOException
        Save the specified ticket as an entry into the specified tickets file. This method will replace the current entry for the user name and server address in the tickets file. If a current entry is not found then the specified entry will be appended to the file.
        Parameters:
        ticket - - non-null ticket
        ticketsFilePath - - non-null path
        Throws:
        java.io.IOException - on error
      • saveTicket

        public static void saveTicket​(AuthTicket ticket,
                                      java.io.File ticketsFile)
                               throws java.io.IOException
        Save the specified ticket as an entry into the specified tickets file. This method will replace the current entry for the user name and server address in the tickets file. If a current entry is not found then the specified entry will be appended to the file.
        Parameters:
        ticket - - non-null ticket
        ticketsFile - - non-null file
        Throws:
        java.io.IOException - on error
      • saveTicket

        public static void saveTicket​(java.lang.String userName,
                                      java.lang.String serverAddress,
                                      java.lang.String ticketValue,
                                      java.lang.String ticketsFilePath)
                               throws java.io.IOException
        Save the specified parameters as an entry into the specified tickets file. This method will replace the current entry for the user name and server address in the tickets 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
        ticketValue - - non-null ticket value
        ticketsFilePath - - non-null file path
        Throws:
        java.io.IOException - on error
      • saveTicket

        public static void saveTicket​(java.lang.String userName,
                                      java.lang.String serverAddress,
                                      java.lang.String ticketValue,
                                      java.io.File ticketsFile)
                               throws java.io.IOException
        Save the specified parameters as an entry into the specified tickets file. This method will replace the current entry for the user name and server address in the tickets file. If a current entry is not found then the specified entry will be appended to the file. If the specified ticket 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
        ticketValue - - possibly null ticket value
        ticketsFile - - non-null file
        Throws:
        java.io.IOException - on error
      • saveTicket

        public static void saveTicket​(java.lang.String userName,
                                      java.lang.String serverAddress,
                                      java.lang.String ticketValue,
                                      java.lang.String ticketsFilePath,
                                      int lockTry,
                                      long lockDelay,
                                      long lockWait)
                               throws java.io.IOException
        Save the specified parameters as an entry into the specified tickets file. This method will replace the current entry for the user name and server address in the tickets 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
        ticketValue - - non-null ticket value
        ticketsFilePath - - 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
      • saveTicket

        public static void saveTicket​(java.lang.String userName,
                                      java.lang.String serverAddress,
                                      java.lang.String ticketValue,
                                      java.io.File ticketsFile,
                                      int lockTry,
                                      long lockDelay,
                                      long lockWait)
                               throws java.io.IOException
        Save the specified parameters as an entry into the specified tickets file. This method will replace the current entry for the user name and server address in the tickets file. If a current entry is not found then the specified entry will be appended to the file. If the specified ticket 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
        ticketValue - - possibly null ticket value
        ticketsFile - - 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