示例#1
0
 public void trxRequest(View view) {
   title.setText("Authentication operation executed");
   String authRequest = auth.getUafMsgRequest(true);
   Intent i = new Intent("org.fidoalliance.intent.FIDO_OPERATION");
   i.addCategory("android.intent.category.DEFAULT");
   i.setType("application/fido.uaf_client+json");
   Bundle data = new Bundle();
   data.putString("message", authRequest);
   data.putString("UAFIntentType", "UAF_OPERATION");
   data.putString("channelBindings", authRequest);
   i.putExtras(data);
   startActivityForResult(i, AUTH_ACTIVITY_RES_5);
 }
示例#2
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (data == null) {
      msg.setText("UAF Client didn't return any data. resultCode=" + resultCode);
      return;
    }
    Object[] array = data.getExtras().keySet().toArray();
    StringBuffer extras = new StringBuffer();
    extras.append("[resultCode=" + resultCode + "]");
    for (int i = 0; i < array.length; i++) {
      extras.append("[" + array[i] + "=");
      //            if ("message".equals(array[i])) {
      //                continue;
      //            }
      extras.append("" + data.getExtras().get((String) array[i]) + "]");
    }
    title.setText("extras=" + extras.toString());

    if (requestCode == 1) {
      if (resultCode == RESULT_OK) {
        String asmResponse = data.getStringExtra("message");
        String discoveryData = data.getStringExtra("discoveryData");
        msg.setText("{message}" + asmResponse + "{discoveryData}" + discoveryData);
        // Prepare ReqResponse
        // post to server
      }
      if (resultCode == RESULT_CANCELED) {
        // Write your code if there's no result
      }
    }
    if (requestCode == 2) {
      if (resultCode == RESULT_OK) {
        String asmResponse = data.getStringExtra("message");
        msg.setText(asmResponse);
        dereg.recordKeyId(asmResponse);
        // Prepare ReqResponse
        // post to server
      }
      if (resultCode == RESULT_CANCELED) {
        // Write your code if there's no result
      }
    } else if (requestCode == REG_ACTIVITY_RES_3) {
      if (resultCode == RESULT_OK) {
        try {
          String uafMessage = data.getStringExtra("message");
          msg.setText(uafMessage);
          // Prepare ReqResponse
          // post to server
          //	            String res = reg.sendRegResponse(asmResponse);
          String res = reg.clientSendRegResponse(uafMessage);
          setContentView(R.layout.activity_registered);
          findFields();
          title.setText("extras=" + extras.toString());
          msg.setText(res);
          username.setText(Preferences.getSettingsParam("username"));
        } catch (Exception e) {
          msg.setText("Registration operation failed.\n" + e);
        }
      }
      if (resultCode == RESULT_CANCELED) {
        // Write your code if there's no result
      }
    } else if (requestCode == DEREG_ACTIVITY_RES_4) {
      if (resultCode == RESULT_OK) {
        Preferences.setSettingsParam("keyID", "");
        Preferences.setSettingsParam("username", "");
        setContentView(R.layout.activity_main);
        findFields();
        title.setText("extras=" + extras.toString());
        String message = data.getStringExtra("message");
        if (message != null) {
          String out = "Dereg done. Client msg=" + message;
          out = out + ". Sent=" + dereg.clientSendDeregResponse(message);
          msg.setText(out);
        } else {
          String deregMsg = Preferences.getSettingsParam("deregMsg");
          String out = "Dereg done. Client msg was empty. Dereg msg = " + deregMsg;
          out = out + ". Response=" + dereg.post(deregMsg);
          msg.setText(out);
        }
      }
      if (resultCode == RESULT_CANCELED) {
        // Write your code if there's no result
      }
    } else if (requestCode == AUTH_ACTIVITY_RES_5) {
      if (resultCode == RESULT_OK) {
        String uafMessage = data.getStringExtra("message");
        if (uafMessage != null) {
          msg.setText(uafMessage);
          // Prepare ReqResponse
          // post to server
          //	            String res = auth.sendAuthResponse(asmResponse);
          String res = auth.clientSendResponse(uafMessage);
          msg.setText("\n" + res);
        }
      }
      if (resultCode == RESULT_CANCELED) {
        // Write your code if there's no result
      }
    }
  }