org.apache.cordova.AuthenticationToken Java Examples

The following examples show how to use org.apache.cordova.AuthenticationToken. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SystemWebViewClient.java    From keemob with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: X5WebViewClient.java    From cordova-plugin-x5-webview with Apache License 2.0 6 votes vote down vote up
/**
 * 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 X5CordovaHttpAuthHandler(handler), host, realm)) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default handle 401 like we'd normally do!
    super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
 
Example #3
Source File: SystemWebViewClient.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #4
Source File: SystemWebViewClient.java    From countly-sdk-cordova with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #5
Source File: SystemWebViewClient.java    From ultimate-cordova-webview-app with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #6
Source File: SystemWebViewClient.java    From xmall with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: SystemWebViewClient.java    From pychat with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: SystemWebViewClient.java    From lona with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #9
Source File: SystemWebViewClient.java    From ultimate-cordova-webview-app with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: SystemWebViewClient.java    From xmall with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #11
Source File: SystemWebViewClient.java    From countly-sdk-cordova with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source File: X5WebViewClient.java    From x5webview-cordova-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * 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 X5CordovaHttpAuthHandler(handler), host, realm)) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default handle 401 like we'd normally do!
    super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
 
Example #13
Source File: X5WebViewClient.java    From cordova-plugin-x5-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #14
Source File: SystemWebViewClient.java    From chappiecast with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #15
Source File: SystemWebViewClient.java    From keemob with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #16
Source File: SystemWebViewClient.java    From keemob with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #17
Source File: SystemWebViewClient.java    From chappiecast with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #18
Source File: SystemWebViewClient.java    From cordova-plugin-intent with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #19
Source File: SystemWebViewClient.java    From keemob with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #20
Source File: X5WebViewClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 6 votes vote down vote up
/**
 * 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 X5CordovaHttpAuthHandler(handler), host, realm)) {
    parentEngine.client.clearLoadTimeoutTimer();
    return;
  }

  // By default handle 401 like we'd normally do!
  super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
 
Example #21
Source File: SystemWebViewClient.java    From cordova-plugin-intent with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #22
Source File: X5WebViewClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 * <p>
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
  AuthenticationToken token = null;
  token = this.authenticationTokens.get(host.concat(realm));

  if (token == null) {
    // try with just the host
    token = this.authenticationTokens.get(host);

    // Try the realm
    if (token == null) {
      token = this.authenticationTokens.get(realm);
    }

    // if no host found, just query for default
    if (token == null) {
      token = this.authenticationTokens.get("");
    }
  }

  return token;
}
 
Example #23
Source File: SystemWebViewClient.java    From app-icon with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #24
Source File: SystemWebViewClient.java    From a2cardboard with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #25
Source File: SystemWebViewClient.java    From app-icon with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #26
Source File: X5WebViewClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 6 votes vote down vote up
/**
 * 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 X5CordovaHttpAuthHandler(handler), host, realm)) {
        parentEngine.client.clearLoadTimeoutTimer();
        return;
    }

    // By default handle 401 like we'd normally do!
    super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
 
Example #27
Source File: SystemWebViewClient.java    From a2cardboard with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #28
Source File: SystemWebViewClient.java    From cordova-plugin-app-update-demo with MIT License 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #29
Source File: X5WebViewClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the authentication token.
 *
 * In order it tries:
 * 1- host + realm
 * 2- host
 * 3- realm
 * 4- no host, no realm
 *
 * @param host
 * @param realm
 *
 * @return the authentication token
 */
public AuthenticationToken getAuthenticationToken(String host, String realm) {
    AuthenticationToken token = null;
    token = this.authenticationTokens.get(host.concat(realm));

    if (token == null) {
        // try with just the host
        token = this.authenticationTokens.get(host);

        // Try the realm
        if (token == null) {
            token = this.authenticationTokens.get(realm);
        }

        // if no host found, just query for default
        if (token == null) {
            token = this.authenticationTokens.get("");
        }
    }

    return token;
}
 
Example #30
Source File: SystemWebViewClient.java    From cordova-plugin-app-update-demo with MIT License 6 votes vote down vote up
/**
 * 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);
}