Beispiel #1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   if (Preferences.getSettingsParam("keyID").equals("")) {
     setContentView(R.layout.activity_main);
     findFields();
   } else {
     setContentView(R.layout.activity_registered);
     findFields();
     username.setText(Preferences.getSettingsParam("username"));
   }
 }
Beispiel #2
0
  public void regRequest(View view) {
    //        String username = Preferences.getSettingsParam("username");
    String username = ((EditText) findViewById(R.id.editTextName)).getText().toString();
    if (username.equals("")) {
      msg.setText("Username cannot be empty.");
      return;
    }
    Preferences.setSettingsParam("username", username);

    title.setText("Registration operation executed, Username = "******"org.fidoalliance.intent.FIDO_OPERATION");
    i.addCategory("android.intent.category.DEFAULT");

    i.setType("application/fido.uaf_client+json");

    List<ResolveInfo> queryIntentActivities =
        this.getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
    String facetID = "";
    try {
      facetID =
          getFacetID(
              this.getPackageManager()
                  .getPackageInfo(this.getPackageName(), this.getPackageManager().GET_SIGNATURES));
      title.setText("facetID=" + facetID);
    } catch (NameNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    String regRequest = reg.getUafMsgRegRequest(username, facetID);
    title.setText("{regRequest}" + regRequest);

    Bundle data = new Bundle();
    data.putString("message", regRequest);
    data.putString("UAFIntentType", UAFIntentType.UAF_OPERATION.name());
    data.putString("channelBindings", regRequest);
    i.putExtras(data);

    //		i.setComponent(new ComponentName(queryIntentActivities.get(0).activityInfo.packageName,
    // queryIntentActivities.get(0).activityInfo.name));
    startActivityForResult(i, REG_ACTIVITY_RES_3);
  }
Beispiel #3
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
      }
    }
  }