Class ClientDetectionDefaultImpl

  • All Implemented Interfaces:
    ClientDetectionInterface

    public class ClientDetectionDefaultImpl
    extends Object
    implements ClientDetectionInterface
    The ClientDetectionInterface interface needs to be implemented by services and applications serving multiple clients, to determine the client from which the request has originated. This interface detects the client type from the client request.
    • Constructor Detail

      • ClientDetectionDefaultImpl

        public ClientDetectionDefaultImpl()
        Creates a client detection default implementation instance.
    • Method Detail

      • getClientType

        public String getClientType​(jakarta.servlet.http.HttpServletRequest request)
                             throws ClientDetectionException
        This is the method used by the interface to set the client-type. ClientDetectionDefaultImpl currently uses the following algorithm.
          if userAgent equals a known user-agent then
             compare userAgent length and store the longest match
          if clientType not found 
             return the default clientType
         
        Specified by:
        getClientType in interface ClientDetectionInterface
        Parameters:
        request - The calling object passes in the HTTPServletRequest.
        Returns:
        The string corresponding to the client type.
        Throws:
        ClientDetectionException - if a default client type cannot be found
      • userAgentCheck

        protected boolean userAgentCheck​(String httpUA,
                                         String clientUA)
        This method contains the algorithm used to compare the HTTPServletRequest user-agent versus the Client user-agent.
        Parameters:
        httpUA - The HTTPServletRequest user-agent
        clientUA - The Client userAgent
        Returns:
        True or false if they match