Class RequestHandler

java.lang.Object
com.subaio.fintechbridge.RequestHandler
Direct Known Subclasses:
NativeRequestHandler, TrustKitRequestHandler

public abstract class RequestHandler
extends java.lang.Object
Abstract handler for handling SSL pinning and other authentication tasks. Override `enhanceConnection` to simply add SSL pinning before the connection is opened. Override `handle` for more fine-grained control of the connection. Override `isEnabled` to control when the handler should be used. Defaults to SDK versions before 24
  • Constructor Summary

    Constructors 
    Constructor Description
    RequestHandler()  
  • Method Summary

    Modifier and Type Method Description
    abstract void enhanceConnection​(javax.net.ssl.HttpsURLConnection connection)
    Modify the connection-object before it is opened.
    protected android.webkit.WebResourceResponse getDefaultError()  
    protected static java.util.Map<java.lang.String,​java.lang.String> getFlattenedHeaders​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)  
    android.webkit.WebResourceResponse handle​(java.net.URL url, java.lang.String method, java.util.Map<java.lang.String,​java.lang.String> headers, java.lang.String body)
    Handle a single request made either as part of bridge initialization or from a webview
    boolean isEnabled()
    Determines whether the requesthandler is used.
    protected static void setHeaders​(javax.net.ssl.HttpsURLConnection connection, java.util.Map<java.lang.String,​java.lang.String> headers)  

    Methods inherited from class java.lang.Object

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

  • Method Details

    • isEnabled

      public boolean isEnabled()
      Determines whether the requesthandler is used. Defaults to checking for SDKs below 24, since this is where native SSL pinning was added.
      Returns:
      Is request handling necessary
    • enhanceConnection

      public abstract void enhanceConnection​(@NonNull javax.net.ssl.HttpsURLConnection connection)
      Modify the connection-object before it is opened.
    • handle

      public android.webkit.WebResourceResponse handle​(@NonNull java.net.URL url, @NonNull java.lang.String method, @NonNull java.util.Map<java.lang.String,​java.lang.String> headers, java.lang.String body)
      Handle a single request made either as part of bridge initialization or from a webview
      Parameters:
      url - URL
      method - HTTP method
      headers - Lookup of request headers
      body - Optional body content
      Returns:
      The result of an authenticated request. Returning null will fail the request with status 526
    • getDefaultError

      @NonNull protected android.webkit.WebResourceResponse getDefaultError()
    • getFlattenedHeaders

      protected static java.util.Map<java.lang.String,​java.lang.String> getFlattenedHeaders​(@NonNull java.util.Map<java.lang.String,​java.util.List<java.lang.String>> headers)
    • setHeaders

      protected static void setHeaders​(@NonNull javax.net.ssl.HttpsURLConnection connection, java.util.Map<java.lang.String,​java.lang.String> headers)