Class HttpChannelAuthorizer

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.RuntimeException authFailureException​(java.io.IOException e)  
      protected java.lang.RuntimeException authFailureException​(java.lang.String msg)  
      java.lang.String authorize​(java.lang.String channelName, java.lang.String socketId)
      Called when a channel subscription is to be authorized.
      java.lang.Boolean isSSL()
      Identifies if the HTTP request will be sent over HTTPS.
      protected java.lang.String performAuthRequest()
      Performs an HTTP request to the endpoint provided on construction.
      void setHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
      Set additional headers to be sent as part of the request.
      • Methods inherited from class java.lang.Object

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

      • HttpChannelAuthorizer

        public HttpChannelAuthorizer​(java.lang.String endPoint)
        Creates a new channel authorizer.
        Parameters:
        endPoint - The endpoint to be called when authorizing.
      • HttpChannelAuthorizer

        public HttpChannelAuthorizer​(java.lang.String endPoint,
                                     ConnectionFactory connectionFactory)
        Creates a new channel authorizer.
        Parameters:
        endPoint - The endpoint to be called when authorizing.
        connectionFactory - a custom connection factory to be used for building the connection
    • Method Detail

      • authorize

        public java.lang.String authorize​(java.lang.String channelName,
                                          java.lang.String socketId)
                                   throws AuthorizationFailureException
        Description copied from interface: ChannelAuthorizer
        Called when a channel subscription is to be authorized.
        Specified by:
        authorize in interface ChannelAuthorizer
        Parameters:
        channelName - The name of the channel to be authorized.
        socketId - A unique socket connection ID to be used with the authorization. This uniquely identifies the connection that the subscription is being authorized for.
        Returns:
        A channel authorization token.
        Throws:
        AuthorizationFailureException - if the authorization fails.
      • authFailureException

        protected java.lang.RuntimeException authFailureException​(java.lang.String msg)
      • authFailureException

        protected java.lang.RuntimeException authFailureException​(java.io.IOException e)
      • setHeaders

        public void setHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
        Set additional headers to be sent as part of the request.
        Parameters:
        headers - A map of headers
      • isSSL

        public java.lang.Boolean isSSL()
        Identifies if the HTTP request will be sent over HTTPS.
        Returns:
        true if the endpoint protocol is 'https'
      • performAuthRequest

        protected java.lang.String performAuthRequest()
        Performs an HTTP request to the endpoint provided on construction.

        The request shall include the headers and parameters provided by the connectionFactory.

        Child classes must provide the connection parameters to the connectionFactory before calling this method.

        Returns:
        HTTP request response body