@Override
    public void onReceivedHttpAuthRequest(
        WebView view, HttpAuthHandler handler, String host, String realm) {
      String[] creds = AppConstants.getHttpAuthCredentials();

      if (creds != null) {
        handler.proceed(creds[0], creds[1]);
      } else {
        handler.cancel();
      }
    }
예제 #2
0
  @Override
  public void onReceivedHttpAuthRequest(
      WebView view, HttpAuthHandler handler, String host, String realm) {

    if (this.username != null && this.password != null) {
      handler.proceed(this.username, this.password);
    }
  }
 public void onReceivedHttpAuthRequest(WebView paramWebView, HttpAuthHandler paramHttpAuthHandler, String paramString1, String paramString2)
 {
   AuthenticationToken localAuthenticationToken = getAuthenticationToken(paramString1, paramString2);
   if (localAuthenticationToken != null)
   {
     paramHttpAuthHandler.proceed(localAuthenticationToken.getUserName(), localAuthenticationToken.getPassword());
     return;
   }
   super.onReceivedHttpAuthRequest(paramWebView, paramHttpAuthHandler, paramString1, paramString2);
 }
  @Override
  public void onReceivedHttpAuthRequest(
      final WebView view, final HttpAuthHandler handler, final String host, final String realm) {
    String username = null;
    String password = null;

    final boolean reuseHttpAuthUsernamePassword = handler.useHttpAuthUsernamePassword();

    if (reuseHttpAuthUsernamePassword && view != null) {
      final String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
      if (credentials != null && credentials.length == 2) {
        username = credentials[0];
        password = credentials[1];
      }
    }

    if (username != null && password != null) {
      handler.proceed(username, password);
    } else {
      createSignInDialog(handler, host, realm, username, password).show();
    }
  }
  @Override
  public void onReceivedHttpAuthRequest(
      WebView view, final HttpAuthHandler handler, final String host, final String realm) {
    String username = null;
    String password = null;

    boolean reuseHttpAuthUsernamePassword = handler.useHttpAuthUsernamePassword();

    if (reuseHttpAuthUsernamePassword && view != null) {
      String[] credentials = view.getHttpAuthUsernamePassword(host, realm);
      if (credentials != null && credentials.length == 2) {
        username = credentials[0];
        password = credentials[1];
      }
    }

    if (username != null && password != null) {
      handler.proceed(username, password);
    } else {
      LayoutInflater factory = LayoutInflater.from(mMainActivity);
      final View v = factory.inflate(R.layout.http_authentication_dialog, null);

      if (username != null) {
        ((EditText) v.findViewById(R.id.username_edit)).setText(username);
      }
      if (password != null) {
        ((EditText) v.findViewById(R.id.password_edit)).setText(password);
      }

      AlertDialog dialog =
          new AlertDialog.Builder(mMainActivity)
              .setTitle(
                  String.format(
                      mMainActivity.getString(R.string.HttpAuthenticationDialog_DialogTitle),
                      host,
                      realm))
              .setIcon(android.R.drawable.ic_dialog_alert)
              .setView(v)
              .setPositiveButton(
                  R.string.Commons_Proceed,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                      String nm =
                          ((EditText) v.findViewById(R.id.username_edit)).getText().toString();
                      String pw =
                          ((EditText) v.findViewById(R.id.password_edit)).getText().toString();
                      mMainActivity.setHttpAuthUsernamePassword(host, realm, nm, pw);
                      handler.proceed(nm, pw);
                    }
                  })
              .setNegativeButton(
                  R.string.Commons_Cancel,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                      handler.cancel();
                    }
                  })
              .setOnCancelListener(
                  new DialogInterface.OnCancelListener() {
                    public void onCancel(DialogInterface dialog) {
                      handler.cancel();
                    }
                  })
              .create();

      dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
      dialog.show();

      v.findViewById(R.id.username_edit).requestFocus();
    }
  }