Class OAuthHandler

    • Field Detail

      • connectionTimeout

        protected final int connectionTimeout
      • connectionRequestTimeout

        protected final int connectionRequestTimeout
      • socketTimeout

        protected final int socketTimeout
    • Constructor Detail

      • OAuthHandler

        protected OAuthHandler​(String tokenApiUrl,
                               String clientId,
                               String clientSecret,
                               String authMode,
                               int connectionTimeout,
                               int connectionRequestTimeout,
                               int socketTimeout)
    • Method Detail

      • setAuthHeader

        public void setAuthHeader​(MessageContext messageContext)
                           throws AuthException
        Description copied from interface: AuthHandler
        This method will set the Authorization header with the relevant auth token.
        Specified by:
        setAuthHeader in interface AuthHandler
        Parameters:
        messageContext - Message context to which the token needs to be set
        Throws:
        AuthException - In the event of errors when generating new token
      • removeTokenFromCache

        public void removeTokenFromCache()
        Method to remove the token from the cache when the endpoint is destroyed.
      • getTokenUrl

        public String getTokenUrl()
        Return the token server url relevant to the OAuth handler.
        Returns:
        String Token server url
      • getClientId

        public String getClientId()
        Return the client id relevant to the OAuth Handler.
        Returns:
        String client id
      • getClientSecret

        public String getClientSecret()
        Return the client secret relevant to the OAuth Handler.
        Returns:
        String client secret
      • buildTokenRequestPayload

        protected abstract String buildTokenRequestPayload​(MessageContext messageContext)
                                                    throws AuthException
        Return the request payload relevant to the OAuth handler.
        Returns:
        String payload
        Throws:
        AuthException
      • serializeSpecificOAuthConfigs

        protected abstract org.apache.axiom.om.OMElement serializeSpecificOAuthConfigs​(org.apache.axiom.om.OMFactory omFactory)
        Return the OMElement for OAuth configuration relevant to the OAuth handler.
        Returns:
        OMElement OAuth configuration
      • serializeOAuthConfiguration

        public org.apache.axiom.om.OMElement serializeOAuthConfiguration​(org.apache.axiom.om.OMFactory omFactory)
        This method returns an OMElement containing the OAuth configuration.
        Returns:
        OMElement OAuth configuration
      • getEncodedCredentials

        protected String getEncodedCredentials​(MessageContext messageContext)
                                        throws AuthException
        Return the base 64 encoded clientId:clientSecret relevant to the OAuth handler.
        Parameters:
        messageContext - Message Context of the request which will be used to resolve dynamic expressions
        Returns:
        String payload
        Throws:
        AuthException - In the event of errors when resolving the dynamic expressions
      • getRequestParametersAsString

        protected String getRequestParametersAsString​(MessageContext messageContext)
                                               throws AuthException
        Return the request parameters as a string.
        Returns:
        String request parameters
        Throws:
        AuthException
      • setRequestParameters

        public void setRequestParameters​(Map<String,​String> requestParameters)
        Method to set the request parameter map.
        Parameters:
        requestParameters - the request parameter map
      • getRequestParametersMap

        public Map<String,​String> getRequestParametersMap()
      • getAuthMode

        public String getAuthMode()
      • setCustomHeaders

        public void setCustomHeaders​(Map<String,​String> customHeadersMap)
      • getConnectionTimeout

        public int getConnectionTimeout()
      • getConnectionRequestTimeout

        public int getConnectionRequestTimeout()
      • getSocketTimeout

        public int getSocketTimeout()