Example usage for org.apache.cordova PluginManager onReceivedHttpAuthRequest

List of usage examples for org.apache.cordova PluginManager onReceivedHttpAuthRequest

Introduction

In this page you can find the example usage for org.apache.cordova PluginManager onReceivedHttpAuthRequest.

Prototype

public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHandler handler, String host,
        String realm) 

Source Link

Document

Called when the system received an HTTP authentication request.

Usage

From source file:com.zsxsoft.cordova.x5.X5WebViewClient.java

License:Apache License

/**
 * On received http auth request.//w  ww .  j a  va 2  s.  c  om
 * The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
 */
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {

    // Get the authentication token (if specified)
    AuthenticationToken token = this.getAuthenticationToken(host, realm);
    if (token != null) {
        handler.proceed(token.getUserName(), token.getPassword());
        return;
    }

    // Check if there is some plugin which can resolve this auth challenge
    PluginManager pluginManager = this.parentEngine.pluginManager;
    if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(null,
            new X5CordovaHttpAuthHandler(handler), host, realm)) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default handle 401 like we'd normally do!
    super.onReceivedHttpAuthRequest(view, handler, host, realm);
}