Search in sources :

Example 1 with CordovaHttpAuthHandler

use of org.apache.cordova.CordovaHttpAuthHandler in project cordova-android by apache.

the class SystemWebViewClient method onReceivedHttpAuthRequest.

/**
     * On received http auth request.
     * 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 CordovaHttpAuthHandler(handler), host, realm)) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }
    // By default handle 401 like we'd normally do!
    super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
Also used : PluginManager(org.apache.cordova.PluginManager) AuthenticationToken(org.apache.cordova.AuthenticationToken) CordovaHttpAuthHandler(org.apache.cordova.CordovaHttpAuthHandler)

Aggregations

AuthenticationToken (org.apache.cordova.AuthenticationToken)1 CordovaHttpAuthHandler (org.apache.cordova.CordovaHttpAuthHandler)1 PluginManager (org.apache.cordova.PluginManager)1